use of org.neo4j.storageengine.api.lock.ResourceType in project neo4j by neo4j.
the class ForsetiClient method collectActiveLocks.
private static void collectActiveLocks(PrimitiveLongIntMap[] counts, List<ActiveLock> locks, ActiveLock.Factory activeLock) {
for (int typeId = 0; typeId < counts.length; typeId++) {
PrimitiveLongIntMap lockCounts = counts[typeId];
if (lockCounts != null) {
ResourceType resourceType = ResourceTypes.fromId(typeId);
lockCounts.visitEntries((resourceId, count) -> {
locks.add(activeLock.create(resourceType, resourceId));
return false;
});
}
}
}
use of org.neo4j.storageengine.api.lock.ResourceType in project neo4j by neo4j.
the class ForsetiLockManager method accept.
@Override
public void accept(Visitor out) {
for (int i = 0; i < lockMaps.length; i++) {
if (lockMaps[i] != null) {
ResourceType type = resourceTypes[i];
for (Map.Entry<Long, Lock> entry : lockMaps[i].entrySet()) {
Lock lock = entry.getValue();
out.visit(type, entry.getKey(), lock.describeWaitList(), 0, System.identityHashCode(lock));
}
}
}
}
use of org.neo4j.storageengine.api.lock.ResourceType in project neo4j by neo4j.
the class DeferringLockClient method acquireDeferredLocks.
void acquireDeferredLocks() {
assertNotStopped();
long[] current = new long[10];
int cursor = 0;
ResourceType currentType = null;
boolean currentExclusive = false;
for (LockUnit lockUnit : locks.keySet()) {
if (currentType == null || (currentType.typeId() != lockUnit.resourceType().typeId() || currentExclusive != lockUnit.isExclusive())) {
// New type, i.e. flush the current array down to delegate in one call
flushLocks(current, cursor, currentType, currentExclusive);
cursor = 0;
currentType = lockUnit.resourceType();
currentExclusive = lockUnit.isExclusive();
}
// Queue into current batch
if (cursor == current.length) {
current = Arrays.copyOf(current, cursor * 2);
}
current[cursor++] = lockUnit.resourceId();
}
flushLocks(current, cursor, currentType, currentExclusive);
}
use of org.neo4j.storageengine.api.lock.ResourceType in project neo4j by neo4j.
the class AquireLockCall method call.
@Override
public Response<LockResult> call(Master master, RequestContext context, ChannelBuffer input, ChannelBuffer target) {
ResourceType type = ResourceTypes.fromId(input.readInt());
long[] ids = new long[input.readInt()];
for (int i = 0; i < ids.length; i++) {
ids[i] = input.readLong();
}
return lock(master, context, type, ids);
}
Aggregations