Return-Path: X-Original-To: apmail-accumulo-commits-archive@www.apache.org Delivered-To: apmail-accumulo-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 7C22E11812 for ; Thu, 19 Jun 2014 20:31:05 +0000 (UTC) Received: (qmail 86294 invoked by uid 500); 19 Jun 2014 20:31:05 -0000 Delivered-To: apmail-accumulo-commits-archive@accumulo.apache.org Received: (qmail 86232 invoked by uid 500); 19 Jun 2014 20:31:05 -0000 Mailing-List: contact commits-help@accumulo.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@accumulo.apache.org Delivered-To: mailing list commits@accumulo.apache.org Received: (qmail 86055 invoked by uid 99); 19 Jun 2014 20:31:05 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 19 Jun 2014 20:31:05 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 0C4EE985646; Thu, 19 Jun 2014 20:31:05 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: elserj@apache.org To: commits@accumulo.apache.org Date: Thu, 19 Jun 2014 20:31:08 -0000 Message-Id: In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [5/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/1.6.1-SNAPSHOT Commit: 344b4d3a31bab7b42538497843df6420bb95b593 Parents: c86b067 f99b565 Author: Josh Elser Authored: Thu Jun 19 13:11:29 2014 -0700 Committer: Josh Elser 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();