Search in sources :

Example 31 with DependencyResolver

use of org.neo4j.graphdb.DependencyResolver in project neo4j by neo4j.

the class BackupServiceIT method shouldContainTransactionsThatHappenDuringBackupProcess.

@Test
public void shouldContainTransactionsThatHappenDuringBackupProcess() throws Throwable {
    // given
    defaultBackupPortHostParams();
    Config defaultConfig = dbRule.getConfigCopy();
    dbRule.setConfig(OnlineBackupSettings.online_backup_enabled, "false");
    Config withOnlineBackupDisabled = dbRule.getConfigCopy();
    final Barrier.Control barrier = new Barrier.Control();
    final GraphDatabaseAPI db = dbRule.getGraphDatabaseAPI();
    // create some data
    createAndIndexNode(db, 1);
    final DependencyResolver resolver = db.getDependencyResolver();
    long expectedLastTxId = resolver.resolveDependency(TransactionIdStore.class).getLastClosedTransactionId();
    // This monitor is added server-side...
    monitors.addMonitorListener(new StoreSnoopingMonitor(barrier));
    Dependencies dependencies = new Dependencies(resolver);
    dependencies.satisfyDependencies(defaultConfig, monitors, NullLogProvider.getInstance());
    OnlineBackupKernelExtension backup = (OnlineBackupKernelExtension) new OnlineBackupExtensionFactory().newInstance(new SimpleKernelContext(storeDir, DatabaseInfo.UNKNOWN, dependencies), DependenciesProxy.dependencies(dependencies, OnlineBackupExtensionFactory.Dependencies.class));
    backup.start();
    // when
    BackupService backupService = backupService();
    ExecutorService executor = Executors.newSingleThreadExecutor();
    executor.execute(() -> {
        barrier.awaitUninterruptibly();
        createAndIndexNode(db, 1);
        resolver.resolveDependency(StorageEngine.class).flushAndForce(limiter);
        barrier.release();
    });
    BackupService.BackupOutcome backupOutcome = backupService.doFullBackup(BACKUP_HOST, backupPort, backupDir.getAbsoluteFile(), ConsistencyCheck.FULL, withOnlineBackupDisabled, BackupClient.BIG_READ_TIMEOUT, false);
    backup.stop();
    executor.shutdown();
    executor.awaitTermination(30, TimeUnit.SECONDS);
    // then
    checkPreviousCommittedTxIdFromLog(0, expectedLastTxId);
    File neoStore = new File(storeDir, MetaDataStore.DEFAULT_NAME);
    long txIdFromOrigin = MetaDataStore.getRecord(resolver.resolveDependency(PageCache.class), neoStore, Position.LAST_TRANSACTION_ID);
    checkLastCommittedTxIdInLogAndNeoStore(expectedLastTxId + 1, txIdFromOrigin);
    assertEquals(DbRepresentation.of(db), getBackupDbRepresentation());
    assertTrue(backupOutcome.isConsistent());
}
Also used : TransactionIdStore(org.neo4j.kernel.impl.transaction.log.TransactionIdStore) Config(org.neo4j.kernel.configuration.Config) Barrier(org.neo4j.test.Barrier) StorageEngine(org.neo4j.storageengine.api.StorageEngine) DependencyResolver(org.neo4j.graphdb.DependencyResolver) GraphDatabaseAPI(org.neo4j.kernel.internal.GraphDatabaseAPI) SimpleKernelContext(org.neo4j.kernel.impl.spi.SimpleKernelContext) ExecutorService(java.util.concurrent.ExecutorService) Dependencies(org.neo4j.kernel.impl.util.Dependencies) LogFile(org.neo4j.kernel.impl.transaction.log.LogFile) StoreFile(org.neo4j.kernel.impl.storemigration.StoreFile) File(java.io.File) PageCache(org.neo4j.io.pagecache.PageCache) Test(org.junit.Test)

Example 32 with DependencyResolver

use of org.neo4j.graphdb.DependencyResolver in project neo4j by neo4j.

the class EnterpriseCypherEngineProvider method createEngine.

