Skip to content

Examples using DataStax Cassandra query builder in 2.x DataStax driver

Notifications You must be signed in to change notification settings

jphaugla/datastaxQueryBuilder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DataStax Query Builder

About

This github covers using DataStax Query Builder to do basic CRUD actions

Prerequisites

  • Basic understanding of Docker images and containers.

  • Docker installed on your local system, see Docker Installation Instructions.

  • When using Docker for Mac or Docker for Windows, the default resources allocated to the linux VM running docker are 2GB RAM and 2 CPU's. Make sure to adjust these resources to meet the resource requirements for the containers you will be running. More information can be found here on adjusting the resources allocated to docker.

Docker for mac

Docker for windows

Getting Started

  1. Prepare Docker environment-see the Prerequisites section above...
  2. Pull this github into a directory
git clone https://github.com/jphaugla/datastaxQueryBuilder.git
  1. Refer to the notes from DataStax Docker github for background on the needed DataStax images. Directions are here: https://github.com/datastax/docker-images/#datastax-platform-overview. Don't get too bogged down here as the included docker-compose.yaml handles most everything.
  2. Open terminal and change to the github home where you will see the docker-compose.yml file, then:
docker-compose up -d
  1. Verify DataStax is working (may take a minute for datastax cassandra to startup so be patient)
docker exec dse cqlsh -e "desc keyspaces"
  1. At this point can use the command shell from cassandra using
docker exec -it dse cqlsh

The java code

The java code demonstrates opening a cassandra session using the datastax driver. Next, standard statement execution is used to create a keyspace and a table. Then, inserts and reads are performed using various techniques to document simple statements and QueryBuilder methods. mvn is used to execute all of this

To execute the code

  1. Complile the code
mvn package
  1. Execute the code
mvn exec:java

Conclusion

At this point, run throught the cql worksheet and enjoy playing with Cassandra!

Additional Notes/tips

  • To get the IP address of the DataStax and openldap:
export DSE_IP=$(docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' dse)

and:

export LDAP_IP=$(docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' openldap)
  • use echo $DSE_IPE and echo $LDAP_IP to view
  • can add to the docker compose to run additional datastax workloads such as analtyics (-k), search (-s), and graph (-g)
 command:
     -s
     -g
     -k

About

Examples using DataStax Cassandra query builder in 2.x DataStax driver

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages