hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From li...@apache.org
Subject svn commit: r1584189 [1/2] - in /hbase/branches/0.89-fb/src: main/java/org/apache/hadoop/hbase/ main/java/org/apache/hadoop/hbase/client/ main/java/org/apache/hadoop/hbase/coprocessor/ main/java/org/apache/hadoop/hbase/mapreduce/ main/java/org/apache/h...
Date Wed, 02 Apr 2014 21:10:54 GMT
Author: liyin
Date: Wed Apr  2 21:10:53 2014
New Revision: 1584189

URL: http://svn.apache.org/r1584189
Log:
[master] Create StringBytes class and use it as main type of table name.

Author: daviddeng

Summary: Create class `StringBytes` which is an immutable instance containing both byte array and String formats.

Test Plan: Run tests

Reviewers: liyintang, manukranthk, gauravm, elliott

Reviewed By: elliott

CC: hbase-eng@, elliott

Differential Revision: https://phabricator.fb.com/D1249373

Added:
    hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/util/StringBytes.java
    hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/util/TestStringBytes.java
Modified:
    hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/HConstants.java
    hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/KeyValue.java
    hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java
    hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/client/HBaseFsck.java
    hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/client/HConnection.java
    hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java
    hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/client/HTable.java
    hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/client/HTableAsync.java
    hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/client/HTableClientScanner.java
    hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/client/MetaCache.java
    hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/client/MetaScanner.java
    hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/client/ScannerCallable.java
    hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/client/ServerCallable.java
    hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/client/TableServers.java
    hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/coprocessor/HTableEndpointClient.java
    hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/mapreduce/LoadIncrementalHFiles.java
    hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/master/HMaster.java
    hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java
    hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/TestZooKeeper.java
    hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/client/TestBatchedUpload.java
    hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide.java
    hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/client/TestHCM.java
    hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/client/TestHTable.java
    hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/client/TestMetaCache.java
    hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/client/TestMetaScanner.java
    hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/regionserver/TestCachingOnCompaction.java

Modified: hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/HConstants.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/HConstants.java?rev=1584189&r1=1584188&r2=1584189&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/HConstants.java (original)
+++ hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/HConstants.java Wed Apr  2 21:10:53 2014
@@ -25,6 +25,7 @@ import org.apache.hadoop.hbase.io.hfile.
 import org.apache.hadoop.hbase.ipc.HRegionInterface;
 import org.apache.hadoop.hbase.regionserver.CompactionManager;
 import org.apache.hadoop.hbase.util.Bytes;
+import org.apache.hadoop.hbase.util.StringBytes;
 import org.apache.hadoop.io.nativeio.NativeIO;
 
 /**
@@ -499,9 +500,15 @@ public final class HConstants {
 
   /** The root table's name.*/
   public static final byte [] ROOT_TABLE_NAME = Bytes.toBytes("-ROOT-");
+  /** The StringBytes instance for ROOT_TABLE_NAME */
+  public static final StringBytes ROOT_TABLE_NAME_STRINGBYTES =
+      new StringBytes(ROOT_TABLE_NAME);
 
   /** The META table's name. */
   public static final byte [] META_TABLE_NAME = Bytes.toBytes(".META.");
+  /** The StringBytes instance for META_TABLE_NAME */
+  public static final StringBytes META_TABLE_NAME_STRINGBYTES =
+      new StringBytes(META_TABLE_NAME);
 
   /** delimiter used between portions of a region name */
   public static final int META_ROW_DELIMITER = ',';
