tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From antel...@apache.org
Subject svn commit: r1127789 - in /tuscany/collaboration/GSoC-2011-Eranda/cassandra: ./ src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/tuscany/ src/main/java/org/apache/tuscany/nosqldatastore/ src/main/java/...
Date Thu, 26 May 2011 05:50:20 GMT
Author: antelder
Date: Thu May 26 05:50:19 2011
New Revision: 1127789

URL: http://svn.apache.org/viewvc?rev=1127789&view=rev
Log:
TUSCANY-3522: Commit rest-api patch from Eranda for the GSoC project on NoSQL components

Added:
    tuscany/collaboration/GSoC-2011-Eranda/cassandra/   (with props)
    tuscany/collaboration/GSoC-2011-Eranda/cassandra/pom.xml
    tuscany/collaboration/GSoC-2011-Eranda/cassandra/src/
    tuscany/collaboration/GSoC-2011-Eranda/cassandra/src/main/
    tuscany/collaboration/GSoC-2011-Eranda/cassandra/src/main/java/
    tuscany/collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/
    tuscany/collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/
    tuscany/collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/tuscany/
    tuscany/collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/tuscany/nosqldatastore/
    tuscany/collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/tuscany/nosqldatastore/Database.java
    tuscany/collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/tuscany/nosqldatastore/Group.java
    tuscany/collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/tuscany/nosqldatastore/Session.java
    tuscany/collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/tuscany/nosqldatastore/SessionFactory.java
    tuscany/collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/tuscany/nosqldatastore/cassandra/
    tuscany/collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/tuscany/nosqldatastore/cassandra/CassandraDatabase.java
    tuscany/collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/tuscany/nosqldatastore/cassandra/CassandraGroup.java
    tuscany/collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/tuscany/nosqldatastore/cassandra/CassandraSession.java
    tuscany/collaboration/GSoC-2011-Eranda/cassandra/src/test/
    tuscany/collaboration/GSoC-2011-Eranda/cassandra/src/test/java/
    tuscany/collaboration/GSoC-2011-Eranda/cassandra/src/test/java/org/
    tuscany/collaboration/GSoC-2011-Eranda/cassandra/src/test/java/org/apache/
    tuscany/collaboration/GSoC-2011-Eranda/cassandra/src/test/java/org/apache/tuscany/
    tuscany/collaboration/GSoC-2011-Eranda/cassandra/src/test/java/org/apache/tuscany/nosqldatastore/
    tuscany/collaboration/GSoC-2011-Eranda/cassandra/src/test/java/org/apache/tuscany/nosqldatastore/cassandra/
    tuscany/collaboration/GSoC-2011-Eranda/cassandra/src/test/java/org/apache/tuscany/nosqldatastore/cassandra/CassandraTest.java

Propchange: tuscany/collaboration/GSoC-2011-Eranda/cassandra/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Thu May 26 05:50:19 2011
@@ -0,0 +1,20 @@
+target
+work
+dojo
+*.iws
+*.ipr
+*.iml
+derby.log
+maven.log
+maven-eclipse.xml
+build.xml
+build-dependency.xml
+velocity.log*
+junit*.properties
+surefire*.properties
+.project
+.classpath
+.settings
+.deployables
+.wtpmodules
+.externalToolBuilders

Added: tuscany/collaboration/GSoC-2011-Eranda/cassandra/pom.xml
URL: http://svn.apache.org/viewvc/tuscany/collaboration/GSoC-2011-Eranda/cassandra/pom.xml?rev=1127789&view=auto
==============================================================================
--- tuscany/collaboration/GSoC-2011-Eranda/cassandra/pom.xml (added)
+++ tuscany/collaboration/GSoC-2011-Eranda/cassandra/pom.xml Thu May 26 05:50:19 2011
@@ -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>

Added: tuscany/collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/tuscany/nosqldatastore/Database.java
URL: http://svn.apache.org/viewvc/tuscany/collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/tuscany/nosqldatastore/Database.java?rev=1127789&view=auto
==============================================================================
--- tuscany/collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/tuscany/nosqldatastore/Database.java
(added)
+++ tuscany/collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/tuscany/nosqldatastore/Database.java
Thu May 26 05:50:19 2011
@@ -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);
+}

Added: tuscany/collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/tuscany/nosqldatastore/Group.java
URL: http://svn.apache.org/viewvc/tuscany/collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/tuscany/nosqldatastore/Group.java?rev=1127789&view=auto
==============================================================================
--- tuscany/collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/tuscany/nosqldatastore/Group.java
(added)
+++ tuscany/collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/tuscany/nosqldatastore/Group.java
Thu May 26 05:50:19 2011
@@ -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);
+}

Added: tuscany/collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/tuscany/nosqldatastore/Session.java
URL: http://svn.apache.org/viewvc/tuscany/collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/tuscany/nosqldatastore/Session.java?rev=1127789&view=auto
==============================================================================
--- tuscany/collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/tuscany/nosqldatastore/Session.java
(added)
+++ tuscany/collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/tuscany/nosqldatastore/Session.java
Thu May 26 05:50:19 2011
@@ -0,0 +1,7 @@
+package org.apache.tuscany.nosqldatastore;
+
+public interface Session {
+	Database createDatabase(String databaseName);
+	Database getDatabase(String databaseName);
+	void deleteDatabase(String databaseName);
+}

Added: tuscany/collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/tuscany/nosqldatastore/SessionFactory.java
URL: http://svn.apache.org/viewvc/tuscany/collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/tuscany/nosqldatastore/SessionFactory.java?rev=1127789&view=auto
==============================================================================
--- tuscany/collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/tuscany/nosqldatastore/SessionFactory.java
(added)
+++ tuscany/collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/tuscany/nosqldatastore/SessionFactory.java
Thu May 26 05:50:19 2011
@@ -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;
+	}
+	
+}

Added: tuscany/collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/tuscany/nosqldatastore/cassandra/CassandraDatabase.java
URL: http://svn.apache.org/viewvc/tuscany/collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/tuscany/nosqldatastore/cassandra/CassandraDatabase.java?rev=1127789&view=auto
==============================================================================
--- tuscany/collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/tuscany/nosqldatastore/cassandra/CassandraDatabase.java
(added)
+++ tuscany/collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/tuscany/nosqldatastore/cassandra/CassandraDatabase.java
Thu May 26 05:50:19 2011
@@ -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);	
+	}
+
+}

Added: tuscany/collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/tuscany/nosqldatastore/cassandra/CassandraGroup.java
URL: http://svn.apache.org/viewvc/tuscany/collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/tuscany/nosqldatastore/cassandra/CassandraGroup.java?rev=1127789&view=auto
==============================================================================
--- tuscany/collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/tuscany/nosqldatastore/cassandra/CassandraGroup.java
(added)
+++ tuscany/collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/tuscany/nosqldatastore/cassandra/CassandraGroup.java
Thu May 26 05:50:19 2011
@@ -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
+		
+	}
+
+}

Added: tuscany/collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/tuscany/nosqldatastore/cassandra/CassandraSession.java
URL: http://svn.apache.org/viewvc/tuscany/collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/tuscany/nosqldatastore/cassandra/CassandraSession.java?rev=1127789&view=auto
==============================================================================
--- tuscany/collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/tuscany/nosqldatastore/cassandra/CassandraSession.java
(added)
+++ tuscany/collaboration/GSoC-2011-Eranda/cassandra/src/main/java/org/apache/tuscany/nosqldatastore/cassandra/CassandraSession.java
Thu May 26 05:50:19 2011
@@ -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);
+	}
+
+}

Added: tuscany/collaboration/GSoC-2011-Eranda/cassandra/src/test/java/org/apache/tuscany/nosqldatastore/cassandra/CassandraTest.java
URL: http://svn.apache.org/viewvc/tuscany/collaboration/GSoC-2011-Eranda/cassandra/src/test/java/org/apache/tuscany/nosqldatastore/cassandra/CassandraTest.java?rev=1127789&view=auto
==============================================================================
--- tuscany/collaboration/GSoC-2011-Eranda/cassandra/src/test/java/org/apache/tuscany/nosqldatastore/cassandra/CassandraTest.java
(added)
+++ tuscany/collaboration/GSoC-2011-Eranda/cassandra/src/test/java/org/apache/tuscany/nosqldatastore/cassandra/CassandraTest.java
Thu May 26 05:50:19 2011
@@ -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");
+	}
+	
+}



Mime
View raw message