[29/50] [abbrv] hbase git commit: HBASE-16345 RpcRetryingCallerWithReadReplicas#call() should catch some RegionServer Exceptions

2016-11-01 Thread larsh
HBASE-16345 RpcRetryingCallerWithReadReplicas#call() should catch some 
RegionServer Exceptions

Fix logic for
1). how to handle exception while waiting for reply from the primary replica.
2). handle exception from replicas while waiting for a correct response.

Signed-off-by: Esteban Gutierrez 


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

Branch: refs/heads/branch-1
Commit: a97aef51635539ea382699495613ebe1bf89e475
Parents: ae15133
Author: Huaxiang Sun 
Authored: Wed Oct 19 14:15:31 2016 -0700
Committer: Esteban Gutierrez 
Committed: Wed Oct 19 14:22:42 2016 -0700

--
 .../client/ResultBoundedCompletionService.java  | 118 +--
 .../RpcRetryingCallerWithReadReplicas.java  |  29 ++--
 .../client/ScannerCallableWithReplicas.java |  60 +---
 .../hbase/client/TestReplicaWithCluster.java| 143 ++-
 4 files changed, 304 insertions(+), 46 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/hbase/blob/a97aef51/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ResultBoundedCompletionService.java
--
diff --git 
a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ResultBoundedCompletionService.java
 
b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ResultBoundedCompletionService.java
index 9b32e93..2848c9d 100644
--- 
a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ResultBoundedCompletionService.java
+++ 
b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ResultBoundedCompletionService.java
@@ -18,13 +18,18 @@
  */
 package org.apache.hadoop.hbase.client;
 
