private MasterSyncObserver getMasterSyncObserver() { return (MasterSyncObserver)TEST_UTIL.getHBaseCluster().getMaster() .getMasterCoprocessorHost().findCoprocessor(MasterSyncObserver.class.getName()); } }
public static void deleteTable(HBaseTestingUtility testUtil, TableName tableName) throws Exception { // NOTE: We need a latch because admin is not sync, // so the postOp coprocessor method may be called after the admin operation returned. MasterSyncCoprocessor coproc = testUtil.getHBaseCluster().getMaster() .getMasterCoprocessorHost().findCoprocessor(MasterSyncCoprocessor.class); coproc.tableDeletionLatch = new CountDownLatch(1); try { admin.disableTable(tableName); } catch (Exception e) { LOG.debug("Table: " + tableName + " already disabled, so just deleting it."); } admin.deleteTable(tableName); coproc.tableDeletionLatch.await(); coproc.tableDeletionLatch = null; } }
private MasterSnapshotObserver getMasterSnapshotObserver() { return TEST_UTIL.getHBaseCluster().getMaster().getMasterCoprocessorHost() .findCoprocessor(MasterSnapshotObserver.class); }
private void deleteTable(final TableName tableName) throws Exception { // NOTE: We need a latch because admin is not sync, // so the postOp coprocessor method may be called after the admin operation returned. MasterSyncObserver observer = UTIL.getHBaseCluster().getMaster() .getMasterCoprocessorHost().findCoprocessor(MasterSyncObserver.class); ADMIN.deleteTable(tableName); observer.tableDeletionLatch.await(); }
public static void deleteTable(HBaseTestingUtility testUtil, Admin admin, TableName tableName) throws Exception { // NOTE: We need a latch because admin is not sync, // so the postOp coprocessor method may be called after the admin operation returned. MasterSyncObserver observer = testUtil.getHBaseCluster().getMaster() .getMasterCoprocessorHost().findCoprocessor(MasterSyncObserver.class); observer.tableDeletionLatch = new CountDownLatch(1); try { admin.disableTable(tableName); } catch (TableNotEnabledException e) { LOG.debug("Table: " + tableName + " already disabled, so just deleting it."); } admin.deleteTable(tableName); observer.tableDeletionLatch.await(); observer.tableDeletionLatch = null; }
public static void deleteTable(HBaseTestingUtility testUtil, TableName tableName) throws Exception { // NOTE: We need a latch because admin is not sync, // so the postOp coprocessor method may be called after the admin operation returned. MasterSyncObserver observer = testUtil.getHBaseCluster().getMaster() .getMasterCoprocessorHost().findCoprocessor(MasterSyncObserver.class); observer.tableDeletionLatch = new CountDownLatch(1); Admin admin = testUtil.getAdmin(); try { admin.disableTable(tableName); } catch (Exception e) { LOG.debug("Table: " + tableName + " already disabled, so just deleting it."); } admin.deleteTable(tableName); observer.tableDeletionLatch.await(); observer.tableDeletionLatch = null; } }
public static void createTable(HBaseTestingUtility testUtil, HTableDescriptor htd, byte [][] splitKeys) throws Exception { // NOTE: We need a latch because admin is not sync, // so the postOp coprocessor method may be called after the admin operation returned. MasterSyncCoprocessor coproc = testUtil.getHBaseCluster().getMaster() .getMasterCoprocessorHost().findCoprocessor(MasterSyncCoprocessor.class); coproc.tableCreationLatch = new CountDownLatch(1); if (splitKeys != null) { admin.createTable(htd, splitKeys); } else { admin.createTable(htd); } coproc.tableCreationLatch.await(); coproc.tableCreationLatch = null; testUtil.waitUntilAllRegionsAssigned(htd.getTableName()); }
public static void createTable(HBaseTestingUtility testUtil, Admin admin, TableDescriptor htd, byte[][] splitKeys) throws Exception { // NOTE: We need a latch because admin is not sync, // so the postOp coprocessor method may be called after the admin operation returned. MasterSyncObserver observer = testUtil.getHBaseCluster().getMaster() .getMasterCoprocessorHost().findCoprocessor(MasterSyncObserver.class); observer.tableCreationLatch = new CountDownLatch(1); if (splitKeys != null) { admin.createTable(htd, splitKeys); } else { admin.createTable(htd); } observer.tableCreationLatch.await(); observer.tableCreationLatch = null; testUtil.waitUntilAllRegionsAssigned(htd.getTableName()); }
protected static void initialize() throws Exception { admin = TEST_UTIL.getAdmin(); cluster = TEST_UTIL.getHBaseCluster(); master = TEST_UTIL.getMiniHBaseCluster().getMaster(); //wait for balancer to come online TEST_UTIL.waitFor(WAIT_TIMEOUT, new Waiter.Predicate<Exception>() { @Override public boolean evaluate() throws Exception { return master.isInitialized() && ((RSGroupBasedLoadBalancer) master.getLoadBalancer()).isOnline(); } }); admin.balancerSwitch(false, true); rsGroupAdmin = new VerifyingRSGroupAdminClient( new RSGroupAdminClient(TEST_UTIL.getConnection()), TEST_UTIL.getConfiguration()); MasterCoprocessorHost host = master.getMasterCoprocessorHost(); observer = (CPMasterObserver) host.findCoprocessor(CPMasterObserver.class.getName()); rsGroupAdminEndpoint = (RSGroupAdminEndpoint) host.findCoprocessor(RSGroupAdminEndpoint.class.getName()); }
public static void createTable(HBaseTestingUtility testUtil, HTableDescriptor htd, byte [][] splitKeys) throws Exception { // NOTE: We need a latch because admin is not sync, // so the postOp coprocessor method may be called after the admin operation returned. MasterSyncObserver observer = testUtil.getHBaseCluster().getMaster() .getMasterCoprocessorHost().findCoprocessor(MasterSyncObserver.class); observer.tableCreationLatch = new CountDownLatch(1); Admin admin = testUtil.getAdmin(); if (splitKeys != null) { admin.createTable(htd, splitKeys); } else { admin.createTable(htd); } observer.tableCreationLatch.await(); observer.tableCreationLatch = null; testUtil.waitUntilAllRegionsAssigned(htd.getTableName()); }
@Test public void testPostCreateNamespace() throws IOException { final Admin admin = UTIL.getAdmin(); final String ns = "postcreatens"; HMaster master = UTIL.getMiniHBaseCluster().getMaster(); MasterObserverForTest observer = master.getMasterCoprocessorHost().findCoprocessor( MasterObserverForTest.class); // Validate that the post hook is called int preCount = observer.postHookCalls.get(); NamespaceDescriptor nsDesc = NamespaceDescriptor.create(ns).build(); admin.createNamespace(nsDesc); int postCount = observer.postHookCalls.get(); assertEquals("Expected 1 invocation of postModifyNamespace", preCount + 1, postCount); // Then, validate that it's not called when the call fails preCount = observer.postHookCalls.get(); try { admin.createNamespace(nsDesc); fail("Creating an already present namespace should fail"); } catch (IOException e) { // Pass } postCount = observer.postHookCalls.get(); assertEquals("Expected no invocations of postModifyNamespace when the operation fails", preCount, postCount); }
@Test public void testAbortProcedureOperation() throws Exception { MiniHBaseCluster cluster = UTIL.getHBaseCluster(); HMaster master = cluster.getMaster(); MasterCoprocessorHost host = master.getMasterCoprocessorHost(); CPMasterObserver cp = host.findCoprocessor(CPMasterObserver.class); cp.resetStates(); master.abortProcedure(1, true); assertTrue( "Coprocessor should be called on abort procedure request", cp.wasAbortProcedureCalled()); }
@Test public void testGetProceduresOperation() throws Exception { MiniHBaseCluster cluster = UTIL.getHBaseCluster(); HMaster master = cluster.getMaster(); MasterCoprocessorHost host = master.getMasterCoprocessorHost(); CPMasterObserver cp = host.findCoprocessor(CPMasterObserver.class); cp.resetStates(); master.getProcedures(); assertTrue( "Coprocessor should be called on get procedures request", cp.wasGetProceduresCalled()); }
@Test public void testGetLocksOperation() throws Exception { MiniHBaseCluster cluster = UTIL.getHBaseCluster(); HMaster master = cluster.getMaster(); MasterCoprocessorHost host = master.getMasterCoprocessorHost(); CPMasterObserver cp = host.findCoprocessor(CPMasterObserver.class); cp.resetStates(); master.getLocks(); assertTrue( "Coprocessor should be called on get locks request", cp.wasGetLocksCalled()); }
@Test public void testTableDescriptorsEnumeration() throws Exception { MiniHBaseCluster cluster = UTIL.getHBaseCluster(); HMaster master = cluster.getMaster(); MasterCoprocessorHost host = master.getMasterCoprocessorHost(); CPMasterObserver cp = host.findCoprocessor(CPMasterObserver.class); cp.resetStates(); GetTableDescriptorsRequest req = RequestConverter.buildGetTableDescriptorsRequest((List<TableName>)null); master.getMasterRpcServices().getTableDescriptors(null, req); assertTrue("Coprocessor should be called on table descriptors request", cp.wasGetTableDescriptorsCalled()); }
@Test public void testCoprocessorLoading() throws Exception { MasterCoprocessorHost cpHost = TEST_UTIL.getMiniHBaseCluster().getMaster().getMasterCoprocessorHost(); cpHost.load(MyAccessController.class, Coprocessor.PRIORITY_HIGHEST, conf); AccessController ACCESS_CONTROLLER = cpHost.findCoprocessor(MyAccessController.class); MasterCoprocessorEnvironment CP_ENV = cpHost.createEnvironment( ACCESS_CONTROLLER, Coprocessor.PRIORITY_HIGHEST, 1, conf); RegionServerCoprocessorHost rsHost = TEST_UTIL.getMiniHBaseCluster().getRegionServer(0) .getRegionServerCoprocessorHost(); RegionServerCoprocessorEnvironment RSCP_ENV = rsHost.createEnvironment( ACCESS_CONTROLLER, Coprocessor.PRIORITY_HIGHEST, 1, conf); }
@Test public void testTableNamesEnumeration() throws Exception { MiniHBaseCluster cluster = UTIL.getHBaseCluster(); HMaster master = cluster.getMaster(); MasterCoprocessorHost host = master.getMasterCoprocessorHost(); CPMasterObserver cp = host.findCoprocessor(CPMasterObserver.class); cp.resetStates(); master.getMasterRpcServices().getTableNames(null, GetTableNamesRequest.newBuilder().build()); assertTrue("Coprocessor should be called on table names request", cp.wasGetTableNamesCalled()); }
@Test public void testQueueLockAndLockHeartbeatOperations() throws Exception { HMaster master = UTIL.getMiniHBaseCluster().getMaster(); CPMasterObserver cp = master.getMasterCoprocessorHost().findCoprocessor(CPMasterObserver.class); cp.resetStates(); final TableName tableName = TableName.valueOf("testLockedTable"); long procId = master.getLockManager().remoteLocks().requestTableLock(tableName, LockType.EXCLUSIVE, "desc", null); master.getLockManager().remoteLocks().lockHeartbeat(procId, false); assertTrue(cp.preAndPostForQueueLockAndHeartbeatLockCalled()); ProcedureTestingUtility.waitNoProcedureRunning(master.getMasterProcedureExecutor()); ProcedureTestingUtility.assertProcNotFailed(master.getMasterProcedureExecutor(), procId); } }
@Test public void testStarted() throws Exception { MiniHBaseCluster cluster = UTIL.getHBaseCluster(); HMaster master = cluster.getMaster(); assertTrue("Master should be active", master.isActiveMaster()); MasterCoprocessorHost host = master.getMasterCoprocessorHost(); assertNotNull("CoprocessorHost should not be null", host); CPMasterObserver cp = host.findCoprocessor(CPMasterObserver.class); assertNotNull("CPMasterObserver coprocessor not found or not installed!", cp); // check basic lifecycle assertTrue("MasterObserver should have been started", cp.wasStarted()); assertTrue("preMasterInitialization() hook should have been called", cp.wasMasterInitializationCalled()); assertTrue("postStartMaster() hook should have been called", cp.wasStartMasterCalled()); }
@Test public void testNamespaceOperations() throws Exception { MiniHBaseCluster cluster = UTIL.getHBaseCluster(); String testNamespace = "observed_ns"; HMaster master = cluster.getMaster(); MasterCoprocessorHost host = master.getMasterCoprocessorHost(); CPMasterObserver cp = host.findCoprocessor(CPMasterObserver.class); // create a table Admin admin = UTIL.getAdmin(); admin.createNamespace(NamespaceDescriptor.create(testNamespace).build()); assertTrue("Test namespace should be created", cp.wasCreateNamespaceCalled()); assertNotNull(admin.getNamespaceDescriptor(testNamespace)); assertTrue("Test namespace descriptor should have been called", cp.wasGetNamespaceDescriptorCalled()); // This test used to do a bunch w/ bypass but bypass of these table and namespace stuff has // been removed so the testing code was removed. }