From c99c04f72e994e626d85a57e345a1b9588da59f7 Mon Sep 17 00:00:00 2001 From: Chris Vest Date: Fri, 13 Nov 2015 16:11:09 +0100 Subject: [PATCH] Congregate more dependencies in the StorageEngine and introduce a CommandStream abstraction to decouple store application from transaction representation --- .../org/neo4j/kernel/NeoStoreDataSource.java | 173 +++++++----------- ...TransactionRepresentationStoreApplier.java | 38 ++-- ...TransactionRepresentationStoreApplier.java | 46 ++--- .../impl/storageengine/StorageEngine.java | 10 + .../recordstorage/RecordStorageEngine.java | 46 +++-- .../impl/transaction/CommandStream.java | 39 ++++ .../TransactionRepresentation.java | 9 +- .../log/rotation/StoreFlusher.java | 11 +- ...nsactionRepresentationCommitProcessIT.java | 20 +- ...sactionRepresentationStoreApplierTest.java | 26 ++- .../state/NeoStoreTransactionTest.java | 15 +- .../org/neo4j/backup/BackupEmbeddedIT.java | 4 +- .../DefaultUnpackerDependencies.java | 13 +- 13 files changed, 241 insertions(+), 209 deletions(-) create mode 100644 community/kernel/src/main/java/org/neo4j/kernel/impl/transaction/CommandStream.java diff --git a/community/kernel/src/main/java/org/neo4j/kernel/NeoStoreDataSource.java b/community/kernel/src/main/java/org/neo4j/kernel/NeoStoreDataSource.java index 2f84c5558bfd9..4509f57f36f59 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/NeoStoreDataSource.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/NeoStoreDataSource.java @@ -77,7 +77,6 @@ import org.neo4j.kernel.impl.api.store.ProcedureCache; import org.neo4j.kernel.impl.api.store.StoreReadLayer; import org.neo4j.kernel.impl.constraints.ConstraintSemantics; -import org.neo4j.kernel.impl.core.CacheAccessBackDoor; import org.neo4j.kernel.impl.core.LabelTokenHolder; import org.neo4j.kernel.impl.core.NodeManager; import org.neo4j.kernel.impl.core.PropertyKeyTokenHolder; @@ -166,29 +165,6 @@ public class NeoStoreDataSource implements NeoStoresSupplier, Lifecycle, IndexProviders { - private interface CacheModule - { - UpdateableSchemaState updateableSchemaState(); - } - - private interface StoreLayerModule extends StorageEngine - { - - NeoStores neoStores(); - MetaDataStore metaDataStore(); - - // TODO encapsulate the indexing methods - IndexingService indexingService(); - IndexUpdatesValidator indexUpdatesValidator(); - LabelScanStore labelScanStore(); - IntegrityValidator integrityValidator(); - SchemaIndexProviderMap schemaIndexProviderMap(); - CacheAccessBackDoor cacheAccess(); - ProcedureCache procedureCache(); - - void loadSchemaCache(); - } - private interface TransactionLogModule { TransactionRepresentationStoreApplier storeApplier(); @@ -230,7 +206,7 @@ enum Diagnostics implements DiagnosticsExtractor @Override void dump( NeoStoreDataSource source, Logger logger ) { - source.storeLayerModule.neoStores().logVersions( logger ); + source.storageEngine.neoStores().logVersions( logger ); } }, NEO_STORE_ID_USAGE( "Id usage:" ) @@ -238,7 +214,7 @@ void dump( NeoStoreDataSource source, Logger logger ) @Override void dump( NeoStoreDataSource source, Logger logger ) { - source.storeLayerModule.neoStores().logIdUsage( logger ); + source.storageEngine.neoStores().logIdUsage( logger ); } }, NEO_STORE_RECORDS( "Neostore records:" ) @@ -246,7 +222,7 @@ void dump( NeoStoreDataSource source, Logger logger ) @Override void dump( NeoStoreDataSource source, Logger log ) { - source.storeLayerModule.neoStores().getMetaDataStore().logRecords( log ); + source.storageEngine.neoStores().getMetaDataStore().logRecords( log ); } }, TRANSACTION_RANGE( "Transaction log:" ) @@ -348,7 +324,7 @@ boolean applicable( DiagnosticsPhase phase ) private File storeDir; private boolean readOnly; - private StoreLayerModule storeLayerModule; + private StorageEngine storageEngine; private TransactionLogModule transactionLogModule; private KernelModule kernelModule; @@ -476,56 +452,55 @@ public void start() throws IOException upgradeStore( storeDir, storeMigrationProcess, indexProvider ); // Build all modules and their services - StoreLayerModule storeLayerModule = null; + StorageEngine storageEngine = null; try { - LegacyIndexApplierLookup legacyIndexApplierLookup = - dependencies.satisfyDependency( new LegacyIndexApplierLookup.Direct( legacyIndexProviderLookup ) ); - UpdateableSchemaState updateableSchemaState = new KernelSchemaStateStore( logProvider ); // TODO Introduce a StorageEngine abstraction at the StoreLayerModule boundary - storeLayerModule = buildStoreLayer( - propertyKeyTokenHolder, labelTokens, relationshipTypeTokens, + storageEngine = buildStorageEngine( + propertyKeyTokenHolder, labelTokens, relationshipTypeTokens, legacyIndexProviderLookup, updateableSchemaState::clear ); TransactionLogModule transactionLogModule = - buildTransactionLogs( storeDir, config, logProvider, scheduler, storeLayerModule.labelScanStore(), - fs, storeLayerModule.neoStores(), storeLayerModule.cacheAccess(), storeLayerModule.indexingService(), - indexProviders.values(), legacyIndexApplierLookup ); + buildTransactionLogs( storeDir, config, logProvider, scheduler, + fs, + indexProviders.values(), storageEngine ); - buildRecovery( fs, storeLayerModule.cacheAccess(), storeLayerModule.indexingService(), - storeLayerModule.labelScanStore(), storeLayerModule.neoStores(), + buildRecovery( fs, storageEngine.indexingService(), + storageEngine.labelScanStore(), storageEngine.neoStores(), monitors.newMonitor( RecoveryVisitor.Monitor.class ), monitors.newMonitor( Recovery.Monitor.class ), transactionLogModule.logFiles(), transactionLogModule.storeFlusher(), startupStatistics, - legacyIndexApplierLookup ); + storageEngine.legacyIndexApplierLookup(), storageEngine ); - KernelModule kernelModule = buildKernel( storeLayerModule.integrityValidator(), - transactionLogModule.transactionAppender(), storeLayerModule.neoStores(), - transactionLogModule.storeApplier(), storeLayerModule.indexingService(), - storeLayerModule.indexUpdatesValidator(), - storeLayerModule.storeReadLayer(), - updateableSchemaState, storeLayerModule.labelScanStore(), - storeLayerModule.schemaIndexProviderMap(), storeLayerModule.procedureCache(), storeLayerModule ); + KernelModule kernelModule = buildKernel( storageEngine.integrityValidator(), + transactionLogModule.transactionAppender(), storageEngine.neoStores(), + transactionLogModule.storeApplier(), storageEngine.indexingService(), + storageEngine.indexUpdatesValidator(), + storageEngine.storeReadLayer(), + updateableSchemaState, storageEngine.labelScanStore(), + storageEngine.schemaIndexProviderMap(), storageEngine.procedureCache(), storageEngine ); // Do these assignments last so that we can ensure no cyclical dependencies exist - this.storeLayerModule = storeLayerModule; + this.storageEngine = storageEngine; this.transactionLogModule = transactionLogModule; this.kernelModule = kernelModule; dependencies.satisfyDependency( this ); dependencies.satisfyDependency( updateableSchemaState ); - dependencies.satisfyDependencies( storeLayerModule.cacheAccess() ); - dependencies.satisfyDependencies( storeLayerModule.indexingService() ); - dependencies.satisfyDependencies( storeLayerModule.indexUpdatesValidator() ); - dependencies.satisfyDependencies( storeLayerModule.integrityValidator() ); - dependencies.satisfyDependencies( storeLayerModule.labelScanStore() ); - dependencies.satisfyDependencies( storeLayerModule.metaDataStore() ); - dependencies.satisfyDependencies( storeLayerModule.neoStores() ); - dependencies.satisfyDependencies( storeLayerModule.procedureCache() ); - dependencies.satisfyDependencies( storeLayerModule.schemaIndexProviderMap() ); - dependencies.satisfyDependencies( storeLayerModule.storeReadLayer() ); + dependencies.satisfyDependency( storageEngine.cacheAccess() ); + dependencies.satisfyDependency( storageEngine.indexingService() ); + dependencies.satisfyDependency( storageEngine.indexUpdatesValidator() ); + dependencies.satisfyDependency( storageEngine.integrityValidator() ); + dependencies.satisfyDependency( storageEngine.labelScanStore() ); + dependencies.satisfyDependency( storageEngine.metaDataStore() ); + dependencies.satisfyDependency( storageEngine.neoStores() ); + dependencies.satisfyDependency( storageEngine.procedureCache() ); + dependencies.satisfyDependency( storageEngine.schemaIndexProviderMap() ); + dependencies.satisfyDependency( storageEngine.legacyIndexApplierLookup() ); + dependencies.satisfyDependency( storageEngine.storeReadLayer() ); + dependencies.satisfyDependency( storageEngine ); satisfyDependencies( transactionLogModule, kernelModule ); } catch ( Throwable e ) @@ -536,9 +511,9 @@ public void start() throws IOException try { // Close the neostore, so that locks are released properly - if ( storeLayerModule != null ) + if ( storageEngine != null ) { - storeLayerModule.neoStores().close(); + storageEngine.neoStores().close(); } } catch ( Exception closeException ) @@ -560,7 +535,7 @@ public void start() throws IOException try { // Close the neostore, so that locks are released properly - storeLayerModule.neoStores().close(); + storageEngine.neoStores().close(); } catch ( Exception closeException ) { @@ -590,50 +565,28 @@ private void upgradeStore( File storeDir, StoreUpgrader storeMigrationProcess, S storeMigrationProcess.migrateIfNeeded( storeDir, upgradableDatabase, indexProvider ); } - private StoreLayerModule buildStoreLayer( + private StorageEngine buildStorageEngine( PropertyKeyTokenHolder propertyKeyTokenHolder, LabelTokenHolder labelTokens, RelationshipTypeTokenHolder relationshipTypeTokens, - Runnable schemaStateChangeCallback ) + LegacyIndexProviderLookup legacyIndexProviderLookup, Runnable schemaStateChangeCallback ) { - class Module extends RecordStorageEngine implements StoreLayerModule - { - public Module( File storeDir, Config config, IdGeneratorFactory idGeneratorFactory, - PageCache pageCache, FileSystemAbstraction fs, LogProvider logProvider, - PropertyKeyTokenHolder propertyKeyTokenHolder, - LabelTokenHolder labelTokens, - RelationshipTypeTokenHolder relationshipTypeTokens, - Runnable schemaStateChangeCallback, - ConstraintSemantics constraintSemantics, JobScheduler scheduler, - TokenNameLookup tokenNameLookup, LockService lockService, - SchemaIndexProvider indexProvider, - IndexingService.Monitor indexingServiceMonitor, KernelHealth kernelHealth, - LabelScanStoreProvider labelScanStoreProvider ) - { - super( storeDir, config, idGeneratorFactory, pageCache, fs, logProvider, propertyKeyTokenHolder, - labelTokens, - relationshipTypeTokens, schemaStateChangeCallback, constraintSemantics, scheduler, - tokenNameLookup, - lockService, indexProvider, indexingServiceMonitor, kernelHealth, labelScanStoreProvider ); - } - } - LabelScanStoreProvider labelScanStore = dependencyResolver.resolveDependency( LabelScanStoreProvider.class, LabelScanStoreProvider.HIGHEST_PRIORITIZED ); return life.add( - new Module( storeDir, config, idGeneratorFactory, pageCache, fs, logProvider, propertyKeyTokenHolder, + new RecordStorageEngine( storeDir, config, idGeneratorFactory, pageCache, fs, logProvider, propertyKeyTokenHolder, labelTokens, relationshipTypeTokens, schemaStateChangeCallback, constraintSemantics, scheduler, tokenNameLookup, lockService, indexProvider, indexingServiceMonitor, kernelHealth, - labelScanStore ) ); + labelScanStore, legacyIndexProviderLookup ) ); } - private TransactionLogModule buildTransactionLogs( File storeDir, Config config, LogProvider logProvider, + private TransactionLogModule buildTransactionLogs( + File storeDir, + Config config, + LogProvider logProvider, JobScheduler scheduler, - LabelScanStore labelScanStore, FileSystemAbstraction fileSystemAbstraction, - NeoStores neoStores, CacheAccessBackDoor cacheAccess, - IndexingService indexingService, Iterable indexProviders, - LegacyIndexApplierLookup legacyIndexApplierLookup ) + StorageEngine storageEngine ) { TransactionMetadataCache transactionMetadataCache = new TransactionMetadataCache( 1000, 100_000 ); final PhysicalLogFiles logFiles = new PhysicalLogFiles( storeDir, PhysicalLogFile.DEFAULT_NAME, @@ -641,11 +594,11 @@ private TransactionLogModule buildTransactionLogs( File storeDir, Config config, final IdOrderingQueue legacyIndexTransactionOrdering = new SynchronizedArrayIdOrderingQueue( 20 ); final TransactionRepresentationStoreApplier storeApplier = dependencies.satisfyDependency( - new TransactionRepresentationStoreApplier( indexingService, alwaysCreateNewWriter( labelScanStore ), - neoStores, cacheAccess, lockService, legacyIndexApplierLookup, indexConfigStore, kernelHealth, - legacyIndexTransactionOrdering ) ); + new TransactionRepresentationStoreApplier( alwaysCreateNewWriter( storageEngine.labelScanStore() ), + lockService, indexConfigStore, + legacyIndexTransactionOrdering, storageEngine ) ); - MetaDataStore metaDataStore = neoStores.getMetaDataStore(); + MetaDataStore metaDataStore = storageEngine.metaDataStore(); final PhysicalLogFile logFile = life.add( new PhysicalLogFile( fileSystemAbstraction, logFiles, config.get( GraphDatabaseSettings.logical_log_rotation_threshold ), metaDataStore, metaDataStore, physicalLogMonitor, transactionMetadataCache ) ); @@ -684,8 +637,7 @@ public long getTimestampForVersion( long version ) throws IOException final LogPruning logPruning = new LogPruningImpl( logPruneStrategy, logProvider ); - final StoreFlusher storeFlusher = new StoreFlusher( - neoStores, indexingService, labelScanStore, indexProviders ); + final StoreFlusher storeFlusher = new StoreFlusher( storageEngine, indexProviders ); final LogRotation logRotation = new LogRotationImpl( monitors.newMonitor( LogRotation.Monitor.class ), logFile, kernelHealth ); @@ -786,12 +738,12 @@ private Supplier alwaysCreateNewWriter( final LabelScanStore la return labelScanStore::newWriter; } - private void buildRecovery( final FileSystemAbstraction fileSystemAbstraction, CacheAccessBackDoor cacheAccess, + private void buildRecovery( final FileSystemAbstraction fileSystemAbstraction, IndexingService indexingService, LabelScanStore labelScanStore, final NeoStores neoStores, RecoveryVisitor.Monitor recoveryVisitorMonitor, Recovery.Monitor recoveryMonitor, final PhysicalLogFiles logFiles, final StoreFlusher storeFlusher, final StartupStatisticsProvider startupStatistics, - LegacyIndexApplierLookup legacyIndexApplierLookup ) + LegacyIndexApplierLookup legacyIndexApplierLookup, StorageEngine storageEngine ) { MetaDataStore metaDataStore = neoStores.getMetaDataStore(); final RecoveryLabelScanWriterProvider labelScanWriters = @@ -800,8 +752,9 @@ private void buildRecovery( final FileSystemAbstraction fileSystemAbstraction, C legacyIndexApplierLookup, 1000 ); final RecoveryIndexingUpdatesValidator indexUpdatesValidator = new RecoveryIndexingUpdatesValidator( indexingService ); final TransactionRepresentationStoreApplier storeRecoverer = - new TransactionRepresentationStoreApplier( indexingService, labelScanWriters, neoStores, cacheAccess, - lockService, legacyIndexApplierLookup, indexConfigStore, kernelHealth, IdOrderingQueue.BYPASS ); + new TransactionRepresentationStoreApplier( labelScanWriters, + lockService, indexConfigStore, IdOrderingQueue.BYPASS, + storageEngine ); RecoveryVisitor recoveryVisitor = new RecoveryVisitor( metaDataStore, storeRecoverer, indexUpdatesValidator, recoveryVisitorMonitor ); @@ -938,17 +891,17 @@ private void satisfyDependencies( Object... modules ) // Only public for testing purpose public NeoStores getNeoStores() { - return storeLayerModule.neoStores(); + return storageEngine.neoStores(); } public IndexingService getIndexService() { - return storeLayerModule.indexingService(); + return storageEngine.indexingService(); } public LabelScanStore getLabelScanStore() { - return storeLayerModule.labelScanStore(); + return storageEngine.labelScanStore(); } @Override @@ -1005,7 +958,7 @@ public synchronized void stop() life.shutdown(); // Close the NeoStores - storeLayerModule.neoStores().close(); + storageEngine.neoStores().close(); msgLog.info( "NeoStores closed" ); } // After we've released the logFile monitor there might be transactions that wants to commit, but had @@ -1015,7 +968,7 @@ public synchronized void stop() private void awaitAllTransactionsClosed() { - while ( !storeLayerModule.neoStores().getMetaDataStore().closedTransactionIdIsOnParWithOpenedTransactionId() ) + while ( !storageEngine.neoStores().getMetaDataStore().closedTransactionIdIsOnParWithOpenedTransactionId() ) { LockSupport.parkNanos( 10_000_000 ); // 10 ms } @@ -1081,12 +1034,12 @@ public void registerDiagnosticsWith( DiagnosticsManager manager ) @Override public NeoStores get() { - return storeLayerModule.neoStores(); + return storageEngine.neoStores(); } public StoreReadLayer getStoreLayer() { - return storeLayerModule.storeReadLayer(); + return storageEngine.storeReadLayer(); } public DependencyResolver getDependencyResolver() @@ -1169,7 +1122,7 @@ public void beforeModeSwitch() */ public void afterModeSwitch() { - storeLayerModule.loadSchemaCache(); + storageEngine.loadSchemaCache(); // Get rid of all pooled transactions, as they will otherwise reference // components that have been swapped out during the mode switch. kernelModule.kernelTransactions().disposeAll(); diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/api/BatchingTransactionRepresentationStoreApplier.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/api/BatchingTransactionRepresentationStoreApplier.java index 7cdcd384bdf63..594c9f8b2cd2d 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/impl/api/BatchingTransactionRepresentationStoreApplier.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/api/BatchingTransactionRepresentationStoreApplier.java @@ -23,12 +23,10 @@ import org.neo4j.kernel.KernelHealth; import org.neo4j.kernel.RecoveryLabelScanWriterProvider; -import org.neo4j.kernel.api.labelscan.LabelScanStore; import org.neo4j.kernel.impl.api.index.IndexingService; -import org.neo4j.kernel.impl.core.CacheAccessBackDoor; import org.neo4j.kernel.impl.index.IndexConfigStore; import org.neo4j.kernel.impl.locking.LockService; -import org.neo4j.kernel.impl.store.NeoStores; +import org.neo4j.kernel.impl.storageengine.StorageEngine; import org.neo4j.kernel.impl.util.IdOrderingQueue; /** @@ -40,35 +38,35 @@ public class BatchingTransactionRepresentationStoreApplier extends TransactionRe { private final RecoveryLabelScanWriterProvider labelScanWriterProvider; private final RecoveryLegacyIndexApplierLookup legacyIndexApplierLookup; - private KernelHealth health; + private final KernelHealth health; + private final IndexingService indexingService; - public BatchingTransactionRepresentationStoreApplier( IndexingService indexingService, - LabelScanStore labelScanStore, NeoStores neoStore, CacheAccessBackDoor cacheAccess, - LockService lockService, LegacyIndexApplierLookup legacyIndexProviderLookup, - IndexConfigStore indexConfigStore, KernelHealth kernelHealth, IdOrderingQueue legacyIndexTransactionOrdering ) + public BatchingTransactionRepresentationStoreApplier( + LockService lockService, + IndexConfigStore indexConfigStore, + IdOrderingQueue legacyIndexTransactionOrdering, + StorageEngine storageEngine ) { - this( indexingService, new RecoveryLabelScanWriterProvider( labelScanStore, 1000 ), - neoStore, cacheAccess, lockService, - new RecoveryLegacyIndexApplierLookup( legacyIndexProviderLookup, 1000 ), - indexConfigStore, kernelHealth, legacyIndexTransactionOrdering ); - this.health = kernelHealth; + this( new RecoveryLabelScanWriterProvider( storageEngine.labelScanStore(), 1000 ), + lockService, + new RecoveryLegacyIndexApplierLookup( storageEngine.legacyIndexApplierLookup(), 1000 ), + indexConfigStore, legacyIndexTransactionOrdering, storageEngine ); } private BatchingTransactionRepresentationStoreApplier( - IndexingService indexingService, RecoveryLabelScanWriterProvider labelScanWriterProvider, - NeoStores neoStore, - CacheAccessBackDoor cacheAccess, LockService lockService, RecoveryLegacyIndexApplierLookup legacyIndexApplierLookup, IndexConfigStore indexConfigStore, - KernelHealth kernelHealth, - IdOrderingQueue legacyIndexTransactionOrdering ) + IdOrderingQueue legacyIndexTransactionOrdering, + StorageEngine storageEngine ) { - super( indexingService, labelScanWriterProvider, neoStore, cacheAccess, lockService, legacyIndexApplierLookup, - indexConfigStore, kernelHealth, legacyIndexTransactionOrdering ); + super( labelScanWriterProvider, lockService, + indexConfigStore, legacyIndexTransactionOrdering, storageEngine ); this.labelScanWriterProvider = labelScanWriterProvider; this.legacyIndexApplierLookup = legacyIndexApplierLookup; + this.health = storageEngine.kernelHealth(); + this.indexingService = storageEngine.indexingService(); } public void closeBatch() throws IOException diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/api/TransactionRepresentationStoreApplier.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/api/TransactionRepresentationStoreApplier.java index d5aa8c873535a..4c91d7052f651 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/impl/api/TransactionRepresentationStoreApplier.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/api/TransactionRepresentationStoreApplier.java @@ -23,14 +23,12 @@ import java.util.function.Supplier; import org.neo4j.concurrent.WorkSync; -import org.neo4j.kernel.KernelHealth; -import org.neo4j.kernel.impl.api.index.IndexingService; import org.neo4j.kernel.impl.api.index.ValidatedIndexUpdates; -import org.neo4j.kernel.impl.core.CacheAccessBackDoor; import org.neo4j.kernel.impl.index.IndexConfigStore; import org.neo4j.kernel.impl.locking.LockGroup; import org.neo4j.kernel.impl.locking.LockService; -import org.neo4j.kernel.impl.store.NeoStores; +import org.neo4j.kernel.impl.storageengine.StorageEngine; +import org.neo4j.kernel.impl.transaction.CommandStream; import org.neo4j.kernel.impl.transaction.TransactionRepresentation; import org.neo4j.kernel.impl.transaction.command.CacheInvalidationTransactionApplier; import org.neo4j.kernel.impl.transaction.command.CommandHandler; @@ -48,53 +46,48 @@ */ public class TransactionRepresentationStoreApplier { - private final NeoStores neoStores; - protected final IndexingService indexingService; - private final CacheAccessBackDoor cacheAccess; private final LockService lockService; private final Supplier labelScanWriters; private final IndexConfigStore indexConfigStore; private final LegacyIndexApplierLookup legacyIndexProviderLookup; - private final KernelHealth health; private final IdOrderingQueue legacyIndexTransactionOrdering; private final WorkSync,IndexTransactionApplier.LabelUpdateWork> labelScanStoreSync; + private final StorageEngine storageEngine; public TransactionRepresentationStoreApplier( - IndexingService indexingService, Supplier labelScanWriters, NeoStores neoStores, - CacheAccessBackDoor cacheAccess, LockService lockService, LegacyIndexApplierLookup - legacyIndexProviderLookup, - IndexConfigStore indexConfigStore, KernelHealth health, IdOrderingQueue legacyIndexTransactionOrdering ) + Supplier labelScanWriters, + LockService lockService, + IndexConfigStore indexConfigStore, + IdOrderingQueue legacyIndexTransactionOrdering, + StorageEngine storageEngine ) { - this.indexingService = indexingService; + this.storageEngine = storageEngine; this.labelScanWriters = labelScanWriters; - this.neoStores = neoStores; - this.cacheAccess = cacheAccess; this.lockService = lockService; - this.legacyIndexProviderLookup = legacyIndexProviderLookup; + this.legacyIndexProviderLookup = storageEngine.legacyIndexApplierLookup(); this.indexConfigStore = indexConfigStore; - this.health = health; this.legacyIndexTransactionOrdering = legacyIndexTransactionOrdering; labelScanStoreSync = new WorkSync<>( labelScanWriters ); } - public void apply( TransactionRepresentation representation, ValidatedIndexUpdates indexUpdates, LockGroup locks, + public void apply( CommandStream representation, ValidatedIndexUpdates indexUpdates, LockGroup locks, long transactionId, TransactionApplicationMode mode ) throws IOException { // Graph store application. The order of the decorated store appliers is irrelevant CommandHandler storeApplier = new NeoStoreTransactionApplier( - neoStores, cacheAccess, lockService, locks, transactionId ); + storageEngine.neoStores(), storageEngine.cacheAccess(), lockService, locks, transactionId ); if ( mode.needsIdTracking() ) { - storeApplier = new HighIdTransactionApplier( storeApplier, neoStores ); + storeApplier = new HighIdTransactionApplier( storeApplier, storageEngine.neoStores() ); } if ( mode.needsCacheInvalidationOnUpdates() ) { - storeApplier = new CacheInvalidationTransactionApplier( storeApplier, neoStores, cacheAccess ); + storeApplier = new CacheInvalidationTransactionApplier( storeApplier, storageEngine.neoStores(), storageEngine.cacheAccess() ); } // Schema index application - IndexTransactionApplier indexApplier = new IndexTransactionApplier( indexingService, indexUpdates, + IndexTransactionApplier indexApplier = new IndexTransactionApplier( storageEngine.indexingService(), indexUpdates, labelScanStoreSync ); // Legacy index application @@ -112,7 +105,7 @@ public void apply( TransactionRepresentation representation, ValidatedIndexUpdat } catch ( Throwable cause ) { - health.panic( cause ); + storageEngine.kernelHealth().panic( cause ); throw cause; } } @@ -120,7 +113,7 @@ public void apply( TransactionRepresentation representation, ValidatedIndexUpdat private CommandHandler getCountsStoreApplier( long transactionId, TransactionApplicationMode mode ) { Optional handlerOption = - neoStores.getCounts().apply( transactionId ).map( CountsStoreApplier.FACTORY ); + storageEngine.neoStores().getCounts().apply( transactionId ).map( CountsStoreApplier.FACTORY ); if ( mode == TransactionApplicationMode.RECOVERY ) { handlerOption = handlerOption.or( CommandHandler.EMPTY ); @@ -131,7 +124,8 @@ private CommandHandler getCountsStoreApplier( long transactionId, TransactionApp public TransactionRepresentationStoreApplier withLegacyIndexTransactionOrdering( IdOrderingQueue legacyIndexTransactionOrdering ) { - return new TransactionRepresentationStoreApplier( indexingService, labelScanWriters, neoStores, cacheAccess, - lockService, legacyIndexProviderLookup, indexConfigStore, health, legacyIndexTransactionOrdering ); + return new TransactionRepresentationStoreApplier( labelScanWriters, + lockService, indexConfigStore, legacyIndexTransactionOrdering, + storageEngine ); } } diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/storageengine/StorageEngine.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/storageengine/StorageEngine.java index 4b2257232087f..be3204fad14b3 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/impl/storageengine/StorageEngine.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/storageengine/StorageEngine.java @@ -19,7 +19,9 @@ */ package org.neo4j.kernel.impl.storageengine; +import org.neo4j.kernel.KernelHealth; import org.neo4j.kernel.api.labelscan.LabelScanStore; +import org.neo4j.kernel.impl.api.LegacyIndexApplierLookup; import org.neo4j.kernel.impl.api.index.IndexUpdatesValidator; import org.neo4j.kernel.impl.api.index.IndexingService; import org.neo4j.kernel.impl.api.index.SchemaIndexProviderMap; @@ -63,4 +65,12 @@ public interface StorageEngine @Deprecated CacheAccessBackDoor cacheAccess(); + + @Deprecated + LegacyIndexApplierLookup legacyIndexApplierLookup(); + + @Deprecated + KernelHealth kernelHealth(); + + void loadSchemaCache(); } diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/storageengine/impl/recordstorage/RecordStorageEngine.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/storageengine/impl/recordstorage/RecordStorageEngine.java index 89a74e8ca7b90..e26169f86a95e 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/impl/storageengine/impl/recordstorage/RecordStorageEngine.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/storageengine/impl/recordstorage/RecordStorageEngine.java @@ -33,6 +33,8 @@ import org.neo4j.kernel.api.index.SchemaIndexProvider; import org.neo4j.kernel.api.labelscan.LabelScanStore; import org.neo4j.kernel.configuration.Config; +import org.neo4j.kernel.impl.api.LegacyIndexApplierLookup; +import org.neo4j.kernel.impl.api.LegacyIndexProviderLookup; import org.neo4j.kernel.impl.api.index.IndexUpdateMode; import org.neo4j.kernel.impl.api.index.IndexUpdatesValidator; import org.neo4j.kernel.impl.api.index.IndexingService; @@ -83,22 +85,28 @@ public class RecordStorageEngine implements StorageEngine, Lifecycle setting( "experimental.use_read_locks_on_property_reads", BOOLEAN, TRUE ); private final StoreReadLayer storeLayer; - protected final IndexingService indexingService; - protected final NeoStores neoStores; + private final IndexingService indexingService; + private final NeoStores neoStores; private final PropertyKeyTokenHolder propertyKeyTokenHolder; private final RelationshipTypeTokenHolder relationshipTypeTokenHolder; private final LabelTokenHolder labelTokenHolder; + private final KernelHealth kernelHealth; private final SchemaCache schemaCache; - protected final IntegrityValidator integrityValidator; - protected final IndexUpdatesValidator indexUpdatesValidator; - protected final CacheAccessBackDoor cacheAccess; - protected final LabelScanStore labelScanStore; - protected final DefaultSchemaIndexProviderMap providerMap; - protected final ProcedureCache procedureCache; + private final IntegrityValidator integrityValidator; + private final IndexUpdatesValidator indexUpdatesValidator; + private final CacheAccessBackDoor cacheAccess; + private final LabelScanStore labelScanStore; + private final DefaultSchemaIndexProviderMap providerMap; + private final ProcedureCache procedureCache; + private final LegacyIndexApplierLookup legacyIndexApplierLookup; public RecordStorageEngine( - File storeDir, Config config, IdGeneratorFactory idGeneratorFactory, PageCache pageCache, - FileSystemAbstraction fs, LogProvider logProvider, + File storeDir, + Config config, + IdGeneratorFactory idGeneratorFactory, + PageCache pageCache, + FileSystemAbstraction fs, + LogProvider logProvider, PropertyKeyTokenHolder propertyKeyTokenHolder, LabelTokenHolder labelTokens, RelationshipTypeTokenHolder relationshipTypeTokens, @@ -110,11 +118,13 @@ public RecordStorageEngine( SchemaIndexProvider indexProvider, IndexingService.Monitor indexingServiceMonitor, KernelHealth kernelHealth, - LabelScanStoreProvider labelScanStoreProvider ) + LabelScanStoreProvider labelScanStoreProvider, + LegacyIndexProviderLookup legacyIndexProviderLookup ) { this.propertyKeyTokenHolder = propertyKeyTokenHolder; this.relationshipTypeTokenHolder = relationshipTypeTokens; this.labelTokenHolder = labelTokens; + this.kernelHealth = kernelHealth; final StoreFactory storeFactory = new StoreFactory( storeDir, config, idGeneratorFactory, pageCache, fs, logProvider ); neoStores = storeFactory.openAllNeoStores( true ); @@ -143,6 +153,7 @@ neoStores, kernelHealth, new PropertyLoader( neoStores ), procedureCache = new ProcedureCache(); storeLayer = new CacheLayer( diskLayer, schemaCache, procedureCache ); this.labelScanStore = labelScanStoreProvider.getLabelScanStore(); + legacyIndexApplierLookup = new LegacyIndexApplierLookup.Direct( legacyIndexProviderLookup ); } catch ( Throwable failure ) { @@ -219,6 +230,18 @@ public CacheAccessBackDoor cacheAccess() return cacheAccess; } + @Override + public LegacyIndexApplierLookup legacyIndexApplierLookup() + { + return legacyIndexApplierLookup; + } + + @Override + public KernelHealth kernelHealth() + { + return kernelHealth; + } + @Override public void init() throws Throwable { @@ -244,6 +267,7 @@ public void start() throws Throwable labelScanStore.start(); } + @Override public void loadSchemaCache() { List schemaRules = toList( neoStores.getSchemaStore().loadAllSchemaRules() ); diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/transaction/CommandStream.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/transaction/CommandStream.java new file mode 100644 index 0000000000000..d9b3a63f9fbb1 --- /dev/null +++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/transaction/CommandStream.java @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2002-2015 "Neo Technology," + * Network Engine for Objects in Lund AB [http://neotechnology.com] + * + * This file is part of Neo4j. + * + * Neo4j is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.neo4j.kernel.impl.transaction; + +import java.io.IOException; + +import org.neo4j.helpers.collection.Visitor; +import org.neo4j.kernel.impl.transaction.command.Command; + +/** + * A stream of commands from one or more transactions, that can be serialised to a transaction log or applied to a + * store. + */ +public interface CommandStream +{ + /** + * Accepts a visitor into the commands making up this transaction. + * @param visitor {@link Visitor} which will see the commands. + * @throws IOException if there were any problem reading the commands. + */ + void accept( Visitor visitor ) throws IOException; +} diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/transaction/TransactionRepresentation.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/transaction/TransactionRepresentation.java index 94dd69cf0724f..606a8b0a5ee7e 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/impl/transaction/TransactionRepresentation.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/transaction/TransactionRepresentation.java @@ -28,15 +28,8 @@ /** * Representation of a transaction that can be written to a {@link TransactionAppender} and read back later. */ -public interface TransactionRepresentation +public interface TransactionRepresentation extends CommandStream { - /** - * Accepts a visitor into the commands making up this transaction. - * @param visitor {@link Visitor} which will see the commands. - * @throws IOException if there were any problem reading the commands. - */ - void accept( Visitor visitor ) throws IOException; - /** * @return an additional header of this transaction. Just arbitrary bytes that means nothing * to this transaction representation. diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/transaction/log/rotation/StoreFlusher.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/transaction/log/rotation/StoreFlusher.java index 1901b4d25bcb8..1d9c12e03dc1d 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/impl/transaction/log/rotation/StoreFlusher.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/transaction/log/rotation/StoreFlusher.java @@ -22,6 +22,7 @@ import org.neo4j.graphdb.index.IndexImplementation; import org.neo4j.kernel.api.labelscan.LabelScanStore; import org.neo4j.kernel.impl.api.index.IndexingService; +import org.neo4j.kernel.impl.storageengine.StorageEngine; import org.neo4j.kernel.impl.store.NeoStores; public class StoreFlusher @@ -31,13 +32,13 @@ public class StoreFlusher private final LabelScanStore labelScanStore; private final Iterable indexProviders; - public StoreFlusher( NeoStores neoStores, IndexingService indexingService, - LabelScanStore labelScanStore, + public StoreFlusher( + StorageEngine storageEngine, Iterable indexProviders ) { - this.neoStores = neoStores; - this.indexingService = indexingService; - this.labelScanStore = labelScanStore; + this.neoStores = storageEngine.neoStores(); + this.indexingService = storageEngine.indexingService(); + this.labelScanStore = storageEngine.labelScanStore(); this.indexProviders = indexProviders; } diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/api/TransactionRepresentationCommitProcessIT.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/api/TransactionRepresentationCommitProcessIT.java index c63cf5af3e176..e0f229f7dc9f4 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/impl/api/TransactionRepresentationCommitProcessIT.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/impl/api/TransactionRepresentationCommitProcessIT.java @@ -61,6 +61,7 @@ import org.neo4j.kernel.impl.index.IndexDefineCommand; import org.neo4j.kernel.impl.locking.LockGroup; import org.neo4j.kernel.impl.locking.LockService; +import org.neo4j.kernel.impl.storageengine.StorageEngine; import org.neo4j.kernel.impl.store.MetaDataStore; import org.neo4j.kernel.impl.store.NeoStores; import org.neo4j.kernel.impl.store.StoreFactory; @@ -252,9 +253,14 @@ private TransactionRepresentationStoreApplier createStoreApplier( IdOrderingQueue legacyIndexTransactionOrdering, KernelHealth kernelHealth ) { - return new TransactionRepresentationStoreApplier( mock( IndexingService.class ), - mock( Supplier.class ), neoStores, mock( CacheAccessBackDoor.class ), mock( LockService.class ), - legacyIndexApplierLookup, indexStore, kernelHealth, legacyIndexTransactionOrdering ); + StorageEngine storageEngine = mock( StorageEngine.class ); + when( storageEngine.neoStores() ).thenReturn( neoStores ); + when( storageEngine.kernelHealth() ).thenReturn( kernelHealth ); + when( storageEngine.legacyIndexApplierLookup() ).thenReturn( legacyIndexApplierLookup ); + when( storageEngine.cacheAccess() ).thenReturn( mock( CacheAccessBackDoor.class ) ); + return new TransactionRepresentationStoreApplier( + mock( Supplier.class ), mock( LockService.class ), + indexStore, legacyIndexTransactionOrdering, storageEngine ); } private CheckPointerImpl createCheckPointer( MetaDataStore metaDataStore, KernelHealth kernelHealth, @@ -262,8 +268,12 @@ private CheckPointerImpl createCheckPointer( MetaDataStore metaDataStore, Kernel { CountCommittedTransactionThreshold committedTransactionThreshold = new CountCommittedTransactionThreshold( 1 ); - final StoreFlusher storeFlusher = new StoreFlusher( neoStores, mock( IndexingService.class ), - mock( LabelScanStore.class ), Iterables.empty() ); + StorageEngine storageEngine = mock( StorageEngine.class ); + when( storageEngine.neoStores() ).thenReturn( neoStores ); + when( storageEngine.indexingService() ).thenReturn( mock( IndexingService.class ) ); + when( storageEngine.labelScanStore() ).thenReturn( mock( LabelScanStore.class ) ); + final StoreFlusher storeFlusher = new StoreFlusher( + storageEngine, Iterables.empty() ); LogProvider logProvider = mock( LogProvider.class ); when( logProvider.getLog( any( Class.class ) ) ).thenReturn( mock( Log.class ) ); return new CheckPointerImpl( metaDataStore, committedTransactionThreshold, storeFlusher, diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/api/TransactionRepresentationStoreApplierTest.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/api/TransactionRepresentationStoreApplierTest.java index 963cad83862b2..a3e1fc0ec001d 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/impl/api/TransactionRepresentationStoreApplierTest.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/impl/api/TransactionRepresentationStoreApplierTest.java @@ -19,6 +19,7 @@ */ package org.neo4j.kernel.impl.api; +import org.junit.Before; import org.junit.Test; import org.mockito.Matchers; @@ -38,6 +39,7 @@ import org.neo4j.kernel.impl.locking.LockGroup; import org.neo4j.kernel.impl.locking.LockService; import org.neo4j.kernel.impl.locking.ReentrantLockService; +import org.neo4j.kernel.impl.storageengine.StorageEngine; import org.neo4j.kernel.impl.store.NeoStores; import org.neo4j.kernel.impl.store.NodeStore; import org.neo4j.kernel.impl.store.counts.CountsTracker; @@ -74,20 +76,28 @@ public class TransactionRepresentationStoreApplierTest private final IndexConfigStore indexConfigStore = mock( IndexConfigStore.class ); private final IdOrderingQueue queue = mock( IdOrderingQueue.class ); private final KernelHealth kernelHealth = mock( KernelHealth.class ); + private final StorageEngine storageEngine = mock( StorageEngine.class ); private final int transactionId = 12; + @Before + public void setUp() { final CountsTracker tracker = mock( CountsTracker.class ); when( neoStores.getCounts() ).thenReturn( tracker ); when( tracker.apply( anyLong() ) ).thenReturn( some( mock( CountsAccessor.Updater.class ) ) ); + when( storageEngine.indexingService() ).thenReturn( indexService ); + when( storageEngine.cacheAccess() ).thenReturn( cacheAccess ); + when( storageEngine.legacyIndexApplierLookup() ).thenReturn( legacyIndexProviderLookup ); + when( storageEngine.neoStores() ).thenReturn( neoStores ); + when( storageEngine.kernelHealth() ).thenReturn( kernelHealth ); } @Test public void transactionRepresentationShouldAcceptApplierVisitor() throws IOException { TransactionRepresentationStoreApplier applier = - new TransactionRepresentationStoreApplier( indexService, labelScanStore, neoStores, cacheAccess, - lockService, legacyIndexProviderLookup, indexConfigStore, kernelHealth, queue ); + new TransactionRepresentationStoreApplier( labelScanStore, + lockService, indexConfigStore, queue, storageEngine ); TransactionRepresentation transaction = mock( TransactionRepresentation.class ); @@ -106,8 +116,8 @@ public void shouldUpdateIdGeneratorsOnExternalCommit() throws IOException NodeStore nodeStore = mock( NodeStore.class ); when( neoStores.getNodeStore() ).thenReturn( nodeStore ); TransactionRepresentationStoreApplier applier = - new TransactionRepresentationStoreApplier( indexService, labelScanStore, neoStores, cacheAccess, - lockService, legacyIndexProviderLookup, indexConfigStore, kernelHealth, queue ); + new TransactionRepresentationStoreApplier( labelScanStore, + lockService, indexConfigStore, queue, storageEngine ); long nodeId = 5L; TransactionRepresentation transaction = createNodeTransaction( nodeId ); @@ -126,8 +136,8 @@ public void shouldNotifyIdQueueWhenAppliedToLegacyIndexes() throws Exception // GIVEN IdOrderingQueue queue = mock( IdOrderingQueue.class ); TransactionRepresentationStoreApplier applier = - new TransactionRepresentationStoreApplier( indexService, labelScanStore, neoStores, cacheAccess, - lockService, legacyIndexProviderLookup, indexConfigStore, kernelHealth, queue ); + new TransactionRepresentationStoreApplier( labelScanStore, + lockService, indexConfigStore, queue, storageEngine ); TransactionRepresentation transaction = new PhysicalTransactionRepresentation( indexTransaction() ); // WHEN @@ -146,8 +156,8 @@ public void shouldPanicOnIOExceptions() throws Exception // GIVEN IdOrderingQueue queue = mock( IdOrderingQueue.class ); TransactionRepresentationStoreApplier applier = - new TransactionRepresentationStoreApplier( indexService, labelScanStore, neoStores, cacheAccess, - lockService, legacyIndexProviderLookup, indexConfigStore, kernelHealth, queue ); + new TransactionRepresentationStoreApplier( labelScanStore, + lockService, indexConfigStore, queue, storageEngine ); TransactionRepresentation transaction = mock( TransactionRepresentation.class ); IOException ioex = new IOException(); //noinspection unchecked diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/transaction/state/NeoStoreTransactionTest.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/transaction/state/NeoStoreTransactionTest.java index 75163e5cd3c04..6f648f8e38b0c 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/impl/transaction/state/NeoStoreTransactionTest.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/impl/transaction/state/NeoStoreTransactionTest.java @@ -77,6 +77,7 @@ import org.neo4j.kernel.impl.locking.LockGroup; import org.neo4j.kernel.impl.locking.LockService; import org.neo4j.kernel.impl.locking.Locks; +import org.neo4j.kernel.impl.storageengine.StorageEngine; import org.neo4j.kernel.impl.store.NeoStores; import org.neo4j.kernel.impl.store.NodeStore; import org.neo4j.kernel.impl.store.SchemaStore; @@ -1479,7 +1480,8 @@ private TransactionRepresentationCommitProcess commitProcess( IndexingService in new PropertyLoader( neoStores ), indexing, IndexUpdateMode.ONLINE ) ); } - private TransactionRepresentationCommitProcess commitProcess( IndexingService indexing, + private TransactionRepresentationCommitProcess commitProcess( + IndexingService indexing, IndexUpdatesValidator indexUpdatesValidator ) throws IOException { TransactionAppender appenderMock = mock( TransactionAppender.class ); @@ -1489,15 +1491,17 @@ private TransactionRepresentationCommitProcess commitProcess( IndexingService in @SuppressWarnings( "unchecked" ) Supplier labelScanStore = mock( Supplier.class ); when( labelScanStore.get() ).thenReturn( mock( LabelScanWriter.class ) ); + StorageEngine storageEngine = mock( StorageEngine.class ); + when( storageEngine.neoStores() ).thenReturn( neoStores ); + when( storageEngine.cacheAccess() ).thenReturn( cacheAccessBackDoor ); + when( storageEngine.indexingService() ).thenReturn( indexing ); TransactionRepresentationStoreApplier applier = new TransactionRepresentationStoreApplier( - indexing, labelScanStore, neoStores, cacheAccessBackDoor, locks, null, null, null, null ); + labelScanStore, locks, null, null, storageEngine ); // Call this just to make sure the counters have been initialized. // This is only a problem in a mocked environment like this. neoStores.getMetaDataStore().nextCommittingTransactionId(); - PropertyLoader propertyLoader = new PropertyLoader( neoStores ); - return new TransactionRepresentationCommitProcess( appenderMock, applier, indexUpdatesValidator ); } @@ -1544,7 +1548,8 @@ private void commit( IndexUpdatesValidator indexUpdatesValidator, TransactionRep try ( LockGroup locks = new LockGroup() ) { - commitProcess( mockIndexing, indexUpdatesValidator ).commit( recoveredTx, locks, CommitEvent.NULL, mode ); + commitProcess( mockIndexing, indexUpdatesValidator ).commit( + recoveredTx, locks, CommitEvent.NULL, mode ); } } diff --git a/enterprise/backup/src/test/java/org/neo4j/backup/BackupEmbeddedIT.java b/enterprise/backup/src/test/java/org/neo4j/backup/BackupEmbeddedIT.java index b1f26accc41ab..f84c1cf00a788 100644 --- a/enterprise/backup/src/test/java/org/neo4j/backup/BackupEmbeddedIT.java +++ b/enterprise/backup/src/test/java/org/neo4j/backup/BackupEmbeddedIT.java @@ -37,6 +37,7 @@ import org.neo4j.graphdb.Node; import org.neo4j.graphdb.Transaction; import org.neo4j.helpers.Settings; +import org.neo4j.io.proc.ProcessUtil; import org.neo4j.test.DbRepresentation; import org.neo4j.test.EmbeddedDatabaseRule; import org.neo4j.test.ProcessStreamHandler; @@ -138,7 +139,8 @@ private void startDb( String backupPort ) public static int runBackupToolFromOtherJvmToGetExitCode( String... args ) throws Exception { - List allArgs = new ArrayList<>( Arrays.asList( "java", "-cp", System.getProperty( "java.class.path" ), BackupTool.class.getName() ) ); + List allArgs = new ArrayList<>( Arrays.asList( + ProcessUtil.getJavaExecutable().toString(), "-cp", ProcessUtil.getClassPath(), BackupTool.class.getName() ) ); allArgs.addAll( Arrays.asList( args ) ); Process process = Runtime.getRuntime().exec( allArgs.toArray( new String[allArgs.size()] )); diff --git a/enterprise/com/src/main/java/org/neo4j/com/storecopy/DefaultUnpackerDependencies.java b/enterprise/com/src/main/java/org/neo4j/com/storecopy/DefaultUnpackerDependencies.java index 59cc30f6d7bdf..f077bbf6039fc 100644 --- a/enterprise/com/src/main/java/org/neo4j/com/storecopy/DefaultUnpackerDependencies.java +++ b/enterprise/com/src/main/java/org/neo4j/com/storecopy/DefaultUnpackerDependencies.java @@ -22,17 +22,15 @@ import org.neo4j.function.Supplier; import org.neo4j.graphdb.DependencyResolver; import org.neo4j.kernel.KernelHealth; -import org.neo4j.kernel.api.labelscan.LabelScanStore; import org.neo4j.kernel.impl.api.BatchingTransactionRepresentationStoreApplier; -import org.neo4j.kernel.impl.api.LegacyIndexApplierLookup; import org.neo4j.kernel.impl.api.index.IndexUpdateMode; import org.neo4j.kernel.impl.api.index.IndexUpdatesValidator; import org.neo4j.kernel.impl.api.index.IndexingService; import org.neo4j.kernel.impl.api.index.OnlineIndexUpdatesValidator; -import org.neo4j.kernel.impl.core.CacheAccessBackDoor; import org.neo4j.kernel.impl.index.IndexConfigStore; import org.neo4j.kernel.impl.locking.LockService; import org.neo4j.kernel.impl.logging.LogService; +import org.neo4j.kernel.impl.storageengine.StorageEngine; import org.neo4j.kernel.impl.store.NeoStores; import org.neo4j.kernel.impl.transaction.log.LogFile; import org.neo4j.kernel.impl.transaction.log.TransactionAppender; @@ -54,20 +52,15 @@ public DefaultUnpackerDependencies( DependencyResolver resolver ) public BatchingTransactionRepresentationStoreApplier transactionRepresentationStoreApplier() { return new BatchingTransactionRepresentationStoreApplier( - resolver.resolveDependency( IndexingService.class ), - resolver.resolveDependency( LabelScanStore.class ), - resolver.resolveDependency( NeoStoresSupplier.class ).get(), - resolver.resolveDependency( CacheAccessBackDoor.class ), resolver.resolveDependency( LockService.class ), - resolver.resolveDependency( LegacyIndexApplierLookup.class ), resolver.resolveDependency( IndexConfigStore.class ), - resolver.resolveDependency( KernelHealth.class ), // Ideally we don't want/need a real IdOrderingQueue here because we know that // we only have a single thread applying updates as a slave anyway. But the thing // is that it's hard to change a TransactionAppender depending on role, so we // use a real one, or rather, whatever is available through the dependency resolver. - resolver.resolveDependency( IdOrderingQueue.class ) ); + resolver.resolveDependency( IdOrderingQueue.class ), + resolver.resolveDependency( StorageEngine.class ) ); } @Override