hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject svn commit: r1507494 [1/2] - in /hbase/branches/0.95: hbase-client/src/main/java/org/apache/hadoop/hbase/client/ hbase-client/src/main/java/org/apache/hadoop/hbase/exceptions/ hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/ hbase-client/src/tes...
Date Fri, 26 Jul 2013 22:36:53 GMT
Author: stack
Date: Fri Jul 26 22:36:53 2013
New Revision: 1507494

URL: http://svn.apache.org/r1507494
Log:
HBASE-8764 Some MasterMonitorCallable should retry

Added:
    hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/client/RegionServerCallable.java
    hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/client/RetryingCallable.java
    hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/client/RpcRetryingCaller.java
    hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ScannerCaller.java
    hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestHBaseAdminNoCluster.java
Removed:
    hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ServerCallable.java
Modified:
    hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncProcess.java
    hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ClientScanner.java
    hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionUtils.java
    hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java
    hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HConnection.java
    hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java
    hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HConnectionWrapper.java
    hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HTable.java
    hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/client/MultiServerCallable.java
    hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/client/RegionOfflineException.java
    hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/client/RetriesExhaustedException.java
    hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ScannerCallable.java
    hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/exceptions/DoNotRetryIOException.java
    hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/exceptions/HBaseSnapshotException.java
    hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/exceptions/InvalidFamilyOperationException.java
    hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/exceptions/LockTimeoutException.java
    hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/exceptions/RegionException.java
    hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/exceptions/TableExistsException.java
    hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/exceptions/TableNotDisabledException.java
    hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/exceptions/TableNotEnabledException.java
    hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/exceptions/TableNotFoundException.java
    hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/RegionCoprocessorRpcChannel.java
    hbase/branches/0.95/hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestAsyncProcess.java
    hbase/branches/0.95/hbase-common/src/main/java/org/apache/hadoop/hbase/util/Threads.java
    hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/LoadIncrementalHFiles.java
    hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/WALEditsReplaySink.java
    hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/client/HConnectionTestingUtility.java
    hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegionServerBulkLoad.java
    hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestHLog.java

