Search in sources :

Example 1 with ProcedureInfo

use of org.apache.hadoop.hbase.ProcedureInfo in project hbase by apache.

the class AccessController method postListProcedures.

@Override
public void postListProcedures(ObserverContext<MasterCoprocessorEnvironment> ctx, List<ProcedureInfo> procInfoList) throws IOException {
    if (procInfoList.isEmpty()) {
        return;
    }
    // Retains only those which passes authorization checks, as the checks weren't done as part
    // of preListProcedures.
    Iterator<ProcedureInfo> itr = procInfoList.iterator();
    User user = getActiveUser(ctx);
    while (itr.hasNext()) {
        ProcedureInfo procInfo = itr.next();
        try {
            if (!ProcedureInfo.isProcedureOwner(procInfo, user)) {
                // If the user is not the procedure owner, then we should further probe whether
                // he can see the procedure.
                requirePermission(user, "listProcedures", Action.ADMIN);
            }
        } catch (AccessDeniedException e) {
            itr.remove();
        }
    }
}
Also used : AccessDeniedException(org.apache.hadoop.hbase.security.AccessDeniedException) User(org.apache.hadoop.hbase.security.User) ProcedureInfo(org.apache.hadoop.hbase.ProcedureInfo)

Example 2 with ProcedureInfo

use of org.apache.hadoop.hbase.ProcedureInfo in project hbase by apache.

the class TestDeleteColumnFamilyProcedure method testDeleteColumnFamilyTwice.

@Test(timeout = 60000)
public void testDeleteColumnFamilyTwice() throws Exception {
    final TableName tableName = TableName.valueOf(name.getMethodName());
    final ProcedureExecutor<MasterProcedureEnv> procExec = getMasterProcedureExecutor();
    final String cf2 = "cf2";
    MasterProcedureTestingUtility.createTable(procExec, tableName, null, "f1", cf2);
    // delete the column family that exists
    long procId1 = procExec.submitProcedure(new DeleteColumnFamilyProcedure(procExec.getEnvironment(), tableName, cf2.getBytes()));
    // Wait the completion
    ProcedureTestingUtility.waitProcedure(procExec, procId1);
    // First delete should succeed
    ProcedureTestingUtility.assertProcNotFailed(procExec, procId1);
    MasterProcedureTestingUtility.validateColumnFamilyDeletion(UTIL.getHBaseCluster().getMaster(), tableName, cf2);
    // delete the column family that does not exist
    long procId2 = procExec.submitProcedure(new DeleteColumnFamilyProcedure(procExec.getEnvironment(), tableName, cf2.getBytes()));
    // Wait the completion
    ProcedureTestingUtility.waitProcedure(procExec, procId2);
    // Second delete should fail with InvalidFamilyOperationException
    ProcedureInfo result = procExec.getResult(procId2);
    assertTrue(result.isFailed());
    LOG.debug("Delete online failed with exception: " + result.getExceptionFullMessage());
    assertTrue(ProcedureTestingUtility.getExceptionCause(result) instanceof InvalidFamilyOperationException);
    // Try again, this time with table disabled.
    UTIL.getAdmin().disableTable(tableName);
    long procId3 = procExec.submitProcedure(new DeleteColumnFamilyProcedure(procExec.getEnvironment(), tableName, cf2.getBytes()));
    // Wait the completion
    ProcedureTestingUtility.waitProcedure(procExec, procId3);
    // Expect fail with InvalidFamilyOperationException
    result = procExec.getResult(procId2);
    assertTrue(result.isFailed());
    LOG.debug("Delete offline failed with exception: " + result.getExceptionFullMessage());
    assertTrue(ProcedureTestingUtility.getExceptionCause(result) instanceof InvalidFamilyOperationException);
}
Also used : TableName(org.apache.hadoop.hbase.TableName) ProcedureInfo(org.apache.hadoop.hbase.ProcedureInfo) InvalidFamilyOperationException(org.apache.hadoop.hbase.InvalidFamilyOperationException) Test(org.junit.Test)

Example 3 with ProcedureInfo

use of org.apache.hadoop.hbase.ProcedureInfo in project hbase by apache.

the class TestDeleteNamespaceProcedure method testDeleteSystemNamespace.

