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;
}
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);
}
}
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());
}
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());
}
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());
}
Aggregations