@Override public StatementLocks newInstance() { if ( locks == null ) { throw new IllegalStateException( "Factory has not been initialized" ); } return new SimpleStatementLocks( locks.newClient() ); } }
LockWorkerState( Locks locks ) { this.grabber = locks; this.client = locks.newClient(); }
StressThread( String name, int numberOfIterations, int depthCount, float readWriteRatio, long nodeId, CountDownLatch startSignal ) { super(); this.nodeId = nodeId; this.client = locks.newClient(); this.name = name; this.numberOfIterations = numberOfIterations; this.depthCount = depthCount; this.readWriteRatio = readWriteRatio; this.startSignal = startSignal; }
@Before public void setUp() { client = locks.newClient(); }
private Locks.Client newLockClient( LockAcquisition lockAcquisition ) { Locks.Client client = locks.newClient(); lockAcquisition.setClient( client ); return client; }
@Before public void before() { this.locks = suite.createLockManager( Config.defaults(), Clocks.systemClock() ); clientA = this.locks.newClient(); clientB = this.locks.newClient(); clientC = this.locks.newClient(); clientToThreadMap.put( clientA, threadA ); clientToThreadMap.put( clientB, threadB ); clientToThreadMap.put( clientC, threadC ); }
@Before public void setUp() { customConfig = Config.defaults( GraphDatabaseSettings.lock_acquisition_timeout, "100ms" ); clock = Clocks.fakeClock(100000, TimeUnit.MINUTES); lockManager = suite.createLockManager( customConfig, clock ); client = lockManager.newClient(); client2 = lockManager.newClient(); }
private static KernelTransactions newKernelTransactions( boolean testKernelTransactions, TransactionCommitProcess commitProcess, StorageReader firstReader, StorageReader... otherReaders ) throws Throwable { Locks locks = mock( Locks.class ); Locks.Client client = mock( Locks.Client.class ); when( locks.newClient() ).thenReturn( client ); StorageEngine storageEngine = mock( StorageEngine.class ); when( storageEngine.newReader() ).thenReturn( firstReader, otherReaders ); doAnswer( invocation -> { Collection<StorageCommand> argument = invocation.getArgument( 0 ); argument.add( mock( StorageCommand.class ) ); return null; } ).when( storageEngine ).createCommands( anyCollection(), any( ReadableTransactionState.class ), any( StorageReader.class ), any( ResourceLocker.class ), anyLong(), any( TxStateVisitor.Decorator.class ) ); return newKernelTransactions( locks, storageEngine, commitProcess, testKernelTransactions ); }
@Test public void shouldNotBeAbleToHandOutClientsIfClosed() { // GIVEN a lock manager and working clients try ( Client client = locks.newClient() ) { client.acquireExclusive( LockTracer.NONE, ResourceTypes.NODE, 0 ); } // WHEN locks.close(); // THEN try { locks.newClient(); fail( "Should fail" ); } catch ( IllegalStateException e ) { // Good } }
@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() ); }
lockManger.newClient().acquireExclusive( LockTracer.NONE, ResourceTypes.LABEL, 1 );
@Override public StatementLocks newInstance() { if ( locks == null ) { throw new IllegalStateException( "Factory has not been initialized" ); } return new SimpleStatementLocks( locks.newClient() ); } }
@Override public Locks.Client newClient() { return new LeaderOnlyLockClient( localLocks.newClient() ); }
@Override public Locks.Client newClient() { return new LeaderOnlyLockClient( localLocks.newClient() ); }