accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ctubb...@apache.org
Subject git commit: ACCUMULO-1545 Switch to UTF-8 Charset constant instead of string literals
Date Tue, 23 Jul 2013 22:34:43 GMT
Updated Branches:
  refs/heads/master 9ae8d3948 -> 07d1b6ea9


ACCUMULO-1545 Switch to UTF-8 Charset constant instead of string literals


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

Branch: refs/heads/master
Commit: 07d1b6ea9148e49cf7911dcd5b56da33fc24d299
Parents: 9ae8d39
Author: Christopher Tubbs <ctubbsii@apache.org>
Authored: Tue Jul 23 18:33:14 2013 -0400
Committer: Christopher Tubbs <ctubbsii@apache.org>
Committed: Tue Jul 23 18:33:14 2013 -0400

----------------------------------------------------------------------
 .../apache/accumulo/core/cli/ClientOpts.java    |  3 +-
 .../accumulo/core/client/BatchWriterConfig.java | 10 ++--
 .../core/client/lexicoder/StringLexicoder.java  | 14 +----
 .../mapreduce/lib/util/ConfiguratorBase.java    | 10 ++--
 .../mapreduce/lib/util/InputConfigurator.java   | 15 +++--
 .../mapreduce/lib/util/OutputConfigurator.java  |  6 +-
 .../core/iterators/user/RegExFilter.java        |  3 +-
 .../core/security/CredentialHelper.java         |  8 +--
 .../core/client/BatchWriterConfigTest.java      |  6 +-
 .../core/iterators/user/RegExFilterTest.java    |  7 ++-
 .../server/monitor/servlets/BasicServlet.java   | 17 +++---
 .../server/monitor/servlets/XMLServlet.java     |  5 +-
 .../accumulo/server/util/DumpZookeeper.java     | 10 ++--
 .../accumulo/server/util/RestoreZookeeper.java  | 14 +++--
 .../accumulo/server/util/SendLogToChainsaw.java | 63 ++++++++++----------
 .../apache/accumulo/test/AuditMessageTest.java  | 17 +++---
 16 files changed, 101 insertions(+), 107 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/07d1b6ea/core/src/main/java/org/apache/accumulo/core/cli/ClientOpts.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/cli/ClientOpts.java b/core/src/main/java/org/apache/accumulo/core/cli/ClientOpts.java
index ec6b198..9247d56 100644
--- a/core/src/main/java/org/apache/accumulo/core/cli/ClientOpts.java
+++ b/core/src/main/java/org/apache/accumulo/core/cli/ClientOpts.java
@@ -16,7 +16,6 @@
  */
 package org.apache.accumulo.core.cli;
 
-import java.nio.charset.Charset;
 import java.util.Iterator;
 import java.util.LinkedHashMap;
 import java.util.Map;
