@Override public String toString() { String lockSessionId = statementLocks == null ? "statementLocks == null" : String.valueOf( statementLocks.pessimistic().getLockSessionId() ); return "KernelTransaction[" + lockSessionId + "]"; }
private void releaseSharedLock( ResourceTypes types, long... ids ) { ktx.statementLocks().pessimistic().releaseShared( types, ids ); }
private void releaseExclusiveLock( ResourceTypes types, long... ids ) { ktx.statementLocks().pessimistic().releaseExclusive( types, ids ); }
private void acquireExclusiveLock( ResourceTypes types, long... ids ) { ktx.statementLocks().pessimistic().acquireExclusive( ktx.lockTracer(), types, ids ); }
private void acquireSharedLock( ResourceTypes types, long... ids ) { ktx.statementLocks().pessimistic().acquireShared( ktx.lockTracer(), types, ids ); }
private ConstraintDescriptor lockConstraint( ConstraintDescriptor constraint ) { SchemaDescriptor schema = constraint.schema(); ktx.statementLocks().pessimistic().acquireShared( ktx.lockTracer(), schema.keyType(), schema.keyId() ); return constraint; } }
@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() ); }
@Test public void shouldReleaseLabelLockWhileAwaitingIndexPopulation() throws Exception { // given StubKernel kernel = new StubKernel(); IndexingService indexingService = mock( IndexingService.class ); NodePropertyAccessor nodePropertyAccessor = mock( NodePropertyAccessor.class ); when( schemaRead.indexGetCommittedId( indexReference ) ).thenReturn( INDEX_ID ); IndexProxy indexProxy = mock( IndexProxy.class ); when( indexingService.getIndexProxy( anyLong() ) ).thenReturn( indexProxy ); when( indexingService.getIndexProxy( descriptor ) ).thenReturn( indexProxy ); when( schemaRead.index( LABEL_ID, PROPERTY_KEY_ID ) ).thenReturn( IndexReference.NO_INDEX ); ConstraintIndexCreator creator = new ConstraintIndexCreator( () -> kernel, indexingService, nodePropertyAccessor, logProvider ); // when KernelTransactionImplementation transaction = createTransaction(); creator.createUniquenessConstraintIndex( transaction, descriptor, getDefaultProvider() ); // then verify( transaction.statementLocks().pessimistic() ) .releaseExclusive( ResourceTypes.LABEL, descriptor.getLabelId() ); verify( transaction.statementLocks().pessimistic() ) .acquireExclusive( transaction.lockTracer(), ResourceTypes.LABEL, descriptor.getLabelId() ); }
Locks.Client locks = mock( Locks.Client.class ); when( statementLocks.optimistic() ).thenReturn( locks ); when( statementLocks.pessimistic() ).thenReturn( locks ); when( locksFactory.newInstance() ).thenReturn( statementLocks );
Client locks = transaction.statementLocks().pessimistic(); try
Locks.Client commitLocks = statementLocks.pessimistic();
@Override public String toString() { String lockSessionId = statementLocks == null ? "statementLocks == null" : String.valueOf( statementLocks.pessimistic().getLockSessionId() ); return "KernelTransaction[" + lockSessionId + "]"; }
private void releaseSharedLock( ResourceTypes types, long... ids ) { ktx.statementLocks().pessimistic().releaseShared( types, ids ); }
private void releaseExclusiveLock( ResourceTypes types, long... ids ) { ktx.statementLocks().pessimistic().releaseExclusive( types, ids ); }
private void acquireSharedLock( ResourceTypes types, long... ids ) { ktx.statementLocks().pessimistic().acquireShared( ktx.lockTracer(), types, ids ); }
private void acquireExclusiveLock( ResourceTypes types, long... ids ) { ktx.statementLocks().pessimistic().acquireExclusive( ktx.lockTracer(), types, ids ); }
private ConstraintDescriptor lockConstraint( ConstraintDescriptor constraint ) { SchemaDescriptor schema = constraint.schema(); ktx.statementLocks().pessimistic().acquireShared( ktx.lockTracer(), schema.keyType(), schema.keyId() ); return constraint; } }
Client locks = transaction.statementLocks().pessimistic(); try
Locks.Client commitLocks = statementLocks.pessimistic();