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:09 UTC
[6/7] git commit: Merge branch '1.6.1-SNAPSHOT'
Merge branch '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/61bf188c
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/61bf188c
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/61bf188c
Branch: refs/heads/master
Commit: 61bf188cef7c7e6f0ad7131880c2ef47e6814387
Parents: e23a543 344b4d3
Author: Josh Elser <el...@apache.org>
Authored: Thu Jun 19 13:30:18 2014 -0700
Committer: Josh Elser <el...@apache.org>
Committed: Thu Jun 19 13:30:18 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/61bf188c/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 a3572e3,105a5d6..e2ec22e
--- a/core/src/main/java/org/apache/accumulo/core/client/BatchWriterConfig.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/BatchWriterConfig.java
@@@ -24,6 -23,8 +24,7 @@@ 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(Constants.UTF8);
- byte[] len = String.format("%6s#", Integer.toString(bytes.length, 36)).getBytes(Constants.UTF8);
+ byte[] bytes = output.getBytes(StandardCharsets.UTF_8);
+ byte[] len = String.format("%6s#", Integer.toString(bytes.length, 36)).getBytes(StandardCharsets.UTF_8);
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, Constants.UTF8);
+ String strFields = new String(bytes, StandardCharsets.UTF_8);
String[] fields = StringUtils.split(strFields, '\\', ',');
for (String field : fields) {
String[] keyValue = StringUtils.split(field, '\\', '=');
http://git-wip-us.apache.org/repos/asf/accumulo/blob/61bf188c/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 7801f4d,259cb06..231afe5
--- 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, Constants.UTF8));
+ assertEquals(" v#maxWriteThreads=24,timeout=3000", new String(bytes, StandardCharsets.UTF_8));
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();