Questions on Spring-data-cassandra for MVC REST application

354 views
Skip to first unread message

ScheideckerAntunes

unread,
Jun 16, 2014, 6:20:41 AM6/16/14
to spring-dat...@googlegroups.com
Hello,

Was hopping to get a full example with authentication, etc on how to use Spring-data-cassandra.

So far, I have been learning from reading the source code.

I saw that another user here has asked a few questions regarding writing a REST application with Cassandra.

I can write the REST app, the service and repository. But I would like to understand a few things.

Well, I am using Cassandra 2.x and 1.1.0.BUILD-SNAPSHOT of Spring-data-Cassandra.

I would like to understand it better.

1) How to write a spring repository to use Spring-data-cassandra?

2) How to initialize it so that I can pass all the machines on the cluster? 

3) I have done a connection pool before with Thrift. Wrote the code for it. Does Spring-data-Cassandra provide a connection pool? If it does, how to configure that?

I see that AbstractSessionConfiguration extends AbstractClusterConfiguration. The AbstractClusterConfiguration defines a bean called cluster ( CassandraCqlClusterFactoryBean cluster()) which returns a bunch of things on the cluster.

To configure a Session I can extend AbstractSessionConfiguration. I see that CassandraCqlClusterFactoryBean has pooling options as well. Interesting that if I create my Cassandra java config from AbstractCassandraConfiguration, it extends AbstractClusterConfiguration which has a bean CassandraCqlClusterFactoryBean.

The AbstractCassandraConfiguration gives me CassandraSessionFactoryBean for Session information, getAuthProvider method that returns the AuthProvider object (so I can do authentication). The getAuthProvider actually comes from AbstractClusterConfiguration which is what AbstrsctCassandraConfiguration extends. 

So I guess the basic thing is to setup a CassandraCqlClusterFactoryBean so you can set a bunch of things:

- setContactPoints so I can pass a list of nodes separated by a comma.
- setAuthProvider so I can set the credentials but there is also setUsername and setPassword. Interesting.

So I would like to also understand the CassandraCqlClusterFactoryBean.

An example would be great on using Spring-Data-Cassandra with Cassandra 2.x so I can have my REST API to use it through a repository.

Thanks,

Carlos.

PS: Sorry for typos, being studying source code for long hours.


David Webb (Prowave)

unread,
Jun 16, 2014, 12:58:56 PM6/16/14
to ScheideckerAntunes, spring-dat...@googlegroups.com
See below:


Hello,

Was hopping to get a full example with authentication, etc on how to use Spring-data-cassandra.

The SDC* Cluster Factory bean uses all the features of the DataStax Java Driver (v2.0.2).  Read on how the driver handles authentication,  then you will notice the nicely named methods on our CassandraClusterFactoryBean, like 

setAuthProvider()
setUsername()
setPassword()


So far, I have been learning from reading the source code.

I would recommend the Reference Guide, followed by integration tests for examples


I saw that another user here has asked a few questions regarding writing a REST application with Cassandra.

I can write the REST app, the service and repository. But I would like to understand a few things.

Well, I am using Cassandra 2.x and 1.1.0.BUILD-SNAPSHOT of Spring-data-Cassandra.

You should really use 1.0.0.RELEASE

I would like to understand it better.

1) How to write a spring repository to use Spring-data-cassandra?

2) How to initialize it so that I can pass all the machines on the cluster? 

3) I have done a connection pool before with Thrift. Wrote the code for it. Does Spring-data-Cassandra provide a connection pool? If it does, how to configure that?

I see that AbstractSessionConfiguration extends AbstractClusterConfiguration. The AbstractClusterConfiguration defines a bean called cluster ( CassandraCqlClusterFactoryBean cluster()) which returns a bunch of things on the cluster.

To configure a Session I can extend AbstractSessionConfiguration. I see that CassandraCqlClusterFactoryBean has pooling options as well. Interesting that if I create my Cassandra java config from AbstractCassandraConfiguration, it extends AbstractClusterConfiguration which has a bean CassandraCqlClusterFactoryBean.