@Override
protected QueryExecutionEngine createEngine(Dependencies deps, GraphDatabaseAPI graphAPI) {
    GraphDatabaseCypherService queryService = new GraphDatabaseCypherService(graphAPI);
    deps.satisfyDependency(queryService);
    DependencyResolver resolver = graphAPI.getDependencyResolver();
    LogService logService = resolver.resolveDependency(LogService.class);
    KernelAPI kernelAPI = resolver.resolveDependency(KernelAPI.class);
    Monitors monitors = resolver.resolveDependency(Monitors.class);
    LogProvider logProvider = logService.getInternalLogProvider();
    CommunityCompatibilityFactory inner = new CommunityCompatibilityFactory(queryService, kernelAPI, monitors, logProvider);
    EnterpriseCompatibilityFactory compatibilityFactory = new EnterpriseCompatibilityFactory(inner, queryService, kernelAPI, monitors, logProvider);
    deps.satisfyDependency(compatibilityFactory);
    return new ExecutionEngine(queryService, logProvider, compatibilityFactory);
}
Also used : LogProvider(org.neo4j.logging.LogProvider) QueryExecutionEngine(org.neo4j.kernel.impl.query.QueryExecutionEngine) Monitors(org.neo4j.kernel.monitoring.Monitors) CommunityCompatibilityFactory(org.neo4j.cypher.internal.CommunityCompatibilityFactory) GraphDatabaseCypherService(org.neo4j.cypher.javacompat.internal.GraphDatabaseCypherService) KernelAPI(org.neo4j.kernel.api.KernelAPI) EnterpriseCompatibilityFactory(org.neo4j.cypher.internal.EnterpriseCompatibilityFactory) LogService(org.neo4j.kernel.impl.logging.LogService) DependencyResolver(org.neo4j.graphdb.DependencyResolver)

Example 33 with DependencyResolver

use of org.neo4j.graphdb.DependencyResolver in project neo4j by neo4j.

the class NodeIdReuseStressIT method maybeRunIdMaintenance.

private static void maybeRunIdMaintenance(GraphDatabaseService db, int iteration) {
    if (iteration % 100 == 0 && ThreadLocalRandom.current().nextBoolean()) {
        DependencyResolver resolver = dependencyResolver(db);
        resolver.resolveDependency(IdController.class).maintenance();
    }
}
Also used : IdController(org.neo4j.kernel.impl.storageengine.impl.recordstorage.id.IdController) DependencyResolver(org.neo4j.graphdb.DependencyResolver)

Example 34 with DependencyResolver

use of org.neo4j.graphdb.DependencyResolver in project neo4j by neo4j.

the class ClusterTest method lastCommittedTxTimestamp.

private static long lastCommittedTxTimestamp(HighlyAvailableGraphDatabase db) {
    DependencyResolver resolver = db.getDependencyResolver();
    MetaDataStore metaDataStore = resolver.resolveDependency(MetaDataStore.class);
    TransactionId txInfo = metaDataStore.getLastCommittedTransaction();
    return txInfo.commitTimestamp();
}
Also used : MetaDataStore(org.neo4j.kernel.impl.store.MetaDataStore) DependencyResolver(org.neo4j.graphdb.DependencyResolver) TransactionId(org.neo4j.kernel.impl.store.TransactionId)

Example 35 with DependencyResolver

use of org.neo4j.graphdb.DependencyResolver in project neo4j by neo4j.

the class TransactionTerminationIT method activeTxCount.

private static int activeTxCount(GraphDatabaseService db) {
    DependencyResolver resolver = ((GraphDatabaseAPI) db).getDependencyResolver();
    KernelTransactions kernelTransactions = resolver.resolveDependency(KernelTransactions.class);
    return kernelTransactions.activeTransactions().size();
}
Also used : GraphDatabaseAPI(org.neo4j.kernel.internal.GraphDatabaseAPI) KernelTransactions(org.neo4j.kernel.impl.api.KernelTransactions) DependencyResolver(org.neo4j.graphdb.DependencyResolver)

Aggregations

DependencyResolver (org.neo4j.graphdb.DependencyResolver)51 GraphDatabaseAPI (org.neo4j.kernel.internal.GraphDatabaseAPI)18 Test (org.junit.Test)15 Transaction (org.neo4j.graphdb.Transaction)10 ThreadToStatementContextBridge (org.neo4j.kernel.impl.core.ThreadToStatementContextBridge)9 Before (org.junit.Before)8 RecordStorageEngine (org.neo4j.kernel.impl.storageengine.impl.recordstorage.RecordStorageEngine)8 GraphDatabaseQueryService (org.neo4j.kernel.GraphDatabaseQueryService)7 NeoStores (org.neo4j.kernel.impl.store.NeoStores)7 Monitors (org.neo4j.kernel.monitoring.Monitors)7 Node (org.neo4j.graphdb.Node)6 TestGraphDatabaseFactory (org.neo4j.test.TestGraphDatabaseFactory)6 NeoStoreDataSource (org.neo4j.kernel.NeoStoreDataSource)5 Statement (org.neo4j.kernel.api.Statement)5 File (java.io.File)4 IOException (java.io.IOException)4 Label (org.neo4j.graphdb.Label)4 PageCache (org.neo4j.io.pagecache.PageCache)4 Guard (org.neo4j.kernel.guard.Guard)4 QueryExecutionEngine (org.neo4j.kernel.impl.query.QueryExecutionEngine)4