accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ktur...@apache.org
Subject git commit: ACCUMULO-1614 added conditional writer randomwalk test
Date Thu, 31 Oct 2013 17:46:39 GMT
Updated Branches:
  refs/heads/master 48fae074d -> df4ba4aed


ACCUMULO-1614 added conditional writer randomwalk test


Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/df4ba4ae
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/df4ba4ae
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/df4ba4ae

Branch: refs/heads/master
Commit: df4ba4aed2c56703aa3f269ba01866c6b8ab39fd
Parents: 48fae07
Author: Keith Turner <kturner@apache.org>
Authored: Thu Oct 31 13:46:10 2013 -0400
Committer: Keith Turner <kturner@apache.org>
Committed: Thu Oct 31 13:46:18 2013 -0400

----------------------------------------------------------------------
 .../test/randomwalk/conditional/Compact.java    |  47 ++++++++
 .../test/randomwalk/conditional/Flush.java      |  47 ++++++++
 .../test/randomwalk/conditional/Init.java       |  64 ++++++++++
 .../test/randomwalk/conditional/Merge.java      |  48 ++++++++
 .../test/randomwalk/conditional/Setup.java      |  59 ++++++++++
 .../test/randomwalk/conditional/Split.java      |  44 +++++++
 .../test/randomwalk/conditional/TearDown.java   |  34 ++++++
 .../test/randomwalk/conditional/Transfer.java   | 118 +++++++++++++++++++
 .../test/randomwalk/conditional/Utils.java      |  36 ++++++
 .../test/randomwalk/conditional/Verify.java     |  86 ++++++++++++++
 test/src/main/resources/randomwalk/module.xsd   |  69 +++++++++++
 test/src/test/resources/randomwalk/module.xsd   |  69 -----------
 test/system/randomwalk/conf/modules/All.xml     |   5 +
 .../randomwalk/conf/modules/Conditional.xml     |  74 ++++++++++++
 14 files changed, 731 insertions(+), 69 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/df4ba4ae/test/src/main/java/org/apache/accumulo/test/randomwalk/conditional/Compact.java