The AbstractCassandraConfiguration gives me CassandraSessionFactoryBean for Session information, getAuthProvider method that returns the AuthProvider object (so I can do authentication). The getAuthProvider actually comes from AbstractClusterConfiguration which is what AbstrsctCassandraConfiguration extends. 

So I guess the basic thing is to setup a CassandraCqlClusterFactoryBean so you can set a bunch of things:

- setContactPoints so I can pass a list of nodes separated by a comma.
- setAuthProvider so I can set the credentials but there is also setUsername and setPassword. Interesting.

So I would like to also understand the CassandraCqlClusterFactoryBean.

An example would be great on using Spring-Data-Cassandra with Cassandra 2.x so I can have my REST API to use it through a repository.

Thanks,

Carlos.

PS: Sorry for typos, being studying source code for long hours.


--
You received this message because you are subscribed to the Google Groups "Spring Data Cassandra" group.
To unsubscribe from this group and stop receiving emails from it, send an email to spring-data-cass...@googlegroups.com.
To post to this group, send email to spring-dat...@googlegroups.com.
Visit this group at http://groups.google.com/group/spring-data-cassandra.
To view this discussion on the web visit https://groups.google.com/d/msgid/spring-data-cassandra/7e516081-640f-456c-a073-4b4d9648350d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

David Webb (Prowave)

unread,
Jun 16, 2014, 1:02:32 PM6/16/14
to ScheideckerAntunes, spring-dat...@googlegroups.com
See below:


Hello,

Was hopping to get a full example with authentication, etc on how to use Spring-data-cassandra.

The SDC* Cluster Factory bean uses all the features of the DataStax Java Driver (v2.0.2).  Read on how the driver handles authentication,  then you will notice the nicely named methods on our CassandraClusterFactoryBean, like 

setAuthProvider()
setUsername()
setPassword()


So far, I have been learning from reading the source code.

I would recommend the Reference Guide, followed by integration tests for examples


I saw that another user here has asked a few questions regarding writing a REST application with Cassandra.

I can write the REST app, the service and repository. But I would like to understand a few things.

Well, I am using Cassandra 2.x and 1.1.0.BUILD-SNAPSHOT of Spring-data-Cassandra.

You should really use 1.0.0.RELEASE

I would like to understand it better.

1) How to write a spring repository to use Spring-data-cassandra?

There are many examples in the Reference Guide about annotating keys and how they are used by the Repository Interfaces.

2) How to initialize it so that I can pass all the machines on the cluster? 

You can pass as many contact points as you want, but the CassandraCluster discovers all the hosts based on just 1 successful contact point…more on this in the DS Java Driver docs.

3) I have done a connection pool before with Thrift. Wrote the code for it. Does Spring-data-Cassandra provide a connection pool? If it does, how to configure that?

Checkout the DS Java Driver Pooling Options, then pass then to our CassandraClusterFactoryBean.

I see that AbstractSessionConfiguration extends AbstractClusterConfiguration. The AbstractClusterConfiguration defines a bean called cluster ( CassandraCqlClusterFactoryBean cluster()) which returns a bunch of things on the cluster.

To configure a Session I can extend AbstractSessionConfiguration. I see that CassandraCqlClusterFactoryBean has pooling options as well. Interesting that if I create my Cassandra java config from AbstractCassandraConfiguration, it extends AbstractClusterConfiguration which has a bean CassandraCqlClusterFactoryBean.

The AbstractCassandraConfiguration gives me CassandraSessionFactoryBean for Session information, getAuthProvider method that returns the AuthProvider object (so I can do authentication). The getAuthProvider actually comes from AbstractClusterConfiguration which is what AbstrsctCassandraConfiguration extends. 

So I guess the basic thing is to setup a CassandraCqlClusterFactoryBean so you can set a bunch of things:

- setContactPoints so I can pass a list of nodes separated by a comma.
- setAuthProvider so I can set the credentials but there is also setUsername and setPassword. Interesting.

So I would like to also understand the CassandraCqlClusterFactoryBean.

An example would be great on using Spring-Data-Cassandra with Cassandra 2.x so I can have my REST API to use it through a repository.

SDC* is agnostic to what sort of app you have calling the repositories.  Mobile, REST, Webflow, doesn’t impact using SDC*.
Reply all
Reply to author
Forward
0 new messages