Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
A cassandra plugin to the java persistence platform Datanucleus
Java
branch: master
Failed to load latest commit information.
META-INF Commiting project
src
LICENSE.txt License changes to include all authors
NOTICE.txt
README.mkd Update readme with link to official plugin
build.xml Debug flag added to compile, allowing application debug when running.
plugin.xml -JDOQL basic range queries are now supported by the plugin.

README.mkd

Purpose:

A simple DataNucleus plugin for Java object persistence in Cassandra 0.6.x. For 0.7.x support checkTodd's version.

This is not currently supported as you may guess, for the official version go to:
https://github.com/datanucleus/datanucleus-cassandra

About:

The current status is as follows:

  • It allows persistence of simple attributes, one-to-one relations, one-to-many and many-to-many relations through collections and maps.

  • It creates a datanucleus.schema every time some element is missing in Cassandra schema, until Cassandra allows dynamic changes to it.

  • It works with Cassandra-0.6.x, under Thrift interface. Data-store code isolation will be improved however, to allow other versions to be used.

  • Basic schema creation tool(beta). Schema creation

  • It supports multiple indexes on each class, here each can only contain one field.

  • It now supports basic JDOQL queries with support to ranges and searches based on indexed fields. Usages

Compiling

To build the plugin place the following libs in a folder named lib:

  • apache-cassandra-0.6.1.jar
  • libthrift-r917130.jar
  • datanucleus-core-2.1.0-m2.jar (*)

Then type ant or ant dist.


(*) Due to API issues, I chose to use the new core version of datanucleus, this however demands that you compile and generate a jar for the new JDO API, when using the plugin. Sources under: JDO2-api

Sample code

Get the JDO sample in Datanucleus at:

http://sourceforge.net/projects/datanucleus/files/

Then:

  • Alter the JDOQL tests from Main.java, as for now, only simple ranges are supported(read/delete) and searches based on single indexed fields.
  • Define the primary key for each class, as the native strategy is not supported (use for example @PrimaryKey annotations in the classes).
  • In the datanucleus.properties add/edit:

    javax.jdo.option.ConnectionURL=cassandra:ORMTest://localhost:9160 (*) datanucleus.cassandra.replicaPlacementStrategy=org.apache.cassandra.locator.RackUnawareStrategy (+)
    datanucleus.cassandra.replicationFactor=1 (+)
    datanucleus.cassandra.endPointSnitch = org.apache.cassandra.locator.EndPointSnitch (+)
    datanucleus.metadata.validate=false datanucleus.autoCreateSchema=true

  • Run the sample according to the original instructions.


(*)The connection URL follows the pattern: cassandra:keySpace://hostaname:port,hostname:port,... cassandra:keySpace://hostname:port,ring:default_port can also be used, where the plugin is responsible for the discover of other nodes using the default port.
(+)Used to generate the schema, that for now is only the generation of a file as said above.

Feedback

Updated source and an issue tracker are available at:

http://github.com/PedroGomes/datanucleus-cassandra

Your feedback is welcome.

Something went wrong with that request. Please try again.