<NME> package-info.java
<BEF> ADDFILE
<MSG> [accumulo] Checkstyle cleanup and enforcement for the Accumulo binding.

Again, a lot of whitespace changes and the normal checkstyle type errors.

2 items of note:

1. Deprecated QueueElement since it is not used.
2. Moved some of the exception handling to common locations to remove
   empty catch blocks.

<DFF> @@ -0,0 +1,21 @@
+/**
+ * Copyright (c) 2015 YCSB contributors. All rights reserved.
+ *
+ * Licensed 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. See accompanying
+ * LICENSE file.
+ */
+
+/**
+ * YCSB binding for <a href="https://accumulo.apache.org/">Accumulo</a>.
+ */
+package com.yahoo.ycsb.db;
\ No newline at end of file

{'commit': 'diff --git a/accumulo/pom.xml b/accumulo/pom.xml\nindex e9f706ff..3e71def2 100644\n--- a/accumulo/pom.xml\n+++ b/accumulo/pom.xml\n@@ -64,4 +64,28 @@ LICENSE file.\n       <scope>provided</scope>\n     </dependency>\n   </dependencies>\n+  <build>\n+    <plugins>\n+      <plugin>\n+        <groupId>org.apache.maven.plugins</groupId>\n+        <artifactId>maven-checkstyle-plugin</artifactId>\n+        <version>2.15</version>\n+        <configuration>\n+          <consoleOutput>true</consoleOutput>\n+          <configLocation>../checkstyle.xml</configLocation>\n+          <failOnViolation>true</failOnViolation>\n+          <failsOnError>true</failsOnError>\n+        </configuration>\n+        <executions>\n+          <execution>\n+            <id>validate</id>\n+            <phase>validate</phase>\n+            <goals>\n+              <goal>checkstyle</goal>\n+            </goals>\n+          </execution>\n+        </executions>\n+      </plugin>\n+    </plugins>\n+  </build>\n </project>\ndiff --git a/accumulo/src/main/java/com/yahoo/ycsb/db/AccumuloClient.java b/accumulo/src/main/java/com/yahoo/ycsb/db/AccumuloClient.java\nindex d661908e..e4e79f92 100644\n--- a/accumulo/src/main/java/com/yahoo/ycsb/db/AccumuloClient.java\n+++ b/accumulo/src/main/java/com/yahoo/ycsb/db/AccumuloClient.java\n@@ -54,400 +54,403 @@ import com.yahoo.ycsb.ByteIterator;\n import com.yahoo.ycsb.DB;\n import com.yahoo.ycsb.DBException;\n \n+/**\n+ * <a href="https://accumulo.apache.org/">Accumulo</a> binding for YCSB.\n+ */\n public class AccumuloClient extends DB {\n-\t// Error code constants.\n-\tpublic static final int Ok = 0;\n-\tpublic static final int ServerError = -1;\n-\tpublic static final int HttpError = -2;\n-\tpublic static final int NoMatchingRecord = -3;\n-\n-\tprivate ZooKeeperInstance _inst;\n-\tprivate Connector _connector;\n-\tprivate String _table = "";\n-\tprivate BatchWriter _bw = null;\n-\tprivate Text _colFam = new Text("");\n-\tprivate Scanner _singleScanner = null;    // A scanner for reads/deletes.\n-\tprivate Scanner _scanScanner = null;      // A scanner for use by scan()\n-\n-\tprivate static final String PC_PRODUCER = "producer";\n-\tprivate static final String PC_CONSUMER = "consumer";\n-\tprivate String _PC_FLAG = "";\n-\tprivate ZKProducerConsumer.Queue q = null;\n-\tprivate static Hashtable<String,Long> hmKeyReads = null;\n-\tprivate static Hashtable<String,Integer> hmKeyNumReads = null;\n-\tprivate Random r = null;\n-\n-\n-\t@Override\n-\tpublic void init() throws DBException {\n-\t\t_colFam = new Text(getProperties().getProperty("accumulo.columnFamily"));\n-\n-\t\t_inst = new ZooKeeperInstance(getProperties().getProperty("accumulo.instanceName"),\n-\t\t\t\tgetProperties().getProperty("accumulo.zooKeepers"));\n-\t\ttry {\n-\t\t\tString principal = getProperties().getProperty("accumulo.username");\n-\t\t\tAuthenticationToken token = new PasswordToken(getProperties().getProperty("accumulo.password"));\n-\t\t\t_connector = _inst.getConnector(principal, token);\n-\t\t} catch (AccumuloException e) {\n-\t\t\tthrow new DBException(e);\n-\t\t} catch (AccumuloSecurityException e) {\n-\t\t\tthrow new DBException(e);\n-\t\t}\n-\n-\t\t_PC_FLAG = getProperties().getProperty("accumulo.PC_FLAG","none");\n-\t\tif (_PC_FLAG.equals(PC_PRODUCER) || _PC_FLAG.equals(PC_CONSUMER)) {\n-\t\t\tSystem.out.println("*** YCSB Client is "+_PC_FLAG);\n-\t\t\tString address = getProperties().getProperty("accumulo.PC_SERVER");\n-\t\t\tString root = getProperties().getProperty("accumulo.PC_ROOT_IN_ZK");\n-\t\t\tSystem.out.println("*** PC_INFO(server:"+address+";root="+root+")");\n-\t\t\tq = new ZKProducerConsumer.Queue(address, root);\n-\t\t\tr = new Random();\n-\t\t}\n-\n-\t\tif (_PC_FLAG.equals(PC_CONSUMER)) {\n-\t\t\thmKeyReads = new Hashtable<String,Long>();\n-\t\t\thmKeyNumReads = new Hashtable<String,Integer>();\n-\t\t\tkeyNotification(null);\n-\t\t}\n-\t}\n-\n-\n-\t@Override\n-\tpublic void cleanup() throws DBException\n-\t{\n-\t\ttry {\n-\t\t\tif (_bw != null) {\n-\t\t\t\t_bw.close();\n-\t\t\t}\n-\t\t} catch (MutationsRejectedException e) {\n-\t\t\tthrow new DBException(e);\n-\t\t}\n-\t\tCleanUp.shutdownNow();\n-\t}\n-\n-\t/**\n-\t * Commonly repeated functionality: Before doing any operation, make sure\n-\t * we\'re working on the correct table. If not, open the correct one.\n-\t * \n-\t * @param table\n-\t */\n-\tpublic void checkTable(String table) throws TableNotFoundException {\n-\t\tif (!_table.equals(table)) {\n-\t\t\tgetTable(table);\n-\t\t}\n-\t}\n-\n-\t/**\n-\t * Called when the user specifies a table that isn\'t the same as the\n-\t * existing table. Connect to it and if necessary, close our current\n-\t * connection.\n-\t * \n-\t * @param table\n-\t */\n-\tpublic void getTable(String table) throws TableNotFoundException {\n-\t\tif (_bw != null) { // Close the existing writer if necessary.\n-\t\t\ttry {\n-\t\t\t\t_bw.close();\n-\t\t\t} catch (MutationsRejectedException e) {\n-\t\t\t\t// Couldn\'t spit out the mutations we wanted.\n-\t\t\t\t// Ignore this for now.\n-\t\t\t}\n-\t\t}\n-\n-\t\tBatchWriterConfig bwc = new BatchWriterConfig();\n-\t\tbwc.setMaxLatency(Long.parseLong(getProperties().getProperty("accumulo.batchWriterMaxLatency", "30000")), TimeUnit.MILLISECONDS);\n-\t\tbwc.setMaxMemory(Long.parseLong(getProperties().getProperty("accumulo.batchWriterSize", "100000")));\n-\t\tbwc.setMaxWriteThreads(Integer.parseInt(getProperties().getProperty("accumulo.batchWriterThreads", "1")));\n-\n-\t\t_bw = _connector.createBatchWriter(table, bwc);\n-\n-\t\t// Create our scanners\n-\t\t_singleScanner = _connector.createScanner(table, Authorizations.EMPTY);\n-\t\t_scanScanner = _connector.createScanner(table, Authorizations.EMPTY);\n-\n-\t\t_table = table; // Store the name of the table we have open.\n-\t}\n-\n-\t/**\n-\t * Gets a scanner from Accumulo over one row\n-\t * \n-\t * @param row the row to scan\n-\t * @param fields the set of columns to scan\n-\t * @return an Accumulo {@link Scanner} bound to the given row and columns\n-\t */\n-\tprivate Scanner getRow(Text row, Set<String> fields) \n-\t{\n-\t\t_singleScanner.clearColumns();\n-\t\t_singleScanner.setRange(new Range(row));\n-\t\tif (fields != null) {\n-\t\t\tfor(String field:fields)\n-\t\t\t{\n-\t\t\t\t_singleScanner.fetchColumn(_colFam, new Text(field));\n-\t\t\t}\n-\t\t}\n-\t\treturn _singleScanner;\n-\t}\n-\n-\t@Override\n-\tpublic int read(String table, String key, Set<String> fields,\n-\t\t\tHashMap<String, ByteIterator> result) {\n-\n-\t\ttry {\n-\t\t\tcheckTable(table);\n-\t\t} catch (TableNotFoundException e) {\n-\t\t\tSystem.err.println("Error trying to connect to Accumulo table." + e);\n-\t\t\treturn ServerError;\n-\t\t}\n-\n-\t\ttry {\n-\t\t\t// Pick out the results we care about.\n-\t\t\tfor (Entry<Key, Value> entry : getRow(new Text(key), null)) {\n-\t\t\t    Value v = entry.getValue();\n-\t\t\t    byte[] buf = v.get();\n-\t\t\t    result.put(entry.getKey().getColumnQualifier().toString(), \n-\t\t\t\t       new ByteArrayByteIterator(buf));\n-\t\t\t}\n-\t\t} catch (Exception e) {\n-\t\t\tSystem.err.println("Error trying to reading Accumulo table" + key + e);\n-\t\t\treturn ServerError;\n-\t\t}\n-\t\treturn Ok;\n-\n-\t}\n-\n-\t@Override\n-\tpublic int scan(String table, String startkey, int recordcount,\n-\t\t\tSet<String> fields, Vector<HashMap<String, ByteIterator>> result) {\n-\t\ttry {\n-\t\t\tcheckTable(table);\n-\t\t} catch (TableNotFoundException e) {\n-\t\t\tSystem.err.println("Error trying to connect to Accumulo table." + e);\n-\t\t\treturn ServerError;\n-\t\t}\n-\n-\t\t// There doesn\'t appear to be a way to create a range for a given\n-\t\t// LENGTH. Just start and end keys. So we\'ll do this the hard way for now: \n-\t\t// Just make the end \'infinity\' and only read as much as we need. \n-\t\t_scanScanner.clearColumns();\n-\t\t_scanScanner.setRange(new Range(new Text(startkey), null));\n-\n-\t\t// Batch size is how many key/values to try to get per call. Here, I\'m\n-\t\t// guessing that the number of keys in a row is equal to the number of fields \n-\t\t// we\'re interested in.\n-\t\t// We try to fetch one more so as to tell when we\'ve run out of fields.\n-\n-\t\tif (fields != null) {\n-\t\t\t// And add each of them as fields we want.\n-\t\t\tfor(String field:fields)\n-\t\t\t{\n-\t\t\t\t_scanScanner.fetchColumn(_colFam, new Text(field));\n-\t\t\t}\n-\t\t} else {\n-\t\t\t// If no fields are provided, we assume one column/row.\n-\t\t}\n-\n-\t\tString rowKey = "";\n-\t\tHashMap<String, ByteIterator> currentHM = null;\n-\t\tint count = 0;\n-\n-\t\t// Begin the iteration.\n-\t\tfor (Entry<Key, Value> entry : _scanScanner) {\n-\t\t\t// Check for a new row.\n-\t\t\tif (!rowKey.equals(entry.getKey().getRow().toString())) {\n-\t\t\t\tif (count++ == recordcount) { // Done reading the last row.\n-\t\t\t\t\tbreak;\n-\t\t\t\t}\n-\t\t\t\trowKey = entry.getKey().getRow().toString();\n-\t\t\t\tif (fields != null) {\n-\t\t\t\t\t// Initial Capacity for all keys.\n-\t\t\t\t\tcurrentHM = new HashMap<String, ByteIterator>(fields.size()); \n-\t\t\t\t}\n-\t\t\t\telse\n-\t\t\t\t{\n-\t\t\t\t\t// An empty result map.\n-\t\t\t\t\tcurrentHM = new HashMap<String, ByteIterator>();\n-\t\t\t\t}\n-\t\t\t\tresult.add(currentHM);\n-\t\t\t}\n-\t\t\t// Now add the key to the hashmap.\n-\t\t\tValue v = entry.getValue();\n-\t\t    byte[] buf = v.get();\n-\t\t\tcurrentHM.put(entry.getKey().getColumnQualifier().toString(), new ByteArrayByteIterator(buf));\n-\t\t}\n-\n-\t\treturn Ok;\n-\n-\t}\n-\n-\t@Override\n-\tpublic int update(String table, String key, HashMap<String, ByteIterator> values) {\n-\t\ttry {\n-\t\t\tcheckTable(table);\n-\t\t} catch (TableNotFoundException e) {\n-\t\t\tSystem.err.println("Error trying to connect to Accumulo table." + e);\n-\t\t\treturn ServerError;\n-\t\t}\n-\n-\t\tMutation mutInsert = new Mutation(new Text(key));\n-\t\tfor (Map.Entry<String, ByteIterator> entry : values.entrySet()) {\n-\t\t\tmutInsert.put(_colFam, new Text(entry.getKey()), System\n-\t\t\t\t\t.currentTimeMillis(),\n-\t\t\t\t\tnew Value(entry.getValue().toArray()));\n-\t\t}\n-\n-\t\ttry {\n-\t\t\t_bw.addMutation(mutInsert);\n-\t\t\t// Distributed YCSB co-ordination: YCSB on a client produces the key to \n-\t\t\t// be stored in the shared queue in ZooKeeper.\n-\t\t\tif (_PC_FLAG.equals(PC_PRODUCER)) {\n-\t\t\t\tif (r.nextFloat() < 0.01)\n-\t\t\t\t\tkeyNotification(key);\n-\t\t\t}\n-\t\t} catch (MutationsRejectedException e) {\n-\t\t\tSystem.err.println("Error performing update.");\n-\t\t\te.printStackTrace();\n-\t\t\treturn ServerError;\n-\t\t}\n-\n-\n-\t\treturn Ok;\n-\t}\n-\n-\t@Override\n-\tpublic int insert(String table, String key, HashMap<String, ByteIterator> values) {\n-\t\treturn update(table, key, values);\n-\t}\n-\n-\t@Override\n-\tpublic int delete(String table, String key) {\n-\t\ttry {\n-\t\t\tcheckTable(table);\n-\t\t} catch (TableNotFoundException e) {\n-\t\t\tSystem.err.println("Error trying to connect to Accumulo table." + e);\n-\t\t\treturn ServerError;\n-\t\t}\n-\n-\t\ttry {\n-\t\t\tdeleteRow(new Text(key));\n-\t\t} catch (RuntimeException e) {\n-\t\t\tSystem.err.println("Error performing delete.");\n-\t\t\te.printStackTrace();\n-\t\t\treturn ServerError;\n-\t\t}\n-\n-\t\treturn Ok;\n-\t}\n-\n-\t// These functions are adapted from RowOperations.java:\n-\tprivate void deleteRow(Text row) {\n-\t\tdeleteRow(getRow(row, null));\n-\t}\n-\n-\n-\t/**\n-\t * Deletes a row, given a Scanner of JUST that row\n-\t * \n-\t */\n-\tprivate void deleteRow(Scanner scanner) {\n-\t\tMutation deleter = null;\n-\t\t// iterate through the keys\n-\t\tfor (Entry<Key,Value> entry : scanner) {\n-\t\t\t// create a mutation for the row\n-\t\t\tif (deleter == null)\n-\t\t\t\tdeleter = new Mutation(entry.getKey().getRow());\n-\t\t\t// the remove function adds the key with the delete flag set to true\n-\t\t\tdeleter.putDelete(entry.getKey().getColumnFamily(), entry.getKey().getColumnQualifier());\n-\t\t}\n-\t\ttry {\n-\t\t\t_bw.addMutation(deleter);\n-\t\t} catch (MutationsRejectedException e) {\n-\t\t\t// TODO Auto-generated catch block\n-\t\t\te.printStackTrace();\n-\t\t}\n-\n-\t}\n-\n-\tprivate void keyNotification(String key) {\n-\n-\t\tif (_PC_FLAG.equals(PC_PRODUCER)) {\n-\t\t\ttry {\n-\t\t\t\tq.produce(key);\n-\t\t\t} catch (KeeperException e) {\n-\n-\t\t\t} catch (InterruptedException e) {\n-\n-\t\t\t}\n-\t\t} else {\n-\t\t\t//XXX: do something better to keep the loop going (while??)\n-\t\t\tfor (int i = 0; i < 10000000; i++) {\n-\t\t\t\ttry {\n-\t\t\t\t\tString strKey = q.consume();\n-\t\t\t\n-\t\t\t\t\tif ((hmKeyReads.containsKey(strKey) == false) && \n-\t\t\t\t\t\t\t(hmKeyNumReads.containsKey(strKey) == false)) { \n-\t\t\t\t\t\thmKeyReads.put(strKey, new Long(System.currentTimeMillis()));\n-\t\t\t\t\t\thmKeyNumReads.put(strKey, new Integer(1));\n-\t\t\t\t\t}\n-\n-\t\t\t\t\t//YCSB Consumer will read the key that was fetched from the \n-\t\t\t\t\t//queue in ZooKeeper.\n-\t\t\t\t\t//(current way is kind of ugly but works, i think)\n-\t\t\t\t\t//TODO : Get table name from configuration or argument\n-\t\t\t\t\tString table = "usertable";\n-\t\t\t\t\tHashSet<String> fields = new HashSet<String>();\n-\t\t\t\t\tfor (int j=0; j<9; j++)\n-\t\t\t\t\t\tfields.add("field"+j);\n-\t\t\t\t\tHashMap<String,ByteIterator> result = new HashMap<String,ByteIterator>();\n-\n-\t\t\t\t\tint retval = read(table, strKey, fields, result);\n-\t\t\t\t\t//If the results are empty, the key is enqueued in Zookeeper\n-\t\t\t\t\t//and tried again, until the results are found.\n-\t\t\t\t\tif (result.size() == 0) { \n-\t\t\t\t\t\tq.produce(strKey);\n-\t\t\t\t\t\tint count = ((Integer)hmKeyNumReads.get(strKey)).intValue(); \n-\t\t\t\t\t\thmKeyNumReads.put(strKey, new Integer(count+1));\n-\t\t\t\t\t}\n-\t\t\t\t\telse {\n-\t\t\t\t\t\tif (((Integer)hmKeyNumReads.get(strKey)).intValue() > 1) { \n-\t\t\t\t\t\t\tlong currTime = System.currentTimeMillis();\n-\t\t\t\t\t\t\tlong writeTime = ((Long)hmKeyReads.get(strKey)).longValue();\n-\t\t\t\t\t\t\tSystem.out.println("Key="+strKey+\n-\t\t\t\t\t\t\t\t\t//";StartSearch="+writeTime+\n-\t\t\t\t\t\t\t\t\t//";EndSearch="+currTime+\n-\t\t\t\t\t\t\t\t\t";TimeLag="+(currTime-writeTime));\n-\t\t\t\t\t\t}\n-\t\t\t\t\t}\n-\n-\t\t\t\t} catch (KeeperException e) {\n-\n-\t\t\t\t} catch (InterruptedException e) {\n-\n-\t\t\t\t}\n-\t\t\t}\n-\t\t}\n-\n-\t}\n-\n-\tpublic int presplit(String table, String[] keys)\n-\t{\n-\t\tTreeSet<Text> splits = new TreeSet<Text>();\n-\t\tfor (int i = 0;i < keys.length; i ++)\n-\t\t{\n-\t\t\tsplits.add(new Text(keys[i]));\n-\t\t}\n-\t\ttry {\n-\t\t\t_connector.tableOperations().addSplits(table, splits);\n-\t\t} catch (TableNotFoundException e) {\n-\t\t\t// TODO Auto-generated catch block\n-\t\t\te.printStackTrace();\n-\t\t} catch (AccumuloException e) {\n-\t\t\t// TODO Auto-generated catch block\n-\t\t\te.printStackTrace();\n-\t\t} catch (AccumuloSecurityException e) {\n-\t\t\t// TODO Auto-generated catch block\n-\t\t\te.printStackTrace();\n-\t\t} \n-\t\treturn Ok;\n-\t}\n+  // Error code constants.\n+  public static final int OK = 0;\n+  public static final int SERVER_ERROR = -1;\n+  public static final int HTTP_ERROR = -2;\n+  public static final int NO_MATCHING_RECORD = -3;\n+\n+  private ZooKeeperInstance inst;\n+  private Connector connector;\n+  private String table = "";\n+  private BatchWriter bw = null;\n+  private Text colFam = new Text("");\n+  private Scanner singleScanner = null; // A scanner for reads/deletes.\n+  private Scanner scanScanner = null; // A scanner for use by scan()\n+\n+  private static final String PC_PRODUCER = "producer";\n+  private static final String PC_CONSUMER = "consumer";\n+  private String pcFlag = "";\n+  private ZKProducerConsumer.Queue q = null;\n+  private static Hashtable<String, Long> hmKeyReads = null;\n+  private static Hashtable<String, Integer> hmKeyNumReads = null;\n+  private Random r = null;\n+\n+  @Override\n+  public void init() throws DBException {\n+    colFam = new Text(getProperties().getProperty("accumulo.columnFamily"));\n+\n+    inst = new ZooKeeperInstance(\n+        getProperties().getProperty("accumulo.instanceName"),\n+        getProperties().getProperty("accumulo.zooKeepers"));\n+    try {\n+      String principal = getProperties().getProperty("accumulo.username");\n+      AuthenticationToken token =\n+          new PasswordToken(getProperties().getProperty("accumulo.password"));\n+      connector = inst.getConnector(principal, token);\n+    } catch (AccumuloException e) {\n+      throw new DBException(e);\n+    } catch (AccumuloSecurityException e) {\n+      throw new DBException(e);\n+    }\n+\n+    pcFlag = getProperties().getProperty("accumulo.PC_FLAG", "none");\n+    if (pcFlag.equals(PC_PRODUCER) || pcFlag.equals(PC_CONSUMER)) {\n+      System.out.println("*** YCSB Client is " + pcFlag);\n+      String address = getProperties().getProperty("accumulo.PC_SERVER");\n+      String root = getProperties().getProperty("accumulo.PC_ROOT_IN_ZK");\n+      System.out\n+          .println("*** PC_INFO(server:" + address + ";root=" + root + ")");\n+      q = new ZKProducerConsumer.Queue(address, root);\n+      r = new Random();\n+    }\n+\n+    if (pcFlag.equals(PC_CONSUMER)) {\n+      hmKeyReads = new Hashtable<String, Long>();\n+      hmKeyNumReads = new Hashtable<String, Integer>();\n+      try {\n+        keyNotification(null);\n+      } catch (KeeperException e) {\n+        throw new DBException(e);\n+      }\n+    }\n+  }\n+\n+  @Override\n+  public void cleanup() throws DBException {\n+    try {\n+      if (bw != null) {\n+        bw.close();\n+      }\n+    } catch (MutationsRejectedException e) {\n+      throw new DBException(e);\n+    }\n+    CleanUp.shutdownNow();\n+  }\n+\n+  /**\n+   * Commonly repeated functionality: Before doing any operation, make sure\n+   * we\'re working on the correct table. If not, open the correct one.\n+   * \n+   * @param t\n+   *          The table to open.\n+   */\n+  public void checkTable(String t) throws TableNotFoundException {\n+    if (!table.equals(t)) {\n+      getTable(t);\n+    }\n+  }\n+\n+  /**\n+   * Called when the user specifies a table that isn\'t the same as the existing\n+   * table. Connect to it and if necessary, close our current connection.\n+   * \n+   * @param t\n+   *          The table to open.\n+   */\n+  public void getTable(String t) throws TableNotFoundException {\n+    if (bw != null) { // Close the existing writer if necessary.\n+      try {\n+        bw.close();\n+      } catch (MutationsRejectedException e) {\n+        // Couldn\'t spit out the mutations we wanted.\n+        // Ignore this for now.\n+        System.err.println("MutationsRejectedException: " + e.getMessage());\n+      }\n+    }\n+\n+    BatchWriterConfig bwc = new BatchWriterConfig();\n+    bwc.setMaxLatency(\n+        Long.parseLong(getProperties()\n+            .getProperty("accumulo.batchWriterMaxLatency", "30000")),\n+        TimeUnit.MILLISECONDS);\n+    bwc.setMaxMemory(Long.parseLong(\n+        getProperties().getProperty("accumulo.batchWriterSize", "100000")));\n+    bwc.setMaxWriteThreads(Integer.parseInt(\n+        getProperties().getProperty("accumulo.batchWriterThreads", "1")));\n+\n+    bw = connector.createBatchWriter(table, bwc);\n+\n+    // Create our scanners\n+    singleScanner = connector.createScanner(table, Authorizations.EMPTY);\n+    scanScanner = connector.createScanner(table, Authorizations.EMPTY);\n+\n+    table = t; // Store the name of the table we have open.\n+  }\n+\n+  /**\n+   * Gets a scanner from Accumulo over one row.\n+   * \n+   * @param row\n+   *          the row to scan\n+   * @param fields\n+   *          the set of columns to scan\n+   * @return an Accumulo {@link Scanner} bound to the given row and columns\n+   */\n+  private Scanner getRow(Text row, Set<String> fields) {\n+    singleScanner.clearColumns();\n+    singleScanner.setRange(new Range(row));\n+    if (fields != null) {\n+      for (String field : fields) {\n+        singleScanner.fetchColumn(colFam, new Text(field));\n+      }\n+    }\n+    return singleScanner;\n+  }\n+\n+  @Override\n+  public int read(String t, String key, Set<String> fields,\n+      HashMap<String, ByteIterator> result) {\n+\n+    try {\n+      checkTable(t);\n+    } catch (TableNotFoundException e) {\n+      System.err.println("Error trying to connect to Accumulo table." + e);\n+      return SERVER_ERROR;\n+    }\n+\n+    try {\n+      // Pick out the results we care about.\n+      for (Entry<Key, Value> entry : getRow(new Text(key), null)) {\n+        Value v = entry.getValue();\n+        byte[] buf = v.get();\n+        result.put(entry.getKey().getColumnQualifier().toString(),\n+            new ByteArrayByteIterator(buf));\n+      }\n+    } catch (Exception e) {\n+      System.err.println("Error trying to reading Accumulo table" + key + e);\n+      return SERVER_ERROR;\n+    }\n+    return OK;\n+\n+  }\n+\n+  @Override\n+  public int scan(String t, String startkey, int recordcount,\n+      Set<String> fields, Vector<HashMap<String, ByteIterator>> result) {\n+    try {\n+      checkTable(t);\n+    } catch (TableNotFoundException e) {\n+      System.err.println("Error trying to connect to Accumulo table." + e);\n+      return SERVER_ERROR;\n+    }\n+\n+    // There doesn\'t appear to be a way to create a range for a given\n+    // LENGTH. Just start and end keys. So we\'ll do this the hard way for\n+    // now:\n+    // Just make the end \'infinity\' and only read as much as we need.\n+    scanScanner.clearColumns();\n+    scanScanner.setRange(new Range(new Text(startkey), null));\n+\n+    // Batch size is how many key/values to try to get per call. Here, I\'m\n+    // guessing that the number of keys in a row is equal to the number of\n+    // fields\n+    // we\'re interested in.\n+    // We try to fetch one more so as to tell when we\'ve run out of fields.\n+\n+    if (fields != null) {\n+      // And add each of them as fields we want.\n+      for (String field : fields) {\n+        scanScanner.fetchColumn(colFam, new Text(field));\n+      }\n+    } // else - If no fields are provided, we assume one column/row.\n+\n+    String rowKey = "";\n+    HashMap<String, ByteIterator> currentHM = null;\n+    int count = 0;\n+\n+    // Begin the iteration.\n+    for (Entry<Key, Value> entry : scanScanner) {\n+      // Check for a new row.\n+      if (!rowKey.equals(entry.getKey().getRow().toString())) {\n+        if (count++ == recordcount) { // Done reading the last row.\n+          break;\n+        }\n+        rowKey = entry.getKey().getRow().toString();\n+        if (fields != null) {\n+          // Initial Capacity for all keys.\n+          currentHM = new HashMap<String, ByteIterator>(fields.size());\n+        } else {\n+          // An empty result map.\n+          currentHM = new HashMap<String, ByteIterator>();\n+        }\n+        result.add(currentHM);\n+      }\n+      // Now add the key to the hashmap.\n+      Value v = entry.getValue();\n+      byte[] buf = v.get();\n+      currentHM.put(entry.getKey().getColumnQualifier().toString(),\n+          new ByteArrayByteIterator(buf));\n+    }\n+\n+    return OK;\n+  }\n+\n+  @Override\n+  public int update(String t, String key,\n+      HashMap<String, ByteIterator> values) {\n+    try {\n+      checkTable(t);\n+    } catch (TableNotFoundException e) {\n+      System.err.println("Error trying to connect to Accumulo table." + e);\n+      return SERVER_ERROR;\n+    }\n+\n+    Mutation mutInsert = new Mutation(new Text(key));\n+    for (Map.Entry<String, ByteIterator> entry : values.entrySet()) {\n+      mutInsert.put(colFam, new Text(entry.getKey()),\n+          System.currentTimeMillis(), new Value(entry.getValue().toArray()));\n+    }\n+\n+    try {\n+      bw.addMutation(mutInsert);\n+      // Distributed YCSB co-ordination: YCSB on a client produces the key\n+      // to\n+      // be stored in the shared queue in ZooKeeper.\n+      if (pcFlag.equals(PC_PRODUCER)) {\n+        if (r.nextFloat() < 0.01) {\n+          keyNotification(key);\n+        }\n+      }\n+    } catch (MutationsRejectedException e) {\n+      System.err.println("Error performing update.");\n+      e.printStackTrace();\n+      return SERVER_ERROR;\n+    } catch (KeeperException e) {\n+      System.err.println("Error notifying the Zookeeper Queue.");\n+      e.printStackTrace();\n+      return SERVER_ERROR;\n+    }\n+\n+    return OK;\n+  }\n+\n+  @Override\n+  public int insert(String t, String key,\n+      HashMap<String, ByteIterator> values) {\n+    return update(t, key, values);\n+  }\n+\n+  @Override\n+  public int delete(String t, String key) {\n+    try {\n+      checkTable(t);\n+    } catch (TableNotFoundException e) {\n+      System.err.println("Error trying to connect to Accumulo table." + e);\n+      return SERVER_ERROR;\n+    }\n+\n+    try {\n+      deleteRow(new Text(key));\n+    } catch (MutationsRejectedException e) {\n+      System.err.println("Error performing delete.");\n+      e.printStackTrace();\n+      return SERVER_ERROR;\n+    } catch (RuntimeException e) {\n+      System.err.println("Error performing delete.");\n+      e.printStackTrace();\n+      return SERVER_ERROR;\n+    }\n+\n+    return OK;\n+  }\n+\n+  // These functions are adapted from RowOperations.java:\n+  private void deleteRow(Text row) throws MutationsRejectedException {\n+    deleteRow(getRow(row, null));\n+  }\n+\n+  /**\n+   * Deletes a row, given a Scanner of JUST that row.\n+   */\n+  private void deleteRow(Scanner scanner) throws MutationsRejectedException {\n+    Mutation deleter = null;\n+    // iterate through the keys\n+    for (Entry<Key, Value> entry : scanner) {\n+      // create a mutation for the row\n+      if (deleter == null) {\n+        deleter = new Mutation(entry.getKey().getRow());\n+      }\n+      // the remove function adds the key with the delete flag set to true\n+      deleter.putDelete(entry.getKey().getColumnFamily(),\n+          entry.getKey().getColumnQualifier());\n+    }\n+\n+    bw.addMutation(deleter);\n+  }\n+\n+  private void keyNotification(String key) throws KeeperException {\n+\n+    if (pcFlag.equals(PC_PRODUCER)) {\n+      try {\n+        q.produce(key);\n+      } catch (InterruptedException e) {\n+        // Reset the interrupted state.\n+        Thread.currentThread().interrupt();\n+      }\n+    } else {\n+      // XXX: do something better to keep the loop going (while??)\n+      for (int i = 0; i < 10000000; i++) {\n+        try {\n+          String strKey = q.consume();\n+\n+          if (!hmKeyReads.containsKey(strKey)\n+              && !hmKeyNumReads.containsKey(strKey)) {\n+            hmKeyReads.put(strKey, new Long(System.currentTimeMillis()));\n+            hmKeyNumReads.put(strKey, new Integer(1));\n+          }\n+\n+          // YCSB Consumer will read the key that was fetched from the\n+          // queue in ZooKeeper.\n+          // (current way is kind of ugly but works, i think)\n+          // TODO : Get table name from configuration or argument\n+          String usertable = "usertable";\n+          HashSet<String> fields = new HashSet<String>();\n+          for (int j = 0; j < 9; j++) {\n+            fields.add("field" + j);\n+          }\n+          HashMap<String, ByteIterator> result =\n+              new HashMap<String, ByteIterator>();\n+\n+          int retval = read(usertable, strKey, fields, result);\n+          // If the results are empty, the key is enqueued in\n+          // Zookeeper\n+          // and tried again, until the results are found.\n+          if (result.size() == 0) {\n+            q.produce(strKey);\n+            int count = ((Integer) hmKeyNumReads.get(strKey)).intValue();\n+            hmKeyNumReads.put(strKey, new Integer(count + 1));\n+          } else {\n+            if (((Integer) hmKeyNumReads.get(strKey)).intValue() > 1) {\n+              long currTime = System.currentTimeMillis();\n+              long writeTime = ((Long) hmKeyReads.get(strKey)).longValue();\n+              System.out.println(\n+                  "Key=" + strKey + ";StartSearch=" + writeTime + ";EndSearch="\n+                      + currTime + ";TimeLag=" + (currTime - writeTime));\n+            }\n+          }\n+        } catch (InterruptedException e) {\n+          // Reset the interrupted state.\n+          Thread.currentThread().interrupt();\n+        }\n+      }\n+    }\n+\n+  }\n+\n+  public int presplit(String t, String[] keys)\n+      throws TableNotFoundException, AccumuloException,\n+      AccumuloSecurityException {\n+    TreeSet<Text> splits = new TreeSet<Text>();\n+    for (int i = 0; i < keys.length; i++) {\n+      splits.add(new Text(keys[i]));\n+    }\n+    connector.tableOperations().addSplits(t, splits);\n+    return OK;\n+  }\n \n }\ndiff --git a/accumulo/src/main/java/com/yahoo/ycsb/db/ZKProducerConsumer.java b/accumulo/src/main/java/com/yahoo/ycsb/db/ZKProducerConsumer.java\nindex 09741641..2d42c79a 100644\n--- a/accumulo/src/main/java/com/yahoo/ycsb/db/ZKProducerConsumer.java\n+++ b/accumulo/src/main/java/com/yahoo/ycsb/db/ZKProducerConsumer.java\n@@ -21,7 +21,6 @@ package com.yahoo.ycsb.db;\n import java.io.IOException;\n import java.util.List;\n \n-\n import org.apache.zookeeper.CreateMode;\n import org.apache.zookeeper.KeeperException;\n import org.apache.zookeeper.WatchedEvent;\n@@ -30,111 +29,165 @@ import org.apache.zookeeper.ZooKeeper;\n import org.apache.zookeeper.ZooDefs.Ids;\n import org.apache.zookeeper.data.Stat;\n \n-// Implementing the PC Queue in ZooKeeper\n-//\n+/**\n+ * Implementing the PC (Producer/Consumer) Queue in ZooKeeper.\n+ */\n public class ZKProducerConsumer implements Watcher {\n \n-    static ZooKeeper zk = null;\n-    static Integer mutex;\n-\n-    String root;\n-\n-    // Constructor that takes tha address of the ZK server\n-    //\n-    ZKProducerConsumer(String address) {\n-        if(zk == null){\n-            try {\n-                System.out.println("Starting ZK:");\n-                zk = new ZooKeeper(address, 3000, this);\n-                mutex = new Integer(-1);\n-                System.out.println("Finished starting ZK: " + zk);\n-            } catch (IOException e) {\n-                System.out.println(e.toString());\n-                zk = null;\n-            }\n-        }\n-        //else mutex = new Integer(-1);\n+  private static ZooKeeper zk = null;\n+  private static Integer mutex;\n+\n+  private String root;\n+\n+  /**\n+   * Constructor that takes the address of the ZK server.\n+   * \n+   * @param address\n+   *          The address of the ZK server.\n+   */\n+  ZKProducerConsumer(String address) {\n+    if (zk == null) {\n+      try {\n+        System.out.println("Starting ZK:");\n+        zk = new ZooKeeper(address, 3000, this);\n+        mutex = new Integer(-1);\n+        System.out.println("Finished starting ZK: " + zk);\n+      } catch (IOException e) {\n+        System.out.println(e.toString());\n+        zk = null;\n+      }\n     }\n+    // else mutex = new Integer(-1);\n+  }\n \n-    synchronized public void process(WatchedEvent event) {\n-        synchronized (mutex) {\n-            //System.out.println("Process: " + event.getType());\n-            mutex.notify();\n-        }\n+  public synchronized void process(WatchedEvent event) {\n+    synchronized (mutex) {\n+      // System.out.println("Process: " + event.getType());\n+      mutex.notify();\n     }\n-\n-\n-    static public class QueueElement {\n-        public String key;\n-        public long writeTime;\n-\n-        QueueElement(String key, long writeTime) {\n-            this.key = key;\n-            this.writeTime = writeTime;\n-        }\n+  }\n+\n+  /**\n+   * Returns the root.\n+   *\n+   * @return The root.\n+   */\n+  protected String getRoot() {\n+    return root;\n+  }\n+\n+  /**\n+   * Sets the root.\n+   * \n+   * @param r\n+   *          The root value.\n+   */\n+  protected void setRoot(String r) {\n+    this.root = r;\n+  }\n+\n+  /**\n+   * QueueElement a single queue element.  No longer used.\n+   * @deprecated No longer used.\n+   */\n+  @Deprecated\n+  public static class QueueElement {\n+    private String key;\n+    private long writeTime;\n+\n+    QueueElement(String key, long writeTime) {\n+      this.key = key;\n+      this.writeTime = writeTime;\n     }\n-\n-    // Producer-Consumer queue\n-    static public class Queue extends ZKProducerConsumer {\n-\n-        // Constructor of producer-consumer queue\n-        Queue(String address, String name) {\n-            super(address);\n-            this.root = name;\n-            // Create ZK node name\n-            if (zk != null) {\n-                try {\n-                    Stat s = zk.exists(root, false);\n-                    if (s == null) {\n-                        zk.create(root, new byte[0], Ids.OPEN_ACL_UNSAFE,\n-                                CreateMode.PERSISTENT);\n-                    }\n-                } catch (KeeperException e) {\n-                    System.out\n-                            .println("Keeper exception when instantiating queue: "\n-                                    + e.toString());\n-                } catch (InterruptedException e) {\n-                    System.out.println("Interrupted exception");\n-                }\n-            }\n+  }\n+\n+  /**\n+   * Producer-Consumer queue.\n+   */\n+  public static class Queue extends ZKProducerConsumer {\n+\n+    /**\n+     * Constructor of producer-consumer queue.\n+     * \n+     * @param address\n+     *          The Zookeeper server address.\n+     * @param name\n+     *          The name of the root element for the queue.\n+     */\n+    Queue(String address, String name) {\n+      super(address);\n+      this.setRoot(name);\n+      // Create ZK node name\n+      if (zk != null) {\n+        try {\n+          Stat s = zk.exists(getRoot(), false);\n+          if (s == null) {\n+            zk.create(getRoot(), new byte[0], Ids.OPEN_ACL_UNSAFE,\n+                CreateMode.PERSISTENT);\n+          }\n+        } catch (KeeperException e) {\n+          System.out.println(\n+              "Keeper exception when instantiating queue: " + e.toString());\n+        } catch (InterruptedException e) {\n+          System.out.println("Interrupted exception");\n         }\n+      }\n+    }\n \n-        // Producer calls this method to insert the key in the queue\n-        //\n-        boolean produce(String key) throws KeeperException, InterruptedException{\n-            byte[] value;\n-            value = key.getBytes();\n-            zk.create(root + "/key", value, \n-                      Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT_SEQUENTIAL);\n+    /**\n+     * Producer calls this method to insert the key in the queue.\n+     * \n+     * @param key\n+     *          The key to produce (add to the queue).\n+     * @return True if the key was added.\n+     * @throws KeeperException\n+     *           On a failure talking to zookeeper.\n+     * @throws InterruptedException\n+     *           If the current thread is interrupted waiting for the zookeeper\n+     *           acknowledgement.\n+     */\n+    //\n+    boolean produce(String key) throws KeeperException, InterruptedException {\n+      byte[] value;\n+      value = key.getBytes();\n+      zk.create(getRoot() + "/key", value, Ids.OPEN_ACL_UNSAFE,\n+          CreateMode.PERSISTENT_SEQUENTIAL);\n \n-            return true;\n-        }\n+      return true;\n+    }\n \n-        // Consumer calls this method to "wait" for the key to the available\n-        //\n-        String consume() throws KeeperException, InterruptedException {\n-            String retvalue = null;\n-            Stat stat = null;\n-\n-            // Get the first element available\n-            while (true) {\n-                synchronized (mutex) {\n-                    List<String> list = zk.getChildren(root, true);\n-                    if (list.size() == 0) {\n-                        System.out.println("Going to wait");\n-                        mutex.wait();\n-                    } else {\n-                        String path = root+"/"+list.get(0);\n-                        byte[] b = zk.getData(path, false, stat);\n-                        retvalue = new String(b);\n-                        zk.delete(path, -1);\n-\n-                        return retvalue;\n-\n-                    }\n-                }\n-            }\n+    /**\n+     * Consumer calls this method to "wait" for the key to the available.\n+     * \n+     * @return The key to consumed (remove from the queue).\n+     * @throws KeeperException\n+     *           On a failure talking to zookeeper.\n+     * @throws InterruptedException\n+     *           If the current thread is interrupted waiting for the zookeeper\n+     *           acknowledgement.\n+     */\n+    String consume() throws KeeperException, InterruptedException {\n+      String retvalue = null;\n+      Stat stat = null;\n+\n+      // Get the first element available\n+      while (true) {\n+        synchronized (mutex) {\n+          List<String> list = zk.getChildren(getRoot(), true);\n+          if (list.size() == 0) {\n+            System.out.println("Going to wait");\n+            mutex.wait();\n+          } else {\n+            String path = getRoot() + "/" + list.get(0);\n+            byte[] b = zk.getData(path, false, stat);\n+            retvalue = new String(b);\n+            zk.delete(path, -1);\n+\n+            return retvalue;\n+\n+          }\n         }\n+      }\n     }\n+  }\n }\n-        \ndiff --git a/accumulo/src/main/java/com/yahoo/ycsb/db/package-info.java b/accumulo/src/main/java/com/yahoo/ycsb/db/package-info.java\nnew file mode 100644\nindex 00000000..fbd7cf85\n--- /dev/null\n+++ b/accumulo/src/main/java/com/yahoo/ycsb/db/package-info.java\n@@ -0,0 +1,21 @@\n+/**\n+ * Copyright (c) 2015 YCSB contributors. All rights reserved.\n+ *\n+ * Licensed under the Apache License, Version 2.0 (the "License"); you\n+ * may not use this file except in compliance with the License. You\n+ * may obtain a copy of the License at\n+ *\n+ * http://www.apache.org/licenses/LICENSE-2.0\n+ *\n+ * Unless required by applicable law or agreed to in writing, software\n+ * distributed under the License is distributed on an "AS IS" BASIS,\n+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\n+ * implied. See the License for the specific language governing\n+ * permissions and limitations under the License. See accompanying\n+ * LICENSE file.\n+ */\n+\n+/**\n+ * YCSB binding for <a href="https://accumulo.apache.org/">Accumulo</a>.\n+ */\n+package com.yahoo.ycsb.db;\n\\ No newline at end of file\n', 'commit_subject': '[accumulo] Checkstyle cleanup and enforcement for the Accumulo binding.', 'repo_name': 'brianfrankcooper/YCSB', 'committer': {'name': 'Robert J. Moore', 'email': '57dd5fa1bb1a48357d9eb1bad9924dd11b255da9@allanbank.com', 'time_sec': '1446407193', 'tz_offset': '-300', 'date': {'seconds': '1446407193'}}, 'commit_tree': 'c5244533fd03264453cf84debcce191a160d74ca', 'commit_message': '[accumulo] Checkstyle cleanup and enforcement for the Accumulo binding.\n\nAgain, a lot of whitespace changes and the normal checkstyle type errors.\n\n2 items of note:\n\n1. Deprecated QueueElement since it is not used.\n2. Moved some of the exception handling to common locations to remove\n   empty catch blocks.\n', 'language_name': 'HTML', 'license': 'apache-2.0', 'hunks': '@@ -0,0 +1,21 @@\n+/**\n+ * Copyright (c) 2015 YCSB contributors. All rights reserved.\n+ *\n+ * Licensed under the Apache License, Version 2.0 (the "License"); you\n+ * may not use this file except in compliance with the License. You\n+ * may obtain a copy of the License at\n+ *\n+ * http://www.apache.org/licenses/LICENSE-2.0\n+ *\n+ * Unless required by applicable law or agreed to in writing, software\n+ * distributed under the License is distributed on an "AS IS" BASIS,\n+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\n+ * implied. See the License for the specific language governing\n+ * permissions and limitations under the License. See accompanying\n+ * LICENSE file.\n+ */\n+\n+/**\n+ * YCSB binding for <a href="https://accumulo.apache.org/">Accumulo</a>.\n+ */\n+package com.yahoo.ycsb.db;\n\\ No newline at end of file\n', 'addition_count': 21, 'deletion_count': 0, 'src_file': '/dev/null', 'tgt_file': 'b/accumulo/src/main/java/com/yahoo/ycsb/db/package-info.java', 'file_extension': '.java', 'before_file': 'ADDFILE', 'message': '[accumulo] Checkstyle cleanup and enforcement for the Accumulo binding.\n\nAgain, a lot of whitespace changes and the normal checkstyle type errors.\n\n2 items of note:\n\n1. Deprecated QueueElement since it is not used.\n2. Moved some of the exception handling to common locations to remove\n   empty catch blocks.\n', 'author_name': 'Robert J. Moore', 'lang': 'java'}