Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

creating keyspace (form, remote method etc.)

  • Loading branch information...
commit 30279f8541b69a73187cc0a053a824aaa83edd68 1 parent bb98ea3
tomek authored
View
32 src/main/frontend/source/class/helenos/components/SchemaPane.js
@@ -63,7 +63,37 @@ qx.Class.define("helenos.components.SchemaPane",
},
__addKeyspace : function() {
-
+ var formData = {
+ 'keyspaceName' : {
+ 'type' : 'TextField',
+ 'label' : 'Name',
+ 'value' : '',
+ 'validation' : {
+ 'required' : true
+ }
+ },
+ 'strategyClass' : {
+ 'type' : 'SelectBox',
+ 'label' : 'Strategy class',
+ 'value' : 1,
+ 'options' : helenos.util.CassandraTypes.strategyClasses,
+ 'validation' : {
+ 'required' : true
+ }
+ },
+ 'replicationFactor' : {
+ 'type' : 'TextField',
+ 'label' : 'Replication factor',
+ 'value' : '1',
+ 'validation' : {
+ 'required' : true
+ }
+ }
+ };
+ dialog.Dialog.form('<h4>Create new keyspace</h4>', formData, function(result) {
+ helenos.util.RpcActionsProvider.createKeyspace(result);
+ helenos.util.GuiObserver.refreshSchemaTree();
+ });
},
refreshSchemaTree : function() {
View
11 src/main/frontend/source/class/helenos/util/CassandraTypes.js
@@ -60,6 +60,17 @@ qx.Class.define('helenos.util.CassandraTypes', {
'value' : "org.apache.cassandra.db.marshal.CounterColumnType"
}
],
+
+ strategyClasses : [
+ {
+ 'label' : "Simple",
+ 'value' : "org.apache.cassandra.locator.SimpleStrategy"
+ },
+ {
+ 'label' : "Network topology",
+ 'value' : "org.apache.cassandra.locator.NetworkTopologyStrategy"
+ }
+ ],
columnTypes : [
{
View
8 src/main/frontend/source/class/helenos/util/RpcActionsProvider.js
@@ -11,7 +11,8 @@ qx.Class.define('helenos.util.RpcActionsProvider', {
statics : {
_SCHEMA : '/Schema.json',
- _QUERY : '/Query.json',
+ _STANDARDQUERY : '/query/Standard.json',
+ _SUPERQUERY : '/query/Super.json',
dropKeyspace : function(keyspaceName) {
var rpc = new helenos.util.Rpc(this._SCHEMA);
@@ -51,6 +52,11 @@ qx.Class.define('helenos.util.RpcActionsProvider', {
createColumnFamily : function(formData) {
var rpc = new helenos.util.Rpc(this._SCHEMA);
return rpc.callSync('createColumnFamily', formData);
+ },
+
+ createKeyspace : function(formData) {
+ var rpc = new helenos.util.Rpc(this._SCHEMA);
+ return rpc.callSync('createKeyspace', formData);
}
}
});
View
19 src/main/java/com/kuprowski/helenos/service/SchemaProvider.java
@@ -7,6 +7,7 @@
import com.kuprowski.helenos.types.JsonColumnFamilyDefinition;
import com.kuprowski.helenos.types.JsonKeyspaceDefinition;
import com.kuprowski.helenos.types.qx.QxJsonColumnFamilyDefinition;
+import com.kuprowski.helenos.types.qx.QxJsonKeyspaceDefinition;
import java.util.List;
/**
@@ -19,20 +20,22 @@
* *******************************************************
*/
public interface SchemaProvider {
-
+
String describeClusterName();
-
+
void dropKeyspace(String keyspaceName);
-
+
void truncateColumnFamily(String keyspaceName, String columnFamily);
-
+
void dropColumnFamily(String keyspaceName, String columnFamily);
-
+
List<JsonKeyspaceDefinition> describeKeyspaces();
-
+
JsonKeyspaceDefinition describeKeyspace(String keyspaceName);
-
+
JsonColumnFamilyDefinition describeColumnFamily(String keyspaceName, String columnFamilyName);
-
+
void createColumnFamily(QxJsonColumnFamilyDefinition qxDef);
+
+ void createKeyspace(QxJsonKeyspaceDefinition qxDef);
}
View
9 src/main/java/com/kuprowski/helenos/service/impl/SchemaProviderImpl.java
@@ -4,9 +4,11 @@
import com.kuprowski.helenos.types.JsonColumnFamilyDefinition;
import com.kuprowski.helenos.types.JsonKeyspaceDefinition;
import com.kuprowski.helenos.types.qx.QxJsonColumnFamilyDefinition;
+import com.kuprowski.helenos.types.qx.QxJsonKeyspaceDefinition;
import java.util.ArrayList;
import java.util.List;
import me.prettyprint.cassandra.service.ThriftCfDef;
+import me.prettyprint.cassandra.service.ThriftKsDef;
import me.prettyprint.hector.api.ddl.ColumnFamilyDefinition;
import me.prettyprint.hector.api.ddl.ColumnType;
import me.prettyprint.hector.api.ddl.ComparatorType;
@@ -89,4 +91,11 @@ public void createColumnFamily(QxJsonColumnFamilyDefinition qxDef) {
cluster.addColumnFamily(cfDef, true);
}
+
+ @Override
+ public void createKeyspace(QxJsonKeyspaceDefinition qxDef) {
+ KeyspaceDefinition ksDef = new ThriftKsDef(qxDef.getKeyspaceName(), qxDef.getStrategyClass(), qxDef.getReplicationFactor(), new ArrayList<ColumnFamilyDefinition>(0));
+
+ cluster.addKeyspace(ksDef, true);
+ }
}
View
8 src/main/java/com/kuprowski/helenos/service/impl/StandardQueryProviderImpl.java
@@ -15,6 +15,14 @@
import org.springframework.stereotype.Component;
/**
+ *
+{
+"id" : 1,
+"method" : "singleColumn",
+"params" : ["java.lang.String", "java.lang.String", "lookminders", "Users", "mama", "userdata"]
+}
+ */
+/**
* ********************************************************
* Copyright: 2012 Tomek Kuprowski
*
View
44 src/main/java/com/kuprowski/helenos/types/qx/QxJsonKeyspaceDefinition.java
@@ -0,0 +1,44 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package com.kuprowski.helenos.types.qx;
+
+/**
+ *
+ * @author tomek
+ */
+public class QxJsonKeyspaceDefinition {
+
+ public QxJsonKeyspaceDefinition() {
+
+ }
+
+ private String keyspaceName;
+ private int replicationFactor;
+ private String strategyClass;
+
+ public String getKeyspaceName() {
+ return keyspaceName;
+ }
+
+ public void setKeyspaceName(String keyspaceName) {
+ this.keyspaceName = keyspaceName;
+ }
+
+ public int getReplicationFactor() {
+ return replicationFactor;
+ }
+
+ public void setReplicationFactor(int replicationFactor) {
+ this.replicationFactor = replicationFactor;
+ }
+
+ public String getStrategyClass() {
+ return strategyClass;
+ }
+
+ public void setStrategyClass(String strategyClass) {
+ this.strategyClass = strategyClass;
+ }
+}
View
3  todo.txt
@@ -7,9 +7,6 @@ Slice predicate:
wola SliceQuery i jego odpowiedniki zgodnie z powyzszym
-
-
-
MultigetSliceCounterQuery<UUID, Character> query = HFactory.createMultigetSliceCounterQuery(getKeyspace(), UUIDSerializer.get(), CharSerializer.get());
query = query.setColumnFamily(PHOTO_COUNTERS_CF_NAME).setColumnNames(LikeType.ALL_COLUMN_NAMES);
query = query.setKeys(photosIds);
Please sign in to comment.
Something went wrong with that request. Please try again.