You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by el...@apache.org on 2014/06/19 22:31:07 UTC

[4/7] git commit: Merge branch '1.5.2-SNAPSHOT' into 1.6.1-SNAPSHOT

Merge branch '1.5.2-SNAPSHOT' into 1.6.1-SNAPSHOT

Conflicts:
	core/src/main/java/org/apache/accumulo/core/client/BatchWriterConfig.java


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

Branch: refs/heads/master
Commit: 344b4d3a31bab7b42538497843df6420bb95b593
Parents: c86b067 f99b565
Author: Josh Elser <el...@apache.org>
Authored: Thu Jun 19 13:11:29 2014 -0700
Committer: Josh Elser <el...@apache.org>
Committed: Thu Jun 19 13:11:29 2014 -0700

----------------------------------------------------------------------
 .../accumulo/core/client/BatchWriterConfig.java | 107 +++++++++++++++----
 .../core/client/BatchWriterConfigTest.java      |  26 +++++
 2 files changed, 113 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/344b4d3a/core/src/main/java/org/apache/accumulo/core/client/BatchWriterConfig.java
----------------------------------------------------------------------
diff --cc core/src/main/java/org/apache/accumulo/core/client/BatchWriterConfig.java
index 5b149fa,28955f5..105a5d6
--- a/core/src/main/java/org/apache/accumulo/core/client/BatchWriterConfig.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/BatchWriterConfig.java
@@@ -23,7 -24,7 +23,8 @@@ import java.util.ArrayList
  import java.util.List;
  import java.util.concurrent.TimeUnit;
  
 +import org.apache.accumulo.core.Constants;
+ import org.apache.commons.lang.builder.HashCodeBuilder;
  import org.apache.hadoop.io.Writable;
  import org.apache.hadoop.util.StringUtils;
  
@@@ -179,9 -180,9 +180,9 @@@ public class BatchWriterConfig implemen
      if (timeout != null)
        addField(fields, "timeout", timeout);
      String output = StringUtils.join(",", fields);
-     
+ 
 -    byte[] bytes = output.getBytes(Charset.forName("UTF-8"));
 -    byte[] len = String.format("%6s#", Integer.toString(bytes.length, 36)).getBytes("UTF-8");
 +    byte[] bytes = output.getBytes(Constants.UTF8);
 +    byte[] len = String.format("%6s#", Integer.toString(bytes.length, 36)).getBytes(Constants.UTF8);
      if (len.length != 7)
        throw new IllegalStateException("encoded length does not match expected value");
      out.write(len);
@@@ -203,8 -204,8 +204,8 @@@
        throw new IllegalStateException("length was not encoded correctly");
      byte[] bytes = new byte[Integer.parseInt(strLen.substring(strLen.lastIndexOf(' ') + 1, strLen.length() - 1), 36)];
      in.readFully(bytes);
-     
+ 
 -    String strFields = new String(bytes, Charset.forName("UTF-8"));
 +    String strFields = new String(bytes, Constants.UTF8);
      String[] fields = StringUtils.split(strFields, '\\', ',');
      for (String field : fields) {
        String[] keyValue = StringUtils.split(field, '\\', '=');

http://git-wip-us.apache.org/repos/asf/accumulo/blob/344b4d3a/core/src/test/java/org/apache/accumulo/core/client/BatchWriterConfigTest.java
----------------------------------------------------------------------
diff --cc core/src/test/java/org/apache/accumulo/core/client/BatchWriterConfigTest.java
index 26f23a5,ddd201a..259cb06
--- a/core/src/test/java/org/apache/accumulo/core/client/BatchWriterConfigTest.java
+++ b/core/src/test/java/org/apache/accumulo/core/client/BatchWriterConfigTest.java
@@@ -155,9 -155,35 +155,35 @@@ public class BatchWriterConfigTest 
      bwConfig.setMaxWriteThreads(24);
      bwConfig.setTimeout(3, TimeUnit.SECONDS);
      bytes = createBytes(bwConfig);
 -    assertEquals("     v#maxWriteThreads=24,timeout=3000", new String(bytes, Charset.forName("UTF-8")));
 +    assertEquals("     v#maxWriteThreads=24,timeout=3000", new String(bytes, Constants.UTF8));
      checkBytes(bwConfig, bytes);
    }
+ 
+   @Test
+   public void testDefaultEquality() {
+     BatchWriterConfig cfg1 = new BatchWriterConfig(), cfg2 = new BatchWriterConfig();
+     assertEquals(cfg1, cfg2);
+     assertEquals(cfg1.hashCode(), cfg2.hashCode());
+     cfg2.setMaxMemory(1);
+     assertNotEquals(cfg1, cfg2);
+   }
+ 
+   @Test
+   public void testManualEquality() {
+     BatchWriterConfig cfg1 = new BatchWriterConfig(), cfg2 = new BatchWriterConfig();
+     cfg1.setMaxLatency(10, TimeUnit.SECONDS);
+     cfg2.setMaxLatency(10000, TimeUnit.MILLISECONDS);
+ 
+     cfg1.setMaxMemory(100);
+     cfg2.setMaxMemory(100);
+ 
+     cfg1.setTimeout(10, TimeUnit.SECONDS);
+     cfg2.setTimeout(10000, TimeUnit.MILLISECONDS);
+     
+     assertEquals(cfg1, cfg2);
+ 
+     assertEquals(cfg1.hashCode(), cfg2.hashCode());
+   }
    
    private byte[] createBytes(BatchWriterConfig bwConfig) throws IOException {
      ByteArrayOutputStream baos = new ByteArrayOutputStream();