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());
}
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);
}
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();
}
}
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();
}
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();
}
Aggregations