labelUpdatesApply = labelScanStoreSync.applyAsync( new LabelUpdateWork( labelUpdates ) ); labelUpdates = null;
@Test void mustApplyWorkAsyncEvenWhenInterrupted() throws Exception { Thread.currentThread().interrupt(); sync.applyAsync( new AddWork( 10 ) ).await(); assertThat( sum.sum(), is( 10L ) ); assertTrue( Thread.interrupted() ); }
@Test void mustApplyWorkAsync() throws Exception { AsyncApply a = sync.applyAsync( new AddWork( 10 ) ); a.await(); assertThat( sum.sum(), is( 10L ) ); AsyncApply b = sync.applyAsync( new AddWork( 20 ) ); AsyncApply c = sync.applyAsync( new AddWork( 30 ) ); b.await(); c.await(); assertThat( sum.sum(), is( 60L ) ); }
@Test void mustCombineWorkAsync() throws Exception { makeWorkStuckAtSemaphore( 1 ); AsyncApply a = sync.applyAsync( new AddWork( 1 ) ); AsyncApply b = sync.applyAsync( new AddWork( 1 ) ); AsyncApply c = sync.applyAsync( new AddWork( 1 ) ); semaphore.release( 2 ); a.await(); b.await(); c.await(); assertThat( sum.sum(), is( 4L ) ); assertThat( count.sum(), is( 2L ) ); }
AsyncApply async = downstreamWorkSync.applyAsync( new SendDownstream( ticket, batch, downstreamIdleTime ) ); if ( downstreamAsync != null )
AsyncApply asyncApply = sync.applyAsync( new AddWork( 10 )
AsyncApply asyncApply = sync.applyAsync( new AddWork( 10 )
@Test public void shouldProvideLabelScanStoreUpdatesSortedByNodeId() throws Exception { // GIVEN IndexingService indexing = mock( IndexingService.class ); when( indexing.convertToIndexUpdates( any(), eq( EntityType.NODE ) ) ).thenAnswer( o -> Iterables.empty() ); LabelScanWriter writer = new OrderVerifyingLabelScanWriter( 10, 15, 20 ); WorkSync<Supplier<LabelScanWriter>,LabelUpdateWork> labelScanSync = spy( new WorkSync<>( singletonProvider( writer ) ) ); WorkSync<IndexingUpdateService,IndexUpdatesWork> indexUpdatesSync = new WorkSync<>( indexing ); TransactionToApply tx = mock( TransactionToApply.class ); PropertyStore propertyStore = mock( PropertyStore.class ); try ( IndexBatchTransactionApplier applier = new IndexBatchTransactionApplier( indexing, labelScanSync, indexUpdatesSync, mock( NodeStore.class ), mock( RelationshipStore.class ), new PropertyPhysicalToLogicalConverter( propertyStore ), new IndexActivator( indexing ) ) ) { try ( TransactionApplier txApplier = applier.startTx( tx ) ) { // WHEN txApplier.visitNodeCommand( node( 15 ) ); txApplier.visitNodeCommand( node( 20 ) ); txApplier.visitNodeCommand( node( 10 ) ); } } // THEN all assertions happen inside the LabelScanWriter#write and #close verify( labelScanSync ).applyAsync( any() ); }
labelUpdatesApply = labelScanStoreSync.applyAsync( new LabelUpdateWork( labelUpdates ) ); labelUpdates = null;
AsyncApply async = downstreamWorkSync.applyAsync( new SendDownstream( ticket, batch, downstreamIdleTime ) ); if ( downstreamAsync != null )