Re: schema generation in cassandra

2015-03-18 Thread Ali Akhtar
Why are you creating new tables dynamically? I would try to use a static
schema and use a collection (list / map / set) for storing arbitrary data.

On Wed, Mar 18, 2015 at 2:52 PM, Ankit Agarwal agarwalankit.k...@gmail.com
wrote:

 Hi,

 I am new to Cassandra, we are planning to use Cassandra for cloud base
 application in our development environment, so for this looking forward for
 best strategies to sync the schema for micro-services while deploy
 application on cloud foundry

 One way which I could use is   Accessor interface with datastax-mapper and
 casandra-core driver.



 1.)  I have created a keyspace using  core driver which will be generated
 on initialization of servlet

 *public* *void* init() *throws* ServletException

 {
 Cluster cluster = Cluster.*builder*().addContactPoint(127.0.0.1
 ).build();

 Session session = cluster.connect();

  String keySpace=sampletest;

 session.execute(CREATE KEYSPACE IF NOT EXISTS + keySpace +

  WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' :
 1 });

 ..


 2.) This is my Accessor Interface which I used to generate Query
 for creating column family ..

 @Accessor

 *public* *interface* UserAccessor

 {

 @Query( CREATE TABLE sampletest.emp (id uuid PRIMARY KEY,name
 text,department text,location text,phone bigint ) WITH caching = '{
 \keys\ : \ALL\ , \rows_per_partition\ : \NONE\ }'  )

 ResultSet create_table();

 }




 3.) Creating  an  instance of Accessor interface to provide mapping  to
 our query to generate column family

 

 MappingManager mapper=*new* MappingManager(session);

 UserAccessor ua= mapper.createAccessor(UserAccessor.*class*);

  ua.create_table();

  



 4.) So far I have created a keyspace with a column family , now I want to
 map my data using POJO class mentioned below


 @Table(keyspace = sampletest, name = emp)
 *public* *class* Employee {

  @PartitionKey

 *private* UUID id;

 *private* String name;

 *private* String department;

 *private* String location;

 *private* Long phone;

 // getter setter method
 .
 }



 Is there any other better approach to achieve this especially for cloud
 environment


 --
 Thanks

 Ankit Agarwal




schema generation in cassandra

2015-03-18 Thread Ankit Agarwal
Hi,

I am new to Cassandra, we are planning to use Cassandra for cloud base
application in our development environment, so for this looking forward for
best strategies to sync the schema for micro-services while deploy
application on cloud foundry

One way which I could use is   Accessor interface with datastax-mapper and
casandra-core driver.



1.)  I have created a keyspace using  core driver which will be generated
on initialization of servlet

*public* *void* init() *throws* ServletException

{
Cluster cluster = Cluster.*builder*().addContactPoint(127.0.0.1).build();

Session session = cluster.connect();

 String keySpace=sampletest;

session.execute(CREATE KEYSPACE IF NOT EXISTS + keySpace +

 WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 1
});

..


2.) This is my Accessor Interface which I used to generate Query
for creating column family ..

@Accessor

*public* *interface* UserAccessor

{

@Query( CREATE TABLE sampletest.emp (id uuid PRIMARY KEY,name
text,department text,location text,phone bigint ) WITH caching = '{
\keys\ : \ALL\ , \rows_per_partition\ : \NONE\ }'  )

ResultSet create_table();

}




3.) Creating  an  instance of Accessor interface to provide mapping  to our
query to generate column family



MappingManager mapper=*new* MappingManager(session);

UserAccessor ua= mapper.createAccessor(UserAccessor.*class*);

 ua.create_table();

 



4.) So far I have created a keyspace with a column family , now I want to
map my data using POJO class mentioned below


@Table(keyspace = sampletest, name = emp)
*public* *class* Employee {

 @PartitionKey

*private* UUID id;

*private* String name;

*private* String department;

*private* String location;

*private* Long phone;

// getter setter method
.
}



Is there any other better approach to achieve this especially for cloud
environment


-- 
Thanks

Ankit Agarwal


Re: schema generation in cassandra

2015-03-18 Thread Ankit Agarwal
Thanks! a lot for your responses,

My question is , what all best practices used for database schema
deployment for a microservice in cloud environment.

e.g., shall we create it with deployement of microservice or it should be
generated via code or should not be generated via code instead should be
generated separately.

On Wed, Mar 18, 2015 at 3:29 PM, Ali Akhtar ali.rac...@gmail.com wrote:

 Why are you creating new tables dynamically? I would try to use a static
 schema and use a collection (list / map / set) for storing arbitrary data.

 On Wed, Mar 18, 2015 at 2:52 PM, Ankit Agarwal 
 agarwalankit.k...@gmail.com wrote:

 Hi,

 I am new to Cassandra, we are planning to use Cassandra for cloud base
 application in our development environment, so for this looking forward for
 best strategies to sync the schema for micro-services while deploy
 application on cloud foundry

 One way which I could use is   Accessor interface with datastax-mapper
 and casandra-core driver.



 1.)  I have created a keyspace using  core driver which will be generated
 on initialization of servlet

 *public* *void* init() *throws* ServletException

 {
 Cluster cluster = Cluster.*builder*().addContactPoint(127.0.0.1
 ).build();

 Session session = cluster.connect();

  String keySpace=sampletest;

 session.execute(CREATE KEYSPACE IF NOT EXISTS + keySpace +

  WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' :
 1 });

 ..


 2.) This is my Accessor Interface which I used to generate Query
 for creating column family ..

 @Accessor

 *public* *interface* UserAccessor

 {

 @Query( CREATE TABLE sampletest.emp (id uuid PRIMARY KEY,name
 text,department text,location text,phone bigint ) WITH caching = '{
 \keys\ : \ALL\ , \rows_per_partition\ : \NONE\ }'  )

 ResultSet create_table();

 }




 3.) Creating  an  instance of Accessor interface to provide mapping  to
 our query to generate column family

 

 MappingManager mapper=*new* MappingManager(session);

 UserAccessor ua= mapper.createAccessor(UserAccessor.*class*);

  ua.create_table();

  



 4.) So far I have created a keyspace with a column family , now I want to
 map my data using POJO class mentioned below


 @Table(keyspace = sampletest, name = emp)
 *public* *class* Employee {

  @PartitionKey

 *private* UUID id;

 *private* String name;

 *private* String department;

 *private* String location;

 *private* Long phone;

 // getter setter method
 .
 }



 Is there any other better approach to achieve this especially for cloud
 environment


 --
 Thanks

 Ankit Agarwal





-- 
Thanks  Regards

Ankit Agarwal
+91-9953235575