From 1e93708268a211b97bc373d56461a797044907c8 Mon Sep 17 00:00:00 2001 From: jeffreyz Date: Sat, 24 Aug 2013 01:09:43 +0000 Subject: [PATCH] HBASE-9318: Procedure#waitForLatch may not throw error even there is one git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1517095 13f79535-47bb-0310-9956-ffa450edef68 --- .../java/org/apache/hadoop/hbase/procedure/Procedure.java | 4 ++++ .../hadoop/hbase/procedure/TestProcedureCoordinator.java | 5 +++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/procedure/Procedure.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/procedure/Procedure.java index adf94efaa46..ab4dfdadb53 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/procedure/Procedure.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/procedure/Procedure.java @@ -375,5 +375,9 @@ public class Procedure implements Callable, ForeignExceptionListener { + wakeFrequency + " ms)"); */ released = latch.await(wakeFrequency, TimeUnit.MILLISECONDS); } + // check error again in case an error raised during last wait + if (monitor != null) { + monitor.rethrowException(); + } } } diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/procedure/TestProcedureCoordinator.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/procedure/TestProcedureCoordinator.java index d0b62b29bc2..5da638f3e19 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/procedure/TestProcedureCoordinator.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/procedure/TestProcedureCoordinator.java @@ -39,6 +39,7 @@ import java.io.IOException; import java.util.Arrays; import java.util.List; import java.util.concurrent.ThreadPoolExecutor; +import java.util.concurrent.TimeUnit; import org.apache.hadoop.hbase.SmallTests; import org.apache.hadoop.hbase.errorhandling.ForeignException; @@ -136,7 +137,7 @@ public class TestProcedureCoordinator { // run the operation proc = coordinator.startProcedure(proc.getErrorMonitor(), procName, procData, expected); // and wait for it to finish - proc.waitForCompleted(); + while(!proc.completedLatch.await(WAKE_FREQUENCY, TimeUnit.MILLISECONDS)); verify(procSpy, atLeastOnce()).receive(any(ForeignException.class)); verify(coordinator, times(1)).rpcConnectionFailure(anyString(), eq(cause)); verify(controller, times(1)).sendGlobalBarrierAcquire(procSpy, procData, expected); @@ -168,7 +169,7 @@ public class TestProcedureCoordinator { // run the operation Procedure task = coordinator.startProcedure(spy.getErrorMonitor(), procName, procData, expected); // and wait for it to finish - task.waitForCompleted(); + while(!task.completedLatch.await(WAKE_FREQUENCY, TimeUnit.MILLISECONDS)); verify(spy, atLeastOnce()).receive(any(ForeignException.class)); verify(coordinator, times(1)).rpcConnectionFailure(anyString(), eq(cause)); verify(controller, times(1)).sendGlobalBarrierAcquire(eq(spy),