@@ -550,6 +557,12 @@ public final class HConstants {
    */
   public static final byte [] EMPTY_START_ROW = EMPTY_BYTE_ARRAY;
 
+  /**
+   * An empty StringBytes.
+   */
+  public static final StringBytes EMPTY_STRING_BYTES = new StringBytes(
+      EMPTY_BYTE_ARRAY);
+
   public static final ByteBuffer EMPTY_START_ROW_BUF = ByteBuffer.wrap(EMPTY_START_ROW);
 
   /**

Modified: hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/KeyValue.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/KeyValue.java?rev=1584189&r1=1584188&r2=1584189&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/KeyValue.java (original)
+++ hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/KeyValue.java Wed Apr  2 21:10:53 2014
@@ -34,6 +34,7 @@ import org.apache.hadoop.hbase.io.HeapSi
 import org.apache.hadoop.hbase.io.hfile.HFile;
 import org.apache.hadoop.hbase.util.Bytes;
 import org.apache.hadoop.hbase.util.ClassSize;
+import org.apache.hadoop.hbase.util.StringBytes;
 import org.apache.hadoop.io.RawComparator;
 import org.apache.hadoop.io.Writable;
 
@@ -126,11 +127,13 @@ public class KeyValue implements Writabl
    * @param tableName  The table name.
    * @return The comparator.
    */
-  public static KeyComparator getRowComparator(byte [] tableName) {
-    if(Bytes.equals(HTableDescriptor.ROOT_TABLEDESC.getName(),tableName)) {
+  public static KeyComparator getRowComparator(StringBytes tableName) {
+    if (Bytes.equals(HTableDescriptor.ROOT_TABLEDESC.getName(),
+        tableName.getBytes())) {
       return ROOT_COMPARATOR.getRawComparator();
     }
-    if(Bytes.equals(HTableDescriptor.META_TABLEDESC.getName(), tableName)) {
+    if (Bytes.equals(HTableDescriptor.META_TABLEDESC.getName(),
+        tableName.getBytes())) {
       return META_COMPARATOR.getRawComparator();
     }
     return COMPARATOR.getRawComparator();

Modified: hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java?rev=1584189&r1=1584188&r2=1584189&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java (original)
+++ hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java Wed Apr  2 21:10:53 2014
@@ -55,6 +55,7 @@ import org.apache.hadoop.hbase.ipc.HRegi
 import org.apache.hadoop.hbase.util.Bytes;
 import org.apache.hadoop.hbase.util.MetaUtils;
 import org.apache.hadoop.hbase.util.Pair;
+import org.apache.hadoop.hbase.util.StringBytes;
 import org.apache.hadoop.hbase.util.Writables;
 import org.apache.hadoop.io.BooleanWritable;
 import org.apache.hadoop.io.Writable;
@@ -151,7 +152,7 @@ public class HBaseAdmin {
     if (this.master == null) {
       throw new MasterNotRunningException("master has been shut down");
     }
-    return connection.tableExists(tableName);
+    return connection.tableExists(new StringBytes(tableName));
   }
 
   /**
@@ -177,7 +178,7 @@ public class HBaseAdmin {
    */
   public HTableDescriptor getTableDescriptor(final byte [] tableName)
   throws IOException {
-    return this.connection.getHTableDescriptor(tableName);
+    return this.connection.getHTableDescriptor(new StringBytes(tableName));
   }
 
   private long getPauseTime(int tries) {
@@ -299,7 +300,7 @@ public class HBaseAdmin {
           return true;
         }
       };
-      MetaScanner.metaScan(conf, visitor, desc.getName());
+      MetaScanner.metaScan(conf, visitor, new StringBytes(desc.getName()));
       if (actualRegCount.get() != numRegs) {
         if (tries == numRetries - 1) {
           throw new RegionOfflineException("Only " + actualRegCount.get() +
@@ -589,7 +590,7 @@ public class HBaseAdmin {
    * @throws IOException if a remote or network exception occurs
    */
   public boolean isTableEnabled(byte[] tableName) throws IOException {
-    return connection.isTableEnabled(tableName);
+    return connection.isTableEnabled(new StringBytes(tableName));
   }
 
   /**
@@ -598,7 +599,7 @@ public class HBaseAdmin {
    * @throws IOException if a remote or network exception occurs
    */
   public boolean isTableDisabled(byte[] tableName) throws IOException {
-    return connection.isTableDisabled(tableName);
+    return connection.isTableDisabled(new StringBytes(tableName));
   }
 
   /**
@@ -607,7 +608,7 @@ public class HBaseAdmin {
    * @throws IOException if a remote or network exception occurs
    */
   public boolean isTableAvailable(byte[] tableName) throws IOException {
-    return connection.isTableAvailable(tableName);
+    return connection.isTableAvailable(new StringBytes(tableName));
   }
 
   /**
@@ -616,7 +617,7 @@ public class HBaseAdmin {
    * @throws IOException if a remote or network exception occurs
    */
   public boolean isTableAvailable(String tableName) throws IOException {
-    return connection.isTableAvailable(Bytes.toBytes(tableName));
+    return connection.isTableAvailable(new StringBytes(tableName));
   }
 
   /**
@@ -1000,13 +1001,13 @@ public class HBaseAdmin {
   private void compactCF(final byte[] tableName, final byte[] columnFamily, HConstants.Modify op)
     throws IOException {
     // Validate table name and column family.
-    if (!this.connection.tableExists(tableName)) {
-      throw new IllegalArgumentException("HTable " + new String(tableName) +
-          " does not exist");
+    if (!this.connection.tableExists(new StringBytes(tableName))) {
+      throw new IllegalArgumentException("HTable " + new StringBytes(tableName)
+          + " does not exist");
     } else if (!getTableDescriptor(tableName).hasFamily(columnFamily)) {
-      throw new IllegalArgumentException("Column Family " +
-          new String(columnFamily) + " does not exist in " +
-          new String(tableName));
+      throw new IllegalArgumentException("Column Family "
+          + new String(columnFamily) + " does not exist in "
+          + new StringBytes(tableName));
     }
 
     // Get all regions for this table.
@@ -1401,7 +1402,7 @@ public class HBaseAdmin {
 
   private HRegionLocation getFirstMetaServerForTable(final byte [] tableName)
   throws IOException {
-    return connection.locateRegion(HConstants.META_TABLE_NAME,
+    return connection.locateRegion(HConstants.META_TABLE_NAME_STRINGBYTES,
       HRegionInfo.createRegionName(tableName, null, HConstants.NINES, false));
   }
 

Modified: hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/client/HBaseFsck.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/client/HBaseFsck.java?rev=1584189&r1=1584188&r2=1584189&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/client/HBaseFsck.java (original)
+++ hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/client/HBaseFsck.java Wed Apr  2 21:10:53 2014
@@ -339,7 +339,7 @@ public class HBaseFsck {
    */
   boolean recordRootRegion() throws IOException {
     HRegionLocation rootLocation = connection.locateRegion(
-      HConstants.ROOT_TABLE_NAME, HConstants.EMPTY_START_ROW);
+      HConstants.ROOT_TABLE_NAME_STRINGBYTES, HConstants.EMPTY_START_ROW);
 
     // Check if Root region is valid and existing
     if (rootLocation == null || rootLocation.getRegionInfo() == null ||
@@ -910,9 +910,8 @@ public class HBaseFsck {
     };
 
     // Scan -ROOT- to pick up META regions
-    MetaScanner.metaScan(conf, visitor,
-      HConstants.ROOT_TABLE_NAME, HConstants.EMPTY_START_ROW, null,
-      Integer.MAX_VALUE);
+    MetaScanner.metaScan(conf, visitor, HConstants.ROOT_TABLE_NAME_STRINGBYTES,
+        HConstants.EMPTY_STRING_BYTES, null, Integer.MAX_VALUE);
 
     List<HbckInfo> metaRegions = getMetaRegions();
     // If there is no region holding .META., no way to fix

Modified: hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/client/HConnection.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/client/HConnection.java?rev=1584189&r1=1584188&r2=1584189&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/client/HConnection.java (original)
+++ hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/client/HConnection.java Wed Apr  2 21:10:53 2014
@@ -36,6 +36,7 @@ import org.apache.hadoop.hbase.MasterNot
 import org.apache.hadoop.hbase.ipc.HBaseRPCOptions;
 import org.apache.hadoop.hbase.ipc.HMasterInterface;
 import org.apache.hadoop.hbase.ipc.HRegionInterface;
+import org.apache.hadoop.hbase.util.StringBytes;
 import org.apache.hadoop.hbase.zookeeper.ZooKeeperWrapper;
 
 /**
@@ -65,8 +66,8 @@ public interface HConnection extends Clo
    * @return True if table exists already.
    * @throws MasterNotRunningException if the master is not running
    */
-  public boolean tableExists(final byte [] tableName)
-  throws MasterNotRunningException;
+  public boolean tableExists(StringBytes tableName)
+      throws MasterNotRunningException;
 
   /**
    * A table that isTableEnabled == false and isTableDisabled == false
@@ -76,21 +77,21 @@ public interface HConnection extends Clo
    * @return true if the table is enabled, false otherwise
    * @throws IOException if a remote or network exception occurs
    */
-  public boolean isTableEnabled(byte[] tableName) throws IOException;
+  public boolean isTableEnabled(StringBytes tableName) throws IOException;
 
   /**
    * @param tableName table name
    * @return true if the table is disabled, false otherwise
    * @throws IOException if a remote or network exception occurs
    */
-  public boolean isTableDisabled(byte[] tableName) throws IOException;
+  public boolean isTableDisabled(StringBytes tableName) throws IOException;
 
   /**
    * @param tableName table name
    * @return true if all regions of the table are available, false otherwise
    * @throws IOException if a remote or network exception occurs
    */
-  public boolean isTableAvailable(byte[] tableName) throws IOException;
+  public boolean isTableAvailable(StringBytes tableName) throws IOException;
 
   /**
    * List all the userspace tables.  In other words, scan the META table.
@@ -109,7 +110,7 @@ public interface HConnection extends Clo
    * @return table metadata
    * @throws IOException if a remote or network exception occurs
    */
-  public HTableDescriptor getHTableDescriptor(byte[] tableName)
+  public HTableDescriptor getHTableDescriptor(StringBytes tableName)
   throws IOException;
 
   /**
@@ -121,8 +122,7 @@ public interface HConnection extends Clo
    * question
    * @throws IOException if a remote or network exception occurs
    */
-  public HRegionLocation locateRegion(final byte [] tableName,
-      final byte [] row)
+  public HRegionLocation locateRegion(StringBytes tableName, byte[] row)
   throws IOException;
 
   /**
@@ -139,8 +139,7 @@ public interface HConnection extends Clo
    * question
    * @throws IOException if a remote or network exception occurs
    */
-  public HRegionLocation relocateRegion(final byte [] tableName,
-      final byte [] row)
+  public HRegionLocation relocateRegion(StringBytes tableName, byte[] row)
   throws IOException;
 
   /**
@@ -193,7 +192,7 @@ public interface HConnection extends Clo
    * @return Location of row.
    * @throws IOException if a remote or network exception occurs
    */
-  HRegionLocation getRegionLocation(byte [] tableName, byte [] row,
+  HRegionLocation getRegionLocation(StringBytes tableName, byte[] row,
     boolean reload)
   throws IOException;
 
@@ -239,9 +238,8 @@ public interface HConnection extends Clo
    * @throws IOException
    *           if a remote or network exception occurs
    */
-  public Result[] processBatchOfGets(List<Get> actions,
-      final byte[] tableName, final HBaseRPCOptions options)
- throws IOException;
+  public Result[] processBatchOfGets(List<Get> actions, StringBytes tableName,
+      final HBaseRPCOptions options) throws IOException;
 
   /**
    * Process a batch of Puts. Does the retries.
@@ -251,8 +249,8 @@ public interface HConnection extends Clo
    * @return Count of committed Puts.  On fault, < list.size().
    * @throws IOException if a remote or network exception occurs
    */
-  public int processBatchOfRows(ArrayList<Put> list, byte[] tableName, HBaseRPCOptions options)
-  throws IOException;
+  public int processBatchOfRows(ArrayList<Put> list, StringBytes tableName,
+      HBaseRPCOptions options) throws IOException;
 
   /**
    * Process a batch of Deletes. Does the retries.
@@ -262,15 +260,15 @@ public interface HConnection extends Clo
    * @return Count of committed Deletes. On fault, < list.size().
    * @throws IOException if a remote or network exception occurs
    */
-  public int processBatchOfDeletes(List<Delete> list, byte[] tableName,
-      final HBaseRPCOptions options)
-  throws IOException;
+  public int processBatchOfDeletes(List<Delete> list, StringBytes tableName,
+      final HBaseRPCOptions options) throws IOException;
 
-  public void processBatchOfPuts(List<Put> list, final byte[] tableName, HBaseRPCOptions options)
+  public void processBatchOfPuts(List<Put> list, StringBytes tableName,
+      HBaseRPCOptions options)
   throws IOException;
 
   public int processBatchOfRowMutations(final List<RowMutations> list,
-      final byte[] tableName, final HBaseRPCOptions options) throws IOException;
+      StringBytes tableName, final HBaseRPCOptions options) throws IOException;
 
   /**
    * Process a mixed batch of Get actions. All actions for a
@@ -287,7 +285,7 @@ public interface HConnection extends Clo
    * @throws IOException,InterruptedException if there are problems talking to META.
    *  Or, operations were not successfully completed.
    */
-  public void processBatchedGets(List<Get> actions, final byte[] tableName,
+  public void processBatchedGets(List<Get> actions, StringBytes tableName,
       ExecutorService pool, Result[] results, HBaseRPCOptions options)
       throws IOException, InterruptedException;
 
@@ -304,9 +302,9 @@ public interface HConnection extends Clo
    * @throws IOException,InterruptedException if there are problems talking to
    * META. Or, operations were not successfully completed.
    */
-  public void processBatchedMutations(List<Mutation> actions, final byte[] tableName,
-      ExecutorService pool, List<Mutation> failures, HBaseRPCOptions options)
-      throws IOException, InterruptedException;
+  public void processBatchedMutations(List<Mutation> actions,
+      StringBytes tableName, ExecutorService pool, List<Mutation> failures,
+      HBaseRPCOptions options) throws IOException, InterruptedException;
 
 
   /**
@@ -324,7 +322,7 @@ public interface HConnection extends Clo
    * @throws IOException
    */
   public List<Put> processListOfMultiPut(List<MultiPut> mputs,
-      final byte[] tableName, HBaseRPCOptions options,
+      StringBytes tableName, HBaseRPCOptions options,
       Map<String, HRegionFailureInfo> failureInfo) throws IOException;
 
   /**
@@ -333,7 +331,7 @@ public interface HConnection extends Clo
    * @param row
    * @param oldLoc
    */
-  public void deleteCachedLocation(final byte [] tableName, final byte [] row,
+  public void deleteCachedLocation(StringBytes tableName, final byte[] row,
       HServerAddress oldLoc);
 
   /**
@@ -343,8 +341,7 @@ public interface HConnection extends Clo
    * @param tableName name of table to configure.
    * @param enable Set to true to enable region cache prefetch.
    */
-  public void setRegionCachePrefetch(final byte[] tableName,
-      final boolean enable);
+  public void setRegionCachePrefetch(StringBytes tableName, boolean enable);
 
   /**
    * Check whether region cache prefetch is enabled or not.
@@ -353,14 +350,14 @@ public interface HConnection extends Clo
    * @return true if table's region cache prefetch is enabled. Otherwise
    *         it is disabled.
    */
-  public boolean getRegionCachePrefetch(final byte[] tableName);
+  public boolean getRegionCachePrefetch(StringBytes tableName);
 
   /**
    * Load the region map and warm up the global region cache for the table.
    * @param tableName name of the table to perform region cache warm-up.
    * @param regions a region map.
    */
-  public void prewarmRegionCache(final byte[] tableName,
+  public void prewarmRegionCache(StringBytes tableName,
       final Map<HRegionInfo, HServerAddress> regions);
 
   /**
@@ -369,7 +366,7 @@ public interface HConnection extends Clo
    * disk at the end of the job.
    * @param tableName -- the table for which we should start tracking
    */
-  public void startBatchedLoad(byte[] tableName);
+  public void startBatchedLoad(StringBytes tableName);
 
   /**
    * Ensure that all the updates made to the table, since
@@ -381,7 +378,8 @@ public interface HConnection extends Clo
    * @param tableName -- tableName to flush all puts/deletes for.
    * @param options -- hbase rpc options to use when talking to regionservers
    */
-  public void endBatchedLoad(byte[] tableName, HBaseRPCOptions options) throws IOException;
+  public void endBatchedLoad(StringBytes tableName, HBaseRPCOptions options)
+      throws IOException;
 
   /**
    * Get the context of the last operation. This call will return a copy
@@ -435,6 +433,6 @@ public interface HConnection extends Clo
    * @param forceRefresh Whether to force to refresh the HRegionLocations from META.
    * @return cachedHRegionLocations
    */
-  public Collection<HRegionLocation> getCachedHRegionLocations(final byte [] tableName,
-                                                               boolean forceRefresh);
+  public Collection<HRegionLocation> getCachedHRegionLocations(
+      StringBytes tableName, boolean forceRefresh);
 }

Modified: hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java?rev=1584189&r1=1584188&r2=1584189&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java (original)
+++ hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java Wed Apr  2 21:10:53 2014
@@ -28,6 +28,7 @@ import org.apache.hadoop.conf.Configurat
 import org.apache.hadoop.hbase.HBaseConfiguration;
 import org.apache.hadoop.hbase.ipc.HBaseRPC;
 import org.apache.hadoop.hbase.ipc.thrift.HBaseThriftRPC;
+import org.apache.hadoop.hbase.util.StringBytes;
 import org.apache.hadoop.hbase.zookeeper.ZooKeeperWrapper;
 
 /**
@@ -167,7 +168,7 @@ public class HConnectionManager {
    *
    * @return Number of cached regions for the table.
    */
-  static int getCachedRegionCount(Configuration conf, byte[] tableName) {
+  static int getCachedRegionCount(Configuration conf, StringBytes tableName) {
     TableServers connection = (TableServers) getConnection(conf);
     return connection.metaCache.getNumber(tableName);
   }
@@ -178,7 +179,7 @@ public class HConnectionManager {
    *
    * @return true if the region where the table and row reside is cached.
    */
-  static boolean isRegionCached(Configuration conf, byte[] tableName,
+  static boolean isRegionCached(Configuration conf, StringBytes tableName,
       byte[] row) {
     TableServers connection = (TableServers) getConnection(conf);
     return connection.metaCache.getForRow(tableName, row) != null;

Modified: hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/client/HTable.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/client/HTable.java?rev=1584189&r1=1584188&r2=1584189&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/client/HTable.java (original)
+++ hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/client/HTable.java Wed Apr  2 21:10:53 2014
@@ -57,6 +57,7 @@ import org.apache.hadoop.hbase.ipc.Profi
 import org.apache.hadoop.hbase.util.Bytes;
 import org.apache.hadoop.hbase.util.DaemonThreadFactory;
 import org.apache.hadoop.hbase.util.Pair;
+import org.apache.hadoop.hbase.util.StringBytes;
 import org.apache.hadoop.hbase.util.Writables;
 
 import com.google.common.base.Preconditions;
@@ -73,7 +74,7 @@ import com.google.common.base.Preconditi
  */
 public class HTable implements HTableInterface, IEndpointClient {
   private final HConnection connection;
-  private final byte [] tableName;
+  protected final StringBytes tableName;
   protected final int scannerTimeout;
   private volatile Configuration configuration;
   private final ArrayList<Put> writeBuffer = new ArrayList<Put>();
@@ -136,6 +137,10 @@ public class HTable implements HTableInt
     this(HBaseConfiguration.create(), tableName);
   }
 
+  public HTable(Configuration conf, byte[] tableName) throws IOException {
+    this(conf, new StringBytes(tableName));
+  }
+
   /**
    * Creates an object to access a HBase table.
    *
@@ -145,7 +150,7 @@ public class HTable implements HTableInt
    */
   public HTable(Configuration conf, final String tableName)
   throws IOException {
-    this(conf, Bytes.toBytes(tableName));
+    this(conf, new StringBytes(tableName));
   }
 
 
@@ -156,7 +161,7 @@ public class HTable implements HTableInt
    * @param tableName Name of the table.
    * @throws IOException if a remote or network exception occurs
    */
-  public HTable(Configuration conf, final byte [] tableName)
+  public HTable(Configuration conf, StringBytes tableName)
   throws IOException {
     this.tableName = tableName;
     if (conf == null) {
@@ -170,7 +175,8 @@ public class HTable implements HTableInt
         HConstants.DEFAULT_HBASE_REGIONSERVER_LEASE_PERIOD);
     this.configuration = conf;
 
-    this.getConnectionAndResetOperationContext().locateRegion(tableName, HConstants.EMPTY_START_ROW);
+    this.getConnectionAndResetOperationContext().locateRegion(this.tableName,
+        HConstants.EMPTY_START_ROW);
     this.writeBufferSize = conf.getLong("hbase.client.write.buffer", 2097152);
     this.clearBufferOnFail = true;
     this.autoFlush = true;
@@ -288,7 +294,8 @@ public class HTable implements HTableInt
    */
   public static boolean isTableEnabled(Configuration conf, byte[] tableName)
   throws IOException {
-    return HConnectionManager.getConnection(conf).isTableEnabled(tableName);
+    return HConnectionManager.getConnection(conf).isTableEnabled(
+        new StringBytes(tableName));
   }
 
   /**
@@ -327,7 +334,11 @@ public class HTable implements HTableInt
   }
 
   @Override
-  public byte [] getTableName() {
+  public byte[] getTableName() {
+    return this.tableName.getBytes();
+  }
+
+  public StringBytes getTableNameStringBytes() {
     return this.tableName;
   }
 
@@ -585,7 +596,8 @@ public class HTable implements HTableInt
    * to region cache.
    */
   public void prewarmRegionCache(Map<HRegionInfo, HServerAddress> regionMap) {
-    this.connection.prewarmRegionCache(this.getTableName(), regionMap);
+    this.connection.prewarmRegionCache(this.getTableNameStringBytes(),
+        regionMap);
   }
 
   /**
@@ -1239,7 +1251,7 @@ public class HTable implements HTableInt
   public static void setRegionCachePrefetch(final byte[] tableName,
       boolean enable) {
     HConnectionManager.getConnection(HBaseConfiguration.create()).
-    setRegionCachePrefetch(tableName, enable);
+setRegionCachePrefetch(new StringBytes(tableName), enable);
   }
 
   /**
@@ -1254,20 +1266,20 @@ public class HTable implements HTableInt
   public static void setRegionCachePrefetch(final Configuration conf,
       final byte[] tableName, boolean enable) {
     HConnectionManager.getConnection(conf).setRegionCachePrefetch(
-        tableName, enable);
+        new StringBytes(tableName), enable);
   }
 
   /**
    * Check whether region cache prefetch is enabled or not for the table.
    * @param conf The Configuration object to use.
    * @param tableName name of table to check
-   * @return true if table's region cache prefecth is enabled. Otherwise
+   * @return true if table's region cache prefetch is enabled. Otherwise
    * it is disabled.
    */
   public static boolean getRegionCachePrefetch(final Configuration conf,
       final byte[] tableName) {
     return HConnectionManager.getConnection(conf).getRegionCachePrefetch(
-        tableName);
+        new StringBytes(tableName));
   }
 
   /**
@@ -1278,7 +1290,7 @@ public class HTable implements HTableInt
    */
   public static boolean getRegionCachePrefetch(final byte[] tableName) {
     return HConnectionManager.getConnection(HBaseConfiguration.create()).
-    getRegionCachePrefetch(tableName);
+getRegionCachePrefetch(new StringBytes(tableName));
   }
 
   /**

Modified: hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/client/HTableAsync.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/client/HTableAsync.java?rev=1584189&r1=1584188&r2=1584189&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/client/HTableAsync.java (original)
+++ hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/client/HTableAsync.java Wed Apr  2 21:10:53 2014
@@ -28,10 +28,6 @@ import java.util.concurrent.ScheduledExe
 import java.util.concurrent.ThreadPoolExecutor;
 import java.util.concurrent.TimeUnit;
 
-import com.google.common.util.concurrent.Futures;
-import com.google.common.util.concurrent.ListenableFuture;
-import com.google.common.util.concurrent.ListeningScheduledExecutorService;
-import com.google.common.util.concurrent.MoreExecutors;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.hbase.HConstants;
 import org.apache.hadoop.hbase.ipc.HConnectionParams;
@@ -40,6 +36,11 @@ import org.apache.hadoop.hbase.thrift.Se
 import org.apache.hadoop.hbase.util.Bytes;
 import org.apache.hadoop.hbase.util.DaemonThreadFactory;
 
+import com.google.common.util.concurrent.Futures;
+import com.google.common.util.concurrent.ListenableFuture;
+import com.google.common.util.concurrent.ListeningScheduledExecutorService;
+import com.google.common.util.concurrent.MoreExecutors;
+
 /**
  * Used to communicate with a single HBase table.
  * Provide additional asynchronous APIs as complement of HTableInterface.
@@ -97,8 +98,9 @@ public class HTableAsync extends HTable 
    */
   @Override
   public ListenableFuture<Result> getAsync(final Get get) {
-    ServerCallable<ListenableFuture<Result>> callable = new ServerCallable<ListenableFuture<Result>>(
-        getConnection(), getTableName(), get.getRow(), getOptions()) {
+    ServerCallable<ListenableFuture<Result>> callable =
+        new ServerCallable<ListenableFuture<Result>>(getConnection(),
+            tableName, get.getRow(), getOptions()) {
       @Override
       public ListenableFuture<Result> call() throws Exception {
         return ((HBaseToThriftAdapter)server).getAsync(location.getRegionInfo().getRegionName(), get);
@@ -117,6 +119,7 @@ public class HTableAsync extends HTable 
   @Override
   public ListenableFuture<Result[]> batchGetAsync(final List<Get> list) {
     return executorService.submit(new Callable<Result[]>() {
+      @Override
       public Result[] call() throws IOException {
         return batchGet(list);
       }
@@ -143,7 +146,7 @@ public class HTableAsync extends HTable 
   @Override
   public ListenableFuture<Result> getRowOrBeforeAsync(final byte[] row, final byte[] family) {
     ServerCallable<ListenableFuture<Result>> callable = new ServerCallable<ListenableFuture<Result>>(
-        getConnection(), getTableName(), row, getOptions()) {
+        getConnection(), tableName, row, getOptions()) {
       @Override
       public ListenableFuture<Result> call() throws Exception {
         return ((HBaseToThriftAdapter)server).getClosestRowBeforeAsync(
@@ -163,7 +166,7 @@ public class HTableAsync extends HTable 
   @Override
   public ListenableFuture<Void> deleteAsync(final Delete delete) {
     ServerCallable<ListenableFuture<Void>> callable = new ServerCallable<ListenableFuture<Void>>(
-        getConnection(), getTableName(), delete.getRow(), getOptions()) {
+        getConnection(), tableName, delete.getRow(), getOptions()) {
       @Override
       public ListenableFuture<Void> call() throws Exception {
         return ((HBaseToThriftAdapter)server).deleteAsync(location.getRegionInfo().getRegionName(), delete);
@@ -182,7 +185,7 @@ public class HTableAsync extends HTable 
   @Override
   public ListenableFuture<Void> mutateRowAsync(final RowMutations arm) {
     ServerCallable<ListenableFuture<Void>> callable = new ServerCallable<ListenableFuture<Void>>(
-        getConnection(), getTableName(), arm.getRow(), getOptions()) {
+        getConnection(), tableName, arm.getRow(), getOptions()) {
       @Override
       public ListenableFuture<Void> call() throws Exception {
         return ((HBaseToThriftAdapter)server).mutateRowAsync(location.getRegionInfo().getRegionName(), arm);
@@ -201,6 +204,7 @@ public class HTableAsync extends HTable 
   @Override
   public ListenableFuture<Void> batchMutateAsync(final List<Mutation> mutations) {
     return executorService.submit(new Callable<Void>() {
+      @Override
       public Void call() throws IOException {
         batchMutate(mutations);
         return null;
@@ -214,6 +218,7 @@ public class HTableAsync extends HTable 
   @Override
   public ListenableFuture<Void> flushCommitsAsync() {
     return executorService.submit(new Callable<Void>() {
+      @Override
       public Void call() throws IOException {
         flushCommits();
         return null;
@@ -226,8 +231,9 @@ public class HTableAsync extends HTable 
    */
   @Override
   public ListenableFuture<RowLock> lockRowAsync(final byte[] row) {
-    ServerCallable<ListenableFuture<RowLock>> callable = new ServerCallable<ListenableFuture<RowLock>>(
-        getConnection(), getTableName(), row, getOptions()) {
+    ServerCallable<ListenableFuture<RowLock>> callable =
+        new ServerCallable<ListenableFuture<RowLock>>(getConnection(),
+            tableName, row, getOptions()) {
       @Override
       public ListenableFuture<RowLock> call() throws Exception {
         return ((HBaseToThriftAdapter)server).lockRowAsync(location.getRegionInfo().getRegionName(), row);
@@ -245,8 +251,9 @@ public class HTableAsync extends HTable 
    */
   @Override
   public ListenableFuture<Void> unlockRowAsync(final RowLock rl) {
-    ServerCallable<ListenableFuture<Void>> callable = new ServerCallable<ListenableFuture<Void>>(
-        getConnection(), getTableName(), rl.getRow(), getOptions()) {
+    ServerCallable<ListenableFuture<Void>> callable =
+        new ServerCallable<ListenableFuture<Void>>(getConnection(), tableName,
+            rl.getRow(), getOptions()) {
       @Override
       public ListenableFuture<Void> call() throws Exception {
         return ((HBaseToThriftAdapter)server).unlockRowAsync(

Modified: hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/client/HTableClientScanner.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/client/HTableClientScanner.java?rev=1584189&r1=1584188&r2=1584189&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/client/HTableClientScanner.java (original)
+++ hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/client/HTableClientScanner.java Wed Apr  2 21:10:53 2014
@@ -233,7 +233,8 @@ public class HTableClientScanner impleme
   private ScannerCallable getScannerCallable(byte[] startKey) {
     scan.setStartRow(startKey);
     ScannerCallable s = new ScannerCallable(
-        table.getConnectionAndResetOperationContext(), table.getTableName(),
+        table.getConnectionAndResetOperationContext(),
+        table.getTableNameStringBytes(),
         scan, table.getOptions());
     s.setCaching(caching);
     return s;

Modified: hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/client/MetaCache.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/client/MetaCache.java?rev=1584189&r1=1584188&r2=1584189&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/client/MetaCache.java (original)
+++ hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/client/MetaCache.java Wed Apr  2 21:10:53 2014
@@ -34,6 +34,7 @@ import org.apache.hadoop.hbase.HRegionLo
 import org.apache.hadoop.hbase.HServerAddress;
 import org.apache.hadoop.hbase.KeyValue;
 import org.apache.hadoop.hbase.util.Bytes;
+import org.apache.hadoop.hbase.util.StringBytes;
 
 /**
  * Cache for meta information (HRegionLocation)
@@ -41,7 +42,7 @@ import org.apache.hadoop.hbase.util.Byte
 public class MetaCache {
   static final Log LOG = LogFactory.getLog(MetaCache.class);
 
-  public final Map<Integer, ConcurrentSkipListMap<byte[], HRegionLocation>>
+  public final Map<StringBytes, ConcurrentSkipListMap<byte[], HRegionLocation>>
     tableToCache = new ConcurrentHashMap<>();
 
   // The presence of a server in the map implies it's likely that there is an
@@ -60,19 +61,17 @@ public class MetaCache {
    * @return Map of cached locations for passed <code>tableName</code>. A new
    *         map is created if not found.
    */
-  public NavigableMap<byte[], HRegionLocation> getForTable(
-      final byte[] tableName) {
+  public NavigableMap<byte[], HRegionLocation> getForTable(StringBytes tableName) {
     // find the map of cached locations for this table
-    Integer key = Bytes.mapKey(tableName);
     ConcurrentSkipListMap<byte[], HRegionLocation> result =
-        this.tableToCache.get(key);
+        this.tableToCache.get(tableName);
     if (result == null) {
       synchronized (this.tableToCache) {
-        result = this.tableToCache.get(key);
+        result = this.tableToCache.get(tableName);
         if (result == null) {
           // if tableLocations for this table isn't built yet, make one
           result = new ConcurrentSkipListMap<>(Bytes.BYTES_COMPARATOR);
-          this.tableToCache.put(key, result);
+          this.tableToCache.put(tableName, result);
         }
       }
     }
@@ -90,7 +89,7 @@ public class MetaCache {
    * @param row  a non-null byte array
    * @return Null or region location found in cache.
    */
-  HRegionLocation getForRow(final byte[] tableName, final byte[] row) {
+  HRegionLocation getForRow(StringBytes tableName, final byte[] row) {
     NavigableMap<byte[], HRegionLocation> tableMeta = getForTable(tableName);
 
     // start to examine the cache. we can only do cache actions
@@ -103,7 +102,7 @@ public class MetaCache {
     if (rl != null) {
       if (LOG.isTraceEnabled()) {
         LOG.trace("Cache hit for row <" + Bytes.toStringBinary(row)
-            + "> in tableName " + Bytes.toStringBinary(tableName)
+            + "> in tableName " + tableName
             + ": location server " + rl.getServerAddress()
             + ", location region name "
             + rl.getRegionInfo().getRegionNameAsString());
@@ -140,7 +139,7 @@ public class MetaCache {
    * Deletes a cached meta for the specified table name and row if it is
    * located on the (optionally) specified old location.
    */
-  public void deleteForRow(final byte[] tableName, final byte[] row,
+  public void deleteForRow(StringBytes tableName, final byte[] row,
       HServerAddress oldServer) {
     synchronized (this.tableToCache) {
       Map<byte[], HRegionLocation> tableLocations = getForTable(tableName);
@@ -158,7 +157,7 @@ public class MetaCache {
           tableLocations.remove(rl.getRegionInfo().getStartKey());
           if (LOG.isDebugEnabled()) {
             LOG.debug("Removed " + rl.getRegionInfo().getRegionNameAsString()
-                + " for tableName=" + Bytes.toStringBinary(tableName)
+                + " for tableName=" + tableName
                 + " from cache " + "because of " + Bytes.toStringBinary(row));
           }
         }
@@ -197,7 +196,7 @@ public class MetaCache {
    *
    * FIXME the first parameter seems not necessary.
    */
-  public void add(final byte[] tableName, final HRegionLocation location) {
+  public void add(StringBytes tableName, final HRegionLocation location) {
     byte[] startKey = location.getRegionInfo().getStartKey();
     HRegionLocation oldLocation;
     synchronized (this.tableToCache) {
@@ -230,10 +229,9 @@ public class MetaCache {
    * Returns the number of cached regions for a table. It will only be called
    * from a unit test.
    */
-  int getNumber(final byte[] tableName) {
-    Integer key = Bytes.mapKey(tableName);
+  int getNumber(StringBytes tableName) {
     synchronized (this.tableToCache) {
-      Map<byte[], HRegionLocation> tableLocs = this.tableToCache.get(key);
+      Map<byte[], HRegionLocation> tableLocs = this.tableToCache.get(tableName);
 
       if (tableLocs == null) {
         return 0;

Modified: hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/client/MetaScanner.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/client/MetaScanner.java?rev=1584189&r1=1584188&r2=1584189&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/client/MetaScanner.java (original)
+++ hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/client/MetaScanner.java Wed Apr  2 21:10:53 2014
@@ -28,6 +28,7 @@ import org.apache.hadoop.hbase.HRegionIn
 import org.apache.hadoop.hbase.TableNotFoundException;
 import org.apache.hadoop.hbase.ipc.HBaseRPCOptions;
 import org.apache.hadoop.hbase.util.Bytes;
+import org.apache.hadoop.hbase.util.StringBytes;
 import org.apache.hadoop.hbase.util.Writables;
 
 /**
@@ -51,7 +52,7 @@ public class MetaScanner {
   public static void metaScan(Configuration configuration,
       MetaScannerVisitor visitor)
   throws IOException {
-    metaScan(configuration, visitor, HConstants.EMPTY_START_ROW);
+    metaScan(configuration, visitor, HConstants.EMPTY_STRING_BYTES);
   }
 
   /**
@@ -64,7 +65,7 @@ public class MetaScanner {
    * @throws IOException e
    */
   public static void metaScan(Configuration configuration,
-      MetaScannerVisitor visitor, byte[] tableName)
+      MetaScannerVisitor visitor, StringBytes tableName)
   throws IOException {
     metaScan(configuration, visitor, tableName, null, Integer.MAX_VALUE);
   }
@@ -84,10 +85,11 @@ public class MetaScanner {
    * @throws IOException e
    */
   public static void metaScan(Configuration configuration,
-      MetaScannerVisitor visitor, byte[] tableName, byte[] row,
+      MetaScannerVisitor visitor, StringBytes tableName, byte[] row,
       int rowLimit)
   throws IOException {
-    metaScan(configuration, visitor, HConstants.META_TABLE_NAME, tableName, row, rowLimit);
+    metaScan(configuration, visitor, HConstants.META_TABLE_NAME_STRINGBYTES,
+        tableName, row, rowLimit);
   }
 
   /**
@@ -106,7 +108,7 @@ public class MetaScanner {
    * @throws IOException e
    */
   public static void metaScan(Configuration configuration, MetaScannerVisitor visitor,
-    byte[] metaTableName, byte[] tableName, byte[] row,
+      StringBytes metaTableName, StringBytes tableName, byte[] row,
       int rowLimit)
   throws IOException {
     int rowUpperLimit = rowLimit > 0 ? rowLimit: Integer.MAX_VALUE;
@@ -119,35 +121,37 @@ public class MetaScanner {
       // Scan starting at a particular row in a particular table
       assert tableName != null;
       byte[] searchRow =
-        HRegionInfo.createRegionName(tableName, row, HConstants.NINES,
+          HRegionInfo.createRegionName(tableName.getBytes(), row,
+              HConstants.NINES,
           false);
-      HTable metaTable = new HTable(configuration , metaTableName);
+      HTable metaTable = new HTable(configuration, metaTableName.getString());
       Result startRowResult = metaTable.getRowOrBefore(searchRow,
           HConstants.CATALOG_FAMILY);
       if (startRowResult == null) {
         throw new TableNotFoundException("Cannot find row in .META. for table: "
-                + Bytes.toStringBinary(tableName) + ", row="
+ + tableName + ", row="
                 + Bytes.toStringBinary(searchRow));
       }
       byte[] value = startRowResult.getValue(HConstants.CATALOG_FAMILY,
           HConstants.REGIONINFO_QUALIFIER);
       if (value == null || value.length == 0) {
         throw new IOException("HRegionInfo was null or empty in Meta for "
-            + Bytes.toStringBinary(tableName) + ", row="
+            + tableName + ", row="
             + Bytes.toStringBinary(searchRow));
       }
       HRegionInfo regionInfo = Writables.getHRegionInfo(value);
 
       byte[] rowBefore = regionInfo.getStartKey();
-      startRow = HRegionInfo.createRegionName(tableName, rowBefore,
+      startRow =
+          HRegionInfo.createRegionName(tableName.getBytes(), rowBefore,
           HConstants.ZEROES, false);
-    } else if (tableName == null || tableName.length == 0) {
+    } else if (tableName == null || tableName.isEmpty()) {
       // Full META scan
       startRow = HConstants.EMPTY_START_ROW;
     } else {
       // Scan META for an entire table
-      startRow = HRegionInfo.createRegionName(
-          tableName, HConstants.EMPTY_START_ROW, HConstants.ZEROES, false);
+      startRow = HRegionInfo.createRegionName(tableName.getBytes(),
+          HConstants.EMPTY_START_ROW, HConstants.ZEROES, false);
     }
 
     // Scan over each meta region

Modified: hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/client/ScannerCallable.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/client/ScannerCallable.java?rev=1584189&r1=1584188&r2=1584189&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/client/ScannerCallable.java (original)
+++ hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/client/ScannerCallable.java Wed Apr  2 21:10:53 2014
@@ -31,6 +31,7 @@ import org.apache.hadoop.hbase.NotServin
 import org.apache.hadoop.hbase.RemoteExceptionHandler;
 import org.apache.hadoop.hbase.ipc.HBaseRPCOptions;
 import org.apache.hadoop.hbase.util.Bytes;
+import org.apache.hadoop.hbase.util.StringBytes;
 import org.apache.hadoop.ipc.RemoteException;
 
 
@@ -52,7 +53,7 @@ public class ScannerCallable extends Ser
    * @param tableName table callable is on
    * @param scan the scan to execute
    */
-  public ScannerCallable (HConnection connection, byte [] tableName,
+  public ScannerCallable(HConnection connection, StringBytes tableName,
       Scan scan, HBaseRPCOptions options) {
     super(connection, tableName, scan.getStartRow(), options);
     this.scan = scan;

Modified: hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/client/ServerCallable.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/client/ServerCallable.java?rev=1584189&r1=1584188&r2=1584189&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/client/ServerCallable.java (original)
+++ hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/client/ServerCallable.java Wed Apr  2 21:10:53 2014
@@ -20,15 +20,16 @@
 
 package org.apache.hadoop.hbase.client;
 
+import java.io.IOException;
+import java.util.concurrent.Callable;
+
 import org.apache.commons.lang.mutable.MutableBoolean;
 import org.apache.hadoop.hbase.HRegionLocation;
 import org.apache.hadoop.hbase.HServerAddress;
 import org.apache.hadoop.hbase.ipc.HBaseRPCOptions;
 import org.apache.hadoop.hbase.ipc.HRegionInterface;
 import org.apache.hadoop.hbase.ipc.thrift.HBaseToThriftAdapter;
-
-import java.io.IOException;
-import java.util.concurrent.Callable;
+import org.apache.hadoop.hbase.util.StringBytes;
 
 /**
  * Abstract class that implements Callable, used by retryable actions.
@@ -36,7 +37,7 @@ import java.util.concurrent.Callable;
  */
 public abstract class ServerCallable<T> implements Callable<T> {
   protected final HConnection connection;
-  protected final byte [] tableName;
+  protected final StringBytes tableName;
   protected final byte [] row;
   protected HRegionLocation location;
   protected HRegionInterface server;
@@ -47,7 +48,8 @@ public abstract class ServerCallable<T> 
    * @param tableName table name callable is on
    * @param row row we are querying
    */
-  public ServerCallable(HConnection connection, byte [] tableName, byte [] row) {
+  public ServerCallable(HConnection connection, StringBytes tableName,
+      byte[] row) {
     this (connection, tableName, row, HBaseRPCOptions.DEFAULT);
   }
 
@@ -58,8 +60,8 @@ public abstract class ServerCallable<T> 
    * @param row row we are querying
    * @param options client options for ipc layer
    */
-  public ServerCallable(HConnection connection, byte [] tableName, byte [] row, 
-      HBaseRPCOptions options) {
+  public ServerCallable(HConnection connection, StringBytes tableName,
+      byte[] row, HBaseRPCOptions options) {
     this.connection = connection;
     this.tableName = tableName;
     this.row = row;
@@ -76,7 +78,7 @@ public abstract class ServerCallable<T> 
   }
 
   /**
-   * Must be called after a successful call to instantiateRegionLocation() 
+   * Must be called after a successful call to instantiateRegionLocation()
    * @throws IOException e
    */
   public void instantiateServer() throws IOException {
@@ -116,7 +118,7 @@ public abstract class ServerCallable<T> 
     return location;
   }
 
-  public byte[] getTableName() {
+  public StringBytes getTableName() {
     return tableName;
   }
 

Modified: hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/client/TableServers.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/client/TableServers.java?rev=1584189&r1=1584188&r2=1584189&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/client/TableServers.java (original)
+++ hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/client/TableServers.java Wed Apr  2 21:10:53 2014
@@ -43,7 +43,6 @@ import java.util.concurrent.Callable;
 import java.util.concurrent.CancellationException;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
-import java.util.concurrent.ConcurrentSkipListSet;
 import java.util.concurrent.CopyOnWriteArraySet;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.ExecutorService;
@@ -81,6 +80,7 @@ import org.apache.hadoop.hbase.regionser
 import org.apache.hadoop.hbase.util.Bytes;
 import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
 import org.apache.hadoop.hbase.util.MetaUtils;
+import org.apache.hadoop.hbase.util.StringBytes;
 import org.apache.hadoop.hbase.util.Threads;
 import org.apache.hadoop.hbase.util.Writables;
 import org.apache.hadoop.hbase.zookeeper.ZooKeeperWrapper;
@@ -226,13 +226,14 @@ public class TableServers implements Ser
     new CopyOnWriteArraySet<Integer>();
   // keep track of servers that have been updated for batchedLoad
   // tablename -> Map
-  Map<String, ConcurrentMap<HRegionInfo, HRegionLocation>> batchedUploadUpdatesMap;
+  final Map<StringBytes, ConcurrentMap<HRegionInfo, HRegionLocation>>
+    batchedUploadUpdatesMap = new ConcurrentHashMap<>();
   private int batchedUploadSoftFlushRetries;
   private long batchedUploadSoftFlushTimeoutMillis;
   private final boolean useThrift;
 
-  private ConcurrentSkipListSet<byte[]> initializedTableSet =
-    new ConcurrentSkipListSet<byte[]>(Bytes.BYTES_COMPARATOR);
+  private Map<StringBytes, StringBytes> initializedTableSet =
+      new ConcurrentHashMap<>();
   /**
    * constructor
    * @param conf Configuration object
@@ -280,8 +281,6 @@ public class TableServers implements Ser
         conf.getInt("hbase.client.batched-upload.softflush.retries", 10);
     this.batchedUploadSoftFlushTimeoutMillis =
         conf.getLong("hbase.client.batched-upload.softflush.timeout.ms", 60000L); // 1 min
-    batchedUploadUpdatesMap  = new ConcurrentHashMap<String,
-        ConcurrentMap<HRegionInfo, HRegionLocation>>();
 
     this.recordClientContext = conf.getBoolean("hbase.client.record.context", false);
 
@@ -380,7 +379,7 @@ public class TableServers implements Ser
   }
 
   @Override
-  public boolean tableExists(final byte[] tableName)
+  public boolean tableExists(StringBytes tableName)
       throws MasterNotRunningException {
     getMaster();
     if (tableName == null) {
@@ -393,7 +392,7 @@ public class TableServers implements Ser
     try {
       HTableDescriptor[] tables = listTables();
       for (HTableDescriptor table : tables) {
-        if (Bytes.equals(table.getName(), tableName)) {
+        if (tableName.equalBytes(table.getName())) {
           exists = true;
         }
       }
@@ -409,14 +408,15 @@ public class TableServers implements Ser
    * @return Truen if passed tablename <code>n</code> is equal to the name of
    * a catalog table.
    */
-  private static boolean isMetaTableName(final byte[] n) {
-    return MetaUtils.isMetaTableName(n);
+  private static boolean isMetaTableName(StringBytes n) {
+    return MetaUtils.isMetaTableName(n.getBytes());
   }
 
   @Override
-  public HRegionLocation getRegionLocation(final byte[] name,
+  public HRegionLocation getRegionLocation(StringBytes tableName,
       final byte[] row, boolean reload) throws IOException {
-    return reload ? relocateRegion(name, row) : locateRegion(name, row);
+    return reload ? relocateRegion(tableName, row) :
+      locateRegion(tableName, row);
   }
 
   @Override
@@ -450,17 +450,18 @@ public class TableServers implements Ser
   }
 
   @Override
-  public boolean isTableEnabled(byte[] tableName) throws IOException {
+  public boolean isTableEnabled(StringBytes tableName) throws IOException {
     return testTableOnlineState(tableName, true);
   }
 
   @Override
-  public boolean isTableDisabled(byte[] tableName) throws IOException {
+  public boolean isTableDisabled(StringBytes tableName) throws IOException {
     return testTableOnlineState(tableName, false);
   }
 
   @Override
-  public boolean isTableAvailable(final byte[] tableName) throws IOException {
+  public boolean isTableAvailable(final StringBytes tableName)
+      throws IOException {
     final AtomicBoolean available = new AtomicBoolean(true);
     MetaScannerVisitor visitor = new MetaScannerVisitor() {
       @Override
@@ -469,7 +470,7 @@ public class TableServers implements Ser
             HConstants.REGIONINFO_QUALIFIER);
         HRegionInfo info = Writables.getHRegionInfoOrNull(value);
         if (info != null) {
-          if (Bytes.equals(tableName, info.getTableDesc().getName())) {
+          if (tableName.equalBytes(info.getTableDesc().getName())) {
             value = row.getValue(HConstants.CATALOG_FAMILY,
                 HConstants.SERVER_QUALIFIER);
             if (value == null) {
@@ -490,18 +491,19 @@ public class TableServers implements Ser
    * any other case If online == false Returns true if all regions are offline
    * Returns false in any other case
    */
-  private boolean testTableOnlineState(byte[] tableName, boolean online)
+  private boolean testTableOnlineState(StringBytes tableName, boolean online)
       throws IOException {
     if (!tableExists(tableName)) {
-      throw new TableNotFoundException(Bytes.toStringBinary(tableName));
+      throw new TableNotFoundException(tableName.toString());
     }
-    if (Bytes.equals(tableName, HConstants.ROOT_TABLE_NAME)) {
+    if (tableName.equals(HConstants.ROOT_TABLE_NAME_STRINGBYTES)) {
       // The root region is always enabled
       return true;
     }
     int rowsScanned = 0;
     int rowsOffline = 0;
-    byte[] startKey = HRegionInfo.createRegionName(tableName, null,
+    byte[] startKey =
+        HRegionInfo.createRegionName(tableName.getBytes(), null,
         HConstants.ZEROES, false);
     byte[] endKey;
     HRegionInfo currentRegion;
@@ -509,9 +511,12 @@ public class TableServers implements Ser
     scan.addColumn(HConstants.CATALOG_FAMILY, HConstants.REGIONINFO_QUALIFIER);
     int rows = this.conf.getInt("hbase.meta.scanner.caching", 100);
     scan.setCaching(rows);
-    ScannerCallable s = new ScannerCallable(this, (Bytes.equals(tableName,
-        HConstants.META_TABLE_NAME) ? HConstants.ROOT_TABLE_NAME
-        : HConstants.META_TABLE_NAME), scan, HBaseRPCOptions.DEFAULT);
+    StringBytes parentTable =
+        tableName.equals(HConstants.META_TABLE_NAME_STRINGBYTES)
+        ? HConstants.ROOT_TABLE_NAME_STRINGBYTES
+        : HConstants.META_TABLE_NAME_STRINGBYTES;
+    ScannerCallable s = new ScannerCallable(this, parentTable, scan,
+        HBaseRPCOptions.DEFAULT);
     try {
       // Open scanner
       getRegionServerWithRetries(s);
@@ -527,7 +532,7 @@ public class TableServers implements Ser
           if (value != null) {
             HRegionInfo info = Writables.getHRegionInfoOrNull(value);
             if (info != null) {
-              if (Bytes.equals(info.getTableDesc().getName(), tableName)) {
+              if (tableName.equalBytes(info.getTableDesc().getName())) {
                 rowsScanned += 1;
                 rowsOffline += info.isOffline() ? 1 : 0;
               }
@@ -576,44 +581,45 @@ public class TableServers implements Ser
   }
 
   @Override
-  public HTableDescriptor getHTableDescriptor(final byte[] tableName)
+  public HTableDescriptor getHTableDescriptor(StringBytes tableName)
       throws IOException {
-    if (Bytes.equals(tableName, HConstants.ROOT_TABLE_NAME)) {
+    if (tableName.equals(HConstants.ROOT_TABLE_NAME_STRINGBYTES)) {
       return new UnmodifyableHTableDescriptor(HTableDescriptor.ROOT_TABLEDESC);
     }
-    if (Bytes.equals(tableName, HConstants.META_TABLE_NAME)) {
+    if (tableName.equals(HConstants.META_TABLE_NAME_STRINGBYTES)) {
       return HTableDescriptor.META_TABLEDESC;
     }
-    TableServers.HTableDescriptorFinder finder = new HTableDescriptorFinder(tableName);
+    TableServers.HTableDescriptorFinder finder =
+        new HTableDescriptorFinder(tableName.getBytes());
     MetaScanner.metaScan(conf, finder, tableName);
     HTableDescriptor result = finder.getResult();
     if (result == null) {
-      throw new TableNotFoundException(Bytes.toStringBinary(tableName));
+      throw new TableNotFoundException(tableName.toString());
     }
     return result;
   }
 
   @Override
-  public HRegionLocation locateRegion(final byte[] tableName, final byte[] row)
+  public HRegionLocation locateRegion(StringBytes tableName, final byte[] row)
       throws IOException {
     return locateRegion(tableName, row, true);
   }
 
   @Override
-  public HRegionLocation relocateRegion(final byte[] tableName,
-      final byte[] row) throws IOException {
+  public HRegionLocation relocateRegion(StringBytes tableName, byte[] row)
+      throws IOException {
     return locateRegion(tableName, row, false);
   }
 
-  private HRegionLocation locateRegion(final byte[] tableName,
+  private HRegionLocation locateRegion(StringBytes tableName,
       final byte[] row, boolean useCache) throws IOException {
-    if (tableName == null || tableName.length == 0) {
+    if (tableName.isEmpty()) {
       throw new IllegalArgumentException(
           "table name cannot be null or zero length");
     }
-    if (Bytes.equals(tableName, HConstants.META_TABLE_NAME)) {
+    if (tableName.equals(HConstants.META_TABLE_NAME_STRINGBYTES)) {
       return locateMetaInRoot(row, useCache, metaRegionLock);
-    } else if (Bytes.equals(tableName, HConstants.ROOT_TABLE_NAME)) {
+    } else if (tableName.equals(HConstants.ROOT_TABLE_NAME_STRINGBYTES)) {
       synchronized (rootRegionLock) {
         // This block guards against two threads trying to find the root
         // region at the same time. One will go do the find while the
@@ -628,12 +634,12 @@ public class TableServers implements Ser
       }
     } else {
       // Region not in the cache - have to go to the meta RS
-      return locateRegionInMeta(HConstants.META_TABLE_NAME, tableName, row,
-          useCache, userRegionLock);
+      return locateRegionInMeta(HConstants.META_TABLE_NAME_STRINGBYTES,
+          tableName, row, useCache, userRegionLock);
     }
   }
 
-  private HRegionLocation prefetchRegionCache(final byte[] tableName,
+  private HRegionLocation prefetchRegionCache(final StringBytes tableName,
       final byte[] row) {
     return prefetchRegionCache(tableName, row, this.prefetchRegionLimit);
   }
@@ -646,7 +652,7 @@ public class TableServers implements Ser
    * @param the row in the .META. table. If it is null, all cache will be
    *        prefetched and null is returned.
    */
-  public HRegionLocation prefetchRegionCache(final byte[] tableName,
+  public HRegionLocation prefetchRegionCache(final StringBytes tableName,
       final byte[] row, int prefetchRegionLimit) {
     // Implement a new visitor for MetaScanner, and use it to walk through
     // the .META.
@@ -663,7 +669,7 @@ public class TableServers implements Ser
             regionInfo = Writables.getHRegionInfo(value);
 
             // possible we got a region of a different table...
-            if (!Bytes.equals(regionInfo.getTableDesc().getName(), tableName)) {
+            if (!tableName.equalBytes(regionInfo.getTableDesc().getName())) {
               return false; // stop scanning
             }
             if (regionInfo.isOffline()) {
@@ -713,8 +719,8 @@ public class TableServers implements Ser
     * Search the meta table (.META.) for the HRegionLocation info that
     * contains the table and row we're seeking.
     */
-  private HRegionLocation locateRegionInMeta(final byte [] parentTable,
-    final byte [] tableName, final byte [] row, boolean useCache,
+  private HRegionLocation locateRegionInMeta(StringBytes parentTable,
+      final StringBytes tableName, final byte[] row, boolean useCache,
     Object regionLockObject)
   throws IOException {
     HRegionLocation location;
@@ -731,7 +737,7 @@ public class TableServers implements Ser
     // build the key of the meta region we should be looking for.
     // the extra 9's on the end are necessary to allow "exact" matches
     // without knowing the precise region names.
-    byte [] metaKey = HRegionInfo.createRegionName(tableName, row,
+    byte[] metaKey = HRegionInfo.createRegionName(tableName.getBytes(), row,
       HConstants.NINES, false);
     for (int tries = 0; true; tries++) {
       if (tries >= params.getNumRetries()) {
@@ -790,8 +796,8 @@ public class TableServers implements Ser
 
             // If the parent table is META, we may want to pre-fetch some
             // region info into the global region cache for this table.
-            if (Bytes.equals(parentTable, HConstants.META_TABLE_NAME) &&
-              (getRegionCachePrefetch(tableName)) )  {
+            if (parentTable.equals(HConstants.META_TABLE_NAME_STRINGBYTES)
+                && getRegionCachePrefetch(tableName)) {
               LOG.debug("Prefetching the client location cache.");
               location = prefetchRegionCache(tableName, row);
               if (location != null) {
@@ -869,22 +875,23 @@ public class TableServers implements Ser
 }
 
 private HRegionLocation getLocationFromRow(Result regionInfoRow,
-                                           byte[] tableName, byte[] parentTable, byte[] row) throws IOException {
+      StringBytes tableName, StringBytes parentTable, byte[] row)
+      throws IOException {
   if (regionInfoRow == null) {
-    throw new TableNotFoundException(Bytes.toStringBinary(tableName));
+      throw new TableNotFoundException(tableName.toString());
   }
   byte[] value = regionInfoRow.getValue(HConstants.CATALOG_FAMILY,
     HConstants.REGIONINFO_QUALIFIER);
   if (value == null || value.length == 0) {
-    throw new IOException("HRegionInfo was null or empty in "
-      + Bytes.toStringBinary(parentTable) + ", row=" + regionInfoRow);
+      throw new IOException("HRegionInfo was null or empty in " + parentTable
+          + ", row=" + regionInfoRow);
   }
   // convert the row result into the HRegionLocation we need!
   HRegionInfo regionInfo = (HRegionInfo) Writables.getWritable(value,
     new HRegionInfo());
   // possible we got a region of a different table...
-  if (!Bytes.equals(regionInfo.getTableDesc().getName(), tableName)) {
-    throw new TableNotFoundException("Table '" + Bytes.toStringBinary(tableName)
+    if (!tableName.equalBytes(regionInfo.getTableDesc().getName())) {
+      throw new TableNotFoundException("Table '" + tableName
       + "' was not found.");
   }
   if (regionInfo.isOffline()) {
@@ -899,10 +906,9 @@ private HRegionLocation getLocationFromR
     serverAddress = Bytes.toString(value);
   }
   if (serverAddress.equals("")) {
-    throw new NoServerForRegionException("No server address listed "
-      + "in " + Bytes.toStringBinary(parentTable) + " for region "
-      + regionInfo.getRegionNameAsString() + " containing row "
-      + Bytes.toStringBinary(row));
+      throw new NoServerForRegionException("No server address listed in "
+          + parentTable + " for region " + regionInfo.getRegionNameAsString()
+          + " containing row " + Bytes.toStringBinary(row));
   }
 
   value = regionInfoRow.getValue(HConstants.CATALOG_FAMILY,
@@ -926,8 +932,8 @@ private HRegionLocation getLocationFromR
 private HRegionLocation locateMetaInRoot(final byte[] row,
                                          boolean useCache, Object regionLockObject) throws IOException {
   HRegionLocation location;
-  final byte[] parentTable = HConstants.ROOT_TABLE_NAME;
-  final byte[] tableName = HConstants.META_TABLE_NAME;
+  final StringBytes parentTable = HConstants.ROOT_TABLE_NAME_STRINGBYTES;
+  final StringBytes tableName = HConstants.META_TABLE_NAME_STRINGBYTES;
   if (useCache) {
       location = metaCache.getForRow(tableName, row);
     if (location != null) {
@@ -940,7 +946,7 @@ private HRegionLocation locateMetaInRoot
   // build the key of the meta region we should be looking for.
   // the extra 9's on the end are necessary to allow "exact" matches
   // without knowing the precise region names.
-  byte[] metaKey = HRegionInfo.createRegionName(tableName, row,
+  byte[] metaKey = HRegionInfo.createRegionName(tableName.getBytes(), row,
     HConstants.NINES, false);
   for (int tries = 0; true; tries++) {
     if (tries >= params.getNumRetries()) {
@@ -1104,17 +1110,17 @@ private HRegionLocation locateMetaInRoot
 
   @Override
   public Collection<HRegionLocation> getCachedHRegionLocations(
-      final byte[] tableName, boolean forceRefresh) {
-    if (forceRefresh || !initializedTableSet.contains(tableName)) {
+      StringBytes tableName, boolean forceRefresh) {
+    if (forceRefresh || !initializedTableSet.containsKey(tableName)) {
       prefetchRegionCache(tableName, null, Integer.MAX_VALUE);
-      initializedTableSet.add(tableName);
+      initializedTableSet.put(tableName, tableName);
     }
 
     return metaCache.getForTable(tableName).values();
   }
 
   @Override
-  public void deleteCachedLocation(final byte[] tableName, final byte[] row,
+  public void deleteCachedLocation(StringBytes tableName, final byte[] row,
       HServerAddress oldServer) {
     metaCache.deleteForRow(tableName, row, oldServer);
   }
@@ -1841,7 +1847,7 @@ private HRegionLocation locateMetaInRoot
   }
 
   private HRegionLocation getRegionLocationForRowWithRetries(
-      byte[] tableName, byte[] rowKey, boolean reload) throws IOException {
+      StringBytes tableName, byte[] rowKey, boolean reload) throws IOException {
     boolean reloadFlag = reload;
     List<Throwable> exceptions = new ArrayList<Throwable>();
     HRegionLocation location = null;
@@ -1866,14 +1872,14 @@ private HRegionLocation locateMetaInRoot
     if (location == null) {
       throw new RetriesExhaustedException(
           " -- nothing found, no 'location' returned," + " tableName="
-              + Bytes.toStringBinary(tableName) + ", reload=" + reload + " --",
+              + tableName + ", reload=" + reload + " --",
           HConstants.EMPTY_BYTE_ARRAY, rowKey, tries, exceptions);
     }
     return location;
   }
 
   private <R extends Row> Map<HServerAddress, MultiAction> splitRequestsByRegionServer(
-      List<R> workingList, final byte[] tableName, boolean isGets)
+      List<R> workingList, StringBytes tableName, boolean isGets)
       throws IOException {
     Map<HServerAddress, MultiAction> actionsByServer = new HashMap<HServerAddress, MultiAction>();
     for (int i = 0; i < workingList.size(); i++) {
@@ -1927,7 +1933,8 @@ private HRegionLocation locateMetaInRoot
    * Collects responses from each of the RegionServers. If there are failures,
    * a list of failed operations is returned.
    */
-  private List<Mutation> collectResponsesForMutateFromAllRS(byte[] tableName,
+  private List<Mutation> collectResponsesForMutateFromAllRS(
+      StringBytes tableName,
       Map<HServerAddress, MultiAction> actionsByServer,
       Map<HServerAddress, Future<MultiResponse>> futures,
       Map<String, HRegionFailureInfo> failureInfo)
@@ -1974,7 +1981,7 @@ private HRegionLocation locateMetaInRoot
    * result array. If there are failures, a list of failed operations is
    * returned.
    */
-  private List<Get> collectResponsesForGetFromAllRS(byte[] tableName,
+  private List<Get> collectResponsesForGetFromAllRS(StringBytes tableName,
       Map<HServerAddress, MultiAction> actionsByServer,
       Map<HServerAddress, Future<MultiResponse>> futures,
       List<Get> orig_list, Result[] results,
@@ -2015,7 +2022,7 @@ private HRegionLocation locateMetaInRoot
   }
 
   private <R extends Mutation> List<Mutation> processMutationResponseFromOneRegionServer(
-      byte[] tableName, HServerAddress address, MultiResponse resp,
+      StringBytes tableName, HServerAddress address, MultiResponse resp,
       Map<byte[], List<R>> map, List<Mutation> newWorkingList,
       boolean isDelete, Map<String, HRegionFailureInfo> failureInfo)
       throws IOException {
@@ -2064,7 +2071,8 @@ private HRegionLocation locateMetaInRoot
     return newWorkingList;
   }
 
-  private List<Get> processGetResponseFromOneRegionServer(byte[] tableName,
+  private List<Get> processGetResponseFromOneRegionServer(
+      StringBytes tableName,
       HServerAddress address, MultiAction request, MultiResponse resp,
       List<Get> orig_list, List<Get> newWorkingList, Result[] results,
       Map<String, HRegionFailureInfo> failureInfo) throws IOException {
@@ -2114,7 +2122,7 @@ private HRegionLocation locateMetaInRoot
 
   @Override
   public void processBatchedMutations(List<Mutation> orig_list,
-      final byte[] tableName, ExecutorService pool, List<Mutation> failures,
+      StringBytes tableName, ExecutorService pool, List<Mutation> failures,
       HBaseRPCOptions options) throws IOException, InterruptedException {
 
     // Keep track of the most recent servers for any given item for better
@@ -2145,7 +2153,7 @@ private HRegionLocation locateMetaInRoot
 
       // step 2: make the requests
       Map<HServerAddress, Future<MultiResponse>> futures = makeServerRequests(
-          actionsByServer, tableName, pool, options);
+          actionsByServer, tableName.getBytes(), pool, options);
 
       // step 3: collect the failures and successes and prepare for retry
       workingList = collectResponsesForMutateFromAllRS(tableName,
@@ -2162,7 +2170,7 @@ private HRegionLocation locateMetaInRoot
   }
 
   @Override
-  public void processBatchedGets(List<Get> orig_list, final byte[] tableName,
+  public void processBatchedGets(List<Get> orig_list, StringBytes tableName,
       ExecutorService pool, Result[] results, HBaseRPCOptions options)
       throws IOException, InterruptedException {
 
@@ -2196,7 +2204,7 @@ private HRegionLocation locateMetaInRoot
 
       // step 2: make the requests
       Map<HServerAddress, Future<MultiResponse>> futures = makeServerRequests(
-          actionsByServer, tableName, pool, options);
+          actionsByServer, tableName.getBytes(), pool, options);
 
       // step 3: collect the failures and successes and prepare for retry
       workingList = collectResponsesForGetFromAllRS(tableName,
@@ -2237,7 +2245,7 @@ private HRegionLocation locateMetaInRoot
      *           other undefined exception
      */
     abstract int doCall(final List<? extends Row> currentList,
-        final byte[] row, final byte[] tableName, T ret) throws IOException,
+        final byte[] row, StringBytes tableName, T ret) throws IOException,
         RuntimeException;
 
     /**
@@ -2251,7 +2259,7 @@ private HRegionLocation locateMetaInRoot
      * @throws IOException
      *           if a remote or network exception occurs
      */
-    int process(final List<? extends Row> list, final byte[] tableName, T ret)
+    int process(final List<? extends Row> list, StringBytes tableName, T ret)
         throws IOException {
       boolean isLastRow;
       boolean retryOnlyOne = false;
@@ -2316,7 +2324,7 @@ private HRegionLocation locateMetaInRoot
      *
      * @throws IOException
      */
-    private byte[] getRegionName(final byte[] t, final byte[] r,
+    private byte[] getRegionName(StringBytes t, final byte[] r,
         final boolean re) throws IOException {
       HRegionLocation location = getRegionLocationForRowWithRetries(t, r, re);
       return location.getRegionInfo().getRegionName();
@@ -2352,15 +2360,14 @@ private HRegionLocation locateMetaInRoot
 
   @Override
   public int processBatchOfRows(final ArrayList<Put> list,
-      final byte[] tableName, final HBaseRPCOptions options)
-      throws IOException {
+      StringBytes tableName, final HBaseRPCOptions options) throws IOException {
     if (list.isEmpty())
       return 0;
     Batch<Object> b = new Batch<Object>(this) {
       @SuppressWarnings("unchecked")
       @Override
       int doCall(final List<? extends Row> currentList, final byte[] row,
-          final byte[] tableName, Object whatevs) throws IOException,
+          StringBytes tableName, Object whatevs) throws IOException,
           RuntimeException {
         final List<Put> puts = (List<Put>) currentList;
         return getRegionServerWithRetries(new ServerCallable<Integer>(this.c,
@@ -2378,7 +2385,7 @@ private HRegionLocation locateMetaInRoot
 
   @Override
   public Result[] processBatchOfGets(final List<Get> list,
-      final byte[] tableName, final HBaseRPCOptions options)
+      StringBytes tableName, final HBaseRPCOptions options)
       throws IOException {
     if (list.isEmpty()) {
       return null;
@@ -2389,7 +2396,7 @@ private HRegionLocation locateMetaInRoot
       @SuppressWarnings("unchecked")
       @Override
       int doCall(final List<? extends Row> currentList, final byte[] row,
-          final byte[] tableName, Result[] res) throws IOException,
+          StringBytes tableName, Result[] res) throws IOException,
           RuntimeException {
         final List<Get> gets = (List<Get>) currentList;
         Result[] tmp = getRegionServerWithRetries(new ServerCallable<Result[]>(
@@ -2412,8 +2419,7 @@ private HRegionLocation locateMetaInRoot
 
   @Override
   public int processBatchOfRowMutations(final List<RowMutations> list,
-      final byte[] tableName, final HBaseRPCOptions options)
-      throws IOException {
+      StringBytes tableName, final HBaseRPCOptions options) throws IOException {
     if (list.isEmpty()) {
       return 0;
     }
@@ -2421,7 +2427,7 @@ private HRegionLocation locateMetaInRoot
       @SuppressWarnings("unchecked")
       @Override
       int doCall(final List<? extends Row> currentList, final byte[] row,
-          final byte[] tableName, Object whatevs) throws IOException,
+          StringBytes tableName, Object whatevs) throws IOException,
           RuntimeException {
         final List<RowMutations> mutations = (List<RowMutations>) currentList;
         getRegionServerWithRetries(new ServerCallable<Void>(this.c,
@@ -2442,8 +2448,7 @@ private HRegionLocation locateMetaInRoot
 
   @Override
   public int processBatchOfDeletes(final List<Delete> list,
-      final byte[] tableName, final HBaseRPCOptions options)
-      throws IOException {
+      StringBytes tableName, final HBaseRPCOptions options) throws IOException {
     if (list.isEmpty()) {
       return 0;
     }
@@ -2451,7 +2456,7 @@ private HRegionLocation locateMetaInRoot
       @SuppressWarnings("unchecked")
       @Override
       int doCall(final List<? extends Row> currentList, final byte[] row,
-          final byte[] tableName, Object whatevs) throws IOException,
+          StringBytes tableName, Object whatevs) throws IOException,
           RuntimeException {
         final List<Delete> deletes = (List<Delete>) currentList;
         return getRegionServerWithRetries(new ServerCallable<Integer>(this.c,
@@ -2493,7 +2498,7 @@ private HRegionLocation locateMetaInRoot
    * @throws IOException
    */
   private List<MultiPut> splitPutsIntoMultiPuts(List<Put> list,
-      final byte[] tableName, HBaseRPCOptions options) throws IOException {
+      StringBytes tableName, HBaseRPCOptions options) throws IOException {
     Map<HServerAddress, MultiPut> regionPuts = new HashMap<HServerAddress, MultiPut>();
 
     for (Put put : list) {
@@ -2517,7 +2522,7 @@ private HRegionLocation locateMetaInRoot
 
   @Override
   public List<Put> processListOfMultiPut(List<MultiPut> multiPuts,
-      final byte[] givenTableName, HBaseRPCOptions options,
+      StringBytes givenTableName, HBaseRPCOptions options,
       Map<String, HRegionFailureInfo> failedRegionsInfo) throws IOException {
     List<Put> failed = null;
 
@@ -2629,8 +2634,9 @@ private HRegionLocation locateMetaInRoot
           // HTableMultiplexer does not specify the tableName, as it is
           // shared across different tables. In that case, let us try
           // and derive the tableName from the regionName.
-          byte[] tableName = (givenTableName != null) ? givenTableName
-              : HRegionInfo.parseRegionName(region)[0];
+          StringBytes tableName =
+              (givenTableName != null) ? givenTableName
+              : new StringBytes(HRegionInfo.parseRegionName(region)[0]);
           deleteCachedLocation(tableName, lst.get(0).getRow(),
               request.address);
 
@@ -2676,7 +2682,7 @@ private HRegionLocation locateMetaInRoot
    *          succeed.
    */
   @Override
-  public void processBatchOfPuts(List<Put> list, final byte[] tableName,
+  public void processBatchOfPuts(List<Put> list, StringBytes tableName,
       HBaseRPCOptions options) throws IOException {
     RegionOverloadedException roe = null;
     long callStartTime;
@@ -2822,23 +2828,24 @@ private HRegionLocation locateMetaInRoot
   }
 
   @Override
-  public void setRegionCachePrefetch(final byte[] tableName,
+  public void setRegionCachePrefetch(StringBytes tableName,
       final boolean enable) {
     if (!enable) {
-      regionCachePrefetchDisabledTables.add(Bytes.mapKey(tableName));
+      regionCachePrefetchDisabledTables.add(Bytes.mapKey(tableName.getBytes()));
     } else {
-      regionCachePrefetchDisabledTables.remove(Bytes.mapKey(tableName));
+      regionCachePrefetchDisabledTables.remove(Bytes.mapKey(tableName
+          .getBytes()));
     }
   }
 
   @Override
-  public boolean getRegionCachePrefetch(final byte[] tableName) {
-    return !regionCachePrefetchDisabledTables.contains(Bytes
-        .mapKey(tableName));
+  public boolean getRegionCachePrefetch(StringBytes tableName) {
+    return !regionCachePrefetchDisabledTables.contains(
+        Bytes.mapKey(tableName.getBytes()));
   }
 
   @Override
-  public void prewarmRegionCache(final byte[] tableName,
+  public void prewarmRegionCache(StringBytes tableName,
       final Map<HRegionInfo, HServerAddress> regions) {
     for (Map.Entry<HRegionInfo, HServerAddress> e : regions.entrySet()) {
       metaCache.add(tableName, new HRegionLocation(e.getKey(), e.getValue()));
@@ -2846,13 +2853,13 @@ private HRegionLocation locateMetaInRoot
   }
 
   @Override
-  public void startBatchedLoad(byte[] tableName) {
-    batchedUploadUpdatesMap.put(Bytes.toString(tableName),
+  public void startBatchedLoad(StringBytes tableName) {
+    batchedUploadUpdatesMap.put(tableName,
         new ConcurrentHashMap<HRegionInfo, HRegionLocation>());
   }
 
   @Override
-  public void endBatchedLoad(byte[] tableName, HBaseRPCOptions options)
+  public void endBatchedLoad(StringBytes tableName, HBaseRPCOptions options)
       throws IOException {
     Map<HRegionInfo, HRegionLocation> regionsUpdated = getRegionsUpdated(tableName);
     try {
@@ -3028,14 +3035,14 @@ private HRegionLocation locateMetaInRoot
     return server.getConfProperty(prop);
   }
 
-  private void trackMutationsToTable(byte[] tableNameBytes,
+  private void trackMutationsToTable(StringBytes tableName,
       HRegionLocation location) throws IOException {
-    String tableName = Bytes.toString(tableNameBytes);
     HRegionInfo regionInfo = location.getRegionInfo();
     HServerAddress serverAddress = location.getServerAddress();
-    HRegionLocation oldLocation = !batchedUploadUpdatesMap
-        .containsKey(tableName) ? null : batchedUploadUpdatesMap.get(
-        tableName).putIfAbsent(regionInfo, location);
+    HRegionLocation oldLocation =
+        !batchedUploadUpdatesMap.containsKey(tableName) ? null
+            : batchedUploadUpdatesMap.get(tableName).putIfAbsent(regionInfo,
+                location);
     if (oldLocation != null && !oldLocation.equals(location)) {
       // check if the old server is alive and update the map with the new
       // location
@@ -3059,8 +3066,9 @@ private HRegionLocation locateMetaInRoot
    * @param tableName
    * @return Map containing regionInfo, and the servers they were on.
    */
-  private Map<HRegionInfo, HRegionLocation> getRegionsUpdated(byte[] tableName) {
-    return batchedUploadUpdatesMap.get(Bytes.toString(tableName));
+  private Map<HRegionInfo, HRegionLocation> getRegionsUpdated(
+      StringBytes tableName) {
+    return batchedUploadUpdatesMap.get(tableName);
   }
 
   /**
@@ -3069,8 +3077,7 @@ private HRegionLocation locateMetaInRoot
    *
    * @param tableName
    */
-  private void clearMutationsToTable(byte[] tableNameBytes) {
-    String tableName = Bytes.toString(tableNameBytes);
+  private void clearMutationsToTable(StringBytes tableName) {
     if (batchedUploadUpdatesMap.containsKey(tableName)) {
       batchedUploadUpdatesMap.get(tableName).clear();
     }

Modified: hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/coprocessor/HTableEndpointClient.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/coprocessor/HTableEndpointClient.java?rev=1584189&r1=1584188&r2=1584189&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/coprocessor/HTableEndpointClient.java (original)
+++ hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/coprocessor/HTableEndpointClient.java Wed Apr  2 21:10:53 2014
@@ -67,8 +67,8 @@ public class HTableEndpointClient implem
           throws Throwable {
         HConnection conn = table.getConnectionAndResetOperationContext();
         return conn.getRegionServerWithRetries(new ServerCallable<byte[]>(
-            table.getConnection(), table.getTableName(), region.getStartKey(),
-            table.getOptions()) {
+            table.getConnection(), table.getTableNameStringBytes(),
+            region.getStartKey(), table.getOptions()) {
           @Override
           public byte[] call() throws IOException {
             // TODO support arguments

Modified: hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/mapreduce/LoadIncrementalHFiles.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/mapreduce/LoadIncrementalHFiles.java?rev=1584189&r1=1584188&r2=1584189&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/mapreduce/LoadIncrementalHFiles.java (original)
+++ hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/mapreduce/LoadIncrementalHFiles.java Wed Apr  2 21:10:53 2014
@@ -36,7 +36,6 @@ import org.apache.hadoop.fs.FileUtil;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.hbase.HBaseConfiguration;
 import org.apache.hadoop.hbase.HColumnDescriptor;
-import org.apache.hadoop.hbase.HConstants;
 import org.apache.hadoop.hbase.HRegionInfo;
 import org.apache.hadoop.hbase.KeyValue;
 import org.apache.hadoop.hbase.TableNotFoundException;
@@ -56,6 +55,7 @@ import org.apache.hadoop.hbase.io.hfile.
 import org.apache.hadoop.hbase.regionserver.StoreFile;
 import org.apache.hadoop.hbase.regionserver.StoreFile.BloomType;
 import org.apache.hadoop.hbase.util.Bytes;
+import org.apache.hadoop.hbase.util.StringBytes;
 import org.apache.hadoop.util.Tool;
 import org.apache.hadoop.util.ToolRunner;
 
@@ -75,13 +75,10 @@ public class LoadIncrementalHFiles exten
   public static String EXIT_ON_FIRST_FAILURE = "hbase.mapreduce.bulkload.failure.exitOnFirst";
   private boolean exitOnFirstFailure;
 
-  private Configuration conf;
-
   public LoadIncrementalHFiles(Configuration conf) {
     super(conf);
     assignSeqIds = conf.getBoolean(ASSIGN_SEQ_IDS, true);
     exitOnFirstFailure = conf.getBoolean(EXIT_ON_FIRST_FAILURE, true);
-    this.conf = conf;
   }
 
   public LoadIncrementalHFiles() {
@@ -163,7 +160,7 @@ public class LoadIncrementalHFiles exten
   {
     HConnection conn = table.getConnectionAndResetOperationContext();
 
-    if (!conn.isTableAvailable(table.getTableName())) {
+    if (!conn.isTableAvailable(table.getTableNameStringBytes())) {
       throw new TableNotFoundException("Table " +
           Bytes.toStringBinary(table.getTableName()) +
           "is not currently available.");
@@ -245,7 +242,7 @@ public class LoadIncrementalHFiles exten
     final Path tmpDir = new Path(item.hfilePath.getParent(), "_tmp");
 
     conn.getRegionServerWithRetries(
-      new ServerCallable<Void>(conn, table, first) {
+      new ServerCallable<Void>(conn, new StringBytes(table), first) {
         @Override
         public Void call() throws Exception {
           LOG.debug("Going to connect to server " + location +



Mime
View raw message