+import java.util.ArrayList;
+import java.util.concurrent.CancellationException;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.Executor;
 import java.util.concurrent.RunnableFuture;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.TimeoutException;
 
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.hbase.classification.InterfaceAudience;
+import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
 import org.apache.htrace.Trace;
 
 /**
@@ -32,13 +37,21 @@ import org.apache.htrace.Trace;
  * Keeps the list of the futures, and allows to cancel them all.
  * This means as well that it can be used for a small set of tasks only.
  * Implementation is not Thread safe.
+ *
+ * CompletedTasks is implemented as a queue, the entry is added based on the 
time order. I.e,
+ * when the first task completes (whether it is a success or failure), it is 
added as a first
+ * entry in the queue, the next completed task is added as a second entry in 
the queue, ...
+ * When iterating through the queue, we know it is based on time order. If the 
first
+ * completed task succeeds, it is returned. If it is failure, the iteration 
goes on until it
+ * finds a success.
  */
 @InterfaceAudience.Private
 public class ResultBoundedCompletionService {
+  private static final Log LOG = 
LogFactory.getLog(ResultBoundedCompletionService.class);
   private final RpcRetryingCallerFactory retryingCallerFactory;
   private final Executor executor;
   private final QueueingFuture[] tasks; // all the tasks
-  private volatile QueueingFuture completed = null;
+  private final ArrayList completedTasks; // completed tasks
   private volatile boolean cancelled = false;
   
   class QueueingFuture implements RunnableFuture {
@@ -49,12 +62,14 @@ public class ResultBoundedCompletionService {
 private final int callTimeout;
 private final RpcRetryingCaller retryingCaller;
 private boolean resultObtained = false;
+private final int replicaId;  // replica id
 
 
-public QueueingFuture(RetryingCallable future, int callTimeout) {
+public QueueingFuture(RetryingCallable future, int callTimeout, int id) 
{
   this.future = future;
   this.callTimeout = callTimeout;
   this.retryingCaller = retryingCallerFactory.newCaller();
+  this.replicaId = id;
 }
 
 @SuppressWarnings("unchecked")
@@ -70,8 +85,8 @@ public class ResultBoundedCompletionService {
   } finally {
 synchronized (tasks) {
   // If this wasn't canceled then store the result.
-  if (!cancelled && completed == null) {
-completed = (QueueingFuture) QueueingFuture.this;
+  if (!cancelled) {
+completedTasks.add(QueueingFuture.this);
   }
 
   // Notify just in case there was someone waiting and this was 
canceled.
@@ -80,6 +95,7 @@ public class 

hbase git commit: HBASE-16345 RpcRetryingCallerWithReadReplicas#call() should catch some RegionServer Exceptions

2016-10-19 Thread esteban
Repository: hbase
Updated Branches:
  refs/heads/branch-1 ae151334b -> a97aef516


HBASE-16345 RpcRetryingCallerWithReadReplicas#call() should catch some 
RegionServer Exceptions

Fix logic for
1). how to handle exception while waiting for reply from the primary replica.
2). handle exception from replicas while waiting for a correct response.

Signed-off-by: Esteban Gutierrez 


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

Branch: refs/heads/branch-1
Commit: a97aef51635539ea382699495613ebe1bf89e475
Parents: ae15133
Author: Huaxiang Sun 
Authored: Wed Oct 19 14:15:31 2016 -0700
Committer: Esteban Gutierrez 
Committed: Wed Oct 19 14:22:42 2016 -0700

--
 .../client/ResultBoundedCompletionService.java  | 118 +--
 .../RpcRetryingCallerWithReadReplicas.java  |  29 ++--
 .../client/ScannerCallableWithReplicas.java |  60 +---
 .../hbase/client/TestReplicaWithCluster.java| 143 ++-
 4 files changed, 304 insertions(+), 46 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/hbase/blob/a97aef51/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ResultBoundedCompletionService.java
--
diff --git 
a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ResultBoundedCompletionService.java
 
b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ResultBoundedCompletionService.java
index 9b32e93..2848c9d 100644
--- 
a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ResultBoundedCompletionService.java
+++ 
b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ResultBoundedCompletionService.java
@@ -18,13 +18,18 @@
  */
 package org.apache.hadoop.hbase.client;
 
+import java.util.ArrayList;
+import java.util.concurrent.CancellationException;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.Executor;
 import java.util.concurrent.RunnableFuture;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.TimeoutException;
 
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.hbase.classification.InterfaceAudience;
+import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
 import org.apache.htrace.Trace;
 
 /**
@@ -32,13 +37,21 @@ import org.apache.htrace.Trace;
  * Keeps the list of the futures, and allows to cancel them all.
  * This means as well that it can be used for a small set of tasks only.
  * Implementation is not Thread safe.
+ *
+ * CompletedTasks is implemented as a queue, the entry is added based on the 
time order. I.e,
+ * when the first task completes (whether it is a success or failure), it is 
added as a first
+ * entry in the queue, the next completed task is added as a second entry in 
the queue, ...
+ * When iterating through the queue, we know it is based on time order. If the 
first
+ * completed task succeeds, it is returned. If it is failure, the iteration 
goes on until it
+ * finds a success.
  */
 @InterfaceAudience.Private
 public class ResultBoundedCompletionService {
+  private static final Log LOG = 
LogFactory.getLog(ResultBoundedCompletionService.class);
   private final RpcRetryingCallerFactory retryingCallerFactory;
   private final Executor executor;
   private final QueueingFuture[] tasks; // all the tasks
-  private volatile QueueingFuture completed = null;
+  private final ArrayList completedTasks; // completed tasks
   private volatile boolean cancelled = false;
   
   class QueueingFuture implements RunnableFuture {
@@ -49,12 +62,14 @@ public class ResultBoundedCompletionService {
 private final int callTimeout;
 private final RpcRetryingCaller retryingCaller;
 private boolean resultObtained = false;
+private final int replicaId;  // replica id
 
 
-public QueueingFuture(RetryingCallable future, int callTimeout) {
+public QueueingFuture(RetryingCallable future, int callTimeout, int id) 
{
   this.future = future;
   this.callTimeout = callTimeout;
   this.retryingCaller = retryingCallerFactory.newCaller();
+  this.replicaId = id;
 }
 
 @SuppressWarnings("unchecked")
@@ -70,8 +85,8 @@ public class ResultBoundedCompletionService {
   } finally {
 synchronized (tasks) {
   // If this wasn't canceled then store the result.
-  if (!cancelled && completed == null) {
-completed = (QueueingFuture) QueueingFuture.this;
+  if (!cancelled) {
+completedTasks.add(QueueingFuture.this);
   }
 
   // Notify just in case there was 

hbase git commit: HBASE-16345 RpcRetryingCallerWithReadReplicas#call() should catch some RegionServer Exceptions

2016-10-19 Thread esteban
Repository: hbase
Updated Branches:
  refs/heads/master d9ee25e82 -> 72db95388


HBASE-16345 RpcRetryingCallerWithReadReplicas#call() should catch some 
RegionServer Exceptions

Fix logic for
1). how to handle exception while waiting for reply from the primary replica.
2). handle exception from replicas while waiting for a correct response.

Signed-off-by: Esteban Gutierrez 


Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/72db9538
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/72db9538
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/72db9538

Branch: refs/heads/master
Commit: 72db95388664fb23314b2e6bb437b961c797f579
Parents: d9ee25e
Author: Huaxiang Sun 
Authored: Tue Oct 18 14:10:09 2016 -0700
Committer: Esteban Gutierrez 
Committed: Wed Oct 19 13:55:43 2016 -0700

--
 .../client/ResultBoundedCompletionService.java  | 118 --
 .../RpcRetryingCallerWithReadReplicas.java  |  32 ++--
 .../client/ScannerCallableWithReplicas.java |  60 ---
 .../hbase/client/TestReplicaWithCluster.java| 155 +--
 4 files changed, 310 insertions(+), 55 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/hbase/blob/72db9538/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ResultBoundedCompletionService.java
--
diff --git 
a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ResultBoundedCompletionService.java
 
b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ResultBoundedCompletionService.java
index 9b32e93..2848c9d 100644
--- 
a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ResultBoundedCompletionService.java
+++ 
b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ResultBoundedCompletionService.java
@@ -18,13 +18,18 @@
  */
 package org.apache.hadoop.hbase.client;
 
+import java.util.ArrayList;
+import java.util.concurrent.CancellationException;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.Executor;
 import java.util.concurrent.RunnableFuture;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.TimeoutException;
 
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.hbase.classification.InterfaceAudience;
+import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
 import org.apache.htrace.Trace;
 
 /**
@@ -32,13 +37,21 @@ import org.apache.htrace.Trace;
  * Keeps the list of the futures, and allows to cancel them all.
  * This means as well that it can be used for a small set of tasks only.
  * Implementation is not Thread safe.
+ *
+ * CompletedTasks is implemented as a queue, the entry is added based on the 
time order. I.e,
+ * when the first task completes (whether it is a success or failure), it is 
added as a first
+ * entry in the queue, the next completed task is added as a second entry in 
the queue, ...
+ * When iterating through the queue, we know it is based on time order. If the 
first
+ * completed task succeeds, it is returned. If it is failure, the iteration 
goes on until it
+ * finds a success.
  */
 @InterfaceAudience.Private
 public class ResultBoundedCompletionService {
+  private static final Log LOG = 
LogFactory.getLog(ResultBoundedCompletionService.class);
   private final RpcRetryingCallerFactory retryingCallerFactory;
   private final Executor executor;
   private final QueueingFuture[] tasks; // all the tasks
-  private volatile QueueingFuture completed = null;
+  private final ArrayList completedTasks; // completed tasks
   private volatile boolean cancelled = false;
   
   class QueueingFuture implements RunnableFuture {
@@ -49,12 +62,14 @@ public class ResultBoundedCompletionService {
 private final int callTimeout;
 private final RpcRetryingCaller retryingCaller;
 private boolean resultObtained = false;
+private final int replicaId;  // replica id
 
 
-public QueueingFuture(RetryingCallable future, int callTimeout) {
+public QueueingFuture(RetryingCallable future, int callTimeout, int id) 
{
   this.future = future;
   this.callTimeout = callTimeout;
   this.retryingCaller = retryingCallerFactory.newCaller();
+  this.replicaId = id;
 }
 
 @SuppressWarnings("unchecked")
@@ -70,8 +85,8 @@ public class ResultBoundedCompletionService {
   } finally {
 synchronized (tasks) {
   // If this wasn't canceled then store the result.
-  if (!cancelled && completed == null) {
-completed = (QueueingFuture) QueueingFuture.this;
+  if (!cancelled) {
+completedTasks.add(QueueingFuture.this);
   }
 
   // Notify just in case there was someone