private IndexBatchTransactionApplier newIndexTransactionApplier() { PropertyStore propertyStore = mock( PropertyStore.class ); return new IndexBatchTransactionApplier( indexingService, labelScanStoreSynchronizer, indexUpdatesSync, mock( NodeStore.class ), mock( RelationshipStore.class ), new PropertyPhysicalToLogicalConverter( propertyStore ), new IndexActivator( indexingService ) ); }
indexActivator.activateIndex( command.getSchemaRule().getId() ); case DELETE: indexingService.dropIndex( (StoreIndexDescriptor) command.getSchemaRule() ); indexActivator.indexDropped( command.getSchemaRule().getId() ); break; default:
private boolean apply( BatchTransactionApplier applier, ApplyFunction function, TransactionToApply transactionToApply ) throws Exception { try { return CommandHandlerContract.apply( applier, function, transactionToApply ); } finally { indexActivator.close(); } }
PropertyStore propertyStore = mock( PropertyStore.class ); TransactionToApply tx = mock( TransactionToApply.class ); IndexActivator indexActivator = new IndexActivator( indexing ); long indexId1 = 1; long indexId2 = 2; indexActivator.close(); verify( indexing ).activateIndex( indexId1 ); verify( indexing ).activateIndex( indexId3 );
@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() ); }
indexActivator.activateIndex( command.getSchemaRule().getId() ); case DELETE: indexingService.dropIndex( (StoreIndexDescriptor) command.getSchemaRule() ); indexActivator.indexDropped( command.getSchemaRule().getId() ); break; default:
@Override public void apply( CommandsToApply batch, TransactionApplicationMode mode ) throws Exception { // Have these command appliers as separate try-with-resource to have better control over // point between closing this and the locks above try ( IndexActivator indexActivator = new IndexActivator( indexingService ); LockGroup locks = new LockGroup(); BatchTransactionApplier batchApplier = applier( mode, indexActivator ) ) { while ( batch != null ) { try ( TransactionApplier txApplier = batchApplier.startTx( batch, locks ) ) { batch.accept( txApplier ); } batch = batch.next(); } } catch ( Throwable cause ) { TransactionApplyKernelException kernelException = new TransactionApplyKernelException( cause, "Failed to apply transaction: %s", batch ); databaseHealth.panic( kernelException ); throw kernelException; } }
@Override public void apply( CommandsToApply batch, TransactionApplicationMode mode ) throws Exception { // Have these command appliers as separate try-with-resource to have better control over // point between closing this and the locks above try ( IndexActivator indexActivator = new IndexActivator( indexingService ); LockGroup locks = new LockGroup(); BatchTransactionApplier batchApplier = applier( mode, indexActivator ) ) { while ( batch != null ) { try ( TransactionApplier txApplier = batchApplier.startTx( batch, locks ) ) { batch.accept( txApplier ); } batch = batch.next(); } } catch ( Throwable cause ) { TransactionApplyKernelException kernelException = new TransactionApplyKernelException( cause, "Failed to apply transaction: %s", batch ); databaseHealth.panic( kernelException ); throw kernelException; } }