----------------------------------------------------------------------
diff --git a/test/src/main/java/org/apache/accumulo/test/randomwalk/conditional/Compact.java
b/test/src/main/java/org/apache/accumulo/test/randomwalk/conditional/Compact.java
new file mode 100644
index 0000000..66acc86
--- /dev/null
+++ b/test/src/main/java/org/apache/accumulo/test/randomwalk/conditional/Compact.java
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.accumulo.test.randomwalk.conditional;
+
+import java.util.Properties;
+import java.util.Random;
+
+import org.apache.accumulo.core.client.Connector;
+import org.apache.accumulo.test.randomwalk.State;
+import org.apache.accumulo.test.randomwalk.Test;
+import org.apache.hadoop.io.Text;
+
+/**
+ * 
+ */
+public class Compact extends Test {
+  @Override
+  public void visit(State state, Properties props) throws Exception {
+    String table = state.getString("tableName");
+    Random rand = (Random) state.get("rand");
+    Connector conn = state.getConnector();
+    Text row1 = new Text(Utils.getBank(rand.nextInt((Integer) state.get("numBanks"))));
+    Text row2 = new Text(Utils.getBank(rand.nextInt((Integer) state.get("numBanks"))));
+
+    if (row1.compareTo(row2) >= 0) {
+      row1 = null;
+      row2 = null;
+    }
+
+    log.debug("compacting " + row1 + " " + row2);
+    conn.tableOperations().compact(table, row1, row2, rand.nextBoolean(), rand.nextBoolean());
+  }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/accumulo/blob/df4ba4ae/test/src/main/java/org/apache/accumulo/test/randomwalk/conditional/Flush.java
----------------------------------------------------------------------
diff --git a/test/src/main/java/org/apache/accumulo/test/randomwalk/conditional/Flush.java
b/test/src/main/java/org/apache/accumulo/test/randomwalk/conditional/Flush.java
new file mode 100644
index 0000000..c4923de
--- /dev/null
+++ b/test/src/main/java/org/apache/accumulo/test/randomwalk/conditional/Flush.java
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.accumulo.test.randomwalk.conditional;
+
+import java.util.Properties;
+import java.util.Random;
+
+import org.apache.accumulo.core.client.Connector;
+import org.apache.accumulo.test.randomwalk.State;
+import org.apache.accumulo.test.randomwalk.Test;
+import org.apache.hadoop.io.Text;
+
+/**
+ * 
+ */
+public class Flush extends Test {
+  @Override
+  public void visit(State state, Properties props) throws Exception {
+    String table = state.getString("tableName");
+    Random rand = (Random) state.get("rand");
+    Connector conn = state.getConnector();
+    Text row1 = new Text(Utils.getBank(rand.nextInt((Integer) state.get("numBanks"))));
+    Text row2 = new Text(Utils.getBank(rand.nextInt((Integer) state.get("numBanks"))));
+
+    if (row1.compareTo(row2) >= 0) {
+      row1 = null;
+      row2 = null;
+    }
+
+    log.debug("flushing " + row1 + " " + row2);
+    conn.tableOperations().flush(table, row1, row2, rand.nextBoolean());
+  }
+}

http://git-wip-us.apache.org/repos/asf/accumulo/blob/df4ba4ae/test/src/main/java/org/apache/accumulo/test/randomwalk/conditional/Init.java
----------------------------------------------------------------------
diff --git a/test/src/main/java/org/apache/accumulo/test/randomwalk/conditional/Init.java
b/test/src/main/java/org/apache/accumulo/test/randomwalk/conditional/Init.java
new file mode 100644
index 0000000..c336e97
--- /dev/null
+++ b/test/src/main/java/org/apache/accumulo/test/randomwalk/conditional/Init.java
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.accumulo.test.randomwalk.conditional;
+
+import java.util.Properties;
+
+import org.apache.accumulo.core.client.ConditionalWriter;
+import org.apache.accumulo.core.data.Condition;
+import org.apache.accumulo.core.data.ConditionalMutation;
+import org.apache.accumulo.test.randomwalk.State;
+import org.apache.accumulo.test.randomwalk.Test;
+
+/**
+ * 
+ */
+public class Init extends Test {
+
+  @Override
+  public void visit(State state, Properties props) throws Exception {
+
+    int numBanks = (Integer) state.get("numBanks");
+    int numAccts = (Integer) state.get("numAccts");
+    ConditionalWriter cw = (ConditionalWriter) state.get("cw");
+
+    for (int i = 0; i < numBanks; i++) {
+      ConditionalMutation m = null;
+      for (int j = 0; j < numAccts; j++) {
+        String cf = Utils.getAccount(j);
+        if (m == null) {
+          m = new ConditionalMutation(Utils.getBank(i), new Condition(cf, "seq"));
+        } else {
+          m.addCondition(new Condition(cf, "seq"));
+        }
+        m.put(cf, "bal", "100");
+        m.put(cf, "seq", Utils.getSeq(0));
+
+        if (j % 1000 == 0) {
+          cw.write(m);
+          m = null;
+        }
+
+      }
+      if (m != null)
+        cw.write(m);
+
+      log.debug("Added bank " + Utils.getBank(i));
+    }
+
+  }
+}

http://git-wip-us.apache.org/repos/asf/accumulo/blob/df4ba4ae/test/src/main/java/org/apache/accumulo/test/randomwalk/conditional/Merge.java
----------------------------------------------------------------------
diff --git a/test/src/main/java/org/apache/accumulo/test/randomwalk/conditional/Merge.java
b/test/src/main/java/org/apache/accumulo/test/randomwalk/conditional/Merge.java
new file mode 100644
index 0000000..bb3cf60
--- /dev/null
+++ b/test/src/main/java/org/apache/accumulo/test/randomwalk/conditional/Merge.java
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.accumulo.test.randomwalk.conditional;
+
+import java.util.Properties;
+import java.util.Random;
+
+import org.apache.accumulo.core.client.Connector;
+import org.apache.accumulo.test.randomwalk.State;
+import org.apache.accumulo.test.randomwalk.Test;
+import org.apache.hadoop.io.Text;
+
+/**
+ * 
+ */
+public class Merge extends Test {
+  @Override
+  public void visit(State state, Properties props) throws Exception {
+    String table = state.getString("tableName");
+    Random rand = (Random) state.get("rand");
+    Connector conn = state.getConnector();
+    Text row1 = new Text(Utils.getBank(rand.nextInt((Integer) state.get("numBanks"))));
+    Text row2 = new Text(Utils.getBank(rand.nextInt((Integer) state.get("numBanks"))));
+
+    if (row1.compareTo(row2) >= 0) {
+      row1 = null;
+      row2 = null;
+    }
+
+    log.debug("merging " + row1 + " " + row2);
+    conn.tableOperations().merge(table, row1, row2);
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/accumulo/blob/df4ba4ae/test/src/main/java/org/apache/accumulo/test/randomwalk/conditional/Setup.java
----------------------------------------------------------------------
diff --git a/test/src/main/java/org/apache/accumulo/test/randomwalk/conditional/Setup.java
b/test/src/main/java/org/apache/accumulo/test/randomwalk/conditional/Setup.java
new file mode 100644
index 0000000..2f39e29
--- /dev/null
+++ b/test/src/main/java/org/apache/accumulo/test/randomwalk/conditional/Setup.java
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.accumulo.test.randomwalk.conditional;
+
+import java.util.Properties;
+import java.util.Random;
+
+import org.apache.accumulo.core.client.ConditionalWriter;
+import org.apache.accumulo.core.client.ConditionalWriterConfig;
+import org.apache.accumulo.core.client.TableExistsException;
+import org.apache.accumulo.test.randomwalk.State;
+import org.apache.accumulo.test.randomwalk.Test;
+
+public class Setup extends Test {
+
+  @Override
+  public void visit(State state, Properties props) throws Exception {
+    Random rand = new Random();
+    state.set("rand", rand);
+    
+    int numBanks = Integer.parseInt(props.getProperty("numBanks", "10"));
+    log.debug("numBanks = " + numBanks);
+    state.set("numBanks", numBanks);
+
+    int numAccts = Integer.parseInt(props.getProperty("numAccts", "1000"));
+    log.debug("numAccts = " + numAccts);
+    state.set("numAccts", numAccts);
+
+    String tableName = "banks";
+    state.set("tableName", tableName);
+
+    try {
+      state.getConnector().tableOperations().create(tableName);
+      log.debug("created table " + tableName);
+    } catch (TableExistsException tee) {}
+
+
+
+
+    ConditionalWriter cw = state.getConnector()
+        .createConditionalWriter(tableName, new ConditionalWriterConfig().setMaxWriteThreads(1));
+    state.set("cw", cw);
+
+  }
+}

http://git-wip-us.apache.org/repos/asf/accumulo/blob/df4ba4ae/test/src/main/java/org/apache/accumulo/test/randomwalk/conditional/Split.java
----------------------------------------------------------------------
diff --git a/test/src/main/java/org/apache/accumulo/test/randomwalk/conditional/Split.java
b/test/src/main/java/org/apache/accumulo/test/randomwalk/conditional/Split.java
new file mode 100644
index 0000000..3b47762
--- /dev/null
+++ b/test/src/main/java/org/apache/accumulo/test/randomwalk/conditional/Split.java
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.accumulo.test.randomwalk.conditional;
+
+import java.util.Arrays;
+import java.util.Properties;
+import java.util.Random;
+import java.util.TreeSet;
+
+import org.apache.accumulo.core.client.Connector;
+import org.apache.accumulo.test.randomwalk.State;
+import org.apache.accumulo.test.randomwalk.Test;
+import org.apache.hadoop.io.Text;
+
+/**
+ * 
+ */
+public class Split extends Test {
+  @Override
+  public void visit(State state, Properties props) throws Exception {
+    String table = state.getString("tableName");
+    Random rand = (Random) state.get("rand");
+    Connector conn = state.getConnector();
+    String row = Utils.getBank(rand.nextInt((Integer) state.get("numBanks")));
+
+    log.debug("adding split " + row);
+    conn.tableOperations().addSplits(table, new TreeSet<Text>(Arrays.asList(new Text(row))));
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/accumulo/blob/df4ba4ae/test/src/main/java/org/apache/accumulo/test/randomwalk/conditional/TearDown.java
----------------------------------------------------------------------
diff --git a/test/src/main/java/org/apache/accumulo/test/randomwalk/conditional/TearDown.java
b/test/src/main/java/org/apache/accumulo/test/randomwalk/conditional/TearDown.java
new file mode 100644
index 0000000..1624371
--- /dev/null
+++ b/test/src/main/java/org/apache/accumulo/test/randomwalk/conditional/TearDown.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.accumulo.test.randomwalk.conditional;
+
+import java.util.Properties;
+
+import org.apache.accumulo.core.client.ConditionalWriter;
+import org.apache.accumulo.test.randomwalk.State;
+import org.apache.accumulo.test.randomwalk.Test;
+
+/**
+ * 
+ */
+public class TearDown extends Test {
+  @Override
+  public void visit(State state, Properties props) throws Exception {
+    ConditionalWriter cw = (ConditionalWriter) state.get("cw");
+    cw.close();
+  }
+}

http://git-wip-us.apache.org/repos/asf/accumulo/blob/df4ba4ae/test/src/main/java/org/apache/accumulo/test/randomwalk/conditional/Transfer.java
----------------------------------------------------------------------
diff --git a/test/src/main/java/org/apache/accumulo/test/randomwalk/conditional/Transfer.java
b/test/src/main/java/org/apache/accumulo/test/randomwalk/conditional/Transfer.java
new file mode 100644
index 0000000..be4deb1
--- /dev/null
+++ b/test/src/main/java/org/apache/accumulo/test/randomwalk/conditional/Transfer.java
@@ -0,0 +1,118 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.accumulo.test.randomwalk.conditional;
+
+import java.util.Map.Entry;
+import java.util.Properties;
+import java.util.Random;
+
+import org.apache.accumulo.core.client.ConditionalWriter;
+import org.apache.accumulo.core.client.ConditionalWriter.Status;
+import org.apache.accumulo.core.client.Connector;
+import org.apache.accumulo.core.client.IsolatedScanner;
+import org.apache.accumulo.core.client.Scanner;
+import org.apache.accumulo.core.data.Condition;
+import org.apache.accumulo.core.data.ConditionalMutation;
+import org.apache.accumulo.core.data.Key;
+import org.apache.accumulo.core.data.Range;
+import org.apache.accumulo.core.data.Value;
+import org.apache.accumulo.core.security.Authorizations;
+import org.apache.accumulo.test.randomwalk.State;
+import org.apache.accumulo.test.randomwalk.Test;
+import org.apache.hadoop.io.Text;
+
+/**
+ * 
+ */
+public class Transfer extends Test {
+
+  private static class Account {
+    int seq;
+    int bal;
+
+    void setBal(String s) {
+      bal = Integer.parseInt(s);
+    }
+
+    void setSeq(String s) {
+      seq = Integer.parseInt(s);
+    }
+
+    public String toString() {
+      return seq + " " + bal;
+    }
+  }
+
+  @Override
+  public void visit(State state, Properties props) throws Exception {
+    String table = state.getString("tableName");
+    Random rand = (Random) state.get("rand");
+    Connector conn = state.getConnector();
+
+    int numAccts = (Integer) state.get("numAccts");
+    String bank = Utils.getBank(rand.nextInt((Integer) state.get("numBanks")));
+    String acct1 = Utils.getAccount(rand.nextInt(numAccts));
+    String acct2 = Utils.getAccount(rand.nextInt(numAccts));
+
+    // TODO document how data should be read when using ConditionalWriter
+    Scanner scanner = new IsolatedScanner(conn.createScanner(table, Authorizations.EMPTY));
+
+    scanner.setRange(new Range(bank));
+    scanner.fetchColumnFamily(new Text(acct1));
+    scanner.fetchColumnFamily(new Text(acct2));
+
+    Account a1 = new Account();
+    Account a2 = new Account();
+    Account a;
+
+    for (Entry<Key,Value> entry : scanner) {
+      String cf = entry.getKey().getColumnFamilyData().toString();
+      String cq = entry.getKey().getColumnQualifierData().toString();
+
+      if (cf.equals(acct1))
+        a = a1;
+      else
+        a = a2;
+
+      if (cq.equals("bal"))
+        a.setBal(entry.getValue().toString());
+      else
+        a.setSeq(entry.getValue().toString());
+    }
+
+
+    int amt = rand.nextInt(50);
+
+    log.debug("transfer req " + bank + " " + amt + " " + a1 + " " + a2);
+
+    if (a1.bal >= amt) {
+      ConditionalMutation cm = new ConditionalMutation(bank, new Condition(acct1, "seq").setValue(Utils.getSeq(a1.seq)),
+          new Condition(acct2, "seq").setValue(Utils.getSeq(a2.seq)));
+      cm.put(acct1, "bal", (a1.bal - amt) + "");
+      cm.put(acct2, "bal", (a2.bal + amt) + "");
+      cm.put(acct1, "seq", Utils.getSeq(a1.seq + 1));
+      cm.put(acct2, "seq", Utils.getSeq(a2.seq + 1));
+
+      ConditionalWriter cw = (ConditionalWriter) state.get("cw");
+      Status status = cw.write(cm).getStatus();
+      log.debug("transfer result " + bank + " " + status + " " + a1 + " " + a2);
+    }
+
+
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/accumulo/blob/df4ba4ae/test/src/main/java/org/apache/accumulo/test/randomwalk/conditional/Utils.java
----------------------------------------------------------------------
diff --git a/test/src/main/java/org/apache/accumulo/test/randomwalk/conditional/Utils.java
b/test/src/main/java/org/apache/accumulo/test/randomwalk/conditional/Utils.java
new file mode 100644
index 0000000..e3314f7
--- /dev/null
+++ b/test/src/main/java/org/apache/accumulo/test/randomwalk/conditional/Utils.java
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.accumulo.test.randomwalk.conditional;
+
+
+/**
+ * 
+ */
+public class Utils {
+
+  static String getBank(int b) {
+    return String.format("b%03d", b);
+  }
+
+  static String getAccount(int a) {
+    return "acct" + String.format("%06d", a);
+  }
+
+  static String getSeq(int s) {
+    return String.format("%06d", s);
+  }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/accumulo/blob/df4ba4ae/test/src/main/java/org/apache/accumulo/test/randomwalk/conditional/Verify.java
----------------------------------------------------------------------
diff --git a/test/src/main/java/org/apache/accumulo/test/randomwalk/conditional/Verify.java
b/test/src/main/java/org/apache/accumulo/test/randomwalk/conditional/Verify.java
new file mode 100644
index 0000000..86a5768
--- /dev/null
+++ b/test/src/main/java/org/apache/accumulo/test/randomwalk/conditional/Verify.java
@@ -0,0 +1,86 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.accumulo.test.randomwalk.conditional;
+
+import java.util.Map.Entry;
+import java.util.Properties;
+
+import org.apache.accumulo.core.client.Connector;
+import org.apache.accumulo.core.client.IsolatedScanner;
+import org.apache.accumulo.core.client.IteratorSetting;
+import org.apache.accumulo.core.client.Scanner;
+import org.apache.accumulo.core.client.TableNotFoundException;
+import org.apache.accumulo.core.data.Key;
+import org.apache.accumulo.core.data.Range;
+import org.apache.accumulo.core.data.Value;
+import org.apache.accumulo.core.iterators.user.ColumnSliceFilter;
+import org.apache.accumulo.core.security.Authorizations;
+import org.apache.accumulo.test.randomwalk.State;
+import org.apache.accumulo.test.randomwalk.Test;
+
+/**
+ * 
+ */
+public class Verify extends Test {
+
+  @Override
+  public void visit(State state, Properties props) throws Exception {
+    String table = state.getString("tableName");
+    Connector conn = state.getConnector();
+
+    int numAccts = (Integer) state.get("numAccts");
+
+    for (int i = 0; i < (Integer) state.get("numBanks"); i++)
+      verifyBank(table, conn, Utils.getBank(i), numAccts);
+
+  }
+
+  private void verifyBank(String table, Connector conn, String row, int numAccts) throws
TableNotFoundException, Exception {
+    log.debug("Verifying bank " + row);
+
+    // TODO do not use IsolatedScanner, just enable isolation on scanner
+    Scanner scanner = new IsolatedScanner(conn.createScanner(table, Authorizations.EMPTY));
+
+    scanner.setRange(new Range(row));
+    IteratorSetting iterConf = new IteratorSetting(100, "cqsl", ColumnSliceFilter.class);
+    ColumnSliceFilter.setSlice(iterConf, "bal", true, "bal", true);
+    scanner.clearScanIterators();
+    scanner.addScanIterator(iterConf);
+
+    int count = 0;
+    int sum = 0;
+    int min = Integer.MAX_VALUE;
+    int max = Integer.MIN_VALUE;
+    for (Entry<Key,Value> entry : scanner) {
+      int bal = Integer.parseInt(entry.getValue().toString());
+      sum += bal;
+      if (bal > max)
+        max = bal;
+      if (bal < min)
+        min = bal;
+      count++;
+    }
+
+    if (count > 0 && sum != numAccts * 100) {
+      throw new Exception("Sum is off " + sum);
+    }
+
+
+    log.debug("Verified " + row + " count = " + count + " sum = " + sum + " min = " + min
+ " max = " + max);
+  }
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/accumulo/blob/df4ba4ae/test/src/main/resources/randomwalk/module.xsd
----------------------------------------------------------------------
diff --git a/test/src/main/resources/randomwalk/module.xsd b/test/src/main/resources/randomwalk/module.xsd
new file mode 100644
index 0000000..bcdaaae0
--- /dev/null
+++ b/test/src/main/resources/randomwalk/module.xsd
@@ -0,0 +1,69 @@
+<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+
+  <xsd:element name="module" type="ModuleType"/>
+
+  <xsd:complexType name="ModuleType">
+    <xsd:sequence>
+      <xsd:element name="package" type="PrefixType" minOccurs="0" maxOccurs="unbounded"/>
+      <xsd:element name="fixture" type="InitType" minOccurs="0" maxOccurs="1"/>
+      <xsd:element name="init" type="InitType"/>
+      <xsd:element name="node" type="NodeType" minOccurs="1" maxOccurs="unbounded"/>
+   </xsd:sequence>
+  </xsd:complexType>
+
+  <xsd:complexType name="PrefixType">
+    <xsd:attribute name="prefix" type="xsd:string"/>
+    <xsd:attribute name="value" type="xsd:string"/>
+  </xsd:complexType>
+
+  <xsd:complexType name="InitType">
+    <xsd:attribute name="id" type="xsd:string"/>
+    <xsd:attribute name="maxHops" type="xsd:nonNegativeInteger"/>
+    <xsd:attribute name="maxSec" type="xsd:nonNegativeInteger"/>
+    <xsd:attribute name="teardown" type="xsd:boolean"/>
+  </xsd:complexType>
+
+  <xsd:complexType name="NodeType">
+    <xsd:sequence>
+      <xsd:element name="alias" type="AliasType" minOccurs="0" maxOccurs="unbounded"/>
+      <xsd:element name="property" type="PropertyType" minOccurs="0" maxOccurs="unbounded"/>
+      <xsd:element name="edge" type="EdgeType" minOccurs="1" maxOccurs="unbounded"/>
+    </xsd:sequence>
+    <xsd:attribute name="id" type="xsd:string"/>
+    <xsd:attribute name="src" type="xsd:string"/>
+    <xsd:attribute name="maxHops" type="xsd:nonNegativeInteger"/>
+    <xsd:attribute name="maxSec" type="xsd:nonNegativeInteger"/>
+    <xsd:attribute name="teardown" type="xsd:boolean"/>
+  </xsd:complexType>
+
+  <xsd:complexType name="EdgeType">
+    <xsd:attribute name="id" type="xsd:string"/>
+    <xsd:attribute name="weight" type="xsd:positiveInteger"/>
+  </xsd:complexType>
+
+  <xsd:complexType name="AliasType">
+    <xsd:attribute name="name" type="xsd:string"/>
+  </xsd:complexType>
+  
+  <xsd:complexType name="PropertyType">
+    <xsd:attribute name="key" type="xsd:string"/>
+    <xsd:attribute name="value" type="xsd:string"/>
+  </xsd:complexType>
+
+</xsd:schema>

http://git-wip-us.apache.org/repos/asf/accumulo/blob/df4ba4ae/test/src/test/resources/randomwalk/module.xsd
----------------------------------------------------------------------
diff --git a/test/src/test/resources/randomwalk/module.xsd b/test/src/test/resources/randomwalk/module.xsd
deleted file mode 100644
index bcdaaae0..0000000
--- a/test/src/test/resources/randomwalk/module.xsd
+++ /dev/null
@@ -1,69 +0,0 @@
-<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
-<!--
-  Licensed to the Apache Software Foundation (ASF) under one or more
-  contributor license agreements.  See the NOTICE file distributed with
-  this work for additional information regarding copyright ownership.
-  The ASF licenses this file to You under the Apache License, Version 2.0
-  (the "License"); you may not use this file except in compliance with
-  the License.  You may obtain a copy of the License at
-
-      http://www.apache.org/licenses/LICENSE-2.0
-
-  Unless required by applicable law or agreed to in writing, software
-  distributed under the License is distributed on an "AS IS" BASIS,
-  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-  See the License for the specific language governing permissions and
-  limitations under the License.
--->
-
-  <xsd:element name="module" type="ModuleType"/>
-
-  <xsd:complexType name="ModuleType">
-    <xsd:sequence>
-      <xsd:element name="package" type="PrefixType" minOccurs="0" maxOccurs="unbounded"/>
-      <xsd:element name="fixture" type="InitType" minOccurs="0" maxOccurs="1"/>
-      <xsd:element name="init" type="InitType"/>
-      <xsd:element name="node" type="NodeType" minOccurs="1" maxOccurs="unbounded"/>
-   </xsd:sequence>
-  </xsd:complexType>
-
-  <xsd:complexType name="PrefixType">
-    <xsd:attribute name="prefix" type="xsd:string"/>
-    <xsd:attribute name="value" type="xsd:string"/>
-  </xsd:complexType>
-
-  <xsd:complexType name="InitType">
-    <xsd:attribute name="id" type="xsd:string"/>
-    <xsd:attribute name="maxHops" type="xsd:nonNegativeInteger"/>
-    <xsd:attribute name="maxSec" type="xsd:nonNegativeInteger"/>
-    <xsd:attribute name="teardown" type="xsd:boolean"/>
-  </xsd:complexType>
-
-  <xsd:complexType name="NodeType">
-    <xsd:sequence>
-      <xsd:element name="alias" type="AliasType" minOccurs="0" maxOccurs="unbounded"/>
-      <xsd:element name="property" type="PropertyType" minOccurs="0" maxOccurs="unbounded"/>
-      <xsd:element name="edge" type="EdgeType" minOccurs="1" maxOccurs="unbounded"/>
-    </xsd:sequence>
-    <xsd:attribute name="id" type="xsd:string"/>
-    <xsd:attribute name="src" type="xsd:string"/>
-    <xsd:attribute name="maxHops" type="xsd:nonNegativeInteger"/>
-    <xsd:attribute name="maxSec" type="xsd:nonNegativeInteger"/>
-    <xsd:attribute name="teardown" type="xsd:boolean"/>
-  </xsd:complexType>
-
-  <xsd:complexType name="EdgeType">
-    <xsd:attribute name="id" type="xsd:string"/>
-    <xsd:attribute name="weight" type="xsd:positiveInteger"/>
-  </xsd:complexType>
-
-  <xsd:complexType name="AliasType">
-    <xsd:attribute name="name" type="xsd:string"/>
-  </xsd:complexType>
-  
-  <xsd:complexType name="PropertyType">
-    <xsd:attribute name="key" type="xsd:string"/>
-    <xsd:attribute name="value" type="xsd:string"/>
-  </xsd:complexType>
-
-</xsd:schema>

http://git-wip-us.apache.org/repos/asf/accumulo/blob/df4ba4ae/test/system/randomwalk/conf/modules/All.xml
----------------------------------------------------------------------
diff --git a/test/system/randomwalk/conf/modules/All.xml b/test/system/randomwalk/conf/modules/All.xml
index 1bd3783..be5c815 100644
--- a/test/system/randomwalk/conf/modules/All.xml
+++ b/test/system/randomwalk/conf/modules/All.xml
@@ -29,6 +29,7 @@
   <edge id="MultiTable.xml" weight="1"/>
   <edge id="Shard.xml" weight="1"/>
   <edge id="Concurrent.xml" weight="1"/>
+  <edge id="Conditional.xml" weight="1"/>
   <edge id="Security.xml" weight="1"/>
   <edge id="Bulk.xml" weight="1"/>
 </node>
@@ -49,6 +50,10 @@
   <edge id="dummy.ToAll" weight="1"/>
 </node>
 
+<node id="Conditional.xml">
+  <edge id="dummy.ToAll" weight="1"/>
+</node>
+
 <node id="Security.xml">
   <edge id="dummy.ToAll" weight="1"/>
 </node>

http://git-wip-us.apache.org/repos/asf/accumulo/blob/df4ba4ae/test/system/randomwalk/conf/modules/Conditional.xml
----------------------------------------------------------------------
diff --git a/test/system/randomwalk/conf/modules/Conditional.xml b/test/system/randomwalk/conf/modules/Conditional.xml
new file mode 100644
index 0000000..42d6326
--- /dev/null
+++ b/test/system/randomwalk/conf/modules/Conditional.xml
@@ -0,0 +1,74 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+<module>
+
+<package prefix="ct" value="org.apache.accumulo.test.randomwalk.conditional"/>
+
+
+<init id="ct.Setup"/>
+
+<node id="dummy.ToAll">
+  <edge id="ct.Compact" weight="100"/>
+  <edge id="ct.Flush" weight="100"/>
+  <edge id="ct.Merge" weight="100"/>
+  <edge id="ct.Split" weight="100"/>
+  <edge id="ct.Transfer" weight="100000"/>
+  <edge id="ct.Verify" weight="500"/>
+</node>
+
+<node id="ct.Setup">
+  <edge id="ct.Init" weight="1"/>
+</node>
+
+<node id="ct.Init">
+  <property key="numAccts" value="10"/>
+  <property key="numBanks" value="1000"/>
+  <edge id="dummy.ToAll" weight="1"/>
+</node>
+
+<node id="ct.Compact">
+  <edge id="dummy.ToAll" weight="1"/>
+</node>
+
+<node id="ct.Flush">
+  <edge id="dummy.ToAll" weight="1"/>
+</node>
+
+<node id="ct.Merge">
+  <edge id="dummy.ToAll" weight="1"/>
+</node>
+
+<node id="ct.Split">
+  <edge id="dummy.ToAll" weight="1"/>
+</node>
+ 
+<node id="ct.Transfer">
+  <edge id="dummy.ToAll" weight="1"/>
+</node>
+
+<node id="ct.Verify">
+  <edge id="dummy.ToAll" weight="1000"/>
+  <edge id="ct.TearDown" weight="1"/>
+</node>
+
+
+<node id="ct.TearDown">
+  <edge id="END" weight="1"/>
+</node>
+
+</module>


Mime
View raw message