Spring Boot Sample Data Cassandra
Stores data using Spring Data Cassandra
CQLsh
cqlsh
Connected to Test Cluster at 127.0.0.1:9042.
[cqlsh 5.0.1 | Cassandra 3.11.2 | CQL spec 3.4.4 | Native protocol v4]
Use HELP for help.
cqlsh>
Keyspace Creation
CREATE KEYSPACE mykeyspace WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 };
Table Creation
use mykeyspace;
CREATE TABLE customer (id TimeUUID PRIMARY KEY, firstname text, lastname text);
CREATE INDEX customerfistnameindex ON customer (firstname);
CREATE INDEX customersecondnameindex ON customer (lastname);
Clone the sample
mkdir -p /home/hadoop/AdithyaJ/Cassandra/java
cd /home/hadoop/AdithyaJ/Cassandra/java
git clone https://github.com/spring-projects/spring-boot
cd spring-boot/spring-boot-samples/spring-boot-sample-data-cassandra/
Compile and run
mvn package
java -jar target/spring-boot-sample-data-cassandra-2.1.0.BUILD-SNAPSHOT.jar
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.1.0.BUILD-SNAPSHOT)
2018-06-03 15:14:31.517 INFO 7066 --- [ main] s.d.c.SampleCassandraApplication : Starting SampleCassandraApplication v2.1.0.BUILD-SNAPSHOT on es1 with PID 7066 (/home/hadoop/AdithyaJ/Cassandra/java/spring-boot/spring-boot-samples/spring-boot-sample-data-cassandra/target/spring-boot-sample-data-cassandra-2.1.0.BUILD-SNAPSHOT.jar started by hadoop in /home/hadoop/AdithyaJ/Cassandra/java/spring-boot/spring-boot-samples/spring-boot-sample-data-cassandra)
2018-06-03 15:14:31.530 INFO 7066 --- [ main] s.d.c.SampleCassandraApplication : No active profile set, falling back to default profiles: default
2018-06-03 15:14:31.726 INFO 7066 --- [ main] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@490d6c15: startup date [Sun Jun 03 15:14:31 UTC 2018]; root of context hierarchy
2018-06-03 15:14:33.542 INFO 7066 --- [ main] com.datastax.driver.core : DataStax Java driver 3.5.0 for Apache Cassandra
2018-06-03 15:14:33.565 INFO 7066 --- [ main] c.d.driver.core.GuavaCompatibility : Detected Guava >= 19 in the classpath, using modern compatibility layer
2018-06-03 15:14:34.447 INFO 7066 --- [ main] com.datastax.driver.core.ClockFactory : Using native clock to generate timestamps.
2018-06-03 15:14:35.106 INFO 7066 --- [ main] com.datastax.driver.core.NettyUtil : Did not find Netty's native epoll transport in the classpath, defaulting to NIO.
2018-06-03 15:14:36.189 INFO 7066 --- [ main] c.d.d.c.p.DCAwareRoundRobinPolicy : Using data-center name 'datacenter1' for DCAwareRoundRobinPolicy (if this is incorrect, please provide the correct datacenter name with DCAwareRoundRobinPolicy constructor)
2018-06-03 15:14:36.193 INFO 7066 --- [ main] com.datastax.driver.core.Cluster : New Cassandra host localhost/127.0.0.1:9042 added
2018-06-03 15:14:37.034 INFO 7066 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup
2018-06-03 15:14:37.064 INFO 7066 --- [ main] s.d.c.SampleCassandraApplication : Started SampleCassandraApplication in 6.511 seconds (JVM running for 7.562)
2018-06-03 15:14:37.561 INFO 7066 --- [ main] com.datastax.driver.core.utils.UUIDs : PID obtained through native call to getpid(): 7066
Customers found with findAll():
-------------------------------
Customer[id=d4816da0-6740-11e8-b96c-975cef06d10f, firstName='Alice', lastName='Smith']
Customer[id=d48ba6d0-6740-11e8-b96c-975cef06d10f, firstName='Bob', lastName='Smith']
Customer found with findByFirstName('Alice'):
--------------------------------
Customer[id=d4816da0-6740-11e8-b96c-975cef06d10f, firstName='Alice', lastName='Smith']
Customers found with findByLastName('Smith'):
--------------------------------
Customer[id=d4816da0-6740-11e8-b96c-975cef06d10f, firstName='Alice', lastName='Smith']
Customer[id=d48ba6d0-6740-11e8-b96c-975cef06d10f, firstName='Bob', lastName='Smith']