Spring – Cassandra – Firebrand ocm

DevEnglishTutorials

As you probably know, NoSQL era has begun for several (good) reasons
– Can run on large clusters
– Are easy to integrate
– Are said to scale in a linear way.
– Addresses different problematic solutions than classical RDBMS systems.

Here we’ll talk about Cassandra integration with Spring and a little (big) framework called Firebrand ocm.

This is quite simple, you just have 5 steps :

  1.  Clone this project: https://github.com/jrevault/SpringFirebrandCassandra or download it (https://github.com/jrevault/SpringFirebrandCassandra/archive/master.zip)
  2. Download and run cassandra : http://cassandra.apache.org/download/
  3. Launch cassandra-cli and ‘create keyspace QUIDQUID;’ case is sensitive
  4. Call : ‘mvn jetty:run’ on the project command line
  5. Play with URLs :

    • http://localhost:8080/v1/users/ok (test if everything works, should return “OK”)
    • http://localhost:8080/v1/users/hello?name=World! (test if everything works, should return “Hello, Wolrd!”)
    • http://localhost:8080/v1/users/list (Lists all users inside Cassandra, should be empty)
    • http://localhost:8080/v1/users/create?email=you@email.ok&name=Toto&pwd=SeCrEt (Creates a user inside Cassandra)
    • http://localhost:8080/v1/users/list
    • http://localhost:8080/v1/users/create?email=me@email.ko&name=Titi&pwd=GrOoVy
    • http://localhost:8080/v1/users/list
    • http://localhost:8080/v1/users/read?id=….. (Reads a specific users from Cassandra)
    • http://localhost:8080/v1/users/delete?id=….. (Deletes a specific users from Cassandra)
    • http://localhost:8080/v1/users/list

Whats behind the hood ?
Check the pom.xml for dependencies, and look inside the WEB-INF/applicationContext.xml for Firebrand ocm configutration.

Just go through code from the UserController to the UserDao (yes it’s empty) that extends a simple GenericDao for basic CRUD(LE) operations (LE stands dor LIST and EXISTS).

As you can see it is damn fast to work on this kind of environement.

Previous
Fast API development using Scalatra and squeryl
Next
Centos 6 – Hadoop

Leave a comment

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload the CAPTCHA.