@Test(timeout = 60000)
public void testDeleteSystemNamespace() throws Exception {
    final String namespaceName = NamespaceDescriptor.SYSTEM_NAMESPACE.getName();
    final ProcedureExecutor<MasterProcedureEnv> procExec = getMasterProcedureExecutor();
    long procId = procExec.submitProcedure(new DeleteNamespaceProcedure(procExec.getEnvironment(), namespaceName));
    // Wait the completion
    ProcedureTestingUtility.waitProcedure(procExec, procId);
    ProcedureInfo result = procExec.getResult(procId);
    assertTrue(result.isFailed());
    LOG.debug("Delete namespace failed with exception: " + result.getExceptionFullMessage());
    assertTrue(ProcedureTestingUtility.getExceptionCause(result) instanceof ConstraintException);
}
Also used : ProcedureInfo(org.apache.hadoop.hbase.ProcedureInfo) ConstraintException(org.apache.hadoop.hbase.constraint.ConstraintException) Test(org.junit.Test)

Example 4 with ProcedureInfo

use of org.apache.hadoop.hbase.ProcedureInfo in project hbase by apache.

the class TestProcedureAdmin method testListProcedure.

@Test(timeout = 60000)
public void testListProcedure() throws Exception {
    final TableName tableName = TableName.valueOf(name.getMethodName());
    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));
    // Wait for one step to complete
    ProcedureTestingUtility.waitProcedure(procExec, procId);
    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);
    }
}
Also used : TableName(org.apache.hadoop.hbase.TableName) ProcedureInfo(org.apache.hadoop.hbase.ProcedureInfo) Test(org.junit.Test)

Example 5 with ProcedureInfo

use of org.apache.hadoop.hbase.ProcedureInfo in project hbase by apache.

the class TestLockManager method tearDown.

@After
public void tearDown() throws Exception {
    for (ProcedureInfo procInfo : getMasterProcedureExecutor().listProcedures()) {
        Procedure proc = getMasterProcedureExecutor().getProcedure(procInfo.getProcId());
        if (proc instanceof LockProcedure) {
            ((LockProcedure) proc).unlock(getMasterProcedureExecutor().getEnvironment());
            ProcedureTestingUtility.waitProcedure(getMasterProcedureExecutor(), proc);
        }
    }
    assertEquals(0, getMasterProcedureExecutor().getEnvironment().getProcedureScheduler().size());
}
Also used : TestLockProcedure(org.apache.hadoop.hbase.master.locking.TestLockProcedure) LockProcedure(org.apache.hadoop.hbase.master.locking.LockProcedure) ProcedureInfo(org.apache.hadoop.hbase.ProcedureInfo) TestLockProcedure(org.apache.hadoop.hbase.master.locking.TestLockProcedure) LockProcedure(org.apache.hadoop.hbase.master.locking.LockProcedure) Procedure(org.apache.hadoop.hbase.procedure2.Procedure) After(org.junit.After)

Aggregations

ProcedureInfo (org.apache.hadoop.hbase.ProcedureInfo)33 Test (org.junit.Test)21 ArrayList (java.util.ArrayList)6 TableName (org.apache.hadoop.hbase.TableName)6 InvalidFamilyOperationException (org.apache.hadoop.hbase.InvalidFamilyOperationException)4 Procedure (org.apache.hadoop.hbase.procedure2.Procedure)3 HColumnDescriptor (org.apache.hadoop.hbase.HColumnDescriptor)2 LockProcedure (org.apache.hadoop.hbase.master.locking.LockProcedure)2 AccessDeniedException (org.apache.hadoop.hbase.security.AccessDeniedException)2 User (org.apache.hadoop.hbase.security.User)2 After (org.junit.After)2 NamespaceNotFoundException (org.apache.hadoop.hbase.NamespaceNotFoundException)1 TableNotDisabledException (org.apache.hadoop.hbase.TableNotDisabledException)1 ConstraintException (org.apache.hadoop.hbase.constraint.ConstraintException)1 TestLockProcedure (org.apache.hadoop.hbase.master.locking.TestLockProcedure)1 MasterProcedureEnv (org.apache.hadoop.hbase.master.procedure.MasterProcedureEnv)1 NonceKey (org.apache.hadoop.hbase.util.NonceKey)1 Pair (org.apache.hadoop.hbase.util.Pair)1