use of org.neo4j.graphdb.DependencyResolver in project neo4j by neo4j.
the class BoltFactoryImplTest method newDbMock.
private static GraphDatabaseAPI newDbMock() {
GraphDatabaseAPI db = mock(GraphDatabaseAPI.class);
DependencyResolver dependencyResolver = mock(DependencyResolver.class);
when(db.getDependencyResolver()).thenReturn(dependencyResolver);
GraphDatabaseQueryService queryService = mock(GraphDatabaseQueryService.class);
when(queryService.getDependencyResolver()).thenReturn(dependencyResolver);
when(dependencyResolver.resolveDependency(GraphDatabaseQueryService.class)).thenReturn(queryService);
return db;
}
use of org.neo4j.graphdb.DependencyResolver in project neo4j by neo4j.
the class ReadReplicaStoreCopyIT method addStoreCopyBlockingMonitor.
private static Semaphore addStoreCopyBlockingMonitor(ReadReplica readReplica) {
DependencyResolver dependencyResolver = readReplica.database().getDependencyResolver();
Monitors monitors = dependencyResolver.resolveDependency(Monitors.class);
Semaphore semaphore = new Semaphore(0);
monitors.addMonitorListener((FileCopyMonitor) file -> {
try {
semaphore.acquire();
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new RuntimeException(e);
}
});
return semaphore;
}
use of org.neo4j.graphdb.DependencyResolver in project neo4j by neo4j.
the class ReadReplicaStoreCopyIT method forceLogRotationAndPruning.
private static void forceLogRotationAndPruning(CoreClusterMember core) {
try {
DependencyResolver dependencyResolver = core.database().getDependencyResolver();
dependencyResolver.resolveDependency(LogRotation.class).rotateLogFile();
SimpleTriggerInfo info = new SimpleTriggerInfo("test");
dependencyResolver.resolveDependency(CheckPointer.class).forceCheckPoint(info);
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
use of org.neo4j.graphdb.DependencyResolver in project neo4j by neo4j.
the class GraphDatabaseFacade method init.
/**
* Create a new Core API facade, backed by the given SPI.
*
* Any required dependencies are resolved using the resolver obtained from the SPI.
*/
public final void init(SPI spi) {
DependencyResolver resolver = spi.resolver();
init(spi, resolver.resolveDependency(Guard.class), resolver.resolveDependency(ThreadToStatementContextBridge.class), resolver.resolveDependency(Config.class));
}
use of org.neo4j.graphdb.DependencyResolver in project neo4j by neo4j.
the class DetectAllRelationshipInconsistenciesIT method shouldDetectSabotagedRelationshipWhereEverItIs.
@Test
public void shouldDetectSabotagedRelationshipWhereEverItIs() throws Exception {
// GIVEN a database which lots of relationships
GraphDatabaseAPI db = getGraphDatabaseAPI();
Sabotage sabotage;
try {
Node[] nodes = new Node[1_000];
Relationship[] relationships = new Relationship[10_000];
try (Transaction tx = db.beginTx()) {
for (int i = 0; i < nodes.length; i++) {
nodes[i] = db.createNode(label("Foo"));
}
for (int i = 0; i < 10_000; i++) {
relationships[i] = random.among(nodes).createRelationshipTo(random.among(nodes), MyRelTypes.TEST);
}
tx.success();
}
// WHEN sabotaging a random relationship
DependencyResolver resolver = db.getDependencyResolver();
PageCache pageCache = resolver.resolveDependency(PageCache.class);
StoreFactory storeFactory = newStoreFactory(pageCache);
try (NeoStores neoStores = storeFactory.openNeoStores(false, StoreType.RELATIONSHIP)) {
RelationshipStore relationshipStore = neoStores.getRelationshipStore();
Relationship sabotagedRelationships = random.among(relationships);
sabotage = sabotage(relationshipStore, sabotagedRelationships.getId());
}
} finally {
db.shutdown();
}
// THEN the checker should find it, where ever it is in the store
db = getGraphDatabaseAPI();
try {
DependencyResolver resolver = db.getDependencyResolver();
PageCache pageCache = resolver.resolveDependency(PageCache.class);
StoreFactory storeFactory = newStoreFactory(pageCache);
try (NeoStores neoStores = storeFactory.openAllNeoStores()) {
StoreAccess storeAccess = new StoreAccess(neoStores).initialize();
DirectStoreAccess directStoreAccess = new DirectStoreAccess(storeAccess, db.getDependencyResolver().resolveDependency(LabelScanStore.class), db.getDependencyResolver().resolveDependency(SchemaIndexProvider.class));
int threads = random.intBetween(2, 10);
FullCheck checker = new FullCheck(getTuningConfiguration(), ProgressMonitorFactory.NONE, Statistics.NONE, threads);
AssertableLogProvider logProvider = new AssertableLogProvider(true);
ConsistencySummaryStatistics summary = checker.execute(directStoreAccess, logProvider.getLog(FullCheck.class));
int relationshipInconsistencies = summary.getInconsistencyCountForRecordType(RecordType.RELATIONSHIP);
assertTrue("Couldn't detect sabotaged relationship " + sabotage, relationshipInconsistencies > 0);
logProvider.assertContainsLogCallContaining(sabotage.after.toString());
}
} finally {
db.shutdown();
}
}
Aggregations