use of org.neo4j.common.DependencyResolver in project neo4j by neo4j.
the class FileWatchIT method doNotNotifyAboutIndexFilesDeletion.
@Test
void doNotNotifyAboutIndexFilesDeletion() throws IOException, InterruptedException {
DependencyResolver dependencyResolver = ((GraphDatabaseAPI) database).getDependencyResolver();
FileWatcher fileWatcher = getFileWatcher(database);
CheckPointer checkPointer = dependencyResolver.resolveDependency(CheckPointer.class);
String propertyStoreName = databaseLayout.propertyStore().getFileName().toString();
AccumulativeDeletionEventListener accumulativeListener = new AccumulativeDeletionEventListener();
ModificationEventListener modificationListener = new ModificationEventListener(propertyStoreName);
fileWatcher.addFileWatchEventListener(modificationListener);
fileWatcher.addFileWatchEventListener(accumulativeListener);
String labelName = "labelName";
String propertyName = "propertyName";
Label testLabel = Label.label(labelName);
createIndexes(database, propertyName, testLabel);
do {
createNode(database, propertyName, testLabel);
forceCheckpoint(checkPointer);
} while (!modificationListener.awaitModificationNotification());
fileWatcher.removeFileWatchEventListener(modificationListener);
ModificationEventListener afterRemovalListener = new ModificationEventListener(propertyStoreName);
fileWatcher.addFileWatchEventListener(afterRemovalListener);
dropAllIndexes(database);
do {
createNode(database, propertyName, testLabel);
forceCheckpoint(checkPointer);
} while (!afterRemovalListener.awaitModificationNotification());
accumulativeListener.assertDoesNotHaveAnyDeletions();
}
use of org.neo4j.common.DependencyResolver in project neo4j by neo4j.
the class CheckerTestBase method context.
CheckerContext context(int numberOfThreads, ConsistencyFlags consistencyFlags, ConsistencySummaryStatistics inconsistenciesSummary) throws Exception {
if (context != null) {
return context;
}
// We do this as late as possible because of how it eagerly caches which indexes exist so if the test creates an index
// this lazy instantiation allows the context to pick it up
Config config = Config.defaults(neo4j_home, directory.homePath());
DependencyResolver dependencies = db.getDependencyResolver();
IndexProviderMap indexProviders = dependencies.resolveDependency(IndexProviderMap.class);
IndexingService indexingService = dependencies.resolveDependency(IndexingService.class);
IndexAccessors indexAccessors = new IndexAccessors(indexProviders, neoStores, new IndexSamplingConfig(config), new LookupAccessorsFromRunningDb(indexingService), PageCacheTracer.NULL, tokenHolders, neoStores.getMetaDataStore());
InconsistencyReport report = new InconsistencyReport(new InconsistencyMessageLogger(NullLog.getInstance()), inconsistenciesSummary);
monitor = mock(ConsistencyReporter.Monitor.class);
reporter = new ConsistencyReporter(report, monitor);
countsState = new CountsState(neoStores, cacheAccess, INSTANCE);
NodeBasedMemoryLimiter limiter = new NodeBasedMemoryLimiter(pageCache.pageSize() * pageCache.maxCachedPages(), Runtime.getRuntime().maxMemory(), Long.MAX_VALUE, CacheSlots.CACHE_LINE_SIZE_BYTES, nodeStore.getHighId(), 1);
ProgressMonitorFactory.MultiPartBuilder progress = ProgressMonitorFactory.NONE.multipleParts("Test");
ParallelExecution execution = new ParallelExecution(numberOfThreads, NOOP_EXCEPTION_HANDLER, IDS_PER_CHUNK);
context = new CheckerContext(neoStores, indexAccessors, execution, reporter, cacheAccess, tokenHolders, new RecordLoading(neoStores), countsState, limiter, progress, pageCache, PageCacheTracer.NULL, INSTANCE, DebugContext.NO_DEBUG, consistencyFlags);
context.initialize();
return context;
}
use of org.neo4j.common.DependencyResolver in project neo4j by neo4j.
the class HttpStructuredLoggingIT method shouldLogRequestsInStructuredFormat.
@Test
public void shouldLogRequestsInStructuredFormat() throws Exception {
var bootstrapper = new CommunityBootstrapper();
HttpResponse<String> response;
Path httpLogPath;
try {
bootstrapper.start(folder.homePath(), Map.of(HttpConnector.listen_address.name(), "localhost:0", ServerSettings.http_log_format.name(), FormattedLogFormat.JSON.name(), ServerSettings.http_logging_enabled.name(), TRUE, HttpConnector.enabled.name(), TRUE));
var dependencyResolver = getDependencyResolver(bootstrapper.getDatabaseManagementService());
var baseUri = dependencyResolver.resolveDependency(AbstractNeoWebServer.class).getBaseUri();
var config = dependencyResolver.resolveDependency(Config.class);
var request = HttpRequest.newBuilder().uri(baseUri).timeout(Duration.ofSeconds(10)).header("Accept", "application/json").header("User-Agent", HttpStructuredLoggingIT.class.getSimpleName()).GET().build();
// Just ask the discovery api for a response we don't actually care of
httpLogPath = config.get(ServerSettings.http_log_path);
response = HTTP_CLIENT.send(request, HttpResponse.BodyHandlers.ofString());
} finally {
bootstrapper.stop();
// Make sure the log manager flushes everything.
LogManager.shutdown();
}
assertThat(response.statusCode()).isEqualTo(200);
var httpLogLines = Files.readAllLines(httpLogPath).stream().map(s -> {
try {
return OBJECT_MAPPER.readValue(s, MAP_TYPE);
} catch (JsonProcessingException e) {
throw new RuntimeException(e);
}
}).collect(Collectors.toList());
assertThat(httpLogLines).anyMatch(logEntry -> logEntry.getOrDefault("message", "").contains(HttpStructuredLoggingIT.class.getSimpleName()));
}
use of org.neo4j.common.DependencyResolver in project neo4j by neo4j.
the class FullCheckTokenIndexIT method updateNodeLabelIndex.
void updateNodeLabelIndex(GraphDatabaseAPI database, IndexDescriptor index) throws IOException, IndexEntryConflictException {
DependencyResolver dependencyResolver = database.getDependencyResolver();
IndexingService indexingService = dependencyResolver.resolveDependency(IndexingService.class);
IndexAccessors.IndexAccessorLookup indexAccessorLookup = new LookupAccessorsFromRunningDb(indexingService);
IndexAccessor accessor = indexAccessorLookup.apply(index);
try (IndexUpdater indexUpdater = accessor.newUpdater(IndexUpdateMode.ONLINE, CursorContext.NULL)) {
indexUpdater.process(IndexEntryUpdate.change(100, index, new long[0], new long[] { 1 }));
}
}
use of org.neo4j.common.DependencyResolver in project neo4j by neo4j.
the class SecurityProcedureQueryTypeTest method beforeAll.
@BeforeAll
static void beforeAll() {
databaseManagementService = new TestDatabaseManagementServiceBuilder(testDirectory.homePath()).setConfig(GraphDatabaseSettings.auth_enabled, true).build();
DependencyResolver dependencyResolver = ((GraphDatabaseFacade) databaseManagementService.database("system")).getDependencyResolver();
planner = dependencyResolver.resolveDependency(FabricPlanner.class);
}
Aggregations