Search in sources :

Example 1 with LockedResource

use of org.apache.hadoop.hbase.procedure2.LockedResource in project hbase by apache.

the class HMaster method getLocks.

@Override
public List<LockedResource> getLocks() throws IOException {
    if (cpHost != null) {
        cpHost.preGetLocks();
    }
    MasterProcedureScheduler procedureScheduler = procedureExecutor.getEnvironment().getProcedureScheduler();
    final List<LockedResource> lockedResources = procedureScheduler.getLocks();
    if (cpHost != null) {
        cpHost.postGetLocks(lockedResources);
    }
    return lockedResources;
}
Also used : LockedResource(org.apache.hadoop.hbase.procedure2.LockedResource) MasterProcedureScheduler(org.apache.hadoop.hbase.master.procedure.MasterProcedureScheduler)

Example 2 with LockedResource

use of org.apache.hadoop.hbase.procedure2.LockedResource in project hbase by apache.

the class MasterProcedureScheduler method logLockedResource.

// ============================================================================
// Table Locking Helpers
// ============================================================================
/**
 * Get lock info for a resource of specified type and name and log details
 */
private void logLockedResource(LockedResourceType resourceType, String resourceName) {
    if (!LOG.isDebugEnabled()) {
        return;
    }
    LockedResource lockedResource = getLockResource(resourceType, resourceName);
    if (lockedResource != null) {
        String msg = resourceType.toString() + " '" + resourceName + "', shared lock count=" + lockedResource.getSharedLockCount();
        Procedure<?> proc = lockedResource.getExclusiveLockOwnerProcedure();
        if (proc != null) {
            msg += ", exclusively locked by procId=" + proc.getProcId();
        }
        LOG.debug(msg);
    }
}
Also used : LockedResource(org.apache.hadoop.hbase.procedure2.LockedResource)

Example 3 with LockedResource

use of org.apache.hadoop.hbase.procedure2.LockedResource in project hbase by apache.

the class TestMasterProcedureScheduler method testListLocksRegion.

@Test
public void testListLocksRegion() throws Exception {
    LockProcedure procedure = createExclusiveLockProcedure(3);
    RegionInfo regionInfo = RegionInfoBuilder.newBuilder(TableName.valueOf("ns3", "table3")).build();
    queue.waitRegion(procedure, regionInfo);
    List<LockedResource> resources = queue.getLocks();
    assertEquals(3, resources.size());
    LockedResource namespaceResource = resources.get(0);
    assertLockResource(namespaceResource, LockedResourceType.NAMESPACE, "ns3");
    assertSharedLock(namespaceResource, 1);
    assertTrue(namespaceResource.getWaitingProcedures().isEmpty());
    LockedResource tableResource = resources.get(1);
    assertLockResource(tableResource, LockedResourceType.TABLE, "ns3:table3");
    assertSharedLock(tableResource, 1);
    assertTrue(tableResource.getWaitingProcedures().isEmpty());
    LockedResource regionResource = resources.get(2);
    assertLockResource(regionResource, LockedResourceType.REGION, regionInfo.getEncodedName());
    assertExclusiveLock(regionResource, procedure);
    assertTrue(regionResource.getWaitingProcedures().isEmpty());
}
Also used : LockProcedure(org.apache.hadoop.hbase.master.locking.LockProcedure) LockedResource(org.apache.hadoop.hbase.procedure2.LockedResource) RegionInfo(org.apache.hadoop.hbase.client.RegionInfo) Test(org.junit.Test)

Example 4 with LockedResource

use of org.apache.hadoop.hbase.procedure2.LockedResource in project hbase by apache.

the class TestMasterProcedureScheduler method testListLocksTable.

@Test
public void testListLocksTable() throws Exception {
    LockProcedure procedure = createExclusiveLockProcedure(2);
    queue.waitTableExclusiveLock(procedure, TableName.valueOf("ns2", "table2"));
    List<LockedResource> locks = queue.getLocks();
    assertEquals(2, locks.size());
    LockedResource namespaceResource = locks.get(0);
    assertLockResource(namespaceResource, LockedResourceType.NAMESPACE, "ns2");
    assertSharedLock(namespaceResource, 1);
    assertTrue(namespaceResource.getWaitingProcedures().isEmpty());
    LockedResource tableResource = locks.get(1);
    assertLockResource(tableResource, LockedResourceType.TABLE, "ns2:table2");
    assertExclusiveLock(tableResource, procedure);
    assertTrue(tableResource.getWaitingProcedures().isEmpty());
}
Also used : LockProcedure(org.apache.hadoop.hbase.master.locking.LockProcedure) LockedResource(org.apache.hadoop.hbase.procedure2.LockedResource) Test(org.junit.Test)

Example 5 with LockedResource

use of org.apache.hadoop.hbase.procedure2.LockedResource in project hbase by apache.

the class TestMasterProcedureScheduler method testListLocksNamespace.

@Test
public void testListLocksNamespace() throws Exception {
    LockProcedure procedure = createExclusiveLockProcedure(1);
    queue.waitNamespaceExclusiveLock(procedure, "ns1");
    List<LockedResource> locks = queue.getLocks();
    assertEquals(2, locks.size());
    LockedResource namespaceResource = locks.get(0);
    assertLockResource(namespaceResource, LockedResourceType.NAMESPACE, "ns1");
    assertExclusiveLock(namespaceResource, procedure);
    assertTrue(namespaceResource.getWaitingProcedures().isEmpty());
    LockedResource tableResource = locks.get(1);
    assertLockResource(tableResource, LockedResourceType.TABLE, TableProcedureInterface.DUMMY_NAMESPACE_TABLE_NAME.getNameAsString());
    assertSharedLock(tableResource, 1);
    assertTrue(tableResource.getWaitingProcedures().isEmpty());
}
Also used : LockProcedure(org.apache.hadoop.hbase.master.locking.LockProcedure) LockedResource(org.apache.hadoop.hbase.procedure2.LockedResource) Test(org.junit.Test)

Aggregations

LockedResource (org.apache.hadoop.hbase.procedure2.LockedResource)9 LockProcedure (org.apache.hadoop.hbase.master.locking.LockProcedure)7 Test (org.junit.Test)6 Procedure (org.apache.hadoop.hbase.procedure2.Procedure)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Function (java.util.function.Function)1 ServerName (org.apache.hadoop.hbase.ServerName)1 TableName (org.apache.hadoop.hbase.TableName)1 RegionInfo (org.apache.hadoop.hbase.client.RegionInfo)1 MasterProcedureScheduler (org.apache.hadoop.hbase.master.procedure.MasterProcedureScheduler)1 LockAndQueue (org.apache.hadoop.hbase.procedure2.LockAndQueue)1 LockType (org.apache.hadoop.hbase.procedure2.LockType)1 LockedResourceType (org.apache.hadoop.hbase.procedure2.LockedResourceType)1 TestProcedure (org.apache.hadoop.hbase.procedure2.ProcedureTestingUtility.TestProcedure)1 ImmutableMap (org.apache.hbase.thirdparty.com.google.common.collect.ImmutableMap)1 InterfaceAudience (org.apache.yetus.audience.InterfaceAudience)1