Modified: hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncProcess.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncProcess.java?rev=1507494&r1=1507493&r2=1507494&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncProcess.java (original)
+++ hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncProcess.java Fri Jul 26 22:36:53 2013
@@ -84,7 +84,6 @@ import java.util.concurrent.atomic.Atomi
  */
 class AsyncProcess<CResult> {
   private static final Log LOG = LogFactory.getLog(AsyncProcess.class);
-
   protected final HConnection hConnection;
   protected final byte[] tableName;
   protected final ExecutorService pool;
@@ -406,9 +405,9 @@ class AsyncProcess<CResult> {
         public void run() {
           MultiResponse res;
           try {
-            ServerCallable<MultiResponse> callable = createCallable(loc, multi);
+            MultiServerCallable<Row> callable = createCallable(loc, multi);
             try {
-              res = callable.withoutRetries();
+              res = createCaller(callable).callWithoutRetries(callable);
             } catch (IOException e) {
               LOG.warn("The call to the RS failed, we don't know where we stand. location="
                   + loc, e);
@@ -441,10 +440,19 @@ class AsyncProcess<CResult> {
   /**
    * Create a callable. Isolated to be easily overridden in the tests.
    */
-  protected ServerCallable<MultiResponse> createCallable(
-      final HRegionLocation loc, final MultiAction<Row> multi) {
+  protected MultiServerCallable<Row> createCallable(final HRegionLocation location,
+      final MultiAction<Row> multi) {
+    return new MultiServerCallable<Row>(hConnection, tableName, location, multi);
+  }
 
-    return new MultiServerCallable<Row>(hConnection, tableName, loc, multi);
+  /**
+   * For tests.
+   * @param callable
+   * @return Returns a caller.
+   */
+  protected RpcRetryingCaller<MultiResponse> createCaller(MultiServerCallable<Row> callable) {
+    // callable is unused.
+    return new RpcRetryingCaller<MultiResponse>();
   }
 
   /**

Modified: hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ClientScanner.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ClientScanner.java?rev=1507494&r1=1507493&r2=1507494&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ClientScanner.java (original)
+++ hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ClientScanner.java Fri Jul 26 22:36:53 2013
@@ -66,6 +66,7 @@ public class ClientScanner extends Abstr
     private final byte[] tableName;
     private final int scannerTimeout;
     private boolean scanMetricsPublished = false;
+    private ScannerCaller caller = new ScannerCaller();
 
     /**
      * Create a new ClientScanner for the specified table. An HConnection will be
@@ -179,7 +180,7 @@ public class ClientScanner extends Abstr
       // Close the previous scanner if it's open
       if (this.callable != null) {
         this.callable.setClose();
-        callable.withRetries();
+        this.caller.callWithRetries(callable, getConnection().getConfiguration());
         this.callable = null;
       }
 
@@ -216,7 +217,7 @@ public class ClientScanner extends Abstr
         callable = getScannerCallable(localStartKey);
         // Open a scanner on the region server starting at the
         // beginning of the region
-        callable.withRetries();
+        this.caller.callWithRetries(callable, getConnection().getConfiguration());
         this.currentRegion = callable.getHRegionInfo();
         if (this.scanMetrics != null) {
           this.scanMetrics.countOfRegions.incrementAndGet();
@@ -276,10 +277,10 @@ public class ClientScanner extends Abstr
             // Server returns a null values if scanning is to stop.  Else,
             // returns an empty array if scanning is to go on and we've just
             // exhausted current region.
-            values = callable.withRetries();
+            values = this.caller.callWithRetries(callable, getConnection().getConfiguration());
             if (skipFirst && values != null && values.length == 1) {
               skipFirst = false; // Already skipped, unset it before scanning again
-              values = callable.withRetries();
+              values = this.caller.callWithRetries(callable, getConnection().getConfiguration());
             }
             retryAfterOutOfOrderException  = true;
           } catch (DoNotRetryIOException e) {
@@ -402,7 +403,7 @@ public class ClientScanner extends Abstr
       if (callable != null) {
         callable.setClose();
         try {
-          callable.withRetries();
+          this.caller.callWithRetries(callable, getConnection().getConfiguration());
         } catch (IOException e) {
           // We used to catch this error, interpret, and rethrow. However, we
           // have since decided that it's not nice for a scanner's close to

Modified: hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionUtils.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionUtils.java?rev=1507494&r1=1507493&r2=1507494&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionUtils.java (original)
+++ hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionUtils.java Fri Jul 26 22:36:53 2013
@@ -24,8 +24,7 @@ import org.apache.hadoop.hbase.HConstant
 import java.util.Random;
 
 /**
- * Utility used by client connections such as {@link HConnection} and
- * {@link ServerCallable}
+ * Utility used by client connections.
  */
 @InterfaceAudience.Public
 @InterfaceStability.Evolving

Modified: hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java?rev=1507494&r1=1507493&r2=1507494&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java (original)
+++ hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java Fri Jul 26 22:36:53 2013
@@ -25,7 +25,6 @@ import java.net.SocketTimeoutException;
 import java.util.Arrays;
 import java.util.LinkedList;
 import java.util.List;
-import java.util.concurrent.Callable;
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.concurrent.atomic.AtomicReference;
 import java.util.regex.Pattern;
@@ -84,7 +83,6 @@ import org.apache.hadoop.hbase.protobuf.
 import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.ScanRequest;
 import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.ScanResponse;
 import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.SnapshotDescription;
-import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.TableSchema;
 import org.apache.hadoop.hbase.protobuf.generated.MasterAdminProtos.AddColumnRequest;
 import org.apache.hadoop.hbase.protobuf.generated.MasterAdminProtos.AssignRegionRequest;
 import org.apache.hadoop.hbase.protobuf.generated.MasterAdminProtos.CreateTableRequest;
@@ -522,7 +520,7 @@ public class HBaseAdmin implements Abort
       }
     }
 
-    execute(new MasterAdminCallable<Void>() {
+    executeCallable(new MasterAdminCallable<Void>(getConnection()) {
       @Override
       public Void call() throws ServiceException {
         CreateTableRequest request = RequestConverter.buildCreateTableRequest(desc, splitKeys);
@@ -555,7 +553,7 @@ public class HBaseAdmin implements Abort
     HRegionLocation firstMetaServer = getFirstMetaServerForTable(tableName);
     boolean tableExists = true;
 
-    execute(new MasterAdminCallable<Void>() {
+    executeCallable(new MasterAdminCallable<Void>(getConnection()) {
       @Override
       public Void call() throws ServiceException {
         DeleteTableRequest req = RequestConverter.buildDeleteTableRequest(tableName);
@@ -753,7 +751,7 @@ public class HBaseAdmin implements Abort
   public void enableTableAsync(final byte [] tableName)
   throws IOException {
     HTableDescriptor.isLegalTableName(tableName);
-    execute(new MasterAdminCallable<Void>() {
+    executeCallable(new MasterAdminCallable<Void>(getConnection()) {
       @Override
       public Void call() throws ServiceException {
         LOG.info("Started enable of " + Bytes.toString(tableName));
@@ -824,7 +822,7 @@ public class HBaseAdmin implements Abort
    */
   public void disableTableAsync(final byte [] tableName) throws IOException {
     HTableDescriptor.isLegalTableName(tableName);
-    execute(new MasterAdminCallable<Void>() {
+    executeCallable(new MasterAdminCallable<Void>(getConnection()) {
       @Override
       public Void call() throws ServiceException {
         LOG.info("Started disable of " + Bytes.toString(tableName));
@@ -1031,7 +1029,7 @@ public class HBaseAdmin implements Abort
   public Pair<Integer, Integer> getAlterStatus(final byte[] tableName)
   throws IOException {
     HTableDescriptor.isLegalTableName(tableName);
-    return execute(new MasterMonitorCallable<Pair<Integer, Integer>>() {
+    return executeCallable(new MasterMonitorCallable<Pair<Integer, Integer>>(getConnection()) {
       @Override
       public Pair<Integer, Integer> call() throws ServiceException {
         GetSchemaAlterStatusRequest req = RequestConverter
@@ -1067,7 +1065,7 @@ public class HBaseAdmin implements Abort
    */
   public void addColumn(final byte [] tableName, final HColumnDescriptor column)
   throws IOException {
-    execute(new MasterAdminCallable<Void>() {
+    executeCallable(new MasterAdminCallable<Void>(getConnection()) {
       @Override
       public Void call() throws ServiceException {
         AddColumnRequest req = RequestConverter.buildAddColumnRequest(tableName, column);
@@ -1100,7 +1098,7 @@ public class HBaseAdmin implements Abort
    */
   public void deleteColumn(final byte [] tableName, final byte [] columnName)
   throws IOException {
-    execute(new MasterAdminCallable<Void>() {
+    executeCallable(new MasterAdminCallable<Void>(getConnection()) {
       @Override
       public Void call() throws ServiceException {
         DeleteColumnRequest req = RequestConverter.buildDeleteColumnRequest(tableName, columnName);
@@ -1135,7 +1133,7 @@ public class HBaseAdmin implements Abort
    */
   public void modifyColumn(final byte [] tableName, final HColumnDescriptor descriptor)
   throws IOException {
-    execute(new MasterAdminCallable<Void>() {
+    executeCallable(new MasterAdminCallable<Void>(getConnection()) {
       @Override
       public Void call() throws ServiceException {
         ModifyColumnRequest req = RequestConverter.buildModifyColumnRequest(tableName, descriptor);
@@ -1542,7 +1540,7 @@ public class HBaseAdmin implements Abort
    */
   public void assign(final byte[] regionName) throws MasterNotRunningException,
       ZooKeeperConnectionException, IOException {
-    execute(new MasterAdminCallable<Void>() {
+    executeCallable(new MasterAdminCallable<Void>(getConnection()) {
       @Override
       public Void call() throws ServiceException {
         AssignRegionRequest request = RequestConverter.buildAssignRegionRequest(regionName);
@@ -1568,7 +1566,7 @@ public class HBaseAdmin implements Abort
    */
   public void unassign(final byte [] regionName, final boolean force)
   throws MasterNotRunningException, ZooKeeperConnectionException, IOException {
-    execute(new MasterAdminCallable<Void>() {
+    executeCallable(new MasterAdminCallable<Void>(getConnection()) {
       @Override
       public Void call() throws ServiceException {
         UnassignRegionRequest request =
@@ -1817,7 +1815,7 @@ public class HBaseAdmin implements Abort
         "' doesn't match with the HTD one: " + htd.getNameAsString());
     }
 
-    execute(new MasterAdminCallable<Void>() {
+    executeCallable(new MasterAdminCallable<Void>(getConnection()) {
       @Override
       public Void call() throws ServiceException {
         ModifyTableRequest request = RequestConverter.buildModifyTableRequest(tableName, htd);
@@ -1890,7 +1888,7 @@ public class HBaseAdmin implements Abort
    * @throws IOException if a remote or network exception occurs
    */
   public synchronized void shutdown() throws IOException {
-    execute(new MasterAdminCallable<Void>() {
+    executeCallable(new MasterAdminCallable<Void>(getConnection()) {
       @Override
       public Void call() throws ServiceException {
         masterAdmin.shutdown(null,ShutdownRequest.newBuilder().build());
@@ -1906,7 +1904,7 @@ public class HBaseAdmin implements Abort
    * @throws IOException if a remote or network exception occurs
    */
   public synchronized void stopMaster() throws IOException {
-    execute(new MasterAdminCallable<Void>() {
+    executeCallable(new MasterAdminCallable<Void>(getConnection()) {
       @Override
       public Void call() throws ServiceException {
         masterAdmin.stopMaster(null,StopMasterRequest.newBuilder().build());
@@ -1942,7 +1940,7 @@ public class HBaseAdmin implements Abort
    * @throws IOException if a remote or network exception occurs
    */
   public ClusterStatus getClusterStatus() throws IOException {
-    return execute(new MasterMonitorCallable<ClusterStatus>() {
+    return executeCallable(new MasterMonitorCallable<ClusterStatus>(getConnection()) {
       @Override
       public ClusterStatus call() throws ServiceException {
         GetClusterStatusRequest req = RequestConverter.buildGetClusterStatusRequest();
@@ -2301,7 +2299,7 @@ public class HBaseAdmin implements Abort
         Thread.currentThread().interrupt();
       }
       LOG.debug("Getting current status of snapshot from master...");
-      done = execute(new MasterAdminCallable<IsSnapshotDoneResponse>() {
+      done = executeCallable(new MasterAdminCallable<IsSnapshotDoneResponse>(getConnection()) {
         @Override
         public IsSnapshotDoneResponse call() throws ServiceException {
           return masterAdmin.isSnapshotDone(null, request);
@@ -2330,7 +2328,7 @@ public class HBaseAdmin implements Abort
     final TakeSnapshotRequest request = TakeSnapshotRequest.newBuilder().setSnapshot(snapshot)
         .build();
     // run the snapshot on the master
-    return execute(new MasterAdminCallable<TakeSnapshotResponse>() {
+    return executeCallable(new MasterAdminCallable<TakeSnapshotResponse>(getConnection()) {
       @Override
       public TakeSnapshotResponse call() throws ServiceException {
         return masterAdmin.snapshot(null, request);
@@ -2361,7 +2359,7 @@ public class HBaseAdmin implements Abort
   public boolean isSnapshotFinished(final SnapshotDescription snapshot)
       throws IOException, HBaseSnapshotException, UnknownSnapshotException {
 
-    return execute(new MasterAdminCallable<IsSnapshotDoneResponse>() {
+    return executeCallable(new MasterAdminCallable<IsSnapshotDoneResponse>(getConnection()) {
       @Override
       public IsSnapshotDoneResponse call() throws ServiceException {
         return masterAdmin.isSnapshotDone(null,
@@ -2503,7 +2501,8 @@ public class HBaseAdmin implements Abort
         Thread.currentThread().interrupt();
       }
       LOG.debug("Getting current status of snapshot restore from master...");
-      done = execute(new MasterAdminCallable<IsRestoreSnapshotDoneResponse>() {
+      done = executeCallable(new MasterAdminCallable<IsRestoreSnapshotDoneResponse>(
+          getConnection()) {
         @Override
         public IsRestoreSnapshotDoneResponse call() throws ServiceException {
           return masterAdmin.isRestoreSnapshotDone(null, request);
@@ -2533,7 +2532,7 @@ public class HBaseAdmin implements Abort
         .build();
 
     // run the snapshot restore on the master
-    return execute(new MasterAdminCallable<RestoreSnapshotResponse>() {
+    return executeCallable(new MasterAdminCallable<RestoreSnapshotResponse>(getConnection()) {
       @Override
       public RestoreSnapshotResponse call() throws ServiceException {
         return masterAdmin.restoreSnapshot(null, request);
@@ -2547,7 +2546,7 @@ public class HBaseAdmin implements Abort
    * @throws IOException if a network error occurs
    */
   public List<SnapshotDescription> listSnapshots() throws IOException {
-    return execute(new MasterAdminCallable<List<SnapshotDescription>>() {
+    return executeCallable(new MasterAdminCallable<List<SnapshotDescription>>(getConnection()) {
       @Override
       public List<SnapshotDescription> call() throws ServiceException {
         return masterAdmin.getCompletedSnapshots(null, ListSnapshotRequest.newBuilder().build())
@@ -2603,13 +2602,12 @@ public class HBaseAdmin implements Abort
     // make sure the snapshot is possibly valid
     HTableDescriptor.isLegalTableName(Bytes.toBytes(snapshotName));
     // do the delete
-    execute(new MasterAdminCallable<Void>() {
+    executeCallable(new MasterAdminCallable<Void>(getConnection()) {
       @Override
       public Void call() throws ServiceException {
-        masterAdmin.deleteSnapshot(
-          null,
-          DeleteSnapshotRequest.newBuilder()
-              .setSnapshot(SnapshotDescription.newBuilder().setName(snapshotName).build()).build());
+        masterAdmin.deleteSnapshot(null,
+          DeleteSnapshotRequest.newBuilder().
+            setSnapshot(SnapshotDescription.newBuilder().setName(snapshotName).build()).build());
         return null;
       }
     });
@@ -2633,75 +2631,88 @@ public class HBaseAdmin implements Abort
     List<SnapshotDescription> snapshots = listSnapshots(pattern);
     for (final SnapshotDescription snapshot : snapshots) {
       // do the delete
-      execute(new MasterAdminCallable<Void>() {
+      executeCallable(new MasterAdminCallable<Void>(getConnection()) {
         @Override
         public Void call() throws ServiceException {
-          masterAdmin.deleteSnapshot(
-            null,
+          this.masterAdmin.deleteSnapshot(null,
             DeleteSnapshotRequest.newBuilder().setSnapshot(snapshot).build());
           return null;
         }
       });
     }
   }
-  
+
   /**
    * @see {@link #execute(MasterAdminCallable<V>)}
    */
-  private abstract static class MasterAdminCallable<V> implements Callable<V>{
+  abstract static class MasterAdminCallable<V> extends MasterCallable<V> {
     protected MasterAdminKeepAliveConnection masterAdmin;
+    private final HConnection connection;
+
+    public MasterAdminCallable(final HConnection connection) {
+      this.connection = connection;
+    }
+
+    @Override
+    public void prepare(boolean reload) throws IOException {
+      this.masterAdmin = this.connection.getKeepAliveMasterAdminService();
+    }
+
+    @Override
+    public void close() throws IOException {
+      this.masterAdmin.close();
+    }
   }
 
   /**
    * @see {@link #execute(MasterMonitorCallable<V>)}
    */
-  private abstract static class MasterMonitorCallable<V> implements Callable<V> {
+  abstract static class MasterMonitorCallable<V> extends MasterCallable<V> {
     protected MasterMonitorKeepAliveConnection masterMonitor;
-  }
+    private final HConnection connection;
 
-  /**
-   * This method allows to execute a function requiring a connection to
-   * master without having to manage the connection creation/close.
-   * Create a {@link MasterAdminCallable} to use it.
-   */
-  private <V> V execute(MasterAdminCallable<V> function) throws IOException {
-    function.masterAdmin = connection.getKeepAliveMasterAdminService();
-    try {
-      return executeCallable(function);
-    } finally {
-      function.masterAdmin.close();
+    public MasterMonitorCallable(final HConnection connection) {
+      this.connection = connection;
+    }
+
+    @Override
+    public void prepare(boolean reload) throws IOException {
+      this.masterMonitor = this.connection.getKeepAliveMasterMonitorService();
+    }
+
+    @Override
+    public void close() throws IOException {
+      this.masterMonitor.close();
     }
   }
 
   /**
-   * This method allows to execute a function requiring a connection to
-   * master without having to manage the connection creation/close.
-   * Create a {@link MasterAdminCallable} to use it.
+   * Parent of {@link MasterMonitorCallable} and {@link MasterAdminCallable}.
+   * Has common methods.
+   * @param <V>
    */
-  private <V> V execute(MasterMonitorCallable<V> function) throws IOException {
-    function.masterMonitor = connection.getKeepAliveMasterMonitorService();
-    try {
-      return executeCallable(function);
-    } finally {
-      function.masterMonitor.close();
+  abstract static class MasterCallable<V> implements RetryingCallable<V>, Closeable {
+    @Override
+    public void throwable(Throwable t, boolean retrying) {
+    }
+
+    @Override
+    public String getExceptionMessageAdditionalDetail() {
+      return "";
+    }
+
+    @Override
+    public long sleep(long pause, int tries) {
+      return ConnectionUtils.getPauseTime(pause, tries);
     }
   }
 
-  /**
-   * Helper function called by other execute functions.
-   */
-  private <V> V executeCallable(Callable<V> function) throws IOException {
+  private <V> V executeCallable(MasterCallable<V> callable) throws IOException {
+    RpcRetryingCaller<V> caller = new RpcRetryingCaller<V>();
     try {
-      return function.call();
-    } catch (RemoteException re) {
-      throw re.unwrapRemoteException();
-    } catch (IOException e) {
-      throw e;
-    } catch (ServiceException se) {
-      throw ProtobufUtil.getRemoteException(se);
-    } catch (Exception e) {
-      // This should not happen...
-      throw new IOException("Unexpected exception when calling master", e);
+      return caller.callWithRetries(callable, getConfiguration());
+    } finally {
+      callable.close();
     }
   }
 
@@ -2729,4 +2740,4 @@ public class HBaseAdmin implements Abort
   public CoprocessorRpcChannel coprocessorService() {
     return new MasterCoprocessorRpcChannel(connection);
   }
-}
+}
\ No newline at end of file

Modified: hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HConnection.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HConnection.java?rev=1507494&r1=1507493&r2=1507494&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HConnection.java (original)
+++ hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HConnection.java Fri Jul 26 22:36:53 2013
@@ -60,6 +60,12 @@ import org.apache.hadoop.hbase.protobuf.
 @InterfaceStability.Stable
 public interface HConnection extends Abortable, Closeable {
   /**
+   * Key for configuration in Configuration whose value is the class we implement making a
+   * new HConnection instance.
+   */
+  public static final String HBASE_CLIENT_CONNECTION_IMPL = "hbase.client.connection.impl";
+
+  /**
    * @return Configuration instance being used by this HConnection instance.
    */
   Configuration getConfiguration();
@@ -270,34 +276,6 @@ public interface HConnection extends Abo
   throws IOException;
 
   /**
-   * Pass in a ServerCallable with your particular bit of logic defined and
-   * this method will manage the process of doing retries with timed waits
-   * and refinds of missing regions.
-   *
-   * @param <T> the type of the return value
-   * @param callable callable to run
-   * @return an object of type T
-   * @throws IOException if a remote or network exception occurs
-   * @throws RuntimeException other unspecified error
-   */
-  @Deprecated
-  <T> T getRegionServerWithRetries(ServerCallable<T> callable)
-  throws IOException, RuntimeException;
-
-  /**
-   * Pass in a ServerCallable with your particular bit of logic defined and
-   * this method will pass it to the defined region server.
-   * @param <T> the type of the return value
-   * @param callable callable to run
-   * @return an object of type T
-   * @throws IOException if a remote or network exception occurs
-   * @throws RuntimeException other unspecified error
-   */
-  @Deprecated
-  <T> T getRegionServerWithoutRetries(ServerCallable<T> callable)
-  throws IOException, RuntimeException;
-
-  /**
    * Process a mixed batch of Get, Put and Delete actions. All actions for a
    * RegionServer are forwarded in one RPC call.
    *

Modified: hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java?rev=1507494&r1=1507493&r2=1507494&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java (original)
+++ hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java Fri Jul 26 22:36:53 2013
@@ -1954,18 +1954,6 @@ public class HConnectionManager {
       }
     }
 
-    @Override
-    public <T> T getRegionServerWithRetries(ServerCallable<T> callable)
-    throws IOException, RuntimeException {
-      return callable.withRetries();
-    }
-
-    @Override
-    public <T> T getRegionServerWithoutRetries(ServerCallable<T> callable)
-    throws IOException, RuntimeException {
-      return callable.withoutRetries();
-    }
-
     void updateCachedLocation(HRegionInfo hri, HRegionLocation source,
                               ServerName serverName, long seqNum) {
       HRegionLocation newHrl = new HRegionLocation(hri, serverName, seqNum);

Modified: hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HConnectionWrapper.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HConnectionWrapper.java?rev=1507494&r1=1507493&r2=1507494&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HConnectionWrapper.java (original)
+++ hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HConnectionWrapper.java Fri Jul 26 22:36:53 2013
@@ -223,18 +223,6 @@ public class HConnectionWrapper implemen
   }
 
   @Override
-  public <T> T getRegionServerWithRetries(ServerCallable<T> callable)
-      throws IOException, RuntimeException {
-    return hconnection.getRegionServerWithRetries(callable);
-  }
-
-  @Override
-  public <T> T getRegionServerWithoutRetries(ServerCallable<T> callable)
-      throws IOException, RuntimeException {
-    return hconnection.getRegionServerWithoutRetries(callable);
-  }
-
-  @Override
   public void processBatch(List<? extends Row> actions, byte[] tableName,
       ExecutorService pool, Object[] results) throws IOException,
       InterruptedException {

Modified: hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HTable.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HTable.java?rev=1507494&r1=1507493&r2=1507494&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HTable.java (original)
+++ hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HTable.java Fri Jul 26 22:36:53 2013
@@ -592,12 +592,15 @@ public class HTable implements HTableInt
    @Override
    public Result getRowOrBefore(final byte[] row, final byte[] family)
    throws IOException {
-     return new ServerCallable<Result>(connection, tableName, row, operationTimeout) {
+     RegionServerCallable<Result> callable = new RegionServerCallable<Result>(this.connection,
+         tableName, row) {
        public Result call() throws IOException {
-         return ProtobufUtil.getRowOrBefore(stub,
-           location.getRegionInfo().getRegionName(), row, family);
+         return ProtobufUtil.getRowOrBefore(getStub(),
+           getLocation().getRegionInfo().getRegionName(), row, family);
        }
-     }.withRetries();
+     };
+     return new RpcRetryingCaller<Result>().
+       callWithRetries(callable, getConfiguration(), this.operationTimeout);
    }
 
    /**
@@ -637,12 +640,14 @@ public class HTable implements HTableInt
    */
   @Override
   public Result get(final Get get) throws IOException {
-    return new ServerCallable<Result>(connection, tableName, get.getRow(), operationTimeout) {
-          public Result call() throws IOException {
-            return ProtobufUtil.get(stub,
-              location.getRegionInfo().getRegionName(), get);
-          }
-        }.withRetries();
+    RegionServerCallable<Result> callable = new RegionServerCallable<Result>(this.connection,
+        getTableName(), get.getRow()) {
+      public Result call() throws IOException {
+        return ProtobufUtil.get(getStub(), getLocation().getRegionInfo().getRegionName(), get);
+      }
+    };
+    return new RpcRetryingCaller<Result>().
+      callWithRetries(callable, getConfiguration(), this.operationTimeout);
   }
 
   /**
@@ -704,18 +709,21 @@ public class HTable implements HTableInt
   @Override
   public void delete(final Delete delete)
   throws IOException {
-    new ServerCallable<Boolean>(connection, tableName, delete.getRow(), operationTimeout) {
-          public Boolean call() throws IOException {
-            try {
-              MutateRequest request = RequestConverter.buildMutateRequest(
-                location.getRegionInfo().getRegionName(), delete);
-              MutateResponse response = stub.mutate(null, request);
-              return Boolean.valueOf(response.getProcessed());
-            } catch (ServiceException se) {
-              throw ProtobufUtil.getRemoteException(se);
-            }
-          }
-        }.withRetries();
+    RegionServerCallable<Boolean> callable = new RegionServerCallable<Boolean>(connection,
+        tableName, delete.getRow()) {
+      public Boolean call() throws IOException {
+        try {
+          MutateRequest request = RequestConverter.buildMutateRequest(
+            getLocation().getRegionInfo().getRegionName(), delete);
+          MutateResponse response = getStub().mutate(null, request);
+          return Boolean.valueOf(response.getProcessed());
+        } catch (ServiceException se) {
+          throw ProtobufUtil.getRemoteException(se);
+        }
+      }
+    };
+    new RpcRetryingCaller<Boolean>().
+      callWithRetries(callable, getConfiguration(), this.operationTimeout);
   }
 
   /**
@@ -838,19 +846,21 @@ public class HTable implements HTableInt
    */
   @Override
   public void mutateRow(final RowMutations rm) throws IOException {
-    new ServerCallable<Void>(connection, tableName, rm.getRow(),
-        operationTimeout) {
+    RegionServerCallable<Void> callable =
+        new RegionServerCallable<Void>(connection, getTableName(), rm.getRow()) {
       public Void call() throws IOException {
         try {
           MultiRequest request = RequestConverter.buildMultiRequest(
-            location.getRegionInfo().getRegionName(), rm);
-          stub.multi(null, request);
+            getLocation().getRegionInfo().getRegionName(), rm);
+          getStub().multi(null, request);
         } catch (ServiceException se) {
           throw ProtobufUtil.getRemoteException(se);
         }
         return null;
       }
-    }.withRetries();
+    };
+    new RpcRetryingCaller<Void>().
+      callWithRetries(callable, getConfiguration(), this.operationTimeout);
   }
 
   /**
@@ -862,21 +872,23 @@ public class HTable implements HTableInt
       throw new IOException(
           "Invalid arguments to append, no columns specified");
     }
-    return new ServerCallable<Result>(connection, tableName, append.getRow(), operationTimeout) {
-          public Result call() throws IOException {
-            try {
-              MutateRequest request = RequestConverter.buildMutateRequest(
-                location.getRegionInfo().getRegionName(), append);
-              PayloadCarryingRpcController rpcController =
-                new PayloadCarryingRpcController();
-              MutateResponse response = stub.mutate(rpcController, request);
-              if (!response.hasResult()) return null;
-              return ProtobufUtil.toResult(response.getResult(), rpcController.cellScanner());
-            } catch (ServiceException se) {
-              throw ProtobufUtil.getRemoteException(se);
-            }
+    RegionServerCallable<Result> callable =
+      new RegionServerCallable<Result>(this.connection, getTableName(), append.getRow()) {
+        public Result call() throws IOException {
+          try {
+            MutateRequest request = RequestConverter.buildMutateRequest(
+              getLocation().getRegionInfo().getRegionName(), append);
+            PayloadCarryingRpcController rpcController = new PayloadCarryingRpcController();
+            MutateResponse response = getStub().mutate(rpcController, request);
+            if (!response.hasResult()) return null;
+            return ProtobufUtil.toResult(response.getResult(), rpcController.cellScanner());
+          } catch (ServiceException se) {
+            throw ProtobufUtil.getRemoteException(se);
           }
-        }.withRetries();
+        }
+      };
+    return new RpcRetryingCaller<Result>().
+      callWithRetries(callable, getConfiguration(), this.operationTimeout);
   }
 
   /**
@@ -888,19 +900,22 @@ public class HTable implements HTableInt
       throw new IOException(
           "Invalid arguments to increment, no columns specified");
     }
-    return new ServerCallable<Result>(connection, tableName, increment.getRow(), operationTimeout) {
-          public Result call() throws IOException {
-            try {
-              MutateRequest request = RequestConverter.buildMutateRequest(
-                location.getRegionInfo().getRegionName(), increment);
-              PayloadCarryingRpcController rpcContoller = new PayloadCarryingRpcController();
-              MutateResponse response = stub.mutate(rpcContoller, request);
-              return ProtobufUtil.toResult(response.getResult(), rpcContoller.cellScanner());
-            } catch (ServiceException se) {
-              throw ProtobufUtil.getRemoteException(se);
-            }
+    RegionServerCallable<Result> callable = new RegionServerCallable<Result>(this.connection,
+        getTableName(), increment.getRow()) {
+      public Result call() throws IOException {
+        try {
+          MutateRequest request = RequestConverter.buildMutateRequest(
+            getLocation().getRegionInfo().getRegionName(), increment);
+            PayloadCarryingRpcController rpcContoller = new PayloadCarryingRpcController();
+            MutateResponse response = getStub().mutate(rpcContoller, request);
+            return ProtobufUtil.toResult(response.getResult(), rpcContoller.cellScanner());
+          } catch (ServiceException se) {
+            throw ProtobufUtil.getRemoteException(se);
           }
-        }.withRetries();
+        }
+      };
+    return new RpcRetryingCaller<Result>().
+      callWithRetries(callable, getConfiguration(), this.operationTimeout);
   }
 
   /**
@@ -932,22 +947,26 @@ public class HTable implements HTableInt
       throw new IOException(
           "Invalid arguments to incrementColumnValue", npe);
     }
-    return new ServerCallable<Long>(connection, tableName, row, operationTimeout) {
-          public Long call() throws IOException {
-            try {
-              MutateRequest request = RequestConverter.buildMutateRequest(
-                location.getRegionInfo().getRegionName(), row, family,
-                qualifier, amount, durability);
-              PayloadCarryingRpcController rpcController = new PayloadCarryingRpcController();
-              MutateResponse response = stub.mutate(rpcController, request);
-              Result result =
-                ProtobufUtil.toResult(response.getResult(), rpcController.cellScanner());
-              return Long.valueOf(Bytes.toLong(result.getValue(family, qualifier)));
-            } catch (ServiceException se) {
-              throw ProtobufUtil.getRemoteException(se);
-            }
+    
+    RegionServerCallable<Long> callable =
+      new RegionServerCallable<Long>(connection, getTableName(), row) {
+        public Long call() throws IOException {
+          try {
+            MutateRequest request = RequestConverter.buildMutateRequest(
+              getLocation().getRegionInfo().getRegionName(), row, family,
+              qualifier, amount, durability);
+            PayloadCarryingRpcController rpcController = new PayloadCarryingRpcController();
+            MutateResponse response = getStub().mutate(rpcController, request);
+            Result result =
+              ProtobufUtil.toResult(response.getResult(), rpcController.cellScanner());
+            return Long.valueOf(Bytes.toLong(result.getValue(family, qualifier)));
+          } catch (ServiceException se) {
+            throw ProtobufUtil.getRemoteException(se);
           }
-        }.withRetries();
+        }
+      };
+    return new RpcRetryingCaller<Long>().
+      callWithRetries(callable, getConfiguration(), this.operationTimeout);
   }
 
   /**
@@ -958,19 +977,22 @@ public class HTable implements HTableInt
       final byte [] family, final byte [] qualifier, final byte [] value,
       final Put put)
   throws IOException {
-    return new ServerCallable<Boolean>(connection, tableName, row, operationTimeout) {
-          public Boolean call() throws IOException {
-            try {
-              MutateRequest request = RequestConverter.buildMutateRequest(
-                location.getRegionInfo().getRegionName(), row, family, qualifier,
+    RegionServerCallable<Boolean> callable =
+      new RegionServerCallable<Boolean>(connection, getTableName(), row) {
+        public Boolean call() throws IOException {
+          try {
+            MutateRequest request = RequestConverter.buildMutateRequest(
+              getLocation().getRegionInfo().getRegionName(), row, family, qualifier,
                 new BinaryComparator(value), CompareType.EQUAL, put);
-              MutateResponse response = stub.mutate(null, request);
-              return Boolean.valueOf(response.getProcessed());
-            } catch (ServiceException se) {
-              throw ProtobufUtil.getRemoteException(se);
-            }
+            MutateResponse response = getStub().mutate(null, request);
+            return Boolean.valueOf(response.getProcessed());
+          } catch (ServiceException se) {
+            throw ProtobufUtil.getRemoteException(se);
           }
-        }.withRetries();
+        }
+      };
+    return new RpcRetryingCaller<Boolean>().
+      callWithRetries(callable, getConfiguration(), this.operationTimeout);
   }
 
 
@@ -982,19 +1004,22 @@ public class HTable implements HTableInt
       final byte [] family, final byte [] qualifier, final byte [] value,
       final Delete delete)
   throws IOException {
-    return new ServerCallable<Boolean>(connection, tableName, row, operationTimeout) {
-          public Boolean call() throws IOException {
-            try {
-              MutateRequest request = RequestConverter.buildMutateRequest(
-                location.getRegionInfo().getRegionName(), row, family, qualifier,
+    RegionServerCallable<Boolean> callable =
+      new RegionServerCallable<Boolean>(connection, getTableName(), row) {
+        public Boolean call() throws IOException {
+          try {
+            MutateRequest request = RequestConverter.buildMutateRequest(
+              getLocation().getRegionInfo().getRegionName(), row, family, qualifier,
                 new BinaryComparator(value), CompareType.EQUAL, delete);
-              MutateResponse response = stub.mutate(null, request);
-              return Boolean.valueOf(response.getProcessed());
-            } catch (ServiceException se) {
-              throw ProtobufUtil.getRemoteException(se);
-            }
+            MutateResponse response = getStub().mutate(null, request);
+            return Boolean.valueOf(response.getProcessed());
+          } catch (ServiceException se) {
+            throw ProtobufUtil.getRemoteException(se);
           }
-        }.withRetries();
+        }
+      };
+    return new RpcRetryingCaller<Boolean>().
+      callWithRetries(callable, getConfiguration(), this.operationTimeout);
   }
 
   /**
@@ -1002,19 +1027,21 @@ public class HTable implements HTableInt
    */
   @Override
   public boolean exists(final Get get) throws IOException {
-    return new ServerCallable<Boolean>(connection, tableName, get.getRow(), operationTimeout) {
-          public Boolean call() throws IOException {
-            try {
-              GetRequest request = RequestConverter.buildGetRequest(
-                  location.getRegionInfo().getRegionName(), get, true);
-
-              GetResponse response = stub.get(null, request);
-              return response.getExists();
-            } catch (ServiceException se) {
-              throw ProtobufUtil.getRemoteException(se);
-            }
-          }
-        }.withRetries();
+    RegionServerCallable<Boolean> callable =
+        new RegionServerCallable<Boolean>(connection, getTableName(), get.getRow()) {
+      public Boolean call() throws IOException {
+        try {
+          GetRequest request = RequestConverter.buildGetRequest(
+            getLocation().getRegionInfo().getRegionName(), get, true);
+          GetResponse response = getStub().get(null, request);
+          return response.getExists();
+        } catch (ServiceException se) {
+          throw ProtobufUtil.getRemoteException(se);
+        }
+      }
+    };
+    return new RpcRetryingCaller<Boolean>().
+      callWithRetries(callable, getConfiguration(), this.operationTimeout);
   }
 
   /**
@@ -1105,19 +1132,23 @@ public class HTable implements HTableInt
     for (final Map.Entry<Integer, List<Get>> getsByRegionEntry : getsByRegion.entrySet()) {
       Callable<List<Boolean>> callable = new Callable<List<Boolean>>() {
         public List<Boolean> call() throws Exception {
-          return new ServerCallable<List<Boolean>>(connection, tableName, getsByRegionEntry.getValue()
-              .get(0).getRow(), operationTimeout) {
+          RegionServerCallable<List<Boolean>> callable =
+            new RegionServerCallable<List<Boolean>>(connection, getTableName(),
+              getsByRegionEntry.getValue().get(0).getRow()) {
             public List<Boolean> call() throws IOException {
               try {
-                MultiGetRequest requests = RequestConverter.buildMultiGetRequest(location
-                    .getRegionInfo().getRegionName(), getsByRegionEntry.getValue(), true, false);
-                MultiGetResponse responses = stub.multiGet(null, requests);
+                MultiGetRequest requests = RequestConverter.buildMultiGetRequest(
+                  getLocation().getRegionInfo().getRegionName(), getsByRegionEntry.getValue(),
+                  true, false);
+                MultiGetResponse responses = getStub().multiGet(null, requests);
                 return responses.getExistsList();
               } catch (ServiceException se) {
                 throw ProtobufUtil.getRemoteException(se);
               }
             }
-          }.withRetries();
+          };
+          return new RpcRetryingCaller<List<Boolean>>().
+            callWithRetries(callable, getConfiguration(), operationTimeout);
         }
       };
       futures.put(getsByRegionEntry.getKey(), pool.submit(callable));

Modified: hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/client/MultiServerCallable.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/client/MultiServerCallable.java?rev=1507494&r1=1507493&r2=1507494&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/client/MultiServerCallable.java (original)
+++ hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/client/MultiServerCallable.java Fri Jul 26 22:36:53 2013
@@ -21,7 +21,6 @@ import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
-import java.util.concurrent.Callable;
 
 import org.apache.hadoop.hbase.CellScannable;
 import org.apache.hadoop.hbase.HRegionLocation;
@@ -36,19 +35,22 @@ import com.google.protobuf.ServiceExcept
 
 /**
  * Callable that handles the <code>multi</code> method call going against a single
- * regionserver; i.e. A {@link ServerCallable} for the multi call (It is not a
- * {@link Callable} that goes against multiple regions.
+ * regionserver; i.e. A {@link RegionServerCallable} for the multi call (It is not a
+ * {@link RegionServerCallable} that goes against multiple regions.
  * @param <R>
  */
-class MultiServerCallable<R> extends ServerCallable<MultiResponse> {
+class MultiServerCallable<R> extends RegionServerCallable<MultiResponse> {
   private final MultiAction<R> multi;
-  private final HRegionLocation loc;
 
   MultiServerCallable(final HConnection connection, final byte [] tableName,
-      final HRegionLocation loc, final MultiAction<R> multi) {
+      final HRegionLocation location, final MultiAction<R> multi) {
     super(connection, tableName, null);
     this.multi = multi;
-    this.loc = loc;
+    setLocation(location);
+  }
+
+  MultiAction<R> getMulti() {
+    return this.multi;
   }
 
   @Override
@@ -74,7 +76,7 @@ class MultiServerCallable<R> extends Ser
                 RequestConverter.buildNoDataMultiRequest(regionName, rms, cells);
             // Carry the cells over the proxy/pb Service interface using the payload carrying
             // rpc controller.
-            stub.multi(new PayloadCarryingRpcController(cells), multiRequest);
+            getStub().multi(new PayloadCarryingRpcController(cells), multiRequest);
             // This multi call does not return results.
             response.add(regionName, action.getOriginalIndex(), Result.EMPTY_RESULT);
           } catch (ServiceException se) {
@@ -99,7 +101,7 @@ class MultiServerCallable<R> extends Ser
           // Controller optionally carries cell data over the proxy/service boundary and also
           // optionally ferries cell response data back out again.
           PayloadCarryingRpcController controller = new PayloadCarryingRpcController(cells);
-          ClientProtos.MultiResponse responseProto = stub.multi(controller, multiRequest);
+          ClientProtos.MultiResponse responseProto = getStub().multi(controller, multiRequest);
           results = ResponseConverter.getResults(responseProto, controller.cellScanner());
         } catch (ServiceException se) {
           ex = ProtobufUtil.getRemoteException(se);
@@ -115,6 +117,7 @@ class MultiServerCallable<R> extends Ser
 
   @Override
   public void prepare(boolean reload) throws IOException {
-    stub = connection.getClient(loc.getServerName());
+    // Use the location we were given in the constructor rather than go look it up.
+    setStub(getConnection().getClient(getLocation().getServerName()));
   }
-}
+}
\ No newline at end of file

Modified: hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/client/RegionOfflineException.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/client/RegionOfflineException.java?rev=1507494&r1=1507493&r2=1507494&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/client/RegionOfflineException.java (original)
+++ hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/client/RegionOfflineException.java Fri Jul 26 22:36:53 2013
@@ -24,7 +24,7 @@ import org.apache.hadoop.hbase.exception
 
 /** Thrown when a table can not be located */
 @InterfaceAudience.Public
-@InterfaceStability.Stable
+@InterfaceStability.Evolving
 public class RegionOfflineException extends RegionException {
   private static final long serialVersionUID = 466008402L;
   /** default constructor */
@@ -36,4 +36,4 @@ public class RegionOfflineException exte
   public RegionOfflineException(String s) {
     super(s);
   }
-}
+}
\ No newline at end of file

Added: hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/client/RegionServerCallable.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/client/RegionServerCallable.java?rev=1507494&view=auto
==============================================================================
--- hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/client/RegionServerCallable.java (added)
+++ hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/client/RegionServerCallable.java Fri Jul 26 22:36:53 2013
@@ -0,0 +1,145 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.hbase.client;
+
+import java.io.IOException;
+import java.net.ConnectException;
+import java.net.SocketTimeoutException;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.hadoop.classification.InterfaceAudience;
+import org.apache.hadoop.classification.InterfaceStability;
+import org.apache.hadoop.hbase.HRegionLocation;
+import org.apache.hadoop.hbase.exceptions.NotServingRegionException;
+import org.apache.hadoop.hbase.exceptions.RegionMovedException;
+import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.ClientService;
+import org.apache.hadoop.hbase.util.Bytes;
+
+/**
+ * Implementations call a RegionServer and implement {@link #call()}.
+ * Passed to a {@link RpcRetryingCaller} so we retry on fail.
+ * @param <T> the class that the ServerCallable handles
+ */
+@InterfaceAudience.Public
+@InterfaceStability.Stable
+public abstract class RegionServerCallable<T> implements RetryingCallable<T> {
+  // Public because used outside of this package over in ipc.
+  static final Log LOG = LogFactory.getLog(RegionServerCallable.class);
+  private final HConnection connection;
+  private final byte [] tableName;
+  private final byte [] row;
+  private HRegionLocation location;
+  private ClientService.BlockingInterface stub;
+
+  protected final static int MIN_WAIT_DEAD_SERVER = 10000;
+
+  /**
+   * @param connection Connection to use.
+   * @param tableName Table name to which <code>row</code> belongs.
+   * @param row The row we want in <code>tableName</code>.
+   */
+  public RegionServerCallable(HConnection connection, byte [] tableName, byte [] row) {
+    this.connection = connection;
+    this.tableName = tableName;
+    this.row = row;
+  }
+
+  /**
+   * Prepare for connection to the server hosting region with row from tablename.  Does lookup
+   * to find region location and hosting server.
+   * @param reload Set this to true if connection should re-find the region
+   * @throws IOException e
+   */
+  public void prepare(final boolean reload) throws IOException {
+    this.location = connection.getRegionLocation(tableName, row, reload);
+    if (this.location == null) {
+      throw new IOException("Failed to find location, tableName=" + Bytes.toString(tableName) +
+        ", row=" + Bytes.toString(row) + ", reload=" + reload);
+    }
+    setStub(getConnection().getClient(getLocation().getServerName()));
+  }
+
+  /**
+   * @return {@link HConnection} instance used by this Callable.
+   */
+  HConnection getConnection() {
+    return this.connection;
+  }
+
+  protected ClientService.BlockingInterface getStub() {
+    return this.stub;
+  }
+
+  void setStub(final ClientService.BlockingInterface stub) {
+    this.stub = stub;
+  }
+
+  protected HRegionLocation getLocation() {
+    return this.location;
+  }
+
+  protected void setLocation(final HRegionLocation location) {
+    this.location = location;
+  }
+
+  public byte [] getTableName() {
+    return this.tableName;
+  }
+
+  public byte [] getRow() {
+    return this.row;
+  }
+
+  @Override
+  public void throwable(Throwable t, boolean retrying) {
+    if (t instanceof SocketTimeoutException ||
+        t instanceof ConnectException ||
+        t instanceof RetriesExhaustedException ||
+        (location != null && getConnection().isDeadServer(location.getServerName()))) {
+      // if thrown these exceptions, we clear all the cache entries that
+      // map to that slow/dead server; otherwise, let cache miss and ask
+      // .META. again to find the new location
+      getConnection().clearCaches(location.getServerName());
+    } else if (t instanceof RegionMovedException) {
+      getConnection().updateCachedLocations(tableName, row, t, location);
+    } else if (t instanceof NotServingRegionException && !retrying) {
+      // Purge cache entries for this specific region from META cache
+      // since we don't call connect(true) when number of retries is 1.
+      getConnection().deleteCachedRegionLocation(location);
+    }
+  }
+
+  @Override
+  public String getExceptionMessageAdditionalDetail() {
+    return "row '" + Bytes.toString(row) + "' on table '" + Bytes.toString(tableName);
+  }
+
+  @Override
+  public long sleep(long pause, int tries) {
+    // Tries hasn't been bumped up yet so we use "tries + 1" to get right pause time
+    long sleep = ConnectionUtils.getPauseTime(pause, tries + 1);
+    if (sleep < MIN_WAIT_DEAD_SERVER 
+        && (location == null || getConnection().isDeadServer(location.getServerName()))) {
+      sleep = ConnectionUtils.addJitter(MIN_WAIT_DEAD_SERVER, 0.10f);
+    }
+    return sleep;
+  }
+}
\ No newline at end of file

Modified: hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/client/RetriesExhaustedException.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/client/RetriesExhaustedException.java?rev=1507494&r1=1507493&r2=1507494&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/client/RetriesExhaustedException.java (original)
+++ hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/client/RetriesExhaustedException.java Fri Jul 26 22:36:53 2013
@@ -20,6 +20,7 @@ import org.apache.hadoop.classification.
 import java.io.IOException;
 import java.util.Date;
 import java.util.List;
+import java.util.concurrent.Callable;
 
 /**
  * Exception thrown by HTable methods when an attempt to do something (like
@@ -61,7 +62,7 @@ public class RetriesExhaustedException e
 
   /**
    * Create a new RetriesExhaustedException from the list of prior failures.
-   * @param callableVitals Details from the {@link ServerCallable} we were using
+   * @param callableVitals Details from the Callable we were using
    * when we got this exception.
    * @param numTries The number of tries we made
    * @param exceptions List of exceptions that failed before giving up

Added: hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/client/RetryingCallable.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/client/RetryingCallable.java?rev=1507494&view=auto
==============================================================================
--- hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/client/RetryingCallable.java (added)
+++ hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/client/RetryingCallable.java Fri Jul 26 22:36:53 2013
@@ -0,0 +1,66 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.hbase.client;
+
+import java.io.IOException;
+import java.util.concurrent.Callable;
+
+import org.apache.hadoop.classification.InterfaceAudience;
+import org.apache.hadoop.classification.InterfaceStability;
+
+/**
+ * A Callable<T> that will be retried.  If {@link #call()} invocation throws exceptions,
+ * we will call {@link #throwable(Throwable, boolean)} with whatever the exception was.
+ * @param <T>
+ */
+@InterfaceAudience.Public
+@InterfaceStability.Stable
+public interface RetryingCallable<T> extends Callable<T> {
+  /**
+   * Prepare by setting up any connections to servers, etc., ahead of {@link #call()} invocation.
+   * @param reload Set this to true if need to requery locations (usually set on second invocation
+   * to {@link #call()} or whatever
+   * @throws IOException e
+   */
+  void prepare(final boolean reload) throws IOException;
+
+  /**
+   * Called when {@link #call()} throws an exception and we are going to retry; take action to
+   * make it so we succeed on next call (clear caches, do relookup of locations, etc.).
+   * @param t
+   * @param retrying True if we are in retrying mode (we are not in retrying mode when max
+   * retries == 1; we ARE in retrying mode if retries > 1 even when we are the last attempt)
+   */
+  void throwable(final Throwable t, boolean retrying);
+
+  /**
+   * @return Some details from the implementation that we would like to add to a terminating
+   * exception; i.e. a fatal exception is being thrown ending retries and we might like to add
+   * more implementation-specific detail on to the exception being thrown.
+   */
+  String getExceptionMessageAdditionalDetail();
+
+  /**
+   * @param pause
+   * @param tries
+   * @return Suggestion on how much to sleep between retries
+   */
+  long sleep(final long pause, final int tries);
+}
\ No newline at end of file

Added: hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/client/RpcRetryingCaller.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/client/RpcRetryingCaller.java?rev=1507494&view=auto
==============================================================================
--- hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/client/RpcRetryingCaller.java (added)
+++ hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/client/RpcRetryingCaller.java Fri Jul 26 22:36:53 2013
@@ -0,0 +1,228 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.hbase.client;
+
+import java.io.IOException;
+import java.io.InterruptedIOException;
+import java.lang.reflect.UndeclaredThrowableException;
+import java.net.SocketTimeoutException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.hadoop.classification.InterfaceAudience;
+import org.apache.hadoop.classification.InterfaceStability;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.hbase.HConstants;
+import org.apache.hadoop.hbase.exceptions.DoNotRetryIOException;
+import org.apache.hadoop.hbase.ipc.RpcClient;
+import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
+import org.apache.hadoop.ipc.RemoteException;
+
+import com.google.protobuf.ServiceException;
+
+/**
+ * Runs an rpc'ing {@link RetryingCallable}. Sets into rpc client
+ * threadlocal outstanding timeouts as so we don't persist too much.
+ * Dynamic rather than static so can set the generic appropriately.
+ */
+@InterfaceAudience.Public
+@InterfaceStability.Stable
+public class RpcRetryingCaller<T> {
+  static final Log LOG = LogFactory.getLog(RpcRetryingCaller.class);
+  /**
+   * Timeout for the call including retries
+   */
+  private int callTimeout;
+  /**
+   * When we started making calls.
+   */
+  private long globalStartTime;
+  /**
+   * Start and end times for a single call.
+   */
+  private long startTime, endTime;
+  private final static int MIN_RPC_TIMEOUT = 2000;
+
+  public RpcRetryingCaller() {
+    super();
+  }
+
+  private void beforeCall() {
+    this.startTime = EnvironmentEdgeManager.currentTimeMillis();
+    int remaining = (int)(callTimeout - (this.startTime - this.globalStartTime));
+    if (remaining < MIN_RPC_TIMEOUT) {
+      // If there is no time left, we're trying anyway. It's too late.
+      // 0 means no timeout, and it's not the intent here. So we secure both cases by
+      // resetting to the minimum.
+      remaining = MIN_RPC_TIMEOUT;
+    }
+    RpcClient.setRpcTimeout(remaining);
+  }
+
+  private void afterCall() {
+    RpcClient.resetRpcTimeout();
+    this.endTime = EnvironmentEdgeManager.currentTimeMillis();
+  }
+
+  public synchronized T callWithRetries(RetryingCallable<T> callable, final Configuration conf)
+  throws IOException, RuntimeException {
+    return callWithRetries(callable, conf, HConstants.DEFAULT_HBASE_CLIENT_OPERATION_TIMEOUT);
+  }
+
+  public synchronized T callWithRetries(RetryingCallable<T> callable, final Configuration conf,
+      final int callTimeout)
+  throws IOException, RuntimeException {
+    final long pause = conf.getLong(HConstants.HBASE_CLIENT_PAUSE,
+      HConstants.DEFAULT_HBASE_CLIENT_PAUSE);
+    final int numRetries = conf.getInt(HConstants.HBASE_CLIENT_RETRIES_NUMBER,
+      HConstants.DEFAULT_HBASE_CLIENT_RETRIES_NUMBER);
+    return callWithRetries(callable, callTimeout, pause, numRetries);
+  }
+
+  /**
+   * Retries if invocation fails.
+   * @param conf
+   * @param callTimeout Timeout for this call
+   * @param callable The {@link RetryingCallable} to run.
+   * @return an object of type T
+   * @throws IOException if a remote or network exception occurs
+   * @throws RuntimeException other unspecified error
+   */
+  synchronized T callWithRetries(RetryingCallable<T> callable, int callTimeout, final long pause,
+      final int retries)
+  throws IOException, RuntimeException {
+    this.callTimeout = callTimeout;
+    List<RetriesExhaustedException.ThrowableWithExtraContext> exceptions =
+      new ArrayList<RetriesExhaustedException.ThrowableWithExtraContext>();
+    this.globalStartTime = EnvironmentEdgeManager.currentTimeMillis();
+    for (int tries = 0;; tries++) {
+      long expectedSleep = 0;
+      try {
+        beforeCall();
+        callable.prepare(tries != 0); // if called with false, check table status on ZK
+        return callable.call();
+      } catch (Throwable t) {
+        LOG.warn("Call exception, tries=" + tries + ", retries=" + retries + ", retryTime=" +
+            (this.globalStartTime - System.currentTimeMillis()) + "ms", t);
+        // translateException throws exception when should not retry: i.e. when request is bad.
+        t = translateException(t);
+        callable.throwable(t, retries != 1);
+        RetriesExhaustedException.ThrowableWithExtraContext qt =
+            new RetriesExhaustedException.ThrowableWithExtraContext(t,
+                EnvironmentEdgeManager.currentTimeMillis(), toString());
+        exceptions.add(qt);
+        if (tries >= retries - 1) {
+          throw new RetriesExhaustedException(tries, exceptions);
+        }
+        // If the server is dead, we need to wait a little before retrying, to give
+        //  a chance to the regions to be
+        // tries hasn't been bumped up yet so we use "tries + 1" to get right pause time
+        expectedSleep = callable.sleep(pause, tries + 1);
+
+        // If, after the planned sleep, there won't be enough time left, we stop now.
+        long duration = singleCallDuration(expectedSleep);
+        if (duration > this.callTimeout) {
+          String msg = "callTimeout=" + this.callTimeout + ", callDuration=" + duration +
+              ": " + callable.getExceptionMessageAdditionalDetail();
+          throw (SocketTimeoutException)(new SocketTimeoutException(msg).initCause(t));
+        }
+      } finally {
+        afterCall();
+      }
+      try {
+        Thread.sleep(expectedSleep);
+      } catch (InterruptedException e) {
+        Thread.currentThread().interrupt();
+        throw new InterruptedIOException("Interrupted after " + tries + " tries  on " + retries);
+      }
+    }
+  }
+
+  /**
+   * @param expectedSleep
+   * @return Calculate how long a single call took
+   */
+  private long singleCallDuration(final long expectedSleep) {
+    return (this.endTime - this.globalStartTime) + MIN_RPC_TIMEOUT + expectedSleep;
+  }
+
+  /**
+   * Call the server once only.
+   * {@link RetryingCallable} has a strange shape so we can do retrys.  Use this invocation if you
+   * want to do a single call only (A call to {@link RetryingCallable#call()} will not likely
+   * succeed).
+   * @return an object of type T
+   * @throws IOException if a remote or network exception occurs
+   * @throws RuntimeException other unspecified error
+   */
+  public T callWithoutRetries(RetryingCallable<T> callable)
+  throws IOException, RuntimeException {
+    // The code of this method should be shared with withRetries.
+    this.globalStartTime = EnvironmentEdgeManager.currentTimeMillis();
+    try {
+      beforeCall();
+      callable.prepare(false);
+      return callable.call();
+    } catch (Throwable t) {
+      Throwable t2 = translateException(t);
+      // It would be nice to clear the location cache here.
+      if (t2 instanceof IOException) {
+        throw (IOException)t2;
+      } else {
+        throw new RuntimeException(t2);
+      }
+    } finally {
+      afterCall();
+    }
+  }
+
+  /**
+   * Get the good or the remote exception if any, throws the DoNotRetryIOException.
+   * @param t the throwable to analyze
+   * @return the translated exception, if it's not a DoNotRetryIOException
+   * @throws DoNotRetryIOException - if we find it, we throw it instead of translating.
+   */
+  static Throwable translateException(Throwable t) throws DoNotRetryIOException {
+    if (t instanceof UndeclaredThrowableException) {
+      if (t.getCause() != null) {
+        t = t.getCause();
+      }
+    }
+    if (t instanceof RemoteException) {
+      t = ((RemoteException)t).unwrapRemoteException();
+    }
+    if (t instanceof ServiceException) {
+      ServiceException se = (ServiceException)t;
+      Throwable cause = se.getCause();
+      if (cause != null && cause instanceof DoNotRetryIOException) {
+        throw (DoNotRetryIOException)cause;
+      }
+      // Don't let ServiceException out; its rpc specific.
+      t = cause;
+      // t could be a RemoteException so go aaround again.
+      translateException(t);
+    } else if (t instanceof DoNotRetryIOException) {
+      throw (DoNotRetryIOException)t;
+    }
+    return t;
+  }
+}
\ No newline at end of file

Modified: hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ScannerCallable.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ScannerCallable.java?rev=1507494&r1=1507493&r2=1507494&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ScannerCallable.java (original)
+++ hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ScannerCallable.java Fri Jul 26 22:36:53 2013
@@ -49,12 +49,13 @@ import java.io.IOException;
 import java.net.UnknownHostException;
 
 /**
- * Retries scanner operations such as create, next, etc.
- * Used by {@link ResultScanner}s made by {@link HTable}.
+ * Scanner operations such as create, next, etc.
+ * Used by {@link ResultScanner}s made by {@link HTable}. Passed to a retrying caller such as
+ * {@link RpcRetryingCaller} so fails are retried.
  */
 @InterfaceAudience.Public
 @InterfaceStability.Stable
-public class ScannerCallable extends ServerCallable<Result[]> {
+public class ScannerCallable extends RegionServerCallable<Result[]> {
   public static final String LOG_SCANNER_LATENCY_CUTOFF
     = "hbase.client.log.scanner.latency.cutoff";
   public static final String LOG_SCANNER_ACTIVITY = "hbase.client.log.scanner.activity";
@@ -126,7 +127,7 @@ public class ScannerCallable extends Ser
    * to decide if hbase client connects to a remote region server
    */
   private void checkIfRegionServerIsRemote() {
-    if (this.location.getHostname().equalsIgnoreCase(myAddress)) {
+    if (getLocation().getHostname().equalsIgnoreCase(myAddress)) {
       isRegionServerRemote = false;
     } else {
       isRegionServerRemote = true;
@@ -154,7 +155,7 @@ public class ScannerCallable extends Ser
           ScanResponse response = null;
           PayloadCarryingRpcController controller = new PayloadCarryingRpcController();
           try {
-            response = stub.scan(controller, request);
+            response = getStub().scan(controller, request);
             // Client and RS maintain a nextCallSeq number during the scan. Every next() call
             // from client to server will increment this number in both sides. Client passes this
             // number along with the request and at RS side both the incoming nextCallSeq and its
@@ -198,7 +199,7 @@ public class ScannerCallable extends Ser
           if (logScannerActivity && (ioe instanceof UnknownScannerException)) {
             try {
               HRegionLocation location =
-                connection.relocateRegion(tableName, scan.getStartRow());
+                getConnection().relocateRegion(getTableName(), scan.getStartRow());
               LOG.info("Scanner=" + scannerId
                 + " expired, current region location is " + location.toString()
                 + " ip:" + location.getHostnamePort());
@@ -270,7 +271,7 @@ public class ScannerCallable extends Ser
       ScanRequest request =
         RequestConverter.buildScanRequest(this.scannerId, 0, true);
       try {
-        stub.scan(null, request);
+        getStub().scan(null, request);
       } catch (ServiceException se) {
         throw ProtobufUtil.getRemoteException(se);
       }
@@ -284,15 +285,15 @@ public class ScannerCallable extends Ser
     incRPCcallsMetrics();
     ScanRequest request =
       RequestConverter.buildScanRequest(
-        this.location.getRegionInfo().getRegionName(),
+        getLocation().getRegionInfo().getRegionName(),
         this.scan, 0, false);
     try {
-      ScanResponse response = stub.scan(null, request);
+      ScanResponse response = getStub().scan(null, request);
       long id = response.getScannerId();
       if (logScannerActivity) {
         LOG.info("Open scanner=" + id + " for scan=" + scan.toString()
-          + " on region " + this.location.toString() + " ip:"
-          + this.location.getHostnamePort());
+          + " on region " + getLocation().toString() + " ip:"
+          + getLocation().getHostnamePort());
       }
       return id;
     } catch (ServiceException se) {
@@ -318,7 +319,7 @@ public class ScannerCallable extends Ser
     if (!instantiated) {
       return null;
     }
-    return location.getRegionInfo();
+    return getLocation().getRegionInfo();
   }
 
   /**
@@ -336,4 +337,4 @@ public class ScannerCallable extends Ser
   public void setCaching(int caching) {
     this.caching = caching;
   }
-}
+}
\ No newline at end of file

Added: hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ScannerCaller.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ScannerCaller.java?rev=1507494&view=auto
==============================================================================
--- hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ScannerCaller.java (added)
+++ hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ScannerCaller.java Fri Jul 26 22:36:53 2013
@@ -0,0 +1,21 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.hbase.client;
+
+
+class ScannerCaller extends RpcRetryingCaller<Result []> {}
\ No newline at end of file

Modified: hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/exceptions/DoNotRetryIOException.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/exceptions/DoNotRetryIOException.java?rev=1507494&r1=1507493&r2=1507494&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/exceptions/DoNotRetryIOException.java (original)
+++ hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/exceptions/DoNotRetryIOException.java Fri Jul 26 22:36:53 2013
@@ -29,7 +29,7 @@ import org.apache.hadoop.hbase.HBaseIOEx
 @InterfaceAudience.Public
 @InterfaceStability.Stable
 public class DoNotRetryIOException extends HBaseIOException {
-
+  // TODO: This would be more useful as a marker interface than as a class.
   private static final long serialVersionUID = 1197446454511704139L;
 
   /**

Modified: hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/exceptions/HBaseSnapshotException.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/exceptions/HBaseSnapshotException.java?rev=1507494&r1=1507493&r2=1507494&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/exceptions/HBaseSnapshotException.java (original)
+++ hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/exceptions/HBaseSnapshotException.java Fri Jul 26 22:36:53 2013
@@ -19,7 +19,6 @@ package org.apache.hadoop.hbase.exceptio
 
 import org.apache.hadoop.classification.InterfaceAudience;
 import org.apache.hadoop.classification.InterfaceStability;
-import org.apache.hadoop.hbase.HBaseIOException;
 import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.SnapshotDescription;
 
 /**
@@ -28,7 +27,7 @@ import org.apache.hadoop.hbase.protobuf.
 @SuppressWarnings("serial")
 @InterfaceAudience.Public
 @InterfaceStability.Evolving
-public class HBaseSnapshotException extends HBaseIOException {
+public class HBaseSnapshotException extends DoNotRetryIOException {
 
   private SnapshotDescription description;
 

Modified: hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/exceptions/InvalidFamilyOperationException.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/exceptions/InvalidFamilyOperationException.java?rev=1507494&r1=1507493&r2=1507494&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/exceptions/InvalidFamilyOperationException.java (original)
+++ hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/exceptions/InvalidFamilyOperationException.java Fri Jul 26 22:36:53 2013
@@ -29,7 +29,7 @@ import java.io.IOException;
  */
 @InterfaceAudience.Public
 @InterfaceStability.Evolving
-public class InvalidFamilyOperationException extends IOException {
+public class InvalidFamilyOperationException extends DoNotRetryIOException {
   private static final long serialVersionUID = 1L << 22 - 1L;
   /** default constructor */
   public InvalidFamilyOperationException() {

Modified: hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/exceptions/LockTimeoutException.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/exceptions/LockTimeoutException.java?rev=1507494&r1=1507493&r2=1507494&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/exceptions/LockTimeoutException.java (original)
+++ hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/exceptions/LockTimeoutException.java Fri Jul 26 22:36:53 2013
@@ -19,9 +19,7 @@
  */
 package org.apache.hadoop.hbase.exceptions;
 
-import java.io.IOException;
-
-public class LockTimeoutException extends IOException {
+public class LockTimeoutException extends DoNotRetryIOException {
 
   private static final long serialVersionUID = -1770764924258999825L;
 
@@ -33,5 +31,4 @@ public class LockTimeoutException extend
   public LockTimeoutException(String s) {
     super(s);
   }
-
-}
+}
\ No newline at end of file

Modified: hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/exceptions/RegionException.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/exceptions/RegionException.java?rev=1507494&r1=1507493&r2=1507494&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/exceptions/RegionException.java (original)
+++ hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/exceptions/RegionException.java Fri Jul 26 22:36:53 2013
@@ -43,5 +43,4 @@ public class RegionException extends HBa
   public RegionException(String s) {
     super(s);
   }
-
-}
+}
\ No newline at end of file

Modified: hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/exceptions/TableExistsException.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/exceptions/TableExistsException.java?rev=1507494&r1=1507493&r2=1507494&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/exceptions/TableExistsException.java (original)
+++ hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/exceptions/TableExistsException.java Fri Jul 26 22:36:53 2013
@@ -17,14 +17,12 @@ package org.apache.hadoop.hbase.exceptio
 import org.apache.hadoop.classification.InterfaceAudience;
 import org.apache.hadoop.classification.InterfaceStability;
 
-import java.io.IOException;
-
 /**
  * Thrown when a table exists but should not
  */
 @InterfaceAudience.Public
 @InterfaceStability.Stable
-public class TableExistsException extends IOException {
+public class TableExistsException extends DoNotRetryIOException {
   private static final long serialVersionUID = 1L << 7 - 1L;
   /** default constructor */
   public TableExistsException() {
@@ -39,4 +37,4 @@ public class TableExistsException extend
   public TableExistsException(String s) {
     super(s);
   }
-}
+}
\ No newline at end of file

Modified: hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/exceptions/TableNotDisabledException.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/exceptions/TableNotDisabledException.java?rev=1507494&r1=1507493&r2=1507494&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/exceptions/TableNotDisabledException.java (original)
+++ hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/exceptions/TableNotDisabledException.java Fri Jul 26 22:36:53 2013
@@ -22,14 +22,12 @@ import org.apache.hadoop.classification.
 import org.apache.hadoop.classification.InterfaceStability;
 import org.apache.hadoop.hbase.util.Bytes;
 
-import java.io.IOException;
-
 /**
  * Thrown if a table should be offline but is not
  */
 @InterfaceAudience.Public
 @InterfaceStability.Stable
-public class TableNotDisabledException extends IOException {
+public class TableNotDisabledException extends DoNotRetryIOException {
   private static final long serialVersionUID = 1L << 19 - 1L;
   /** default constructor */
   public TableNotDisabledException() {

Modified: hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/exceptions/TableNotEnabledException.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/exceptions/TableNotEnabledException.java?rev=1507494&r1=1507493&r2=1507494&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/exceptions/TableNotEnabledException.java (original)
+++ hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/exceptions/TableNotEnabledException.java Fri Jul 26 22:36:53 2013
@@ -22,14 +22,13 @@ import org.apache.hadoop.classification.
 import org.apache.hadoop.classification.InterfaceStability;
 import org.apache.hadoop.hbase.util.Bytes;
 
-import java.io.IOException;
 
 /**
  * Thrown if a table should be enabled but is not
  */
 @InterfaceAudience.Public
 @InterfaceStability.Stable
-public class TableNotEnabledException extends IOException {
+public class TableNotEnabledException extends DoNotRetryIOException {
   private static final long serialVersionUID = 262144L;
   /** default constructor */
   public TableNotEnabledException() {
@@ -50,4 +49,4 @@ public class TableNotEnabledException ex
   public TableNotEnabledException(byte[] tableName) {
     this(Bytes.toString(tableName));
   }
-}
+}
\ No newline at end of file



Mime
View raw message