Repository: hbase Updated Branches: refs/heads/master 5e26ae043 -> 5b7894f92
http://git-wip-us.apache.org/repos/asf/hbase/blob/5b7894f9/hbase-protocol/src/main/protobuf/Master.proto ---------------------------------------------------------------------- diff --git a/hbase-protocol/src/main/protobuf/Master.proto b/hbase-protocol/src/main/protobuf/Master.proto index 2cd0b5f..c616840 100644 --- a/hbase-protocol/src/main/protobuf/Master.proto +++ b/hbase-protocol/src/main/protobuf/Master.proto @@ -30,6 +30,7 @@ import "HBase.proto"; import "Client.proto"; import "ClusterStatus.proto"; import "ErrorHandling.proto"; +import "Procedure.proto"; import "Quota.proto"; /* Column-level protobufs */ @@ -440,6 +441,13 @@ message AbortProcedureResponse { required bool is_procedure_aborted = 1; } +message ListProceduresRequest { +} + +message ListProceduresResponse { + repeated Procedure procedure = 1; +} + message SetQuotaRequest { optional string user_name = 1; optional string user_group = 2; @@ -720,4 +728,8 @@ service MasterService { /** Abort a procedure */ rpc AbortProcedure(AbortProcedureRequest) returns(AbortProcedureResponse); + + /** returns a list of procedures */ + rpc ListProcedures(ListProceduresRequest) + returns(ListProceduresResponse); } http://git-wip-us.apache.org/repos/asf/hbase/blob/5b7894f9/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java ---------------------------------------------------------------------- diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java index 75fe759..fba6bf5 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java @@ -65,6 +65,7 @@ import org.apache.hadoop.hbase.MetaTableAccessor; import org.apache.hadoop.hbase.NamespaceDescriptor; import org.apache.hadoop.hbase.NamespaceNotFoundException; import org.apache.hadoop.hbase.PleaseHoldException; +import org.apache.hadoop.hbase.ProcedureInfo; import org.apache.hadoop.hbase.Server; import org.apache.hadoop.hbase.ServerLoad; import org.apache.hadoop.hbase.ServerName; @@ -74,7 +75,6 @@ import org.apache.hadoop.hbase.TableNotDisabledException; import org.apache.hadoop.hbase.TableNotFoundException; import org.apache.hadoop.hbase.UnknownRegionException; import org.apache.hadoop.hbase.classification.InterfaceAudience; -import org.apache.hadoop.hbase.client.ClusterConnection; import org.apache.hadoop.hbase.client.RegionReplicaUtil; import org.apache.hadoop.hbase.client.Result; import org.apache.hadoop.hbase.client.TableState; @@ -2486,6 +2486,11 @@ public class HMaster extends HRegionServer implements MasterServices, Server { } @Override + public List<ProcedureInfo> listProcedures() throws IOException { + return this.procedureExecutor.listProcedures(); + } + + @Override public List<HTableDescriptor> listTableDescriptorsByNamespace(String name) throws IOException { ensureNamespaceExists(name); return listTableDescriptors(name, null, null, true); http://git-wip-us.apache.org/repos/asf/hbase/blob/5b7894f9/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterRpcServices.java ---------------------------------------------------------------------- diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterRpcServices.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterRpcServices.java index 85e3acc..0044996 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterRpcServices.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterRpcServices.java @@ -35,6 +35,7 @@ import org.apache.hadoop.hbase.HTableDescriptor; import org.apache.hadoop.hbase.MetaTableAccessor; import org.apache.hadoop.hbase.NamespaceDescriptor; import org.apache.hadoop.hbase.PleaseHoldException; +import org.apache.hadoop.hbase.ProcedureInfo; import org.apache.hadoop.hbase.ServerLoad; import org.apache.hadoop.hbase.ServerName; import org.apache.hadoop.hbase.TableName; @@ -51,7 +52,6 @@ import org.apache.hadoop.hbase.ipc.ServerRpcController; import org.apache.hadoop.hbase.mob.MobUtils; import org.apache.hadoop.hbase.procedure.MasterProcedureManager; import org.apache.hadoop.hbase.procedure2.Procedure; -import org.apache.hadoop.hbase.procedure2.ProcedureResult; import org.apache.hadoop.hbase.protobuf.ProtobufUtil; import org.apache.hadoop.hbase.protobuf.RequestConverter; import org.apache.hadoop.hbase.protobuf.ResponseConverter; @@ -123,6 +123,8 @@ import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.IsSnapshotDoneReq import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.IsSnapshotDoneResponse; import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.ListNamespaceDescriptorsRequest; import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.ListNamespaceDescriptorsResponse; +import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.ListProceduresRequest; +import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.ListProceduresResponse; import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.ListTableDescriptorsByNamespaceRequest; import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.ListTableDescriptorsByNamespaceResponse; import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.ListTableNamesByNamespaceRequest; @@ -1032,15 +1034,15 @@ public class MasterRpcServices extends RSRpcServices master.checkInitialized(); GetProcedureResultResponse.Builder builder = GetProcedureResultResponse.newBuilder(); - Pair<ProcedureResult, Procedure> v = master.getMasterProcedureExecutor() + Pair<ProcedureInfo, Procedure> v = master.getMasterProcedureExecutor() .getResultOrProcedure(request.getProcId()); if (v.getFirst() != null) { - ProcedureResult result = v.getFirst(); + ProcedureInfo result = v.getFirst(); builder.setState(GetProcedureResultResponse.State.FINISHED); builder.setStartTime(result.getStartTime()); builder.setLastUpdate(result.getLastUpdate()); if (result.isFailed()) { - builder.setException(result.getException().convert()); + builder.setException(result.getForeignExceptionMessage()); } if (result.hasResultData()) { builder.setResult(ByteStringer.wrap(result.getResult())); @@ -1089,6 +1091,22 @@ public class MasterRpcServices extends RSRpcServices } @Override + public ListProceduresResponse listProcedures( + RpcController rpcController, + ListProceduresRequest request) throws ServiceException { + try { + ListProceduresResponse.Builder response = + ListProceduresResponse.newBuilder(); + for(ProcedureInfo p: master.listProcedures()) { + response.addProcedure(ProcedureInfo.convertToProcedureProto(p)); + } + return response.build(); + } catch (IOException e) { + throw new ServiceException(e); + } + } + + @Override public ListTableDescriptorsByNamespaceResponse listTableDescriptorsByNamespace(RpcController c, ListTableDescriptorsByNamespaceRequest request) throws ServiceException { try { http://git-wip-us.apache.org/repos/asf/hbase/blob/5b7894f9/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterServices.java ---------------------------------------------------------------------- diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterServices.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterServices.java index e7f4f21..9a8a334 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterServices.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterServices.java @@ -26,6 +26,7 @@ import org.apache.hadoop.hbase.HColumnDescriptor; import org.apache.hadoop.hbase.HRegionInfo; import org.apache.hadoop.hbase.HTableDescriptor; import org.apache.hadoop.hbase.NamespaceDescriptor; +import org.apache.hadoop.hbase.ProcedureInfo; import org.apache.hadoop.hbase.Server; import org.apache.hadoop.hbase.TableDescriptors; import org.apache.hadoop.hbase.TableName; @@ -344,6 +345,13 @@ public interface MasterServices extends Server { public List<NamespaceDescriptor> listNamespaceDescriptors() throws IOException; /** + * List procedures + * @return procedure list + * @throws IOException + */ + public List<ProcedureInfo> listProcedures() throws IOException; + + /** * Get list of table descriptors by namespace * @param name namespace name * @return descriptors http://git-wip-us.apache.org/repos/asf/hbase/blob/5b7894f9/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/ProcedureSyncWait.java ---------------------------------------------------------------------- diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/ProcedureSyncWait.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/ProcedureSyncWait.java index 1eb0073..6a7e267 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/ProcedureSyncWait.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/ProcedureSyncWait.java @@ -24,12 +24,12 @@ import java.util.List; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; - import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hbase.CoordinatedStateException; import org.apache.hadoop.hbase.HRegionInfo; import org.apache.hadoop.hbase.MetaTableAccessor; import org.apache.hadoop.hbase.NotAllMetaRegionsOnlineException; +import org.apache.hadoop.hbase.ProcedureInfo; import org.apache.hadoop.hbase.ServerName; import org.apache.hadoop.hbase.TableName; import org.apache.hadoop.hbase.classification.InterfaceAudience; @@ -41,7 +41,7 @@ import org.apache.hadoop.hbase.master.RegionState.State; import org.apache.hadoop.hbase.master.ServerManager; import org.apache.hadoop.hbase.procedure2.Procedure; import org.apache.hadoop.hbase.procedure2.ProcedureExecutor; -import org.apache.hadoop.hbase.procedure2.ProcedureResult; +import org.apache.hadoop.hbase.procedure2.RemoteProcedureException; import org.apache.hadoop.hbase.quotas.MasterQuotaManager; import org.apache.hadoop.hbase.util.EnvironmentEdgeManager; import org.apache.hadoop.hbase.util.Threads; @@ -78,11 +78,12 @@ public final class ProcedureSyncWait { // Dev Consideration: are we waiting forever, or we can set up some timeout value? Threads.sleepWithoutInterrupt(250); } - ProcedureResult result = procExec.getResult(procId); + ProcedureInfo result = procExec.getResult(procId); if (result != null) { if (result.isFailed()) { // If the procedure fails, we should always have an exception captured. Throw it. - throw result.getException().unwrapRemoteException(); + throw RemoteProcedureException.fromProto( + result.getForeignExceptionMessage()).unwrapRemoteException(); } return result.getResult(); } else { http://git-wip-us.apache.org/repos/asf/hbase/blob/5b7894f9/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAdmin2.java ---------------------------------------------------------------------- diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAdmin2.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAdmin2.java index dc06071..6f83d4a 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAdmin2.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAdmin2.java @@ -26,7 +26,6 @@ import static org.junit.Assert.fail; import java.io.IOException; import java.util.List; import java.util.Random; -import java.util.concurrent.Future; import java.util.concurrent.atomic.AtomicInteger; import org.apache.commons.logging.Log; @@ -41,6 +40,7 @@ import org.apache.hadoop.hbase.HTableDescriptor; import org.apache.hadoop.hbase.MasterNotRunningException; import org.apache.hadoop.hbase.MiniHBaseCluster; import org.apache.hadoop.hbase.NotServingRegionException; +import org.apache.hadoop.hbase.ProcedureInfo; import org.apache.hadoop.hbase.ServerName; import org.apache.hadoop.hbase.TableExistsException; import org.apache.hadoop.hbase.TableName; @@ -52,7 +52,6 @@ import org.apache.hadoop.hbase.constraint.ConstraintException; import org.apache.hadoop.hbase.master.AssignmentManager; import org.apache.hadoop.hbase.master.HMaster; import org.apache.hadoop.hbase.protobuf.ProtobufUtil; -import org.apache.hadoop.hbase.regionserver.HRegion; import org.apache.hadoop.hbase.regionserver.HRegionServer; import org.apache.hadoop.hbase.regionserver.Region; import org.apache.hadoop.hbase.testclassification.ClientTests; @@ -738,4 +737,10 @@ public class TestAdmin2 { boolean abortResult = admin.abortProcedure(procId, true); assertFalse(abortResult); } + + @Test(timeout = 300000) + public void testListProcedures() throws Exception { + ProcedureInfo[] procList = admin.listProcedures(); + assertTrue(procList.length >= 0); + } } http://git-wip-us.apache.org/repos/asf/hbase/blob/5b7894f9/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestCatalogJanitor.java ---------------------------------------------------------------------- diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestCatalogJanitor.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestCatalogJanitor.java index c7fe187..e9816e2 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestCatalogJanitor.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestCatalogJanitor.java @@ -48,6 +48,7 @@ import org.apache.hadoop.hbase.HTableDescriptor; import org.apache.hadoop.hbase.MetaMockingUtil; import org.apache.hadoop.hbase.NamespaceDescriptor; import org.apache.hadoop.hbase.NotAllMetaRegionsOnlineException; +import org.apache.hadoop.hbase.ProcedureInfo; import org.apache.hadoop.hbase.Server; import org.apache.hadoop.hbase.ServerName; import org.apache.hadoop.hbase.TableDescriptor; @@ -442,6 +443,11 @@ public class TestCatalogJanitor { } @Override + public List<ProcedureInfo> listProcedures() throws IOException { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + @Override public List<HTableDescriptor> listTableDescriptorsByNamespace(String name) throws IOException { return null; //To change body of implemented methods use File | Settings | File Templates. } http://git-wip-us.apache.org/repos/asf/hbase/blob/5b7894f9/hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestAddColumnFamilyProcedure.java ---------------------------------------------------------------------- diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestAddColumnFamilyProcedure.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestAddColumnFamilyProcedure.java index 5d8da9c..a98d468 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestAddColumnFamilyProcedure.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestAddColumnFamilyProcedure.java @@ -28,9 +28,9 @@ import org.apache.hadoop.hbase.HColumnDescriptor; import org.apache.hadoop.hbase.HConstants; import org.apache.hadoop.hbase.HTableDescriptor; import org.apache.hadoop.hbase.InvalidFamilyOperationException; +import org.apache.hadoop.hbase.ProcedureInfo; import org.apache.hadoop.hbase.TableName; import org.apache.hadoop.hbase.procedure2.ProcedureExecutor; -import org.apache.hadoop.hbase.procedure2.ProcedureResult; import org.apache.hadoop.hbase.procedure2.ProcedureTestingUtility; import org.apache.hadoop.hbase.protobuf.generated.MasterProcedureProtos.AddColumnFamilyState; import org.apache.hadoop.hbase.testclassification.MasterTests; @@ -153,10 +153,11 @@ public class TestAddColumnFamilyProcedure { ProcedureTestingUtility.waitProcedure(procExec, procId2); // Second add should fail with InvalidFamilyOperationException - ProcedureResult result = procExec.getResult(procId2); + ProcedureInfo result = procExec.getResult(procId2); assertTrue(result.isFailed()); - LOG.debug("Add failed with exception: " + result.getException()); - assertTrue(result.getException().getCause() instanceof InvalidFamilyOperationException); + LOG.debug("Add failed with exception: " + result.getExceptionFullMessage()); + assertTrue( + ProcedureTestingUtility.getExceptionCause(result) instanceof InvalidFamilyOperationException); // Do the same add the existing column family - this time offline UTIL.getHBaseAdmin().disableTable(tableName); @@ -170,8 +171,9 @@ public class TestAddColumnFamilyProcedure { // Second add should fail with InvalidFamilyOperationException result = procExec.getResult(procId3); assertTrue(result.isFailed()); - LOG.debug("Add failed with exception: " + result.getException()); - assertTrue(result.getException().getCause() instanceof InvalidFamilyOperationException); + LOG.debug("Add failed with exception: " + result.getExceptionFullMessage()); + assertTrue( + ProcedureTestingUtility.getExceptionCause(result) instanceof InvalidFamilyOperationException); } @Test(timeout=60000) http://git-wip-us.apache.org/repos/asf/hbase/blob/5b7894f9/hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestCreateNamespaceProcedure.java ---------------------------------------------------------------------- diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestCreateNamespaceProcedure.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestCreateNamespaceProcedure.java index d25e61f..c01755f 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestCreateNamespaceProcedure.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestCreateNamespaceProcedure.java @@ -32,9 +32,9 @@ import org.apache.hadoop.hbase.HConstants; import org.apache.hadoop.hbase.NamespaceDescriptor; import org.apache.hadoop.hbase.NamespaceExistException; import org.apache.hadoop.hbase.NamespaceNotFoundException; +import org.apache.hadoop.hbase.ProcedureInfo; import org.apache.hadoop.hbase.constraint.ConstraintException; import org.apache.hadoop.hbase.procedure2.ProcedureExecutor; -import org.apache.hadoop.hbase.procedure2.ProcedureResult; import org.apache.hadoop.hbase.procedure2.ProcedureTestingUtility; import org.apache.hadoop.hbase.protobuf.generated.MasterProcedureProtos.CreateNamespaceState; import org.apache.hadoop.hbase.testclassification.MasterTests; @@ -126,10 +126,11 @@ public class TestCreateNamespaceProcedure { ProcedureTestingUtility.waitProcedure(procExec, procId2); // Second create should fail with NamespaceExistException - ProcedureResult result = procExec.getResult(procId2); + ProcedureInfo result = procExec.getResult(procId2); assertTrue(result.isFailed()); - LOG.debug("Create namespace failed with exception: " + result.getException()); - assertTrue(result.getException().getCause() instanceof NamespaceExistException); + LOG.debug("Create namespace failed with exception: " + result.getExceptionFullMessage()); + assertTrue( + ProcedureTestingUtility.getExceptionCause(result) instanceof NamespaceExistException); } @Test(timeout=60000) @@ -144,10 +145,11 @@ public class TestCreateNamespaceProcedure { nonce); // Wait the completion ProcedureTestingUtility.waitProcedure(procExec, procId); - ProcedureResult result = procExec.getResult(procId); + ProcedureInfo result = procExec.getResult(procId); assertTrue(result.isFailed()); - LOG.debug("Create namespace failed with exception: " + result.getException()); - assertTrue(result.getException().getCause() instanceof NamespaceExistException); + LOG.debug("Create namespace failed with exception: " + result.getExceptionFullMessage()); + assertTrue( + ProcedureTestingUtility.getExceptionCause(result) instanceof NamespaceExistException); } @Test(timeout=60000) @@ -166,10 +168,10 @@ public class TestCreateNamespaceProcedure { nonce); // Wait the completion ProcedureTestingUtility.waitProcedure(procExec, procId); - ProcedureResult result = procExec.getResult(procId); + ProcedureInfo result = procExec.getResult(procId); assertTrue(result.isFailed()); - LOG.debug("Create namespace failed with exception: " + result.getException()); - assertTrue(result.getException().getCause() instanceof ConstraintException); + LOG.debug("Create namespace failed with exception: " + result.getExceptionFullMessage()); + assertTrue(ProcedureTestingUtility.getExceptionCause(result) instanceof ConstraintException); } @Test(timeout=60000) @@ -188,10 +190,10 @@ public class TestCreateNamespaceProcedure { nonce); // Wait the completion ProcedureTestingUtility.waitProcedure(procExec, procId); - ProcedureResult result = procExec.getResult(procId); + ProcedureInfo result = procExec.getResult(procId); assertTrue(result.isFailed()); - LOG.debug("Create namespace failed with exception: " + result.getException()); - assertTrue(result.getException().getCause() instanceof ConstraintException); + LOG.debug("Create namespace failed with exception: " + result.getExceptionFullMessage()); + assertTrue(ProcedureTestingUtility.getExceptionCause(result) instanceof ConstraintException); } @Test(timeout=60000) http://git-wip-us.apache.org/repos/asf/hbase/blob/5b7894f9/hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestDeleteColumnFamilyProcedure.java ---------------------------------------------------------------------- diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestDeleteColumnFamilyProcedure.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestDeleteColumnFamilyProcedure.java index ad68354..3980274 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestDeleteColumnFamilyProcedure.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestDeleteColumnFamilyProcedure.java @@ -28,9 +28,9 @@ import org.apache.hadoop.hbase.HConstants; import org.apache.hadoop.hbase.HRegionInfo; import org.apache.hadoop.hbase.HTableDescriptor; import org.apache.hadoop.hbase.InvalidFamilyOperationException; +import org.apache.hadoop.hbase.ProcedureInfo; import org.apache.hadoop.hbase.TableName; import org.apache.hadoop.hbase.procedure2.ProcedureExecutor; -import org.apache.hadoop.hbase.procedure2.ProcedureResult; import org.apache.hadoop.hbase.procedure2.ProcedureTestingUtility; import org.apache.hadoop.hbase.protobuf.generated.MasterProcedureProtos.DeleteColumnFamilyState; import org.apache.hadoop.hbase.testclassification.MasterTests; @@ -151,10 +151,11 @@ public class TestDeleteColumnFamilyProcedure { ProcedureTestingUtility.waitProcedure(procExec, procId2); // Second delete should fail with InvalidFamilyOperationException - ProcedureResult result = procExec.getResult(procId2); + ProcedureInfo result = procExec.getResult(procId2); assertTrue(result.isFailed()); - LOG.debug("Delete online failed with exception: " + result.getException()); - assertTrue(result.getException().getCause() instanceof InvalidFamilyOperationException); + LOG.debug("Delete online failed with exception: " + result.getExceptionFullMessage()); + assertTrue( + ProcedureTestingUtility.getExceptionCause(result) instanceof InvalidFamilyOperationException); // Try again, this time with table disabled. UTIL.getHBaseAdmin().disableTable(tableName); @@ -167,8 +168,9 @@ public class TestDeleteColumnFamilyProcedure { // Expect fail with InvalidFamilyOperationException result = procExec.getResult(procId2); assertTrue(result.isFailed()); - LOG.debug("Delete offline failed with exception: " + result.getException()); - assertTrue(result.getException().getCause() instanceof InvalidFamilyOperationException); + LOG.debug("Delete offline failed with exception: " + result.getExceptionFullMessage()); + assertTrue( + ProcedureTestingUtility.getExceptionCause(result) instanceof InvalidFamilyOperationException); } @Test(timeout=60000) @@ -219,10 +221,11 @@ public class TestDeleteColumnFamilyProcedure { // Wait the completion ProcedureTestingUtility.waitProcedure(procExec, procId1); - ProcedureResult result = procExec.getResult(procId1); + ProcedureInfo result = procExec.getResult(procId1); assertTrue(result.isFailed()); - LOG.debug("Delete failed with exception: " + result.getException()); - assertTrue(result.getException().getCause() instanceof InvalidFamilyOperationException); + LOG.debug("Delete failed with exception: " + result.getExceptionFullMessage()); + assertTrue( + ProcedureTestingUtility.getExceptionCause(result) instanceof InvalidFamilyOperationException); } @Test(timeout=60000) http://git-wip-us.apache.org/repos/asf/hbase/blob/5b7894f9/hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestDeleteNamespaceProcedure.java ---------------------------------------------------------------------- diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestDeleteNamespaceProcedure.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestDeleteNamespaceProcedure.java index dd22de7..4c5f87b 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestDeleteNamespaceProcedure.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestDeleteNamespaceProcedure.java @@ -32,10 +32,10 @@ import org.apache.hadoop.hbase.HConstants; import org.apache.hadoop.hbase.HTableDescriptor; import org.apache.hadoop.hbase.NamespaceDescriptor; import org.apache.hadoop.hbase.NamespaceNotFoundException; +import org.apache.hadoop.hbase.ProcedureInfo; import org.apache.hadoop.hbase.TableName; import org.apache.hadoop.hbase.constraint.ConstraintException; import org.apache.hadoop.hbase.procedure2.ProcedureExecutor; -import org.apache.hadoop.hbase.procedure2.ProcedureResult; import org.apache.hadoop.hbase.procedure2.ProcedureTestingUtility; import org.apache.hadoop.hbase.protobuf.generated.MasterProcedureProtos.DeleteNamespaceState; import org.apache.hadoop.hbase.testclassification.MasterTests; @@ -124,10 +124,11 @@ public class TestDeleteNamespaceProcedure { // Wait the completion ProcedureTestingUtility.waitProcedure(procExec, procId); // Expect fail with NamespaceNotFoundException - ProcedureResult result = procExec.getResult(procId); + ProcedureInfo result = procExec.getResult(procId); assertTrue(result.isFailed()); - LOG.debug("Delete namespace failed with exception: " + result.getException()); - assertTrue(result.getException().getCause() instanceof NamespaceNotFoundException); + LOG.debug("Delete namespace failed with exception: " + result.getExceptionFullMessage()); + assertTrue( + ProcedureTestingUtility.getExceptionCause(result) instanceof NamespaceNotFoundException); } @Test(timeout=60000) @@ -141,10 +142,10 @@ public class TestDeleteNamespaceProcedure { nonce); // Wait the completion ProcedureTestingUtility.waitProcedure(procExec, procId); - ProcedureResult result = procExec.getResult(procId); + ProcedureInfo result = procExec.getResult(procId); assertTrue(result.isFailed()); - LOG.debug("Delete namespace failed with exception: " + result.getException()); - assertTrue(result.getException().getCause() instanceof ConstraintException); + LOG.debug("Delete namespace failed with exception: " + result.getExceptionFullMessage()); + assertTrue(ProcedureTestingUtility.getExceptionCause(result) instanceof ConstraintException); } @Test(timeout=60000) @@ -163,10 +164,10 @@ public class TestDeleteNamespaceProcedure { nonce); // Wait the completion ProcedureTestingUtility.waitProcedure(procExec, procId); - ProcedureResult result = procExec.getResult(procId); + ProcedureInfo result = procExec.getResult(procId); assertTrue(result.isFailed()); - LOG.debug("Delete namespace failed with exception: " + result.getException()); - assertTrue(result.getException().getCause() instanceof ConstraintException); + LOG.debug("Delete namespace failed with exception: " + result.getExceptionFullMessage()); + assertTrue(ProcedureTestingUtility.getExceptionCause(result) instanceof ConstraintException); } @Test(timeout=60000) http://git-wip-us.apache.org/repos/asf/hbase/blob/5b7894f9/hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestDeleteTableProcedure.java ---------------------------------------------------------------------- diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestDeleteTableProcedure.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestDeleteTableProcedure.java index f4afd31..4f62537 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestDeleteTableProcedure.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestDeleteTableProcedure.java @@ -25,11 +25,11 @@ import org.apache.hadoop.hbase.HBaseTestingUtility; import org.apache.hadoop.hbase.HConstants; import org.apache.hadoop.hbase.HTableDescriptor; import org.apache.hadoop.hbase.HRegionInfo; +import org.apache.hadoop.hbase.ProcedureInfo; import org.apache.hadoop.hbase.TableName; import org.apache.hadoop.hbase.TableNotDisabledException; import org.apache.hadoop.hbase.TableNotFoundException; import org.apache.hadoop.hbase.procedure2.ProcedureExecutor; -import org.apache.hadoop.hbase.procedure2.ProcedureResult; import org.apache.hadoop.hbase.procedure2.ProcedureTestingUtility; import org.apache.hadoop.hbase.protobuf.generated.MasterProcedureProtos.DeleteTableState; import org.apache.hadoop.hbase.testclassification.MasterTests; @@ -142,10 +142,10 @@ public class TestDeleteTableProcedure { UTIL.getHBaseCluster().getMaster(), tableName, regions, "f"); // Second delete should fail with TableNotFound - ProcedureResult result = procExec.getResult(procId2); + ProcedureInfo result = procExec.getResult(procId2); assertTrue(result.isFailed()); - LOG.debug("Delete failed with exception: " + result.getException()); - assertTrue(result.getException().getCause() instanceof TableNotFoundException); + LOG.debug("Delete failed with exception: " + result.getExceptionFullMessage()); + assertTrue(ProcedureTestingUtility.getExceptionCause(result) instanceof TableNotFoundException); } @Test(timeout=60000) http://git-wip-us.apache.org/repos/asf/hbase/blob/5b7894f9/hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestDisableTableProcedure.java ---------------------------------------------------------------------- diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestDisableTableProcedure.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestDisableTableProcedure.java index 6959af9..eb58cd5 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestDisableTableProcedure.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestDisableTableProcedure.java @@ -26,10 +26,10 @@ import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hbase.HBaseTestingUtility; import org.apache.hadoop.hbase.HConstants; import org.apache.hadoop.hbase.HTableDescriptor; +import org.apache.hadoop.hbase.ProcedureInfo; import org.apache.hadoop.hbase.TableName; import org.apache.hadoop.hbase.TableNotEnabledException; import org.apache.hadoop.hbase.procedure2.ProcedureExecutor; -import org.apache.hadoop.hbase.procedure2.ProcedureResult; import org.apache.hadoop.hbase.procedure2.ProcedureTestingUtility; import org.apache.hadoop.hbase.protobuf.generated.MasterProcedureProtos.DisableTableState; import org.apache.hadoop.hbase.testclassification.MasterTests; @@ -126,10 +126,11 @@ public class TestDisableTableProcedure { procExec.getEnvironment(), tableName, false), nonceGroup + 1, nonce + 1); // Wait the completion ProcedureTestingUtility.waitProcedure(procExec, procId2); - ProcedureResult result = procExec.getResult(procId2); + ProcedureInfo result = procExec.getResult(procId2); assertTrue(result.isFailed()); - LOG.debug("Disable failed with exception: " + result.getException()); - assertTrue(result.getException().getCause() instanceof TableNotEnabledException); + LOG.debug("Disable failed with exception: " + result.getExceptionFullMessage()); + assertTrue( + ProcedureTestingUtility.getExceptionCause(result) instanceof TableNotEnabledException); // Disable the table - expect failure from ProcedurePrepareLatch try { http://git-wip-us.apache.org/repos/asf/hbase/blob/5b7894f9/hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestEnableTableProcedure.java ---------------------------------------------------------------------- diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestEnableTableProcedure.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestEnableTableProcedure.java index 0204e52..5c2aa29 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestEnableTableProcedure.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestEnableTableProcedure.java @@ -26,10 +26,10 @@ import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hbase.HBaseTestingUtility; import org.apache.hadoop.hbase.HConstants; import org.apache.hadoop.hbase.HTableDescriptor; +import org.apache.hadoop.hbase.ProcedureInfo; import org.apache.hadoop.hbase.TableName; import org.apache.hadoop.hbase.TableNotDisabledException; import org.apache.hadoop.hbase.procedure2.ProcedureExecutor; -import org.apache.hadoop.hbase.procedure2.ProcedureResult; import org.apache.hadoop.hbase.procedure2.ProcedureTestingUtility; import org.apache.hadoop.hbase.protobuf.generated.MasterProcedureProtos.EnableTableState; import org.apache.hadoop.hbase.testclassification.MasterTests; @@ -141,10 +141,11 @@ public class TestEnableTableProcedure { new EnableTableProcedure(procExec.getEnvironment(), tableName, false), nonceGroup, nonce); ProcedureTestingUtility.waitProcedure(procExec, procId1); - ProcedureResult result = procExec.getResult(procId1); + ProcedureInfo result = procExec.getResult(procId1); assertTrue(result.isFailed()); - LOG.debug("Enable failed with exception: " + result.getException()); - assertTrue(result.getException().getCause() instanceof TableNotDisabledException); + LOG.debug("Enable failed with exception: " + result.getExceptionFullMessage()); + assertTrue( + ProcedureTestingUtility.getExceptionCause(result) instanceof TableNotDisabledException); // Enable the table with skipping table state check flag (simulate recovery scenario) long procId2 = procExec.submitProcedure( http://git-wip-us.apache.org/repos/asf/hbase/blob/5b7894f9/hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestModifyColumnFamilyProcedure.java ---------------------------------------------------------------------- diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestModifyColumnFamilyProcedure.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestModifyColumnFamilyProcedure.java index 3b40955..e983459 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestModifyColumnFamilyProcedure.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestModifyColumnFamilyProcedure.java @@ -28,9 +28,9 @@ import org.apache.hadoop.hbase.HColumnDescriptor; import org.apache.hadoop.hbase.HConstants; import org.apache.hadoop.hbase.HTableDescriptor; import org.apache.hadoop.hbase.InvalidFamilyOperationException; +import org.apache.hadoop.hbase.ProcedureInfo; import org.apache.hadoop.hbase.TableName; import org.apache.hadoop.hbase.procedure2.ProcedureExecutor; -import org.apache.hadoop.hbase.procedure2.ProcedureResult; import org.apache.hadoop.hbase.procedure2.ProcedureTestingUtility; import org.apache.hadoop.hbase.protobuf.generated.MasterProcedureProtos.ModifyColumnFamilyState; import org.apache.hadoop.hbase.testclassification.MasterTests; @@ -146,10 +146,11 @@ public class TestModifyColumnFamilyProcedure { // Wait the completion ProcedureTestingUtility.waitProcedure(procExec, procId1); - ProcedureResult result = procExec.getResult(procId1); + ProcedureInfo result = procExec.getResult(procId1); assertTrue(result.isFailed()); - LOG.debug("Modify failed with exception: " + result.getException()); - assertTrue(result.getException().getCause() instanceof InvalidFamilyOperationException); + LOG.debug("Modify failed with exception: " + result.getExceptionFullMessage()); + assertTrue( + ProcedureTestingUtility.getExceptionCause(result) instanceof InvalidFamilyOperationException); } @Test(timeout=60000) http://git-wip-us.apache.org/repos/asf/hbase/blob/5b7894f9/hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestModifyNamespaceProcedure.java ---------------------------------------------------------------------- diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestModifyNamespaceProcedure.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestModifyNamespaceProcedure.java index e946043..9208df7 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestModifyNamespaceProcedure.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestModifyNamespaceProcedure.java @@ -29,9 +29,9 @@ import org.apache.hadoop.hbase.HConstants; import org.apache.hadoop.hbase.HTableDescriptor; import org.apache.hadoop.hbase.NamespaceDescriptor; import org.apache.hadoop.hbase.NamespaceNotFoundException; +import org.apache.hadoop.hbase.ProcedureInfo; import org.apache.hadoop.hbase.constraint.ConstraintException; import org.apache.hadoop.hbase.procedure2.ProcedureExecutor; -import org.apache.hadoop.hbase.procedure2.ProcedureResult; import org.apache.hadoop.hbase.procedure2.ProcedureTestingUtility; import org.apache.hadoop.hbase.protobuf.generated.MasterProcedureProtos.ModifyNamespaceState; import org.apache.hadoop.hbase.testclassification.MasterTests; @@ -150,10 +150,11 @@ public class TestModifyNamespaceProcedure { ProcedureTestingUtility.waitProcedure(procExec, procId); // Expect fail with NamespaceNotFoundException - ProcedureResult result = procExec.getResult(procId); + ProcedureInfo result = procExec.getResult(procId); assertTrue(result.isFailed()); - LOG.debug("modify namespace failed with exception: " + result.getException()); - assertTrue(result.getException().getCause() instanceof NamespaceNotFoundException); + LOG.debug("modify namespace failed with exception: " + result.getExceptionFullMessage()); + assertTrue( + ProcedureTestingUtility.getExceptionCause(result) instanceof NamespaceNotFoundException); } @Test(timeout=60000) @@ -175,10 +176,10 @@ public class TestModifyNamespaceProcedure { nonce); // Wait the completion ProcedureTestingUtility.waitProcedure(procExec, procId); - ProcedureResult result = procExec.getResult(procId); + ProcedureInfo result = procExec.getResult(procId); assertTrue(result.isFailed()); - LOG.debug("Modify namespace failed with exception: " + result.getException()); - assertTrue(result.getException().getCause() instanceof ConstraintException); + LOG.debug("Modify namespace failed with exception: " + result.getExceptionFullMessage()); + assertTrue(ProcedureTestingUtility.getExceptionCause(result) instanceof ConstraintException); } @Test(timeout=60000) @@ -200,10 +201,10 @@ public class TestModifyNamespaceProcedure { nonce); // Wait the completion ProcedureTestingUtility.waitProcedure(procExec, procId); - ProcedureResult result = procExec.getResult(procId); + ProcedureInfo result = procExec.getResult(procId); assertTrue(result.isFailed()); - LOG.debug("Modify namespace failed with exception: " + result.getException()); - assertTrue(result.getException().getCause() instanceof ConstraintException); + LOG.debug("Modify namespace failed with exception: " + result.getExceptionFullMessage()); + assertTrue(ProcedureTestingUtility.getExceptionCause(result) instanceof ConstraintException); } @Test(timeout = 60000) http://git-wip-us.apache.org/repos/asf/hbase/blob/5b7894f9/hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestProcedureAdmin.java ---------------------------------------------------------------------- diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestProcedureAdmin.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestProcedureAdmin.java index d304ecd..39808db 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestProcedureAdmin.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestProcedureAdmin.java @@ -19,6 +19,7 @@ package org.apache.hadoop.hbase.master.procedure; import java.util.Random; +import java.util.List; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -27,11 +28,13 @@ import org.apache.hadoop.hbase.HBaseTestingUtility; import org.apache.hadoop.hbase.HConstants; import org.apache.hadoop.hbase.HRegionInfo; import org.apache.hadoop.hbase.HTableDescriptor; +import org.apache.hadoop.hbase.ProcedureInfo; import org.apache.hadoop.hbase.TableName; import org.apache.hadoop.hbase.procedure2.ProcedureExecutor; import org.apache.hadoop.hbase.procedure2.ProcedureTestingUtility; import org.apache.hadoop.hbase.testclassification.MasterTests; import org.apache.hadoop.hbase.testclassification.MediumTests; +import org.apache.hadoop.hbase.protobuf.generated.ProcedureProtos.ProcedureState; import org.junit.After; import org.junit.AfterClass; import org.junit.Before; @@ -181,6 +184,41 @@ public class TestProcedureAdmin { assertFalse(abortResult); } + @Test(timeout=60000) + public void testListProcedure() throws Exception { + final TableName tableName = TableName.valueOf("testListProcedure"); + final ProcedureExecutor<MasterProcedureEnv> procExec = getMasterProcedureExecutor(); + + MasterProcedureTestingUtility.createTable(procExec, tableName, null, "f"); + ProcedureTestingUtility.waitNoProcedureRunning(procExec); + ProcedureTestingUtility.setKillAndToggleBeforeStoreUpdate(procExec, true); + + long procId = procExec.submitProcedure( + new DisableTableProcedure(procExec.getEnvironment(), tableName, false), nonceGroup, nonce); + + List<ProcedureInfo> listProcedures = procExec.listProcedures(); + assertTrue(listProcedures.size() >= 1); + boolean found = false; + for (ProcedureInfo procInfo: listProcedures) { + if (procInfo.getProcId() == procId) { + assertTrue(procInfo.getProcState() == ProcedureState.RUNNABLE); + found = true; + } else { + assertTrue(procInfo.getProcState() == ProcedureState.FINISHED); + } + } + assertTrue(found); + + ProcedureTestingUtility.setKillAndToggleBeforeStoreUpdate(procExec, false); + ProcedureTestingUtility.restart(procExec); + ProcedureTestingUtility.waitNoProcedureRunning(procExec); + ProcedureTestingUtility.assertProcNotFailed(procExec, procId); + listProcedures = procExec.listProcedures(); + for (ProcedureInfo procInfo: listProcedures) { + assertTrue(procInfo.getProcState() == ProcedureState.FINISHED); + } + } + private ProcedureExecutor<MasterProcedureEnv> getMasterProcedureExecutor() { return UTIL.getHBaseCluster().getMaster().getMasterProcedureExecutor(); } http://git-wip-us.apache.org/repos/asf/hbase/blob/5b7894f9/hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestTruncateTableProcedure.java ---------------------------------------------------------------------- diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestTruncateTableProcedure.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestTruncateTableProcedure.java index e9f5746..6490a92 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestTruncateTableProcedure.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestTruncateTableProcedure.java @@ -25,11 +25,11 @@ import org.apache.hadoop.hbase.HBaseTestingUtility; import org.apache.hadoop.hbase.HConstants; import org.apache.hadoop.hbase.HTableDescriptor; import org.apache.hadoop.hbase.HRegionInfo; +import org.apache.hadoop.hbase.ProcedureInfo; import org.apache.hadoop.hbase.TableName; import org.apache.hadoop.hbase.TableNotDisabledException; import org.apache.hadoop.hbase.TableNotFoundException; import org.apache.hadoop.hbase.procedure2.ProcedureExecutor; -import org.apache.hadoop.hbase.procedure2.ProcedureResult; import org.apache.hadoop.hbase.procedure2.ProcedureTestingUtility; import org.apache.hadoop.hbase.protobuf.generated.MasterProcedureProtos.TruncateTableState; import org.apache.hadoop.hbase.testclassification.MasterTests; @@ -102,10 +102,10 @@ public class TestTruncateTableProcedure { new TruncateTableProcedure(procExec.getEnvironment(), tableName, true)); // Second delete should fail with TableNotFound - ProcedureResult result = procExec.getResult(procId); + ProcedureInfo result = procExec.getResult(procId); assertTrue(result.isFailed()); - LOG.debug("Truncate failed with exception: " + result.getException()); - assertTrue(result.getException().getCause() instanceof TableNotFoundException); + LOG.debug("Truncate failed with exception: " + result.getExceptionFullMessage()); + assertTrue(ProcedureTestingUtility.getExceptionCause(result) instanceof TableNotFoundException); } @Test(timeout=60000) @@ -119,10 +119,11 @@ public class TestTruncateTableProcedure { new TruncateTableProcedure(procExec.getEnvironment(), tableName, false)); // Second delete should fail with TableNotDisabled - ProcedureResult result = procExec.getResult(procId); + ProcedureInfo result = procExec.getResult(procId); assertTrue(result.isFailed()); - LOG.debug("Truncate failed with exception: " + result.getException()); - assertTrue(result.getException().getCause() instanceof TableNotDisabledException); + LOG.debug("Truncate failed with exception: " + result.getExceptionFullMessage()); + assertTrue( + ProcedureTestingUtility.getExceptionCause(result) instanceof TableNotDisabledException); } @Test(timeout=60000)