/** * For a given Enum type, creates an immutable map from each of the Enum's values to a * corresponding LockGraphNode, with the {@code allowedPriorLocks} and {@code * disallowedPriorLocks} prepopulated with nodes according to the natural ordering of the * associated Enum values. */ @VisibleForTesting static <E extends Enum<E>> Map<E, LockGraphNode> createNodes(Class<E> clazz) { EnumMap<E, LockGraphNode> map = Maps.newEnumMap(clazz); E[] keys = clazz.getEnumConstants(); final int numKeys = keys.length; ArrayList<LockGraphNode> nodes = Lists.newArrayListWithCapacity(numKeys); // Create a LockGraphNode for each enum value. for (E key : keys) { LockGraphNode node = new LockGraphNode(getLockName(key)); nodes.add(node); map.put(key, node); } // Pre-populate all allowedPriorLocks with nodes of smaller ordinal. for (int i = 1; i < numKeys; i++) { nodes.get(i).checkAcquiredLocks(Policies.THROW, nodes.subList(0, i)); } // Pre-populate all disallowedPriorLocks with nodes of larger ordinal. for (int i = 0; i < numKeys - 1; i++) { nodes.get(i).checkAcquiredLocks(Policies.DISABLED, nodes.subList(i + 1, numKeys)); } return Collections.unmodifiableMap(map); }
void checkAcquiredLocks(Policy policy, List<LockGraphNode> acquiredLocks) { for (int i = 0, size = acquiredLocks.size(); i < size; i++) { checkAcquiredLock(policy, acquiredLocks.get(i)); } }
this != acquiredLock, "Attempted to acquire multiple locks with the same rank %s", acquiredLock.getLockName()); ExampleStackTrace path = acquiredLock.findPathTo(this, seen);
this != acquiredLock, "Attempted to acquire multiple locks with the same rank " + acquiredLock.getLockName()); ExampleStackTrace path = acquiredLock.findPathTo(this, seen);
this != acquiredLock, "Attempted to acquire multiple locks with the same rank " + acquiredLock.getLockName()); ExampleStackTrace path = acquiredLock.findPathTo(this, seen);
this != acquiredLock, "Attempted to acquire multiple locks with the same rank " + acquiredLock.getLockName()); ExampleStackTrace path = acquiredLock.findPathTo(this, seen);
this != acquiredLock, "Attempted to acquire multiple locks with the same rank " + acquiredLock.getLockName()); ExampleStackTrace path = acquiredLock.findPathTo(this, seen);
this != acquiredLock, "Attempted to acquire multiple locks with the same rank %s", acquiredLock.getLockName()); ExampleStackTrace path = acquiredLock.findPathTo(this, seen);
this != acquiredLock, "Attempted to acquire multiple locks with the same rank %s", acquiredLock.getLockName()); ExampleStackTrace path = acquiredLock.findPathTo(this, seen);
this != acquiredLock, "Attempted to acquire multiple locks with the same rank " + acquiredLock.getLockName()); ExampleStackTrace path = acquiredLock.findPathTo(this, seen);
"Attempted to acquire multiple locks with the same rank %s", acquiredLock.getLockName()); ExampleStackTrace path = acquiredLock.findPathTo(this, seen);
this != acquiredLock, "Attempted to acquire multiple locks with the same rank " + acquiredLock.getLockName()); ExampleStackTrace path = acquiredLock.findPathTo(this, seen);
allowedPriorLocks.entrySet()) { LockGraphNode preAcquiredLock = entry.getKey(); found = preAcquiredLock.findPathTo(node, seen); if (found != null) {
allowedPriorLocks.entrySet()) { LockGraphNode preAcquiredLock = entry.getKey(); found = preAcquiredLock.findPathTo(node, seen); if (found != null) {
allowedPriorLocks.entrySet()) { LockGraphNode preAcquiredLock = entry.getKey(); found = preAcquiredLock.findPathTo(node, seen); if (found != null) {
allowedPriorLocks.entrySet()) { LockGraphNode preAcquiredLock = entry.getKey(); found = preAcquiredLock.findPathTo(node, seen); if (found != null) {
allowedPriorLocks.entrySet()) { LockGraphNode preAcquiredLock = entry.getKey(); found = preAcquiredLock.findPathTo(node, seen); if (found != null) {
found = preAcquiredLock.findPathTo(node, seen); if (found != null) {
allowedPriorLocks.entrySet()) { LockGraphNode preAcquiredLock = entry.getKey(); found = preAcquiredLock.findPathTo(node, seen); if (found != null) {
found = preAcquiredLock.findPathTo(node, seen); if (found != null) {