Skip to content
This repository

A cassandra plugin to the java persistence platform Datanucleus

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 META-INF
Octocat-spinner-32 src
Octocat-spinner-32 LICENSE.txt
Octocat-spinner-32 NOTICE.txt
Octocat-spinner-32 README.mkd
Octocat-spinner-32 build.xml
Octocat-spinner-32 plugin.xml
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.