void acquireSharedLock( ResourceType resource, long resourceId ) { ktx.statementLocks().optimistic().acquireShared( ktx.lockTracer(), resource, resourceId ); }
private void exclusiveOptimisticLock( ResourceType resource, long resourceId ) { ktx.statementLocks().optimistic().acquireExclusive( ktx.lockTracer(), resource, resourceId ); }
private void sharedSchemaLock( ResourceType type, int tokenId ) { ktx.statementLocks().optimistic().acquireShared( ktx.lockTracer(), type, tokenId ); }
private void exclusiveSchemaLock( SchemaDescriptor schema ) { long[] lockingIds = schemaTokenLockingIds( schema ); ktx.statementLocks().optimistic().acquireExclusive( ktx.lockTracer(), schema.keyType(), lockingIds ); }
@Override public long lockingNodeUniqueIndexSeek( IndexReference index, IndexQuery.ExactPredicate... predicates ) throws IndexNotApplicableKernelException, IndexNotFoundKernelException, IndexBrokenKernelException { assertIndexOnline( index ); assertPredicatesMatchSchema( index, predicates ); Locks.Client locks = ktx.statementLocks().optimistic(); LockTracer lockTracer = ktx.lockTracer(); return LockingNodeUniqueIndexSeek.apply( locks, lockTracer, cursors::allocateNodeValueIndexCursor, this, this, index, predicates ); }
/** * Assuming that the nodeCursor have been initialized to the node that labels are retrieved from */ private void acquireSharedNodeLabelLocks() { ktx.statementLocks().optimistic().acquireShared( ktx.lockTracer(), ResourceTypes.LABEL, nodeCursor.labels().all() ); }
void acquireSharedSchemaLock( SchemaDescriptor schema ) { long[] lockingIds = schemaTokenLockingIds( schema ); ktx.statementLocks().optimistic().acquireShared( ktx.lockTracer(), schema.keyType(), lockingIds ); }
private void acquireExclusiveRelationshipLock( long relationshipId ) { if ( !ktx.hasTxStateWithChanges() || !ktx.txState().relationshipIsAddedInThisTx( relationshipId ) ) { ktx.statementLocks().optimistic() .acquireExclusive( ktx.lockTracer(), ResourceTypes.RELATIONSHIP, relationshipId ); } }
private void acquireExclusiveNodeLock( long node ) { if ( !ktx.hasTxStateWithChanges() || !ktx.txState().nodeIsAddedInThisTx( node ) ) { ktx.statementLocks().optimistic().acquireExclusive( ktx.lockTracer(), ResourceTypes.NODE, node ); } }
@Test public void loadSimpleStatementLocksFactoryWhenNoServices() { Locks locks = mock( Locks.class ); Locks.Client locksClient = mock( Client.class ); when( locks.newClient() ).thenReturn( locksClient ); StatementLocksFactorySelector loader = newLoader( locks ); StatementLocksFactory factory = loader.select(); StatementLocks statementLocks = factory.newInstance(); assertThat( factory, instanceOf( SimpleStatementLocksFactory.class ) ); assertThat( statementLocks, instanceOf( SimpleStatementLocks.class ) ); assertSame( locksClient, statementLocks.optimistic() ); assertSame( locksClient, statementLocks.pessimistic() ); }
@Override public Value graphRemoveProperty( int propertyKey ) { ktx.statementLocks().optimistic() .acquireExclusive( ktx.lockTracer(), ResourceTypes.GRAPH_PROPS, ResourceTypes.graphPropertyResource() ); ktx.assertOpen(); Value existingValue = readGraphProperty( propertyKey ); if ( existingValue != Values.NO_VALUE ) { ktx.txState().graphDoRemoveProperty( propertyKey ); } return existingValue; }
@Override public Value graphSetProperty( int propertyKey, Value value ) { ktx.statementLocks().optimistic() .acquireExclusive( ktx.lockTracer(), ResourceTypes.GRAPH_PROPS, ResourceTypes.graphPropertyResource() ); ktx.assertOpen(); Value existingValue = readGraphProperty( propertyKey ); if ( !existingValue.equals( value ) ) { ktx.txState().graphDoReplaceProperty( propertyKey, existingValue, value ); } return existingValue; }
long[] lockingIds = SchemaDescriptor.schemaTokenLockingIds( labels ); ktx.statementLocks().optimistic().acquireShared( ktx.lockTracer(), ResourceTypes.LABEL, lockingIds ); long nodeId = statement.reserveNode(); ktx.txState().nodeDoCreate( nodeId );
@Override public int nodeDetachDelete( final long nodeId ) throws KernelException { final MutableInt count = new MutableInt(); TwoPhaseNodeForRelationshipLocking locking = new TwoPhaseNodeForRelationshipLocking( relId -> { ktx.assertOpen(); if ( relationshipDelete( relId, false ) ) { count.increment(); } }, ktx.statementLocks().optimistic(), ktx.lockTracer() ); locking.lockAllNodesAndConsumeRelationships( nodeId, ktx, ktx.ambientNodeCursor() ); ktx.assertOpen(); //we are already holding the lock nodeDelete( nodeId, false ); return count.intValue(); }
StatementLocks statementLocks = mock( StatementLocks.class ); Locks.Client locks = mock( Locks.Client.class ); when( statementLocks.optimistic() ).thenReturn( locks ); when( statementLocks.pessimistic() ).thenReturn( locks ); when( locksFactory.newInstance() ).thenReturn( statementLocks );
ktx.statementLocks().optimistic().acquireExclusive( ktx.lockTracer(), ResourceTypes.NODE, node );
ktx.statementLocks().optimistic().acquireExclusive( ktx.lockTracer(), INDEX_ENTRY, indexEntryResourceId( labelId, propertyValues )
private void sharedSchemaLock( ResourceType type, int tokenId ) { ktx.statementLocks().optimistic().acquireShared( ktx.lockTracer(), type, tokenId ); }
private void exclusiveSchemaLock( SchemaDescriptor schema ) { long[] lockingIds = schemaTokenLockingIds( schema ); ktx.statementLocks().optimistic().acquireExclusive( ktx.lockTracer(), schema.keyType(), lockingIds ); }
/** * Assuming that the nodeCursor have been initialized to the node that labels are retrieved from */ private void acquireSharedNodeLabelLocks() { ktx.statementLocks().optimistic().acquireShared( ktx.lockTracer(), ResourceTypes.LABEL, nodeCursor.labels().all() ); }