Skip to content

An example of sharing a session between multiple threads. This example uses the idea of inserting messages into a followers timeline.

Notifications You must be signed in to change notification settings

DataStaxCodeSamples/datastax-shared-session-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 

Repository files navigation

Shared Session example

This is a simple example of sharing sessions in the DataStax Java Driver.

Running the demo

You will need a java runtime (preferably 7) along with maven 3 to run this demo. Start DSE 4.X or a cassandra 2.X instance on your local machine. This demo just runs as a standalone process on the localhost.

This demo uses quite a lot of memory so it is worth setting the MAVEN_OPTS to run maven with more memory

export MAVEN_OPTS=-Xmx512M

Schema Setup

Note : This will drop the keyspace "datastax_shared_session_demo" and create a new one. All existing data will be lost.

To specify contact points use the contactPoints command line parameter e.g. '-DcontactPoints=192.168.25.100,192.168.25.101' The contact points can take mulitple points in the IP,IP,IP (no spaces).

To create the a single node cluster with replication factor of 1 for standard localhost setup, run the following

mvn clean compile exec:java -Dexec.mainClass="com.datastax.demo.SchemaSetup"

To run the insert

mvn clean compile exec:java -Dexec.mainClass="com.datastax.sharedsession.Main" -DnoOfThreads=5

You can also pass in the no of messages to send and the number of followers to sent to

mvn clean compile exec:java -Dexec.mainClass="com.datastax.sharedsession.Main" -DnoOfThreads=10 -DcontactPoints=cassandra1,cassandra2 -DmessageCount=50 -DnoOfFollowers=10000

To remove the tables and the schema, run the following.

mvn clean compile exec:java -Dexec.mainClass="com.datastax.demo.SchemaTeardown"

About

An example of sharing a session between multiple threads. This example uses the idea of inserting messages into a followers timeline.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors