Skip to content
Browse files

Forgot the keyspace holder

  • Loading branch information...
1 parent 4fd5287 commit e1b2327b31257deefd42c889ed48d445de5d29f4 @wolpert committed Dec 7, 2010
Showing with 51 additions and 1 deletion.
  1. +1 −1 README
  2. +50 −0 src/java/codehead/KeyspaceHolder.java
View
2 README
@@ -1,7 +1,7 @@
http://www.opensource.org/licenses/apache2.0.php
Cassandra Version: 0.7.0
-Hector Version: 0.7.0-19_10212010
+Hector Version: 0.7.0-20
Grails: 1.2.2 or higher
View
50 src/java/codehead/KeyspaceHolder.java
@@ -0,0 +1,50 @@
+package codehead;
+
+import me.prettyprint.hector.api.Cluster;
+import me.prettyprint.hector.api.Keyspace;
+import me.prettyprint.hector.api.factory.HFactory;
+
+public class KeyspaceHolder extends ThreadLocal <Keyspace>{
+
+ private String clusterName="Test Cluster";
+ private String keyspaceName="Keyspace1";
+ private String servers="localhost:9160";
+
+ protected Keyspace initialValue() {
+ return HFactory.createKeyspace(keyspaceName, getCluster());
+ }
+
+ /**
+ * Returns the hector cluster object
+ * @return
+ */
+ public Cluster getCluster(){
+ return HFactory.getOrCreateCluster(clusterName, servers);
+ }
+
+ public String getClusterName() {
+ return clusterName;
+ }
+
+ public void setClusterName(String clusterName) {
+ this.clusterName = clusterName;
+ }
+
+ public String getKeyspaceName() {
+ return keyspaceName;
+ }
+
+ public void setKeyspaceName(String keyspaceName) {
+ this.keyspaceName = keyspaceName;
+ }
+
+ public String getServers() {
+ return servers;
+ }
+
+ public void setServers(String servers) {
+ this.servers = servers;
+ }
+
+
+}

0 comments on commit e1b2327

Please sign in to comment.
Something went wrong with that request. Please try again.