accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From els...@apache.org
Subject [23/26] git commit: Fix start and proxy
Date Sat, 01 Feb 2014 03:23:22 GMT
Fix start and proxy


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

Branch: refs/heads/2292-findbugs
Commit: 8181a399dd3bb6a15f389a331999dd19ee154b76
Parents: c06a72d
Author: Josh Elser <elserj@apache.org>
Authored: Fri Jan 31 17:34:20 2014 -0500
Committer: Josh Elser <elserj@apache.org>
Committed: Fri Jan 31 22:18:53 2014 -0500

----------------------------------------------------------------------
 .../org/apache/accumulo/proxy/ProxyServer.java     | 17 +++++++++--------
 .../org/apache/accumulo/proxy/TestProxyClient.java | 13 +++++++------
 .../main/java/org/apache/accumulo/proxy/Util.java  |  9 +++++----
 .../start/classloader/AccumuloClassLoader.java     |  6 ++----
 .../vfs/FinalCloseDefaultFileSystemManager.java    |  2 +-
 .../vfs/PostDelegatingVFSClassLoader.java          |  2 +-
 .../vfs/providers/HdfsRandomAccessContent.java     |  4 +++-
 7 files changed, 28 insertions(+), 25 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/8181a399/proxy/src/main/java/org/apache/accumulo/proxy/ProxyServer.java
----------------------------------------------------------------------
diff --git a/proxy/src/main/java/org/apache/accumulo/proxy/ProxyServer.java b/proxy/src/main/java/org/apache/accumulo/proxy/ProxyServer.java
index 2a9a055..48e2906 100644
--- a/proxy/src/main/java/org/apache/accumulo/proxy/ProxyServer.java
+++ b/proxy/src/main/java/org/apache/accumulo/proxy/ProxyServer.java
@@ -25,6 +25,7 @@ import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
+import java.util.Map.Entry;
 import java.util.Properties;
 import java.util.Set;
 import java.util.SortedSet;
