Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

moved static factory IntraOp methods up to Operations class

  • Loading branch information...
commit 1127ad0c93678be7e959421eb42a6e7c168e7f03 1 parent f7ab375
@zznate authored
View
14 src/main/java/org/usergrid/vx/experimental/IntraClient.java
@@ -112,13 +112,13 @@ public static void main(String[] args) throws Exception {
IntraClient i = new IntraClient();
i.payload="json";
IntraReq req = new IntraReq();
- req.add( IntraOp.setKeyspaceOp("myks") );
- req.add( IntraOp.createKsOp("myks", 1));
- req.add( IntraOp.createCfOp("mycf"));
- req.add( IntraOp.setColumnFamilyOp("mycf") );
- req.add( IntraOp.setAutotimestampOp() );
- req.add( IntraOp.setOp("5", "6", "7"));
- req.add( IntraOp.sliceOp("5", "1", "9", 4));
+ req.add( Operations.setKeyspaceOp("myks") );
+ req.add( Operations.createKsOp("myks", 1));
+ req.add( Operations.createCfOp("mycf"));
+ req.add( Operations.setColumnFamilyOp("mycf") );
+ req.add( Operations.setAutotimestampOp() );
+ req.add( Operations.setOp("5", "6", "7"));
+ req.add( Operations.sliceOp("5", "1", "9", 4));
//req.add( IntraOp.setOp("bob", new Object [] { 4, "stuff" }, 10) );
//req.add( IntraOp.getOp("bob", new Object [] { 4, "stuff" }) );
//req.add( IntraOp.setKeyspaceOp("otherks") );
View
210 src/main/java/org/usergrid/vx/experimental/IntraOp.java
@@ -49,224 +49,14 @@ public IntraOp set(String key, Object value){
return this;
}
-
public Map<String, Object> getOp() {
return op;
}
-
- public static IntraOp setKeyspaceOp(String keyspace){
- checkForBlankStr(keyspace, "keyspace", Type.SETKEYSPACE);
- IntraOp i = new IntraOp(Type.SETKEYSPACE);
- i.set("keyspace", keyspace);
- return i;
- }
-
- public static IntraOp setColumnFamilyOp(String columnFamily){
- checkForBlankStr(columnFamily, "columnFamily",Type.SETCOLUMNFAMILY);
- IntraOp i = new IntraOp(Type.SETCOLUMNFAMILY);
- i.set("columnfamily", columnFamily);
- return i;
- }
-
- public static IntraOp setAutotimestampOp(){
- IntraOp i = new IntraOp(Type.AUTOTIMESTAMP);
- return i;
- }
-
- public static IntraOp setOp(Object rowkey, Object columnName, Object columnValue){
- Preconditions.checkArgument(rowkey != null, "The rowkey cannot be null for {}", Type.SET);
- Preconditions.checkArgument(columnName != null, "The columnName cannot be null for {}", Type.SET);
- Preconditions.checkArgument(columnValue != null, "Cannot set a column to null for {}", Type.SET);
- IntraOp i = new IntraOp(Type.SET);
- i.set("rowkey", rowkey);
- i.set("name", columnName);
- i.set("value", columnValue);
- return i;
- }
-
- public static IntraOp batchSetOp(List<Map> rows){
- IntraOp i = new IntraOp(Type.BATCHSET);
- i.set("rows", rows);
- return i;
- }
- public static IntraOp getOp(Object rowkey, Object columnName){
- Preconditions.checkArgument(rowkey != null, "The rowkey cannot be null for {}", Type.GET);
- Preconditions.checkArgument(columnName != null, "The columnName cannot be null for {}", Type.GET);
- IntraOp i = new IntraOp(Type.GET);
- i.set("rowkey", rowkey);
- i.set("name", columnName);
- return i;
- }
-
- public static IntraOp getResRefOp(int reference, String wanted){
- Preconditions.checkArgument(reference >= 0);
- checkForBlankStr(wanted, "wanted", Type.GETREF);
- IntraOp i = new IntraOp(Type.GETREF);
- i.set("resultref", reference);
- i.set("wanted", wanted);
- return i;
- }
-
- public static IntraOp sliceOp( Object rowkey , Object start, Object end, int size){
- Preconditions.checkArgument(rowkey != null,"A row key is required for {}", Type.SLICE);
- Preconditions.checkArgument(size > 0, "A slice size must be positive integer for {}", Type.SLICE);
- IntraOp i = new IntraOp(Type.SLICE);
- i.set("rowkey", rowkey);
- i.set("start", start);
- i.set("end", end);
- i.set("size", size);
- return i;
- }
-
- public static IntraOp columnPredicateOp( Object rowkey, Object [] columnList){
- Preconditions.checkArgument(columnList != null, "You much provide a columnList array");
- IntraOp i = new IntraOp(Type.COLUMNPREDICATE);
- i.set("wantedcols", columnList);
- return i;
- }
-
- public static IntraOp forEachOp( int opRef, IntraOp action){
- Preconditions.checkArgument(action != null, "The IntraOp action cannot be null");
- IntraOp i = new IntraOp(Type.FOREACH);
- i.set("action", action);
- return i;
- }
-
- public static IntraOp createCfOp(String cfName){
- checkForBlankStr(cfName, "columnFamily name", Type.CREATECOLUMNFAMILY);
- IntraOp i = new IntraOp(Type.CREATECOLUMNFAMILY);
- i.set("name", cfName);
- return i;
- }
-
- public static IntraOp createKsOp(String ksname, int replication){
- checkForBlankStr(ksname, "keyspace name", Type.CREATEKEYSPACE);
- Preconditions.checkArgument(replication > 0,
- "A value for positive value for 'replication' is required for {}", Type.CREATEKEYSPACE);
- IntraOp i = new IntraOp(Type.CREATEKEYSPACE);
- i.set("name", ksname);
- i.set("replication", replication);
- return i;
- }
-
- public static IntraOp consistencyOp(String name){
- // Force an IllegalArgumentException
- ConsistencyLevel.valueOf(name);
- IntraOp i = new IntraOp(Type.CONSISTENCY);
- i.set("level", name);
- return i;
- }
-
- public static IntraOp listKeyspacesOp(){
- IntraOp i = new IntraOp(Type.LISTKEYSPACES);
- return i;
- }
-
- public static IntraOp listColumnFamilyOp(String keyspace){
- checkForBlankStr(keyspace, "Keyspace name", Type.LISTCOLUMNFAMILY);
- IntraOp i = new IntraOp(Type.LISTCOLUMNFAMILY);
- i.set("keyspace", keyspace);
- return i;
- }
-
- public static IntraOp assumeOp(String keyspace,String columnfamily,String type, String clazz){
- IntraOp i = new IntraOp(Type.ASSUME);
- i.set("keyspace", keyspace);
- i.set("columnfamily", columnfamily);
- i.set("type", type); //should be column rowkey value
- i.set("clazz", clazz );
- return i;
- }
-
- public static IntraOp createProcessorOp(String name, String spec, String value){
- IntraOp i = new IntraOp(Type.CREATEPROCESSOR);
- i.set("name",name);
- i.set("spec", spec);
- i.set("value", value);
- return i;
- }
-
- public static IntraOp processOp(String processorName, Map params, int inputId){
- IntraOp i = new IntraOp(Type.PROCESS);
- i.set("processorname", processorName);
- i.set("params", params);
- i.set("input", inputId);
- return i;
- }
-
- public static IntraOp dropKeyspaceOp(String ksname){
- IntraOp i = new IntraOp(Type.DROPKEYSPACE);
- i.set("keyspace", ksname);
- return i;
- }
-
- public static IntraOp createFilterOp(String name, String spec, String value) {
- IntraOp i = new IntraOp(Type.CREATEFILTER);
- i.set("name", name);
- i.set("spec", spec);
- i.set("value", value);
- return i;
- }
-
- public static IntraOp filterModeOp(String name, boolean on) {
- IntraOp i = new IntraOp(Type.FILTERMODE);
- i.set("name", name);
- i.set("on", on);
- return i;
- }
-
- public static IntraOp cqlQuery(String query, String version){
- IntraOp i = new IntraOp(Type.CQLQUERY);
- i.set("query", query);
- i.set("version", version );
- return i;
- }
-
- public static IntraOp clear(int resultId){
- IntraOp i = new IntraOp(Type.CLEAR);
- i.set("id", resultId);
- return i;
- }
-
- public static IntraOp createMultiProcess(String name, String spec, String value){
- IntraOp i = new IntraOp(Type.CREATEMULTIPROCESS);
- i.set("name", name);
- i.set("spec", spec);
- i.set("value", value);
- return i;
- }
-
- public static IntraOp multiProcess(String processorName, Map params){
- IntraOp i = new IntraOp(Type.MULTIPROCESS);
- i.set("name", processorName);
- i.set("params", params);
- return i;
- }
-
public Type getType() {
return type;
}
-
- public static IntraOp saveState(){
- IntraOp i = new IntraOp(Type.STATE);
- i.set("mode", "save");
- return i;
- }
-
- public static IntraOp restoreState(int id){
- IntraOp i = new IntraOp(Type.STATE);
- i.set("mode", "get");
- i.set("id", id);
- return i;
- }
- private static void checkForBlankStr(String arg, String msg, Type type) {
- Preconditions.checkArgument(arg != null && arg.length() > 0,
- "A non-blank '{}' is required for {}", new Object[]{msg,type});
- }
-
-
public enum Type {
LISTCOLUMNFAMILY {
View
196 src/main/java/org/usergrid/vx/experimental/Operations.java
@@ -0,0 +1,196 @@
+package org.usergrid.vx.experimental;
+
+import com.google.common.base.Preconditions;
+import org.apache.cassandra.db.ConsistencyLevel;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Factory class for building IntraOp objects
+ * @author zznate
+ */
+public class Operations {
+ private Operations() {}
+
+ public static IntraOp setKeyspaceOp(String keyspace){
+ checkForBlankStr(keyspace, "keyspace", IntraOp.Type.SETKEYSPACE);
+ return new IntraOp(IntraOp.Type.SETKEYSPACE)
+ .set("keyspace", keyspace);
+ }
+
+ public static IntraOp setColumnFamilyOp(String columnFamily){
+ checkForBlankStr(columnFamily, "columnFamily", IntraOp.Type.SETCOLUMNFAMILY);
+ return new IntraOp(IntraOp.Type.SETCOLUMNFAMILY)
+ .set("columnfamily", columnFamily);
+ }
+
+ public static IntraOp setAutotimestampOp(){
+ return new IntraOp(IntraOp.Type.AUTOTIMESTAMP);
+ }
+
+ public static IntraOp setOp(Object rowkey, Object columnName, Object columnValue){
+ Preconditions.checkArgument(rowkey != null, "The rowkey cannot be null for {}", IntraOp.Type.SET);
+ Preconditions.checkArgument(columnName != null, "The columnName cannot be null for {}", IntraOp.Type.SET);
+ Preconditions.checkArgument(columnValue != null, "Cannot set a column to null for {}", IntraOp.Type.SET);
+ return new IntraOp(IntraOp.Type.SET)
+ .set("rowkey", rowkey)
+ .set("name", columnName)
+ .set("value", columnValue);
+ }
+
+ public static IntraOp batchSetOp(List<Map> rows){
+ return new IntraOp(IntraOp.Type.BATCHSET).set("rows", rows);
+ }
+
+ public static IntraOp getOp(Object rowkey, Object columnName){
+ Preconditions.checkArgument(rowkey != null, "The rowkey cannot be null for {}", IntraOp.Type.GET);
+ Preconditions.checkArgument(columnName != null, "The columnName cannot be null for {}", IntraOp.Type.GET);
+ return new IntraOp(IntraOp.Type.GET)
+ .set("rowkey", rowkey)
+ .set("name", columnName);
+ }
+
+ public static IntraOp getResRefOp(int reference, String wanted){
+ Preconditions.checkArgument(reference >= 0);
+ checkForBlankStr(wanted, "wanted", IntraOp.Type.GETREF);
+ return new IntraOp(IntraOp.Type.GETREF)
+ .set("resultref", reference)
+ .set("wanted", wanted);
+ }
+
+ public static IntraOp sliceOp( Object rowkey , Object start, Object end, int size){
+ Preconditions.checkArgument(rowkey != null,"A row key is required for {}", IntraOp.Type.SLICE);
+ Preconditions.checkArgument(size > 0, "A slice size must be positive integer for {}", IntraOp.Type.SLICE);
+ return new IntraOp(IntraOp.Type.SLICE)
+ .set("rowkey", rowkey)
+ .set("start", start)
+ .set("end", end)
+ .set("size", size);
+ }
+
+ public static IntraOp columnPredicateOp( Object rowkey, Object [] columnList){
+ Preconditions.checkArgument(columnList != null, "You much provide a columnList array");
+ return new IntraOp(IntraOp.Type.COLUMNPREDICATE)
+ .set("wantedcols", columnList);
+ }
+
+ public static IntraOp forEachOp( int opRef, IntraOp action){
+ Preconditions.checkArgument(action != null, "The IntraOp action cannot be null");
+ return new IntraOp(IntraOp.Type.FOREACH)
+ .set("action", action);
+ }
+
+ public static IntraOp createCfOp(String cfName){
+ checkForBlankStr(cfName, "columnFamily name", IntraOp.Type.CREATECOLUMNFAMILY);
+ return new IntraOp(IntraOp.Type.CREATECOLUMNFAMILY)
+ .set("name", cfName);
+ }
+
+ public static IntraOp createKsOp(String ksname, int replication){
+ checkForBlankStr(ksname, "keyspace name", IntraOp.Type.CREATEKEYSPACE);
+ Preconditions.checkArgument(replication > 0,
+ "A value for positive value for 'replication' is required for {}", IntraOp.Type.CREATEKEYSPACE);
+ return new IntraOp(IntraOp.Type.CREATEKEYSPACE)
+ .set("name", ksname)
+ .set("replication", replication);
+ }
+
+ public static IntraOp consistencyOp(String name){
+ // Force an IllegalArgumentException
+ ConsistencyLevel.valueOf(name);
+ return new IntraOp(IntraOp.Type.CONSISTENCY)
+ .set("level", name);
+ }
+
+ public static IntraOp listKeyspacesOp(){
+ return new IntraOp(IntraOp.Type.LISTKEYSPACES);
+ }
+
+ public static IntraOp listColumnFamilyOp(String keyspace){
+ checkForBlankStr(keyspace, "Keyspace name", IntraOp.Type.LISTCOLUMNFAMILY);
+ return new IntraOp(IntraOp.Type.LISTCOLUMNFAMILY)
+ .set("keyspace", keyspace);
+ }
+
+ public static IntraOp assumeOp(String keyspace,String columnfamily,String type, String clazz){
+ return new IntraOp(IntraOp.Type.ASSUME)
+ .set("keyspace", keyspace)
+ .set("columnfamily", columnfamily)
+ .set("type", type) //should be column rowkey value
+ .set("clazz", clazz );
+ }
+
+ public static IntraOp createProcessorOp(String name, String spec, String value){
+ return new IntraOp(IntraOp.Type.CREATEPROCESSOR)
+ .set("name",name)
+ .set("spec", spec)
+ .set("value", value);
+ }
+
+ public static IntraOp processOp(String processorName, Map params, int inputId){
+ return new IntraOp(IntraOp.Type.PROCESS)
+ .set("processorname", processorName)
+ .set("params", params)
+ .set("input", inputId);
+ }
+
+ public static IntraOp dropKeyspaceOp(String ksname){
+ return new IntraOp(IntraOp.Type.DROPKEYSPACE)
+ .set("keyspace", ksname);
+ }
+
+ public static IntraOp createFilterOp(String name, String spec, String value) {
+ return new IntraOp(IntraOp.Type.CREATEFILTER)
+ .set("name", name)
+ .set("spec", spec)
+ .set("value", value);
+ }
+
+ public static IntraOp filterModeOp(String name, boolean on) {
+ return new IntraOp(IntraOp.Type.FILTERMODE)
+ .set("name", name)
+ .set("on", on);
+ }
+
+ public static IntraOp cqlQuery(String query, String version){
+ return new IntraOp(IntraOp.Type.CQLQUERY)
+ .set("query", query)
+ .set("version", version);
+ }
+
+ public static IntraOp clear(int resultId){
+ return new IntraOp(IntraOp.Type.CLEAR)
+ .set("id", resultId);
+ }
+
+ public static IntraOp createMultiProcess(String name, String spec, String value){
+ return new IntraOp(IntraOp.Type.CREATEMULTIPROCESS)
+ .set("name", name)
+ .set("spec", spec)
+ .set("value", value);
+ }
+
+ public static IntraOp multiProcess(String processorName, Map params){
+ return new IntraOp(IntraOp.Type.MULTIPROCESS)
+ .set("name", processorName)
+ .set("params", params);
+ }
+
+ public static IntraOp saveState(){
+ return new IntraOp(IntraOp.Type.STATE)
+ .set("mode", "save");
+ }
+
+ public static IntraOp restoreState(int id){
+ return new IntraOp(IntraOp.Type.STATE)
+ .set("mode", "get")
+ .set("id", id);
+ }
+
+
+ private static void checkForBlankStr(String arg, String msg, IntraOp.Type type) {
+ Preconditions.checkArgument(arg != null && arg.length() > 0,
+ "A non-blank '{}' is required for {}", new Object[]{msg, type});
+ }
+}
View
22 src/test/java/org/usergrid/vx/experimental/IntraOpUnitTest.java
@@ -12,22 +12,22 @@
@Test
public void validateOk() {
- IntraOp op = IntraOp.listColumnFamilyOp("mykeyspace");
- op = IntraOp.consistencyOp("QUORUM");
- op = IntraOp.createKsOp("mykeyspace",1);
- op = IntraOp.getOp("rowkey","colname");
- op = IntraOp.setOp("rowkey","colname","colvalue");
- op = IntraOp.sliceOp("rowkey","start","end",10);
- op = IntraOp.sliceOp("rowkey", null, null, 10);
- op = IntraOp.createCfOp("MyCf");
- op = IntraOp.createKsOp("MyKeyspace",3);
+ IntraOp op = Operations.listColumnFamilyOp("mykeyspace");
+ op = Operations.consistencyOp("QUORUM");
+ op = Operations.createKsOp("mykeyspace",1);
+ op = Operations.getOp("rowkey","colname");
+ op = Operations.setOp("rowkey","colname","colvalue");
+ op = Operations.sliceOp("rowkey","start","end",10);
+ op = Operations.sliceOp("rowkey", null, null, 10);
+ op = Operations.createCfOp("MyCf");
+ op = Operations.createKsOp("MyKeyspace",3);
try {
- op = IntraOp.createKsOp("mykeyspace",0);
+ op = Operations.createKsOp("mykeyspace",0);
fail(op.getType().toString());
} catch (IllegalArgumentException iae) {} // nom nom nom
try {
- op = IntraOp.consistencyOp("foo");
+ op = Operations.consistencyOp("foo");
fail(op.getType().toString());
} catch (IllegalArgumentException iae) {} // nom nom nom
View
234 src/test/java/org/usergrid/vx/experimental/IntraServiceTest.java
@@ -45,20 +45,20 @@
@Test
public void atest() throws CharacterCodingException{
IntraReq req = new IntraReq();
- req.add( IntraOp.setKeyspaceOp("myks") ); //0
- req.add( IntraOp.setColumnFamilyOp("mycf") ); //1
- req.add( IntraOp.setAutotimestampOp() ); //2
- req.add( IntraOp.setOp("rowa", "col1", "7")); //3
- req.add( IntraOp.sliceOp("rowa", "col1", "z", 4)); //4
- req.add( IntraOp.getOp("rowa", "col1")); //5
+ req.add( Operations.setKeyspaceOp("myks") ); //0
+ req.add( Operations.setColumnFamilyOp("mycf") ); //1
+ req.add( Operations.setAutotimestampOp() ); //2
+ req.add( Operations.setOp("rowa", "col1", "7")); //3
+ req.add( Operations.sliceOp("rowa", "col1", "z", 4)); //4
+ req.add( Operations.getOp("rowa", "col1")); //5
//create a rowkey "rowb" with a column "col2" and a value of the result of operation 7
- req.add( IntraOp.setOp("rowb", "col2", IntraOp.getResRefOp(5, "value"))); //6
+ req.add( Operations.setOp("rowb", "col2", Operations.getResRefOp(5, "value"))); //6
//Read this row back
- req.add( IntraOp.getOp("rowb", "col2"));//7
+ req.add( Operations.getOp("rowb", "col2"));//7
- req.add( IntraOp.consistencyOp("ALL")); //8
- req.add( IntraOp.listKeyspacesOp()); //9
- req.add(IntraOp.listColumnFamilyOp("myks"));//10
+ req.add( Operations.consistencyOp("ALL")); //8
+ req.add( Operations.listKeyspacesOp()); //9
+ req.add(Operations.listColumnFamilyOp("myks"));//10
IntraRes res = new IntraRes();
is.handleIntraReq(req, res, x);
@@ -90,9 +90,9 @@ public void atest() throws CharacterCodingException{
@Test
public void exceptionHandleTest() throws CharacterCodingException{
IntraReq req = new IntraReq();
- req.add( IntraOp.createKsOp("makeksagain", 1)); //0
- req.add( IntraOp.createKsOp("makeksagain", 1)); //1
- req.add( IntraOp.createKsOp("makeksagain", 1)); //2
+ req.add( Operations.createKsOp("makeksagain", 1)); //0
+ req.add( Operations.createKsOp("makeksagain", 1)); //1
+ req.add( Operations.createKsOp("makeksagain", 1)); //2
IntraRes res = new IntraRes();
is.handleIntraReq(req, res, x);
Assert.assertEquals ( "OK" , res.getOpsRes().get(0) );
@@ -104,14 +104,14 @@ public void exceptionHandleTest() throws CharacterCodingException{
@Test
public void assumeTest() throws CharacterCodingException{
IntraReq req = new IntraReq();
- req.add( IntraOp.setKeyspaceOp("assks") ); //0
- req.add( IntraOp.createKsOp("assks", 1)); //1
- req.add( IntraOp.createCfOp("asscf")); //2
- req.add( IntraOp.setColumnFamilyOp("asscf") ); //3
- req.add( IntraOp.setAutotimestampOp() ); //4
- req.add( IntraOp.assumeOp("assks", "asscf", "value", "UTF-8"));//5
- req.add( IntraOp.setOp("rowa", "col1", "wow")); //6
- req.add( IntraOp.getOp("rowa", "col1")); //7
+ req.add( Operations.setKeyspaceOp("assks") ); //0
+ req.add( Operations.createKsOp("assks", 1)); //1
+ req.add( Operations.createCfOp("asscf")); //2
+ req.add( Operations.setColumnFamilyOp("asscf") ); //3
+ req.add( Operations.setAutotimestampOp() ); //4
+ req.add( Operations.assumeOp("assks", "asscf", "value", "UTF-8"));//5
+ req.add( Operations.setOp("rowa", "col1", "wow")); //6
+ req.add( Operations.getOp("rowa", "col1")); //7
IntraRes res = new IntraRes();
is.handleIntraReq(req, res, x);
List<Map> x = (List<Map>) res.getOpsRes().get(7);
@@ -121,15 +121,15 @@ public void assumeTest() throws CharacterCodingException{
@Test
public void filterTest() throws CharacterCodingException{
IntraReq req = new IntraReq();
- req.add( IntraOp.setKeyspaceOp("filterks") ); //0
- req.add( IntraOp.createKsOp("filterks", 1)); //1
- req.add( IntraOp.createCfOp("filtercf")); //2
- req.add( IntraOp.setColumnFamilyOp("filtercf") ); //3
- req.add( IntraOp.setAutotimestampOp() ); //4
- req.add( IntraOp.assumeOp("filterks", "filtercf", "value", "UTF-8"));//5
- req.add( IntraOp.setOp("rowa", "col1", "20")); //6
- req.add( IntraOp.setOp("rowa", "col2", "22")); //7
- req.add( IntraOp.createFilterOp("over21", "groovy",
+ req.add( Operations.setKeyspaceOp("filterks") ); //0
+ req.add( Operations.createKsOp("filterks", 1)); //1
+ req.add( Operations.createCfOp("filtercf")); //2
+ req.add( Operations.setColumnFamilyOp("filtercf") ); //3
+ req.add( Operations.setAutotimestampOp() ); //4
+ req.add( Operations.assumeOp("filterks", "filtercf", "value", "UTF-8"));//5
+ req.add( Operations.setOp("rowa", "col1", "20")); //6
+ req.add( Operations.setOp("rowa", "col2", "22")); //7
+ req.add( Operations.createFilterOp("over21", "groovy",
"public class Over21 implements org.usergrid.vx.experimental.Filter { \n"+
" public Map filter(Map row){ \n" +
" if (Integer.parseInt( row.get(\"value\") ) >21){ \n"+
@@ -138,8 +138,8 @@ public void filterTest() throws CharacterCodingException{
" } \n" +
"} \n"
)); //8
- req.add( IntraOp.filterModeOp("over21", true)); //9
- req.add( IntraOp.sliceOp("rowa", "col1", "col3", 10)); //10
+ req.add( Operations.filterModeOp("over21", true)); //9
+ req.add( Operations.sliceOp("rowa", "col1", "col3", 10)); //10
IntraRes res = new IntraRes();
is.handleIntraReq(req, res, x);
System.out.println ( res.getException() );
@@ -152,15 +152,15 @@ public void filterTest() throws CharacterCodingException{
@Test
public void processorTest() throws CharacterCodingException{
IntraReq req = new IntraReq();
- req.add( IntraOp.setKeyspaceOp("procks") ); //0
- req.add( IntraOp.createKsOp("procks", 1)); //1
- req.add( IntraOp.createCfOp("proccf")); //2
- req.add( IntraOp.setColumnFamilyOp("proccf") ); //3
- req.add( IntraOp.setAutotimestampOp() ); //4
- req.add( IntraOp.assumeOp("procks", "proccf", "value", "UTF-8"));//5
- req.add( IntraOp.setOp("rowa", "col1", "wow")); //6
- req.add( IntraOp.getOp("rowa", "col1")); //7
- req.add( IntraOp.createProcessorOp("capitalize", "groovy",
+ req.add( Operations.setKeyspaceOp("procks") ); //0
+ req.add( Operations.createKsOp("procks", 1)); //1
+ req.add( Operations.createCfOp("proccf")); //2
+ req.add( Operations.setColumnFamilyOp("proccf") ); //3
+ req.add( Operations.setAutotimestampOp() ); //4
+ req.add( Operations.assumeOp("procks", "proccf", "value", "UTF-8"));//5
+ req.add( Operations.setOp("rowa", "col1", "wow")); //6
+ req.add( Operations.getOp("rowa", "col1")); //7
+ req.add( Operations.createProcessorOp("capitalize", "groovy",
"public class Capitalize implements org.usergrid.vx.experimental.Processor { \n"+
" public List<Map> process(List<Map> input){" +
" List<Map> results = new ArrayList<HashMap>();"+
@@ -174,7 +174,7 @@ public void processorTest() throws CharacterCodingException{
"}\n"
));//8
//TAKE THE RESULT OF STEP 7 AND APPLY THE PROCESSOR TO IT
- req.add( IntraOp.processOp("capitalize", new HashMap(), 7));//9
+ req.add( Operations.processOp("capitalize", new HashMap(), 7));//9
IntraRes res = new IntraRes();
is.handleIntraReq(req, res, x);
List<Map> x = (List<Map>) res.getOpsRes().get(7);
@@ -189,15 +189,15 @@ public void processorTest() throws CharacterCodingException{
@Test
public void intTest() throws CharacterCodingException{
IntraReq req = new IntraReq();
- req.add( IntraOp.setKeyspaceOp("intks") ); //0
- req.add( IntraOp.createKsOp("intks", 1)); //1
- req.add( IntraOp.createCfOp("intcf")); //2
- req.add( IntraOp.setColumnFamilyOp("intcf") ); //3
- req.add( IntraOp.setAutotimestampOp() ); //4
- req.add( IntraOp.assumeOp("intks", "intcf", "value", "UTF-8"));//5
- req.add( IntraOp.assumeOp("intks", "intcf", "column", "int32"));//6
- req.add( IntraOp.setOp("rowa", 1, "wow")); //7
- req.add( IntraOp.getOp("rowa", 1)); //8
+ req.add( Operations.setKeyspaceOp("intks") ); //0
+ req.add( Operations.createKsOp("intks", 1)); //1
+ req.add( Operations.createCfOp("intcf")); //2
+ req.add( Operations.setColumnFamilyOp("intcf") ); //3
+ req.add( Operations.setAutotimestampOp() ); //4
+ req.add( Operations.assumeOp("intks", "intcf", "value", "UTF-8"));//5
+ req.add( Operations.assumeOp("intks", "intcf", "column", "int32"));//6
+ req.add( Operations.setOp("rowa", 1, "wow")); //7
+ req.add( Operations.getOp("rowa", 1)); //8
IntraRes res = new IntraRes();
is.handleIntraReq(req, res, x);
@@ -210,15 +210,15 @@ public void intTest() throws CharacterCodingException{
@Test
public void compositeTest() throws CharacterCodingException{
IntraReq req = new IntraReq();
- req.add( IntraOp.setKeyspaceOp("compks") ); //0
- req.add( IntraOp.createKsOp("compks", 1)); //1
- req.add( IntraOp.createCfOp("compcf")); //2
- req.add( IntraOp.setColumnFamilyOp("compcf") ); //3
- req.add( IntraOp.setAutotimestampOp() ); //4
- req.add( IntraOp.assumeOp("compks", "compcf", "value", "CompositeType(UTF-8,int32)"));//5
- req.add( IntraOp.assumeOp("compks", "compcf", "column", "int32"));//6
- req.add( IntraOp.setOp("rowa", 1, new Object[] {"yo",0, 2,0})); //7
- req.add( IntraOp.getOp("rowa", 1)); //8
+ req.add( Operations.setKeyspaceOp("compks") ); //0
+ req.add( Operations.createKsOp("compks", 1)); //1
+ req.add( Operations.createCfOp("compcf")); //2
+ req.add( Operations.setColumnFamilyOp("compcf") ); //3
+ req.add( Operations.setAutotimestampOp() ); //4
+ req.add( Operations.assumeOp("compks", "compcf", "value", "CompositeType(UTF-8,int32)"));//5
+ req.add( Operations.assumeOp("compks", "compcf", "column", "int32"));//6
+ req.add( Operations.setOp("rowa", 1, new Object[] {"yo",0, 2,0})); //7
+ req.add( Operations.getOp("rowa", 1)); //8
IntraRes res = new IntraRes();
is.handleIntraReq(req, res, x);
@@ -232,16 +232,16 @@ public void compositeTest() throws CharacterCodingException{
@Test
public void CqlTest() throws CharacterCodingException{
IntraReq req = new IntraReq();
- req.add( IntraOp.setKeyspaceOp("cqlks") ); //0
- req.add( IntraOp.createKsOp("cqlks", 1)); //1
- req.add( IntraOp.createCfOp("cqlcf")); //2
- req.add( IntraOp.setColumnFamilyOp("cqlcf") ); //3
- req.add( IntraOp.setAutotimestampOp() ); //4
- req.add( IntraOp.assumeOp("cqlks", "cqlcf", "value", "int32"));//5
- req.add( IntraOp.assumeOp("cqlks", "cqlcf", "column", "int32"));//6
- req.add( IntraOp.setOp("rowa", 1, 2)); //7
- req.add( IntraOp.getOp("rowa", 1)); //8
- req.add( IntraOp.cqlQuery("select * from cqlcf", "3.0.0"));//9
+ req.add( Operations.setKeyspaceOp("cqlks") ); //0
+ req.add( Operations.createKsOp("cqlks", 1)); //1
+ req.add( Operations.createCfOp("cqlcf")); //2
+ req.add( Operations.setColumnFamilyOp("cqlcf") ); //3
+ req.add( Operations.setAutotimestampOp() ); //4
+ req.add( Operations.assumeOp("cqlks", "cqlcf", "value", "int32"));//5
+ req.add( Operations.assumeOp("cqlks", "cqlcf", "column", "int32"));//6
+ req.add( Operations.setOp("rowa", 1, 2)); //7
+ req.add( Operations.getOp("rowa", 1)); //8
+ req.add( Operations.cqlQuery("select * from cqlcf", "3.0.0"));//9
IntraRes res = new IntraRes();
is.handleIntraReq(req, res, x);
@@ -259,16 +259,16 @@ public void CqlTest() throws CharacterCodingException{
@Test
public void clearTest() throws CharacterCodingException{
IntraReq req = new IntraReq();
- req.add( IntraOp.setKeyspaceOp("clearks") ); //0
- req.add( IntraOp.createKsOp("clearks", 1)); //1
- req.add( IntraOp.createCfOp("clearcf")); //2
- req.add( IntraOp.setColumnFamilyOp("clearcf") ); //3
- req.add( IntraOp.setAutotimestampOp() ); //4
- req.add( IntraOp.assumeOp("clearks", "clearcf", "value", "UTF-8")); //5
- req.add( IntraOp.setOp("rowa", 1, "wow")); //6
- req.add( IntraOp.getOp("rowa", 1)); //7
- req.add( IntraOp.getOp("rowa", 1)); //8
- req.add( IntraOp.clear(8)); //9
+ req.add( Operations.setKeyspaceOp("clearks") ); //0
+ req.add( Operations.createKsOp("clearks", 1)); //1
+ req.add( Operations.createCfOp("clearcf")); //2
+ req.add( Operations.setColumnFamilyOp("clearcf") ); //3
+ req.add( Operations.setAutotimestampOp() ); //4
+ req.add( Operations.assumeOp("clearks", "clearcf", "value", "UTF-8")); //5
+ req.add( Operations.setOp("rowa", 1, "wow")); //6
+ req.add( Operations.getOp("rowa", 1)); //7
+ req.add( Operations.getOp("rowa", 1)); //8
+ req.add( Operations.clear(8)); //9
IntraRes res = new IntraRes();
is.handleIntraReq(req, res, x);
@@ -284,10 +284,10 @@ public void clearTest() throws CharacterCodingException{
@RequiresColumnFamily(ksName = "myks", cfName = "mycf")
public void cqlEngineTest() throws Exception {
IntraReq req = new IntraReq();
- req.add( IntraOp.setKeyspaceOp("myks") ); //0
- req.add( IntraOp.setColumnFamilyOp("mycf") ); //1
- req.add( IntraOp.setAutotimestampOp() ); //2
- req.add( IntraOp.setOp("rowa", "col1", "7")); //3
+ req.add( Operations.setKeyspaceOp("myks") ); //0
+ req.add( Operations.setColumnFamilyOp("mycf") ); //1
+ req.add( Operations.setAutotimestampOp() ); //2
+ req.add( Operations.setOp("rowa", "col1", "7")); //3
IntraRes res = new IntraRes();
is.handleIntraReq(req, res, x);
@@ -310,18 +310,18 @@ public void cqlEngineTest() throws Exception {
@RequiresColumnFamily(ksName = "myks", cfName = "mycf")
public void multiProcessTest() throws Exception {
IntraReq req = new IntraReq();
- req.add( IntraOp.setKeyspaceOp("myks") ); //0
- req.add( IntraOp.setColumnFamilyOp("mycf") ); //1
- req.add( IntraOp.setAutotimestampOp() ); //2
- req.add( IntraOp.assumeOp("myks", "mycf", "value", "UTF-8")); //3
- req.add( IntraOp.setOp("rowzz", "col1", "7")); //4
- req.add( IntraOp.setOp("rowzz", "col2", "8")); //5
- req.add( IntraOp.setOp("rowyy", "col4", "9")); //6
- req.add( IntraOp.setOp("rowyy", "col2", "7")); //7
- req.add( IntraOp.sliceOp("rowzz", "a", "z", 100));//8
- req.add( IntraOp.sliceOp("rowyy", "a", "z", 100));//9
+ req.add( Operations.setKeyspaceOp("myks") ); //0
+ req.add( Operations.setColumnFamilyOp("mycf") ); //1
+ req.add( Operations.setAutotimestampOp() ); //2
+ req.add( Operations.assumeOp("myks", "mycf", "value", "UTF-8")); //3
+ req.add( Operations.setOp("rowzz", "col1", "7")); //4
+ req.add( Operations.setOp("rowzz", "col2", "8")); //5
+ req.add( Operations.setOp("rowyy", "col4", "9")); //6
+ req.add( Operations.setOp("rowyy", "col2", "7")); //7
+ req.add( Operations.sliceOp("rowzz", "a", "z", 100));//8
+ req.add( Operations.sliceOp("rowyy", "a", "z", 100));//9
- req.add( IntraOp.createMultiProcess("union", "groovy",
+ req.add( Operations.createMultiProcess("union", "groovy",
"public class Union implements org.usergrid.vx.experimental.MultiProcessor { \n"+
" public List<Map> multiProcess(Map<Integer,Object> results, Map params){ \n"+
" java.util.HashMap s = new java.util.HashMap(); \n"+
@@ -342,7 +342,7 @@ public void multiProcessTest() throws Exception {
steps.add(8);
steps.add(9);
paramsMap.put("steps", steps);
- req.add( IntraOp.multiProcess("union", paramsMap)); //11
+ req.add( Operations.multiProcess("union", paramsMap)); //11
IntraRes res = new IntraRes();
is.handleIntraReq(req, res, x);
@@ -361,11 +361,11 @@ public void multiProcessTest() throws Exception {
@RequiresColumnFamily(ksName = "myks", cfName = "mycf")
public void batchSetTest() throws Exception {
IntraReq req = new IntraReq();
- req.add( IntraOp.setKeyspaceOp("myks") ); //0
- req.add( IntraOp.setColumnFamilyOp("mycf") ); //1
- req.add( IntraOp.setAutotimestampOp() ); //2
- req.add( IntraOp.assumeOp("myks", "mycf", "value", "UTF-8")); //3
- req.add( IntraOp.assumeOp("myks", "mycf", "column", "UTF-8")); //4
+ req.add( Operations.setKeyspaceOp("myks") ); //0
+ req.add( Operations.setColumnFamilyOp("mycf") ); //1
+ req.add( Operations.setAutotimestampOp() ); //2
+ req.add( Operations.assumeOp("myks", "mycf", "value", "UTF-8")); //3
+ req.add( Operations.assumeOp("myks", "mycf", "column", "UTF-8")); //4
Map row1 = new HashMap();
row1.put("rowkey", "batchkeya");
row1.put("name", "col1");
@@ -379,8 +379,8 @@ public void batchSetTest() throws Exception {
List<Map> rows = new ArrayList<Map>();
rows.add(row1);
rows.add(row2);
- req.add( IntraOp.batchSetOp(rows));//5
- req.add( IntraOp.sliceOp("batchkeya", "a", "z", 100));//6
+ req.add( Operations.batchSetOp(rows));//5
+ req.add( Operations.sliceOp("batchkeya", "a", "z", 100));//6
IntraRes res = new IntraRes();
is.handleIntraReq(req, res, x);
List<Map> x = (List<Map>) res.getOpsRes().get(6);
@@ -396,12 +396,12 @@ public void saveStateTest() throws Exception {
//IntraClient ic = new IntraClient();
//ic.setPayload("json");
IntraReq r = new IntraReq();
- r.add( IntraOp.setKeyspaceOp("myks"));//0
- r.add( IntraOp.setColumnFamilyOp("mycf")); //1
- r.add( IntraOp.setAutotimestampOp() ); //2
- r.add( IntraOp.setOp("a", "b", "c") ); //3
- r.add( IntraOp.assumeOp("myks", "mycf", "value", "UTF-8") );//4
- r.add( IntraOp.saveState() );//5
+ r.add( Operations.setKeyspaceOp("myks"));//0
+ r.add( Operations.setColumnFamilyOp("mycf")); //1
+ r.add( Operations.setAutotimestampOp() ); //2
+ r.add( Operations.setOp("a", "b", "c") ); //3
+ r.add( Operations.assumeOp("myks", "mycf", "value", "UTF-8") );//4
+ r.add( Operations.saveState() );//5
IntraRes res = new IntraRes();
is.handleIntraReq(r, res, x);
@@ -411,9 +411,9 @@ public void saveStateTest() throws Exception {
int id = (Integer) res.getOpsRes().get(5);
IntraReq r2 = new IntraReq();
- r2.add( IntraOp.restoreState(id));//0
- r2.add( IntraOp.setOp("d", "e", "f"));//1
- r2.add( IntraOp.getOp("d", "e")); //2
+ r2.add( Operations.restoreState(id));//0
+ r2.add( Operations.setOp("d", "e", "f"));//1
+ r2.add( Operations.getOp("d", "e")); //2
IntraRes res2 = new IntraRes();
is.handleIntraReq(r2, res2, x);
Assert.assertEquals("f", ((List<Map>) res2.getOpsRes().get(2)).get(0).get("value") );
@@ -433,10 +433,10 @@ public void run(){
ic.setPayload("jsonsmile");
for (int i =0;i<ops;++i){
IntraReq req = new IntraReq();
- req.add( IntraOp.setKeyspaceOp("myks") ); //0
- req.add( IntraOp.setColumnFamilyOp("mycf") ); //1
- req.add( IntraOp.setAutotimestampOp() ); //2
- req.add( IntraOp.setOp("rowzz", "col1", "7")); //4
+ req.add( Operations.setKeyspaceOp("myks") ); //0
+ req.add( Operations.setColumnFamilyOp("mycf") ); //1
+ req.add( Operations.setAutotimestampOp() ); //2
+ req.add( Operations.setOp("rowzz", "col1", "7")); //4
IntraRes res = null;
try {
res = ic.sendBlocking(req);
Please sign in to comment.
Something went wrong with that request. Please try again.