summaryrefslogtreecommitdiffstats
path: root/collaboration
diff options
context:
space:
mode:
authorantelder <antelder@13f79535-47bb-0310-9956-ffa450edef68>2011-05-26 05:50:19 +0000
committerantelder <antelder@13f79535-47bb-0310-9956-ffa450edef68>2011-05-26 05:50:19 +0000
commitb8a11d3ca54f4b1c1566fe2b1f6cd71544ca1e7e (patch)
tree03e1e7da4265bd48bc702f5decec8ad0daa40ddf /collaboration
parentaaa33c48492d50b4bf136b791c557753fd8eb685 (diff)
TUSCANY-3522: Commit rest-api patch from Eranda for the GSoC project on NoSQL components
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1127789 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'collaboration')
-rw-r--r--collaboration/GSoC-2011-Eranda/cassandra/pom.xml47
-rw-r--r--collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/tuscany/nosqldatastore/Database.java7
-rw-r--r--collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/tuscany/nosqldatastore/Group.java7
-rw-r--r--collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/tuscany/nosqldatastore/Session.java7
-rw-r--r--collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/tuscany/nosqldatastore/SessionFactory.java17
-rw-r--r--collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/tuscany/nosqldatastore/cassandra/CassandraDatabase.java42
-rw-r--r--collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/tuscany/nosqldatastore/cassandra/CassandraGroup.java25
-rw-r--r--collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/tuscany/nosqldatastore/cassandra/CassandraSession.java36
-rw-r--r--collaboration/GSoC-2011-Eranda/cassandra/src/test/java/org/apache/tuscany/nosqldatastore/cassandra/CassandraTest.java36
9 files changed, 224 insertions, 0 deletions
diff --git a/collaboration/GSoC-2011-Eranda/cassandra/pom.xml b/collaboration/GSoC-2011-Eranda/cassandra/pom.xml
new file mode 100644
index 0000000000..9a685054d8
--- /dev/null
+++ b/collaboration/GSoC-2011-Eranda/cassandra/pom.xml
@@ -0,0 +1,47 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.apache.tuscany</groupId>
+ <artifactId>nosql-datastore</artifactId>
+ <version>0.0.1</version>
+
+ <packaging>jar</packaging>
+ <name>tuscany</name>
+ <url>http://maven.apache.org</url>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>me.prettyprint</groupId>
+ <artifactId>hector-core</artifactId>
+ <version>0.7.0-29</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cassandra</groupId>
+ <artifactId>cassandra-javautils</artifactId>
+ <version>0.7.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cassandra</groupId>
+ <artifactId>cassandra-all</artifactId>
+ <version>0.7.4</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>2.0.2</version>
+ <configuration>
+ <source>1.5</source>
+ <target>1.5</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/tuscany/nosqldatastore/Database.java b/collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/tuscany/nosqldatastore/Database.java
new file mode 100644
index 0000000000..02315a6e43
--- /dev/null
+++ b/collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/tuscany/nosqldatastore/Database.java
@@ -0,0 +1,7 @@
+package org.apache.tuscany.nosqldatastore;
+
+public interface Database {
+ org.apache.tuscany.nosqldatastore.Group createGroup(String groupId);
+ boolean isAvailable(String key);
+ void deleteGroup(String key);
+}
diff --git a/collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/tuscany/nosqldatastore/Group.java b/collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/tuscany/nosqldatastore/Group.java
new file mode 100644
index 0000000000..8874494b08
--- /dev/null
+++ b/collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/tuscany/nosqldatastore/Group.java
@@ -0,0 +1,7 @@
+package org.apache.tuscany.nosqldatastore;
+
+public interface Group {
+ void addEntry(String key, Object value);
+ void updateEntry(String key, Object value);
+ void deleteEntry(String key);
+}
diff --git a/collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/tuscany/nosqldatastore/Session.java b/collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/tuscany/nosqldatastore/Session.java
new file mode 100644
index 0000000000..983c487369
--- /dev/null
+++ b/collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/tuscany/nosqldatastore/Session.java
@@ -0,0 +1,7 @@
+package org.apache.tuscany.nosqldatastore;
+
+public interface Session {
+ Database createDatabase(String databaseName);
+ Database getDatabase(String databaseName);
+ void deleteDatabase(String databaseName);
+}
diff --git a/collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/tuscany/nosqldatastore/SessionFactory.java b/collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/tuscany/nosqldatastore/SessionFactory.java
new file mode 100644
index 0000000000..a2821a58ee
--- /dev/null
+++ b/collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/tuscany/nosqldatastore/SessionFactory.java
@@ -0,0 +1,17 @@
+package org.apache.tuscany.nosqldatastore;
+
+import org.apache.tuscany.nosqldatastore.cassandra.CassandraSession;
+
+public class SessionFactory {
+
+ private static org.apache.tuscany.nosqldatastore.Session session;
+
+ private SessionFactory(){
+ }
+
+ public static Session getCassandraSession(){
+ session = new CassandraSession("DataCluster");
+ return session;
+ }
+
+}
diff --git a/collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/tuscany/nosqldatastore/cassandra/CassandraDatabase.java b/collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/tuscany/nosqldatastore/cassandra/CassandraDatabase.java
new file mode 100644
index 0000000000..9572476941
--- /dev/null
+++ b/collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/tuscany/nosqldatastore/cassandra/CassandraDatabase.java
@@ -0,0 +1,42 @@
+package org.apache.tuscany.nosqldatastore.cassandra;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import me.prettyprint.cassandra.service.ThriftCluster;
+import me.prettyprint.cassandra.service.ThriftKsDef;
+import me.prettyprint.hector.api.ddl.ColumnFamilyDefinition;
+import me.prettyprint.hector.api.ddl.KeyspaceDefinition;
+import me.prettyprint.hector.api.factory.HFactory;
+import org.apache.tuscany.nosqldatastore.Database;
+import org.apache.tuscany.nosqldatastore.Group;
+
+class CassandraDatabase implements Database {
+
+ private String keyspace;
+ private ThriftCluster cluster;
+ private List<ColumnFamilyDefinition> cfDefList;
+
+ CassandraDatabase(String databaseName, ThriftCluster cluster) {
+ this.keyspace = databaseName;
+ this.cluster = cluster;
+ KeyspaceDefinition ksDef = cluster.describeKeyspace(keyspace);
+ cfDefList = ksDef.getCfDefs();
+ }
+
+ public Group createGroup(String groupId) {
+ ColumnFamilyDefinition cfDef = HFactory.createColumnFamilyDefinition(keyspace, groupId);
+ cluster.addColumnFamily(cfDef);
+ CassandraGroup group = new CassandraGroup(groupId);
+ return group;
+ }
+
+ public boolean isAvailable(String key) {
+ return false;
+ }
+
+ public void deleteGroup(String key) {
+ cluster.dropColumnFamily(keyspace, key);
+ }
+
+}
diff --git a/collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/tuscany/nosqldatastore/cassandra/CassandraGroup.java b/collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/tuscany/nosqldatastore/cassandra/CassandraGroup.java
new file mode 100644
index 0000000000..36a5bddf7b
--- /dev/null
+++ b/collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/tuscany/nosqldatastore/cassandra/CassandraGroup.java
@@ -0,0 +1,25 @@
+package org.apache.tuscany.nosqldatastore.cassandra;
+
+import org.apache.tuscany.nosqldatastore.Group;
+
+class CassandraGroup implements Group {
+
+ CassandraGroup(String groupName) {
+ }
+
+ public void addEntry(String key, Object value) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void deleteEntry(String key) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void updateEntry(String key, Object value) {
+ // TODO Auto-generated method stub
+
+ }
+
+}
diff --git a/collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/tuscany/nosqldatastore/cassandra/CassandraSession.java b/collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/tuscany/nosqldatastore/cassandra/CassandraSession.java
new file mode 100644
index 0000000000..f9cd7a62c5
--- /dev/null
+++ b/collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/tuscany/nosqldatastore/cassandra/CassandraSession.java
@@ -0,0 +1,36 @@
+package org.apache.tuscany.nosqldatastore.cassandra;
+
+import me.prettyprint.cassandra.service.CassandraHostConfigurator;
+import me.prettyprint.cassandra.service.ThriftCluster;
+import me.prettyprint.cassandra.service.ThriftKsDef;
+import me.prettyprint.hector.api.ddl.KeyspaceDefinition;
+import org.apache.tuscany.nosqldatastore.Database;
+import org.apache.tuscany.nosqldatastore.Session;
+
+public class CassandraSession implements Session {
+
+ private CassandraHostConfigurator cassandraHostConfigurator;
+ private ThriftCluster cluster;
+
+ public CassandraSession(String clusterName) {
+ cassandraHostConfigurator = new CassandraHostConfigurator("localhost:9160");
+ cluster = new ThriftCluster(clusterName, cassandraHostConfigurator);
+ }
+
+ public Database createDatabase(String keyspaceName) {
+ KeyspaceDefinition ksDef = new ThriftKsDef(keyspaceName, "org.apache.cassandra.locator.SimpleStrategy", 1, null);
+ cluster.addKeyspace(ksDef);
+ Database database = new CassandraDatabase(keyspaceName, cluster);
+ return database;
+ }
+
+ public Database getDatabase(String keyspaceName) {
+ Database database = new CassandraDatabase(keyspaceName, cluster);
+ return database;
+ }
+
+ public void deleteDatabase(String keyspaceName) {
+ cluster.dropKeyspace(keyspaceName);
+ }
+
+}
diff --git a/collaboration/GSoC-2011-Eranda/cassandra/src/test/java/org/apache/tuscany/nosqldatastore/cassandra/CassandraTest.java b/collaboration/GSoC-2011-Eranda/cassandra/src/test/java/org/apache/tuscany/nosqldatastore/cassandra/CassandraTest.java
new file mode 100644
index 0000000000..117836ea1f
--- /dev/null
+++ b/collaboration/GSoC-2011-Eranda/cassandra/src/test/java/org/apache/tuscany/nosqldatastore/cassandra/CassandraTest.java
@@ -0,0 +1,36 @@
+package org.apache.tuscany.nosqldatastore.cassandra;
+
+import org.apache.tuscany.nosqldatastore.Database;
+import org.apache.tuscany.nosqldatastore.Group;
+import org.apache.tuscany.nosqldatastore.Session;
+import org.apache.tuscany.nosqldatastore.SessionFactory;
+
+
+public class CassandraTest {
+
+ Session session;
+
+ public CassandraTest(){
+ session = SessionFactory.getCassandraSession();
+ }
+
+ public static void main(String[] args){
+ CassandraTest test = new CassandraTest();
+ test.create();
+ //test.delete();
+ }
+
+ public void create(){
+ Database db = session.createDatabase("TwitApp");
+ //Group group1 = db.createGroup("twits");
+ //Group group2 = db.createGroup("users");
+ }
+
+ public void delete(){
+ Database db = session.getDatabase("TwitApp");
+ db.deleteGroup("twits");
+ db.deleteGroup("users");
+ session.deleteDatabase("TwitApp");
+ }
+
+}