Search in sources :

Example 1 with ResourceType

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;
            });
        }
    }
}
Also used : PrimitiveLongIntMap(org.neo4j.collection.primitive.PrimitiveLongIntMap) ResourceType(org.neo4j.storageengine.api.lock.ResourceType)

Example 2 with ResourceType

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));
            }
        }
    }
}
Also used : ResourceType(org.neo4j.storageengine.api.lock.ResourceType) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) ConcurrentMap(java.util.concurrent.ConcurrentMap) Map(java.util.Map)

Example 3 with ResourceType

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);
}
Also used : ResourceType(org.neo4j.storageengine.api.lock.ResourceType)

Example 4 with ResourceType

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);
}
Also used : ResourceType(org.neo4j.storageengine.api.lock.ResourceType)

Aggregations

ResourceType (org.neo4j.storageengine.api.lock.ResourceType)4 Map (java.util.Map)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 ConcurrentMap (java.util.concurrent.ConcurrentMap)1 PrimitiveLongIntMap (org.neo4j.collection.primitive.PrimitiveLongIntMap)1