Search in sources :

Example 1 with LockedResourceType

use of org.apache.hadoop.hbase.procedure2.LockedResourceType 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 2 with LockedResourceType

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

the class SchemaLocking method createLockedResource.

private LockedResource createLockedResource(LockedResourceType resourceType, String resourceName, LockAndQueue queue) {
    LockType lockType;
    Procedure<?> exclusiveLockOwnerProcedure;
    int sharedLockCount;
    if (queue.hasExclusiveLock()) {
        lockType = LockType.EXCLUSIVE;
        exclusiveLockOwnerProcedure = queue.getExclusiveLockOwnerProcedure();
        sharedLockCount = 0;
    } else {
        lockType = LockType.SHARED;
        exclusiveLockOwnerProcedure = null;
        sharedLockCount = queue.getSharedLockCount();
    }
    List<Procedure<?>> waitingProcedures = new ArrayList<>();
    queue.filterWaitingQueue(p -> p instanceof LockProcedure).forEachOrdered(waitingProcedures::add);
    return new LockedResource(resourceType, resourceName, lockType, exclusiveLockOwnerProcedure, sharedLockCount, waitingProcedures);
}
Also used : TableName(org.apache.hadoop.hbase.TableName) LockedResourceType(org.apache.hadoop.hbase.procedure2.LockedResourceType) ImmutableMap(org.apache.hbase.thirdparty.com.google.common.collect.ImmutableMap) HashMap(java.util.HashMap) LockAndQueue(org.apache.hadoop.hbase.procedure2.LockAndQueue) Function(java.util.function.Function) LockProcedure(org.apache.hadoop.hbase.master.locking.LockProcedure) Procedure(org.apache.hadoop.hbase.procedure2.Procedure) LockType(org.apache.hadoop.hbase.procedure2.LockType) ArrayList(java.util.ArrayList) LockedResource(org.apache.hadoop.hbase.procedure2.LockedResource) List(java.util.List) InterfaceAudience(org.apache.yetus.audience.InterfaceAudience) Map(java.util.Map) ServerName(org.apache.hadoop.hbase.ServerName) LockProcedure(org.apache.hadoop.hbase.master.locking.LockProcedure) LockedResource(org.apache.hadoop.hbase.procedure2.LockedResource) ArrayList(java.util.ArrayList) LockProcedure(org.apache.hadoop.hbase.master.locking.LockProcedure) Procedure(org.apache.hadoop.hbase.procedure2.Procedure) LockType(org.apache.hadoop.hbase.procedure2.LockType)

Aggregations

LockedResource (org.apache.hadoop.hbase.procedure2.LockedResource)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 LockProcedure (org.apache.hadoop.hbase.master.locking.LockProcedure)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 Procedure (org.apache.hadoop.hbase.procedure2.Procedure)1 ImmutableMap (org.apache.hbase.thirdparty.com.google.common.collect.ImmutableMap)1 InterfaceAudience (org.apache.yetus.audience.InterfaceAudience)1