@@ -81,7 +80,7 @@ public class ClientOpts extends Help {
     public byte[] value;
     
     public Password(String dfault) {
-      value = dfault.getBytes(Charset.forName("UTF-8"));
+      value = dfault.getBytes(Constants.UTF8);
     }
     
     @Override

http://git-wip-us.apache.org/repos/asf/accumulo/blob/07d1b6ea/core/src/main/java/org/apache/accumulo/core/client/BatchWriterConfig.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/client/BatchWriterConfig.java b/core/src/main/java/org/apache/accumulo/core/client/BatchWriterConfig.java
index d3ad3fe..5b149fa 100644
--- a/core/src/main/java/org/apache/accumulo/core/client/BatchWriterConfig.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/BatchWriterConfig.java
@@ -19,11 +19,11 @@ package org.apache.accumulo.core.client;
 import java.io.DataInput;
 import java.io.DataOutput;
 import java.io.IOException;
-import java.nio.charset.Charset;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.concurrent.TimeUnit;
 
+import org.apache.accumulo.core.Constants;
 import org.apache.hadoop.io.Writable;
 import org.apache.hadoop.util.StringUtils;
 
@@ -180,8 +180,8 @@ public class BatchWriterConfig implements Writable {
       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);
@@ -198,13 +198,13 @@ public class BatchWriterConfig implements Writable {
   public void readFields(DataInput in) throws IOException {
     byte[] len = new byte[7];
     in.readFully(len);
-    String strLen = new String(len, Charset.forName("UTF-8"));
+    String strLen = new String(len, Constants.UTF8);
     if (!strLen.endsWith("#"))
       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/07d1b6ea/core/src/main/java/org/apache/accumulo/core/client/lexicoder/StringLexicoder.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/client/lexicoder/StringLexicoder.java
b/core/src/main/java/org/apache/accumulo/core/client/lexicoder/StringLexicoder.java
index c06a898..a071d07 100644
--- a/core/src/main/java/org/apache/accumulo/core/client/lexicoder/StringLexicoder.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/lexicoder/StringLexicoder.java
@@ -16,7 +16,7 @@
  */
 package org.apache.accumulo.core.client.lexicoder;
 
-import java.io.UnsupportedEncodingException;
+import org.apache.accumulo.core.Constants;
 
 /**
  * This lexicoder encodes/decodes a given String to/from bytes without further processing.
It can be combined with other encoders like the
@@ -29,20 +29,12 @@ public class StringLexicoder implements Lexicoder<String> {
   
   @Override
   public byte[] encode(String data) {
-    try {
-      return data.getBytes("UTF-8");
-    } catch (UnsupportedEncodingException e) {
-      throw new RuntimeException(e);
-    }
+    return data.getBytes(Constants.UTF8);
   }
   
   @Override
   public String decode(byte[] data) {
-    try {
-      return new String(data, "UTF-8");
-    } catch (UnsupportedEncodingException e) {
-      throw new RuntimeException(e);
-    }
+    return new String(data, Constants.UTF8);
   }
   
 }

http://git-wip-us.apache.org/repos/asf/accumulo/blob/07d1b6ea/core/src/main/java/org/apache/accumulo/core/client/mapreduce/lib/util/ConfiguratorBase.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/client/mapreduce/lib/util/ConfiguratorBase.java
b/core/src/main/java/org/apache/accumulo/core/client/mapreduce/lib/util/ConfiguratorBase.java
index dbc9d5e..31964e8 100644
--- a/core/src/main/java/org/apache/accumulo/core/client/mapreduce/lib/util/ConfiguratorBase.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/mapreduce/lib/util/ConfiguratorBase.java
@@ -16,11 +16,11 @@
  */
 package org.apache.accumulo.core.client.mapreduce.lib.util;
 
+import java.io.IOException;
 import java.net.URI;
 import java.net.URISyntaxException;
-import java.nio.charset.Charset;
-import java.io.IOException;
 
+import org.apache.accumulo.core.Constants;
 import org.apache.accumulo.core.client.AccumuloSecurityException;
 import org.apache.accumulo.core.client.Instance;
 import org.apache.accumulo.core.client.ZooKeeperInstance;
@@ -30,12 +30,12 @@ import org.apache.accumulo.core.security.CredentialHelper;
 import org.apache.accumulo.core.util.ArgumentChecker;
 import org.apache.commons.codec.binary.Base64;
 import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.util.StringUtils;
 import org.apache.hadoop.filecache.DistributedCache;
 import org.apache.hadoop.fs.FSDataInputStream;
-import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.mapred.JobConf;
+import org.apache.hadoop.util.StringUtils;
 import org.apache.log4j.Level;
 import org.apache.log4j.Logger;
 
@@ -220,7 +220,7 @@ public class ConfiguratorBase {
     } else {
       token = readTokenFile(implementingClass, conf).split(":")[2];
     }
-    return Base64.decodeBase64(token.getBytes(Charset.forName("UTF-8")));
+    return Base64.decodeBase64(token.getBytes(Constants.UTF8));
   }
   
   /**

http://git-wip-us.apache.org/repos/asf/accumulo/blob/07d1b6ea/core/src/main/java/org/apache/accumulo/core/client/mapreduce/lib/util/InputConfigurator.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/client/mapreduce/lib/util/InputConfigurator.java
b/core/src/main/java/org/apache/accumulo/core/client/mapreduce/lib/util/InputConfigurator.java
index 15e045b..61792e0 100644
--- a/core/src/main/java/org/apache/accumulo/core/client/mapreduce/lib/util/InputConfigurator.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/mapreduce/lib/util/InputConfigurator.java
@@ -21,7 +21,6 @@ import java.io.ByteArrayOutputStream;
 import java.io.DataInputStream;
 import java.io.DataOutputStream;
 import java.io.IOException;
-import java.nio.charset.Charset;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashSet;
@@ -29,6 +28,7 @@ import java.util.List;
 import java.util.Set;
 import java.util.StringTokenizer;
 
+import org.apache.accumulo.core.Constants;
 import org.apache.accumulo.core.client.AccumuloException;
 import org.apache.accumulo.core.client.AccumuloSecurityException;
 import org.apache.accumulo.core.client.ClientSideIteratorScanner;
@@ -158,7 +158,7 @@ public class InputConfigurator extends ConfiguratorBase {
       for (Range r : ranges) {
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
         r.write(new DataOutputStream(baos));
-        rangeStrings.add(new String(Base64.encodeBase64(baos.toByteArray()), Charset.forName("UTF-8")));
+        rangeStrings.add(new String(Base64.encodeBase64(baos.toByteArray()), Constants.UTF8));
       }
     } catch (IOException ex) {
       throw new IllegalArgumentException("Unable to encode ranges to Base64", ex);
@@ -182,7 +182,7 @@ public class InputConfigurator extends ConfiguratorBase {
   public static List<Range> getRanges(Class<?> implementingClass, Configuration
conf) throws IOException {
     ArrayList<Range> ranges = new ArrayList<Range>();
     for (String rangeString : conf.getStringCollection(enumToConfKey(implementingClass, ScanOpts.RANGES)))
{
-      ByteArrayInputStream bais = new ByteArrayInputStream(Base64.decodeBase64(rangeString.getBytes(Charset.forName("UTF-8"))));
+      ByteArrayInputStream bais = new ByteArrayInputStream(Base64.decodeBase64(rangeString.getBytes(Constants.UTF8)));
       Range range = new Range();
       range.readFields(new DataInputStream(bais));
       ranges.add(range);
@@ -209,9 +209,9 @@ public class InputConfigurator extends ConfiguratorBase {
       if (column.getFirst() == null)
         throw new IllegalArgumentException("Column family can not be null");
       
-      String col = new String(Base64.encodeBase64(TextUtil.getBytes(column.getFirst())),
Charset.forName("UTF-8"));
+      String col = new String(Base64.encodeBase64(TextUtil.getBytes(column.getFirst())),
Constants.UTF8);
       if (column.getSecond() != null)
-        col += ":" + new String(Base64.encodeBase64(TextUtil.getBytes(column.getSecond())),
Charset.forName("UTF-8"));
+        col += ":" + new String(Base64.encodeBase64(TextUtil.getBytes(column.getSecond())),
Constants.UTF8);
       columnStrings.add(col);
     }
     conf.setStrings(enumToConfKey(implementingClass, ScanOpts.COLUMNS), columnStrings.toArray(new
String[0]));
@@ -232,8 +232,7 @@ public class InputConfigurator extends ConfiguratorBase {
     Set<Pair<Text,Text>> columns = new HashSet<Pair<Text,Text>>();
     for (String col : conf.getStringCollection(enumToConfKey(implementingClass, ScanOpts.COLUMNS)))
{
       int idx = col.indexOf(":");
-      Text cf = new Text(idx < 0 ? Base64.decodeBase64(col.getBytes(Charset.forName("UTF-8")))
: Base64.decodeBase64(col.substring(0, idx).getBytes(
-          Charset.forName("UTF-8"))));
+      Text cf = new Text(idx < 0 ? Base64.decodeBase64(col.getBytes(Constants.UTF8)) :
Base64.decodeBase64(col.substring(0, idx).getBytes(Constants.UTF8)));
       Text cq = idx < 0 ? null : new Text(Base64.decodeBase64(col.substring(idx + 1).getBytes()));
       columns.add(new Pair<Text,Text>(cf, cq));
     }
@@ -256,7 +255,7 @@ public class InputConfigurator extends ConfiguratorBase {
     String newIter;
     try {
       cfg.write(new DataOutputStream(baos));
-      newIter = new String(Base64.encodeBase64(baos.toByteArray()), Charset.forName("UTF-8"));
+      newIter = new String(Base64.encodeBase64(baos.toByteArray()), Constants.UTF8);
       baos.close();
     } catch (IOException e) {
       throw new IllegalArgumentException("unable to serialize IteratorSetting");

http://git-wip-us.apache.org/repos/asf/accumulo/blob/07d1b6ea/core/src/main/java/org/apache/accumulo/core/client/mapreduce/lib/util/OutputConfigurator.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/client/mapreduce/lib/util/OutputConfigurator.java
b/core/src/main/java/org/apache/accumulo/core/client/mapreduce/lib/util/OutputConfigurator.java
index f4c0c0e..3654440 100644
--- a/core/src/main/java/org/apache/accumulo/core/client/mapreduce/lib/util/OutputConfigurator.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/mapreduce/lib/util/OutputConfigurator.java
@@ -21,8 +21,8 @@ import java.io.ByteArrayOutputStream;
 import java.io.DataInputStream;
 import java.io.DataOutputStream;
 import java.io.IOException;
-import java.nio.charset.Charset;
 
+import org.apache.accumulo.core.Constants;
 import org.apache.accumulo.core.client.BatchWriter;
 import org.apache.accumulo.core.client.BatchWriterConfig;
 import org.apache.hadoop.conf.Configuration;
@@ -99,7 +99,7 @@ public class OutputConfigurator extends ConfiguratorBase {
     String serialized;
     try {
       bwConfig.write(new DataOutputStream(baos));
-      serialized = new String(baos.toByteArray(), Charset.forName("UTF-8"));
+      serialized = new String(baos.toByteArray(), Constants.UTF8);
       baos.close();
     } catch (IOException e) {
       throw new IllegalArgumentException("unable to serialize " + BatchWriterConfig.class.getName());
@@ -125,7 +125,7 @@ public class OutputConfigurator extends ConfiguratorBase {
       return bwConfig;
     } else {
       try {
-        ByteArrayInputStream bais = new ByteArrayInputStream(serialized.getBytes(Charset.forName("UTF-8")));
+        ByteArrayInputStream bais = new ByteArrayInputStream(serialized.getBytes(Constants.UTF8));
         bwConfig.readFields(new DataInputStream(bais));
         bais.close();
         return bwConfig;

http://git-wip-us.apache.org/repos/asf/accumulo/blob/07d1b6ea/core/src/main/java/org/apache/accumulo/core/iterators/user/RegExFilter.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/iterators/user/RegExFilter.java b/core/src/main/java/org/apache/accumulo/core/iterators/user/RegExFilter.java
index b110d34..4b35f5e 100644
--- a/core/src/main/java/org/apache/accumulo/core/iterators/user/RegExFilter.java
+++ b/core/src/main/java/org/apache/accumulo/core/iterators/user/RegExFilter.java
@@ -22,6 +22,7 @@ import java.util.Map;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
+import org.apache.accumulo.core.Constants;
 import org.apache.accumulo.core.client.IteratorSetting;
 import org.apache.accumulo.core.data.ByteSequence;
 import org.apache.accumulo.core.data.Key;
@@ -54,7 +55,7 @@ public class RegExFilter extends Filter {
   public static final String ENCODING = "encoding";
   public static final String MATCH_SUBSTRING = "matchSubstring";
   
-  public static final String ENCODING_DEFAULT = "UTF-8";
+  public static final String ENCODING_DEFAULT = Constants.UTF8.name();
   
   private Matcher rowMatcher;
   private Matcher colfMatcher;

http://git-wip-us.apache.org/repos/asf/accumulo/blob/07d1b6ea/core/src/main/java/org/apache/accumulo/core/security/CredentialHelper.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/security/CredentialHelper.java b/core/src/main/java/org/apache/accumulo/core/security/CredentialHelper.java
index 15fc47a..24f72cf 100644
--- a/core/src/main/java/org/apache/accumulo/core/security/CredentialHelper.java
+++ b/core/src/main/java/org/apache/accumulo/core/security/CredentialHelper.java
@@ -21,8 +21,8 @@ import java.io.DataInputStream;
 import java.io.DataOutputStream;
 import java.io.IOException;
 import java.nio.ByteBuffer;
-import java.nio.charset.Charset;
 
+import org.apache.accumulo.core.Constants;
 import org.apache.accumulo.core.client.AccumuloSecurityException;
 import org.apache.accumulo.core.client.impl.thrift.SecurityErrorCode;
 import org.apache.accumulo.core.client.security.tokens.AuthenticationToken;
@@ -43,7 +43,7 @@ public class CredentialHelper {
   }
   
   public static String asBase64String(TCredentials cred) throws AccumuloSecurityException
{
-    return new String(Base64.encodeBase64(asByteArray(cred)), Charset.forName("UTF-8"));
+    return new String(Base64.encodeBase64(asByteArray(cred)), Constants.UTF8);
   }
   
   public static byte[] asByteArray(TCredentials cred) throws AccumuloSecurityException {
@@ -58,7 +58,7 @@ public class CredentialHelper {
   }
   
   public static TCredentials fromBase64String(String string) throws AccumuloSecurityException
{
-    return fromByteArray(Base64.decodeBase64(string.getBytes(Charset.forName("UTF-8"))));
+    return fromByteArray(Base64.decodeBase64(string.getBytes(Constants.UTF8)));
   }
   
   public static TCredentials fromByteArray(byte[] serializedCredential) throws AccumuloSecurityException
{
@@ -90,7 +90,7 @@ public class CredentialHelper {
   }
   
   public static String tokenAsBase64(AuthenticationToken token) throws AccumuloSecurityException
{
-    return new String(Base64.encodeBase64(toBytes(token)), Charset.forName("UTF-8"));
+    return new String(Base64.encodeBase64(toBytes(token)), Constants.UTF8);
   }
   
   private static byte[] toBytes(AuthenticationToken token) throws AccumuloSecurityException
{

http://git-wip-us.apache.org/repos/asf/accumulo/blob/07d1b6ea/core/src/test/java/org/apache/accumulo/core/client/BatchWriterConfigTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/accumulo/core/client/BatchWriterConfigTest.java
b/core/src/test/java/org/apache/accumulo/core/client/BatchWriterConfigTest.java
index 6549421..26f23a5 100644
--- a/core/src/test/java/org/apache/accumulo/core/client/BatchWriterConfigTest.java
+++ b/core/src/test/java/org/apache/accumulo/core/client/BatchWriterConfigTest.java
@@ -24,9 +24,9 @@ import java.io.ByteArrayOutputStream;
 import java.io.DataInputStream;
 import java.io.DataOutputStream;
 import java.io.IOException;
-import java.nio.charset.Charset;
 import java.util.concurrent.TimeUnit;
 
+import org.apache.accumulo.core.Constants;
 import org.junit.Test;
 
 /**
@@ -147,7 +147,7 @@ public class BatchWriterConfigTest {
     bwConfig = new BatchWriterConfig();
     bwConfig.setMaxWriteThreads(42);
     bytes = createBytes(bwConfig);
-    assertEquals("     i#maxWriteThreads=42", new String(bytes, Charset.forName("UTF-8")));
+    assertEquals("     i#maxWriteThreads=42", new String(bytes, Constants.UTF8));
     checkBytes(bwConfig, bytes);
     
     // test human-readable with 2 fields
@@ -155,7 +155,7 @@ 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);
   }
   

http://git-wip-us.apache.org/repos/asf/accumulo/blob/07d1b6ea/core/src/test/java/org/apache/accumulo/core/iterators/user/RegExFilterTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/accumulo/core/iterators/user/RegExFilterTest.java
b/core/src/test/java/org/apache/accumulo/core/iterators/user/RegExFilterTest.java
index 574f96e..6d2b36b 100644
--- a/core/src/test/java/org/apache/accumulo/core/iterators/user/RegExFilterTest.java
+++ b/core/src/test/java/org/apache/accumulo/core/iterators/user/RegExFilterTest.java
@@ -23,6 +23,7 @@ import java.util.TreeMap;
 
 import junit.framework.TestCase;
 
+import org.apache.accumulo.core.Constants;
 import org.apache.accumulo.core.client.IteratorSetting;
 import org.apache.accumulo.core.data.ByteSequence;
 import org.apache.accumulo.core.data.Key;
@@ -67,7 +68,7 @@ public class RegExFilterTest extends TestCase {
     assertTrue(rei.getTopKey().equals(k3));
     rei.next();
     assertFalse(rei.hasTop());
-        
+    
     // -----------------------------------------------------
     // Test substring regex
     is.clearOptions();
@@ -220,7 +221,7 @@ public class RegExFilterTest extends TestCase {
     String multiByteRegex = new String(".*" + "\u6F68" + ".*");
     
     Key k4 = new Key("boo4".getBytes(), "hoo".getBytes(), "20080203".getBytes(), "".getBytes(),
1l);
-    Value inVal = new Value(multiByteText.getBytes("UTF-8"));
+    Value inVal = new Value(multiByteText.getBytes(Constants.UTF8));
     tm.put(k4, inVal);
     
     is.clearOptions();
@@ -231,7 +232,7 @@ public class RegExFilterTest extends TestCase {
     
     assertTrue(rei.hasTop());
     Value outValue = rei.getTopValue();
-    String outVal = new String(outValue.get(), "UTF-8");
+    String outVal = new String(outValue.get(), Constants.UTF8);
     assertTrue(outVal.equals(multiByteText));
     
   }

http://git-wip-us.apache.org/repos/asf/accumulo/blob/07d1b6ea/server/src/main/java/org/apache/accumulo/server/monitor/servlets/BasicServlet.java
----------------------------------------------------------------------
diff --git a/server/src/main/java/org/apache/accumulo/server/monitor/servlets/BasicServlet.java
b/server/src/main/java/org/apache/accumulo/server/monitor/servlets/BasicServlet.java
index 093850b..6e38175 100644
--- a/server/src/main/java/org/apache/accumulo/server/monitor/servlets/BasicServlet.java
+++ b/server/src/main/java/org/apache/accumulo/server/monitor/servlets/BasicServlet.java
@@ -50,6 +50,7 @@ abstract public class BasicServlet extends HttpServlet {
   
   abstract protected String getTitle(HttpServletRequest req);
   
+  @Override
   public void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException,
IOException {
     StringBuilder sb = new StringBuilder();
     try {
@@ -73,6 +74,7 @@ abstract public class BasicServlet extends HttpServlet {
     }
   }
   
+  @Override
   protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException,
IOException {
     doGet(req, resp);
   }
@@ -222,11 +224,10 @@ abstract public class BasicServlet extends HttpServlet {
     sb.append("</body>\n");
     sb.append("</html>\n");
   }
-
+  
   /**
-   * Allow the concrete servlet implementation to provide attributes on the body HTML tag,
-   * such as 'onload', which can be used to call Javascript methods on page load.
-   * By default, nothing is specified.
+   * Allow the concrete servlet implementation to provide attributes on the body HTML tag,
such as 'onload', which can be used to call Javascript methods on
+   * page load. By default, nothing is specified.
    */
   protected String getBodyAttributes() {
     return "";
@@ -234,18 +235,18 @@ abstract public class BasicServlet extends HttpServlet {
   
   public static String encode(String s) {
     try {
-      return URLEncoder.encode(s, "UTF-8");
+      return URLEncoder.encode(s, Constants.UTF8.name());
     } catch (UnsupportedEncodingException e) {
-      Logger.getLogger(BasicServlet.class).fatal("UTF-8 is not a recognized encoding", e);
+      Logger.getLogger(BasicServlet.class).fatal(Constants.UTF8.name() + " is not a recognized
encoding", e);
       throw new RuntimeException(e);
     }
   }
   
   public static String decode(String s) {
     try {
-      return URLDecoder.decode(s, "UTF-8");
+      return URLDecoder.decode(s, Constants.UTF8.name());
     } catch (UnsupportedEncodingException e) {
-      Logger.getLogger(BasicServlet.class).fatal("UTF-8 is not a recognized encoding", e);
+      Logger.getLogger(BasicServlet.class).fatal(Constants.UTF8.name() + " is not a recognized
encoding", e);
       throw new RuntimeException(e);
     }
   }

http://git-wip-us.apache.org/repos/asf/accumulo/blob/07d1b6ea/server/src/main/java/org/apache/accumulo/server/monitor/servlets/XMLServlet.java
----------------------------------------------------------------------
diff --git a/server/src/main/java/org/apache/accumulo/server/monitor/servlets/XMLServlet.java
b/server/src/main/java/org/apache/accumulo/server/monitor/servlets/XMLServlet.java
index d1f2c14..a76723a 100644
--- a/server/src/main/java/org/apache/accumulo/server/monitor/servlets/XMLServlet.java
+++ b/server/src/main/java/org/apache/accumulo/server/monitor/servlets/XMLServlet.java
@@ -23,6 +23,7 @@ import java.util.TreeMap;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
+import org.apache.accumulo.core.Constants;
 import org.apache.accumulo.core.client.Instance;
 import org.apache.accumulo.core.client.impl.Tables;
 import org.apache.accumulo.core.master.thrift.Compacting;
@@ -44,8 +45,8 @@ public class XMLServlet extends BasicServlet {
   
   @Override
   protected void pageStart(HttpServletRequest req, HttpServletResponse resp, StringBuilder
sb) {
-    resp.setContentType("text/xml;charset=UTF-8");
-    sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
+    resp.setContentType("text/xml;charset=" + Constants.UTF8.name());
+    sb.append("<?xml version=\"1.0\" encoding=\"" + Constants.UTF8.name() + "\"?>\n");
     sb.append("<stats>\n");
   }
   

http://git-wip-us.apache.org/repos/asf/accumulo/blob/07d1b6ea/server/src/main/java/org/apache/accumulo/server/util/DumpZookeeper.java
----------------------------------------------------------------------
diff --git a/server/src/main/java/org/apache/accumulo/server/util/DumpZookeeper.java b/server/src/main/java/org/apache/accumulo/server/util/DumpZookeeper.java
index d1858a1..c688869 100644
--- a/server/src/main/java/org/apache/accumulo/server/util/DumpZookeeper.java
+++ b/server/src/main/java/org/apache/accumulo/server/util/DumpZookeeper.java
@@ -19,6 +19,7 @@ package org.apache.accumulo.server.util;
 import java.io.PrintStream;
 import java.io.UnsupportedEncodingException;
 
+import org.apache.accumulo.core.Constants;
 import org.apache.accumulo.core.cli.Help;
 import org.apache.accumulo.fate.zookeeper.IZooReaderWriter;
 import org.apache.accumulo.server.zookeeper.ZooReaderWriter;
@@ -47,13 +48,10 @@ public class DumpZookeeper {
   }
   
   static class Opts extends Help {
-    @Parameter(names="--root", description="the root of the znode tree to dump")
+    @Parameter(names = "--root", description = "the root of the znode tree to dump")
     String root = "/";
   }
   
-  /**
-   * @param args
-   */
   public static void main(String[] args) {
     Opts opts = new Opts();
     opts.parseArgs(DumpZookeeper.class.getName(), args);
@@ -112,9 +110,9 @@ public class DumpZookeeper {
     for (int i = 0; i < data.length; i++) {
       // does this look like simple ascii?
       if (data[i] < ' ' || data[i] > '~')
-        return new Encoded("base64", new String(Base64.encodeBase64(data), "utf8"));
+        return new Encoded("base64", new String(Base64.encodeBase64(data), Constants.UTF8));
     }
-    return new Encoded("utf8", new String(data, "utf8"));
+    return new Encoded(Constants.UTF8.name(), new String(data, Constants.UTF8));
   }
   
   private static void write(PrintStream out, int indent, String fmt, Object... args) {

http://git-wip-us.apache.org/repos/asf/accumulo/blob/07d1b6ea/server/src/main/java/org/apache/accumulo/server/util/RestoreZookeeper.java
----------------------------------------------------------------------
diff --git a/server/src/main/java/org/apache/accumulo/server/util/RestoreZookeeper.java b/server/src/main/java/org/apache/accumulo/server/util/RestoreZookeeper.java
index bad0d8b..6e5607e 100644
--- a/server/src/main/java/org/apache/accumulo/server/util/RestoreZookeeper.java
+++ b/server/src/main/java/org/apache/accumulo/server/util/RestoreZookeeper.java
@@ -23,6 +23,7 @@ import java.util.Stack;
 import javax.xml.parsers.SAXParser;
 import javax.xml.parsers.SAXParserFactory;
 
+import org.apache.accumulo.core.Constants;
 import org.apache.accumulo.core.cli.Help;
 import org.apache.accumulo.fate.zookeeper.IZooReaderWriter;
 import org.apache.accumulo.fate.zookeeper.ZooUtil.NodeExistsPolicy;
@@ -68,7 +69,7 @@ public class RestoreZookeeper {
           cwd.push("");
         else
           cwd.push(root);
-        create(root, "", "utf-8");
+        create(root, "", Constants.UTF8.name());
       }
     }
     
@@ -77,10 +78,11 @@ public class RestoreZookeeper {
       cwd.pop();
     }
     
+    // assume UTF-8 if not "base64"
     private void create(String path, String value, String encoding) {
-      byte[] data = value.getBytes();
+      byte[] data = value.getBytes(Constants.UTF8);
       if ("base64".equals(encoding))
-        data = Base64.decodeBase64(value.getBytes());
+        data = Base64.decodeBase64(data);
       try {
         try {
           zk.putPersistentData(path, data, overwrite ? NodeExistsPolicy.OVERWRITE : NodeExistsPolicy.FAIL);
@@ -96,11 +98,11 @@ public class RestoreZookeeper {
   }
   
   static class Opts extends Help {
-    @Parameter(names={"-z", "--keepers"})
+    @Parameter(names = {"-z", "--keepers"})
     String keepers = "localhost:2181";
-    @Parameter(names="--overwrite")
+    @Parameter(names = "--overwrite")
     boolean overwrite = false;
-    @Parameter(names="--file")
+    @Parameter(names = "--file")
     String file;
   }
   

http://git-wip-us.apache.org/repos/asf/accumulo/blob/07d1b6ea/server/src/main/java/org/apache/accumulo/server/util/SendLogToChainsaw.java
----------------------------------------------------------------------
diff --git a/server/src/main/java/org/apache/accumulo/server/util/SendLogToChainsaw.java b/server/src/main/java/org/apache/accumulo/server/util/SendLogToChainsaw.java
index 5e52ede..d80adc9 100644
--- a/server/src/main/java/org/apache/accumulo/server/util/SendLogToChainsaw.java
+++ b/server/src/main/java/org/apache/accumulo/server/util/SendLogToChainsaw.java
@@ -35,6 +35,7 @@ import java.util.regex.Pattern;
 
 import javax.net.SocketFactory;
 
+import org.apache.accumulo.core.Constants;
 import org.apache.accumulo.core.cli.Help;
 import org.apache.commons.io.filefilter.WildcardFileFilter;
 import org.apache.commons.lang.math.LongRange;
@@ -125,24 +126,24 @@ public class SendLogToChainsaw extends XMLLayout {
         } catch (FileNotFoundException e) {
           System.out.println("Unable to find file: " + log.getAbsolutePath());
           throw e;
-	    }
+        }
         reader = new BufferedReader(fReader);
         
         try {
           line = reader.readLine();
           while (null != line) {
-                out = convertLine(line, threadName);
-                if (null != out) {
-                  if (socket != null && socket.isConnected())
-                    socket.getOutputStream().write(out.getBytes());
-                  else
-                    System.err.println("Unable to send data to transport");
-                }
-              line = reader.readLine();
+            out = convertLine(line, threadName);
+            if (null != out) {
+              if (socket != null && socket.isConnected())
+                socket.getOutputStream().write(out.getBytes());
+              else
+                System.err.println("Unable to send data to transport");
             }
+            line = reader.readLine();
+          }
         } catch (IOException e) {
-            System.out.println("Error processing line: " + line + ". Output was " + out);
-            throw e;
+          System.out.println("Error processing line: " + line + ". Output was " + out);
+          throw e;
         } finally {
           if (reader != null) {
             reader.close();
@@ -181,7 +182,7 @@ public class SendLogToChainsaw extends XMLLayout {
           return null;
       }
       // URL encode the message
-      message = URLEncoder.encode(message, "UTF-8");
+      message = URLEncoder.encode(message, Constants.UTF8.name());
       // Assume that we are processing logs from today.
       // If the date in the line is greater than today, then it must be
       // from the previous month.
@@ -225,46 +226,44 @@ public class SendLogToChainsaw extends XMLLayout {
   
   private static class Opts extends Help {
     
-    @Parameter(names={"-d", "--logDirectory"}, description="ACCUMULO log directory path",
required=true)
+    @Parameter(names = {"-d", "--logDirectory"}, description = "ACCUMULO log directory path",
required = true)
     String dir;
     
-    @Parameter(names={"-f", "--fileFilter"}, description="filter to apply to names of logs")
+    @Parameter(names = {"-f", "--fileFilter"}, description = "filter to apply to names of
logs")
     String filter;
     
-    @Parameter(names={"-h", "--host"}, description="host where chainsaw is running", required=true)
+    @Parameter(names = {"-h", "--host"}, description = "host where chainsaw is running",
required = true)
     String hostname;
     
-    @Parameter(names={"-p", "--port"}, description="port where XMLSocketReceiver is listening",
required=true)
+    @Parameter(names = {"-p", "--port"}, description = "port where XMLSocketReceiver is listening",
required = true)
     int portnum;
     
-    @Parameter(names={"-s", "--start"}, description="start date filter (yyyyMMddHHmmss)",
required=true, converter=DateConverter.class)
+    @Parameter(names = {"-s", "--start"}, description = "start date filter (yyyyMMddHHmmss)",
required = true, converter = DateConverter.class)
     Date startDate;
     
-    @Parameter(names={"-e", "--end"}, description="end date filter (yyyyMMddHHmmss)", required=true,
converter=DateConverter.class)
+    @Parameter(names = {"-e", "--end"}, description = "end date filter (yyyyMMddHHmmss)",
required = true, converter = DateConverter.class)
     Date endDate;
     
-    @Parameter(names={"-l", "--level"}, description="filter log level")
+    @Parameter(names = {"-l", "--level"}, description = "filter log level")
     String level;
     
-    @Parameter(names={"-m", "--messageFilter"}, description="regex filter for log messages")
+    @Parameter(names = {"-m", "--messageFilter"}, description = "regex filter for log messages")
     String regex;
   }
   
-  
-  
-  
   /**
    * 
    * @param args
-   *   0: path to log directory parameter 
-   *   1: filter to apply for logs to include (uses wildcards (i.e. logger* and IS case sensitive)
parameter
-   *   2: chainsaw host parameter 
-   *   3: chainsaw port parameter 
-   *   4: start date filter parameter 
-   *   5: end date filter parameter 
-   *   6: optional regex filter to match on each log4j message parameter 
-   *   7: optional level filter
-   * @throws Exception
+   *          <ol>
+   *          <li>path to log directory</li>
+   *          <li>filter to apply for logs to include (uses wildcards (i.e. logger*
and IS case sensitive)</li>
+   *          <li>chainsaw host</li>
+   *          <li>chainsaw port</li>
+   *          <li>start date filter</li>
+   *          <li>end date filter</li>
+   *          <li>optional regex filter to match on each log4j message</li>
+   *          <li>optional level filter</li>
+   *          </ol>
    */
   public static void main(String[] args) throws Exception {
     Opts opts = new Opts();

http://git-wip-us.apache.org/repos/asf/accumulo/blob/07d1b6ea/test/src/test/java/org/apache/accumulo/test/AuditMessageTest.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/accumulo/test/AuditMessageTest.java b/test/src/test/java/org/apache/accumulo/test/AuditMessageTest.java
index d01414f..f4b601f 100644
--- a/test/src/test/java/org/apache/accumulo/test/AuditMessageTest.java
+++ b/test/src/test/java/org/apache/accumulo/test/AuditMessageTest.java
@@ -27,6 +27,7 @@ import java.util.Collections;
 import java.util.List;
 import java.util.Map;
 
+import org.apache.accumulo.core.Constants;
 import org.apache.accumulo.core.client.AccumuloException;
 import org.apache.accumulo.core.client.AccumuloSecurityException;
 import org.apache.accumulo.core.client.BatchScanner;
@@ -122,7 +123,7 @@ public class AuditMessageTest {
     for (File file : logDir.listFiles()) {
       // We want to grab the files called .out
       if (file.getName().contains(".out") && file.isFile() && file.canRead())
{
-        LineIterator it = FileUtils.lineIterator(file, "UTF-8");
+        LineIterator it = FileUtils.lineIterator(file, Constants.UTF8.name());
         try {
           while (it.hasNext()) {
             String line = it.nextLine();
@@ -181,7 +182,7 @@ public class AuditMessageTest {
     
   }
   
-  @Test(timeout=60*1000)
+  @Test(timeout = 60 * 1000)
   @SuppressWarnings("unchecked")
   public void testTableOperationsAudits() throws AccumuloException, AccumuloSecurityException,
TableExistsException, TableNotFoundException, IOException,
       InterruptedException {
@@ -212,7 +213,7 @@ public class AuditMessageTest {
     
   }
   
-  @Test(timeout=60*1000)
+  @Test(timeout = 60 * 1000)
   public void testUserOperationsAudits() throws AccumuloSecurityException, AccumuloException,
TableExistsException, InterruptedException, IOException {
     
     conn.securityOperations().createLocalUser(AUDIT_USER_1, new PasswordToken(PASSWORD));
@@ -261,7 +262,7 @@ public class AuditMessageTest {
     assertEquals(1, findAuditMessage(auditMessages, "action: dropUser; targetUser: " + AUDIT_USER_2).size());
   }
   
-  @Test(timeout=60*1000)
+  @Test(timeout = 60 * 1000)
   public void testImportExportOperationsAudits() throws AccumuloSecurityException, AccumuloException,
TableExistsException, TableNotFoundException,
       IOException, InterruptedException {
     
@@ -292,7 +293,7 @@ public class AuditMessageTest {
     // We've exported the table metadata to the MiniAccumuloCluster root dir. Grab the .rf
file path to re-import it
     File distCpTxt = new File(exportDir.toString() + "/distcp.txt");
     File importFile = null;
-    LineIterator it = FileUtils.lineIterator(distCpTxt, "UTF-8");
+    LineIterator it = FileUtils.lineIterator(distCpTxt, Constants.UTF8.name());
     
     // Just grab the first rf file, it will do for now.
     String filePrefix = "file:";
@@ -341,7 +342,7 @@ public class AuditMessageTest {
     
   }
   
-  @Test(timeout=60*1000)
+  @Test(timeout = 60 * 1000)
   public void testDataOperationsAudits() throws AccumuloSecurityException, AccumuloException,
TableExistsException, TableNotFoundException, IOException,
       InterruptedException {
     
@@ -394,7 +395,7 @@ public class AuditMessageTest {
     
   }
   
-  @Test(timeout=60*1000)
+  @Test(timeout = 60 * 1000)
   public void testDeniedAudits() throws AccumuloSecurityException, AccumuloException, TableExistsException,
TableNotFoundException, IOException,
       InterruptedException {
     
@@ -461,7 +462,7 @@ public class AuditMessageTest {
             "operation: denied;.*" + String.format(AuditedSecurityOperation.CAN_DELETE_RANGE_AUDIT_TEMPLATE,
OLD_TEST_TABLE_NAME, "myRow", "myRow~")).size());
   }
   
-  @Test(timeout=60*1000)
+  @Test(timeout = 60 * 1000)
   public void testFailedAudits() throws AccumuloSecurityException, AccumuloException, TableExistsException,
TableNotFoundException, IOException,
       InterruptedException {
     


Mime
View raw message