@@ -394,10 +395,10 @@ public class ProxyServer implements AccumuloProxy.Iface {
     try {
       Map<String,Set<Text>> groups = getConnector(login).tableOperations().getLocalityGroups(tableName);
       Map<String,Set<String>> ret = new HashMap<String,Set<String>>();
-      for (String key : groups.keySet()) {
-        ret.put(key, new HashSet<String>());
-        for (Text val : groups.get(key)) {
-          ret.get(key).add(val.toString());
+      for (Entry<String,Set<Text>> groupEntry : groups.entrySet()) {
+        ret.put(groupEntry.getKey(), new HashSet<String>());
+        for (Text val : groupEntry.getValue()) {
+          ret.get(groupEntry.getKey()).add(val.toString());
         }
       }
       return ret;
@@ -551,10 +552,10 @@ public class ProxyServer implements AccumuloProxy.Iface {
       org.apache.accumulo.proxy.thrift.TableNotFoundException, TException {
     try {
       Map<String,Set<Text>> groups = new HashMap<String,Set<Text>>();
-      for (String key : groupStrings.keySet()) {
-        groups.put(key, new HashSet<Text>());
-        for (String val : groupStrings.get(key)) {
-          groups.get(key).add(new Text(val));
+      for (Entry<String,Set<String>> groupEntry : groupStrings.entrySet()) {
+        groups.put(groupEntry.getKey(), new HashSet<Text>());
+        for (String val : groupEntry.getValue()) {
+          groups.get(groupEntry.getKey()).add(new Text(val));
         }
       }
       getConnector(login).tableOperations().setLocalityGroups(tableName, groups);

http://git-wip-us.apache.org/repos/asf/accumulo/blob/8181a399/proxy/src/main/java/org/apache/accumulo/proxy/TestProxyClient.java
----------------------------------------------------------------------
diff --git a/proxy/src/main/java/org/apache/accumulo/proxy/TestProxyClient.java b/proxy/src/main/java/org/apache/accumulo/proxy/TestProxyClient.java
index 4547684..6d6da7a 100644
--- a/proxy/src/main/java/org/apache/accumulo/proxy/TestProxyClient.java
+++ b/proxy/src/main/java/org/apache/accumulo/proxy/TestProxyClient.java
@@ -24,6 +24,7 @@ import java.util.List;
 import java.util.Map;
 import java.util.TreeMap;
 
+import org.apache.accumulo.core.Constants;
 import org.apache.accumulo.core.client.IteratorSetting;
 import org.apache.accumulo.core.iterators.user.RegExFilter;
 import org.apache.accumulo.proxy.thrift.AccumuloProxy;
@@ -73,7 +74,7 @@ public class TestProxyClient {
     
     System.out.println("Creating user: ");
     if (!tpc.proxy().listLocalUsers(login).contains("testuser")) {
-      tpc.proxy().createLocalUser(login, "testuser", ByteBuffer.wrap("testpass".getBytes()));
+      tpc.proxy().createLocalUser(login, "testuser", ByteBuffer.wrap("testpass".getBytes(Constants.UTF8)));
     }
     System.out.println("UserList: " + tpc.proxy().listLocalUsers(login));
     
@@ -99,9 +100,9 @@ public class TestProxyClient {
     Map<ByteBuffer,List<ColumnUpdate>> mutations = new HashMap<ByteBuffer,List<ColumnUpdate>>();
     for (int i = 0; i < maxInserts; i++) {
       String result = String.format(format, i);
-      ColumnUpdate update = new ColumnUpdate(ByteBuffer.wrap(("cf" + i).getBytes()), ByteBuffer.wrap(("cq"
+ i).getBytes()));
+      ColumnUpdate update = new ColumnUpdate(ByteBuffer.wrap(("cf" + i).getBytes(Constants.UTF8)),
ByteBuffer.wrap(("cq" + i).getBytes(Constants.UTF8)));
       update.setValue(Util.randStringBuffer(10));
-      mutations.put(ByteBuffer.wrap(result.getBytes()), Collections.singletonList(update));
+      mutations.put(ByteBuffer.wrap(result.getBytes(Constants.UTF8)), Collections.singletonList(update));
       
       if (i % 1000 == 0) {
         tpc.proxy().updateAndFlush(login, testTable, mutations);
@@ -125,10 +126,10 @@ public class TestProxyClient {
     for (int i = 0; i < maxInserts; i++) {
       String result = String.format(format, i);
       Key pkey = new Key();
-      pkey.setRow(result.getBytes());
-      ColumnUpdate update = new ColumnUpdate(ByteBuffer.wrap(("cf" + i).getBytes()), ByteBuffer.wrap(("cq"
+ i).getBytes()));
+      pkey.setRow(result.getBytes(Constants.UTF8));
+      ColumnUpdate update = new ColumnUpdate(ByteBuffer.wrap(("cf" + i).getBytes(Constants.UTF8)),
ByteBuffer.wrap(("cq" + i).getBytes(Constants.UTF8)));
       update.setValue(Util.randStringBuffer(10));
-      mutations.put(ByteBuffer.wrap(result.getBytes()), Collections.singletonList(update));
+      mutations.put(ByteBuffer.wrap(result.getBytes(Constants.UTF8)), Collections.singletonList(update));
       tpc.proxy().update(writer, mutations);
       mutations.clear();
     }

http://git-wip-us.apache.org/repos/asf/accumulo/blob/8181a399/proxy/src/main/java/org/apache/accumulo/proxy/Util.java
----------------------------------------------------------------------
diff --git a/proxy/src/main/java/org/apache/accumulo/proxy/Util.java b/proxy/src/main/java/org/apache/accumulo/proxy/Util.java
index a166983..9f9c836 100644
--- a/proxy/src/main/java/org/apache/accumulo/proxy/Util.java
+++ b/proxy/src/main/java/org/apache/accumulo/proxy/Util.java
@@ -16,13 +16,14 @@
  */
 package org.apache.accumulo.proxy;
 
-import org.apache.accumulo.proxy.thrift.IteratorSetting;
-import org.apache.accumulo.proxy.thrift.Key;
-
 import java.math.BigInteger;
 import java.nio.ByteBuffer;
 import java.util.Random;
 
+import org.apache.accumulo.core.Constants;
+import org.apache.accumulo.proxy.thrift.IteratorSetting;
+import org.apache.accumulo.proxy.thrift.Key;
+
 public class Util {
   
   private static Random random = new Random(0);
@@ -32,7 +33,7 @@ public class Util {
   }
   
   public static ByteBuffer randStringBuffer(int numbytes) {
-    return ByteBuffer.wrap(new BigInteger(numbytes * 5, random).toString(32).getBytes());
+    return ByteBuffer.wrap(new BigInteger(numbytes * 5, random).toString(32).getBytes(Constants.UTF8));
   }
   
   public static IteratorSetting iteratorSetting2ProxyIteratorSetting(org.apache.accumulo.core.client.IteratorSetting
is) {

http://git-wip-us.apache.org/repos/asf/accumulo/blob/8181a399/start/src/main/java/org/apache/accumulo/start/classloader/AccumuloClassLoader.java
----------------------------------------------------------------------
diff --git a/start/src/main/java/org/apache/accumulo/start/classloader/AccumuloClassLoader.java
b/start/src/main/java/org/apache/accumulo/start/classloader/AccumuloClassLoader.java
index 478f4bc..51aefa5 100644
--- a/start/src/main/java/org/apache/accumulo/start/classloader/AccumuloClassLoader.java
+++ b/start/src/main/java/org/apache/accumulo/start/classloader/AccumuloClassLoader.java
@@ -235,10 +235,8 @@ public class AccumuloClassLoader {
             if (c == null) {
               try {
                 // try finding this class here instead of parent
-                c = findClass(name);
-              } catch (ClassNotFoundException e) {
-                
-              }
+                findClass(name);
+              } catch (ClassNotFoundException e) {}
             }
           }
           return super.loadClass(name, resolve);

http://git-wip-us.apache.org/repos/asf/accumulo/blob/8181a399/start/src/main/java/org/apache/accumulo/start/classloader/vfs/FinalCloseDefaultFileSystemManager.java
----------------------------------------------------------------------
diff --git a/start/src/main/java/org/apache/accumulo/start/classloader/vfs/FinalCloseDefaultFileSystemManager.java
b/start/src/main/java/org/apache/accumulo/start/classloader/vfs/FinalCloseDefaultFileSystemManager.java
index e4737ec..a6cc19a 100644
--- a/start/src/main/java/org/apache/accumulo/start/classloader/vfs/FinalCloseDefaultFileSystemManager.java
+++ b/start/src/main/java/org/apache/accumulo/start/classloader/vfs/FinalCloseDefaultFileSystemManager.java
@@ -19,7 +19,7 @@ package org.apache.accumulo.start.classloader.vfs;
 import org.apache.commons.vfs2.impl.DefaultFileSystemManager;
 
 public class FinalCloseDefaultFileSystemManager extends DefaultFileSystemManager {
-  public void finalize() {
+  protected void finalize() {
     close();
   }
 }

http://git-wip-us.apache.org/repos/asf/accumulo/blob/8181a399/start/src/main/java/org/apache/accumulo/start/classloader/vfs/PostDelegatingVFSClassLoader.java
----------------------------------------------------------------------
diff --git a/start/src/main/java/org/apache/accumulo/start/classloader/vfs/PostDelegatingVFSClassLoader.java
b/start/src/main/java/org/apache/accumulo/start/classloader/vfs/PostDelegatingVFSClassLoader.java
index 723484c..0a6931f 100644
--- a/start/src/main/java/org/apache/accumulo/start/classloader/vfs/PostDelegatingVFSClassLoader.java
+++ b/start/src/main/java/org/apache/accumulo/start/classloader/vfs/PostDelegatingVFSClassLoader.java
@@ -41,7 +41,7 @@ public class PostDelegatingVFSClassLoader extends VFSClassLoader {
     if (c == null) {
       try {
         // try finding this class here instead of parent
-        c = findClass(name);
+        findClass(name);
       } catch (ClassNotFoundException e) {
 
       }

http://git-wip-us.apache.org/repos/asf/accumulo/blob/8181a399/start/src/main/java/org/apache/accumulo/start/classloader/vfs/providers/HdfsRandomAccessContent.java
----------------------------------------------------------------------
diff --git a/start/src/main/java/org/apache/accumulo/start/classloader/vfs/providers/HdfsRandomAccessContent.java
b/start/src/main/java/org/apache/accumulo/start/classloader/vfs/providers/HdfsRandomAccessContent.java
index 76de726..e3566f0 100644
--- a/start/src/main/java/org/apache/accumulo/start/classloader/vfs/providers/HdfsRandomAccessContent.java
+++ b/start/src/main/java/org/apache/accumulo/start/classloader/vfs/providers/HdfsRandomAccessContent.java
@@ -20,7 +20,9 @@ import java.io.BufferedReader;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
+import java.nio.charset.Charset;
 
+import org.apache.accumulo.core.Constants;
 import org.apache.commons.vfs2.RandomAccessContent;
 import org.apache.hadoop.fs.FSDataInputStream;
 import org.apache.hadoop.fs.FileSystem;
@@ -153,7 +155,7 @@ public class HdfsRandomAccessContent implements RandomAccessContent {
    */
   @Override
   public String readLine() throws IOException {
-    BufferedReader d = new BufferedReader(new InputStreamReader(this.fis));
+    BufferedReader d = new BufferedReader(new InputStreamReader(this.fis, Charset.forName("UTF-8")));
     return d.readLine();
   }
   


Mime
View raw message