use of org.neo4j.scheduler.JobScheduler in project neo4j by neo4j.
the class IndexCheckingSelectorTest method checkIndexesWithoutValuesWithNodeChecker.
@Test
void checkIndexesWithoutValuesWithNodeChecker() throws Exception {
try (Transaction tx = db.beginTx()) {
Node node = tx.createNode(label1);
node.setProperty(property1, "value");
tx.commit();
}
try (Transaction tx = db.beginTx()) {
tx.execute("CREATE FULLTEXT INDEX FOR (n:Label1) ON EACH [n.property1]");
tx.commit();
}
dbms.shutdown();
Config config = defaults(GraphDatabaseSettings.logs_directory, layout.databaseDirectory());
JobScheduler jobScheduler = JobSchedulerFactory.createInitialisedScheduler();
ConfiguringPageCacheFactory pageCacheFactory = new ConfiguringPageCacheFactory(fs, config, NULL, NullLog.getInstance(), jobScheduler, Clocks.nanoClock(), new MemoryPools(config.get(memory_tracking)));
PageCache pageCache = pageCacheFactory.getOrCreatePageCache();
ConsistencyCheckService.Result result;
try {
result = new ConsistencyCheckService().runFullConsistencyCheck(layout, config, NONE, nullLogProvider(), fs, pageCache, debugContext, layout.databaseDirectory(), DEFAULT, NULL, INSTANCE);
} finally {
pageCache.close();
jobScheduler.close();
}
assertTrue(result.isSuccessful());
assertThat(output.toString()).contains("IndexChecker[entityType:NODE,indexesToCheck:1]").containsPattern("NodeChecker\\[highId:.,indexesToCheck:0\\]");
}
use of org.neo4j.scheduler.JobScheduler in project neo4j by neo4j.
the class ConsistencyCheckService method runFullConsistencyCheck.
public Result runFullConsistencyCheck(DatabaseLayout databaseLayout, Config config, ProgressMonitorFactory progressFactory, LogProvider logProvider, FileSystemAbstraction fileSystem, boolean verbose, Path reportDir, ConsistencyFlags consistencyFlags) throws ConsistencyCheckIncompleteException {
Log log = logProvider.getLog(getClass());
JobScheduler jobScheduler = JobSchedulerFactory.createInitialisedScheduler();
var pageCacheTracer = PageCacheTracer.NULL;
var memoryTracker = EmptyMemoryTracker.INSTANCE;
ConfiguringPageCacheFactory pageCacheFactory = new ConfiguringPageCacheFactory(fileSystem, config, pageCacheTracer, logProvider.getLog(PageCache.class), jobScheduler, Clocks.nanoClock(), new MemoryPools(config.get(memory_tracking)));
PageCache pageCache = pageCacheFactory.getOrCreatePageCache();
try {
return runFullConsistencyCheck(databaseLayout, config, progressFactory, logProvider, fileSystem, pageCache, verbose, reportDir, consistencyFlags, pageCacheTracer, memoryTracker);
} finally {
try {
pageCache.close();
} catch (Exception e) {
log.error("Failure during shutdown of the page cache", e);
}
try {
jobScheduler.close();
} catch (Exception e) {
log.error("Failure during shutdown of the job scheduler", e);
}
}
}
use of org.neo4j.scheduler.JobScheduler in project neo4j by neo4j.
the class ConsistencyCheckService method runFullConsistencyCheck.
public Result runFullConsistencyCheck(DatabaseLayout databaseLayout, Config config, ProgressMonitorFactory progressFactory, final LogProvider logProvider, final FileSystemAbstraction fileSystem, final PageCache pageCache, DebugContext debugContext, Path reportDir, ConsistencyFlags consistencyFlags, PageCacheTracer pageCacheTracer, MemoryTracker memoryTracker) throws ConsistencyCheckIncompleteException {
assertRecovered(databaseLayout, config, fileSystem, memoryTracker);
Log outLog = logProvider.getLog(getClass());
config.set(GraphDatabaseSettings.pagecache_warmup_enabled, false);
LifeSupport life = new LifeSupport();
final DefaultIdGeneratorFactory idGeneratorFactory = new DefaultIdGeneratorFactory(fileSystem, immediate(), databaseLayout.getDatabaseName());
DatabaseReadOnlyChecker readOnlyChecker = readOnly();
StoreFactory factory = new StoreFactory(databaseLayout, config, idGeneratorFactory, pageCache, fileSystem, logProvider, pageCacheTracer, readOnlyChecker);
// Don't start the counts stores here as part of life, instead only shut down. This is because it's better to let FullCheck
// start it and add its missing/broken detection where it can report to user.
ConsistencySummaryStatistics summary;
final Path reportFile = chooseReportPath(reportDir);
Log4jLogProvider reportLogProvider = new Log4jLogProvider(LogConfig.createBuilder(fileSystem, reportFile, Level.INFO).createOnDemand().withCategory(false).build());
Log reportLog = reportLogProvider.getLog(getClass());
Log log = new DuplicatingLog(outLog, reportLog);
// Bootstrap kernel extensions
Monitors monitors = new Monitors();
JobScheduler jobScheduler = life.add(JobSchedulerFactory.createInitialisedScheduler());
TokenHolders tokenHolders = new TokenHolders(new DelegatingTokenHolder(new ReadOnlyTokenCreator(), TokenHolder.TYPE_PROPERTY_KEY), new DelegatingTokenHolder(new ReadOnlyTokenCreator(), TokenHolder.TYPE_LABEL), new DelegatingTokenHolder(new ReadOnlyTokenCreator(), TokenHolder.TYPE_RELATIONSHIP_TYPE));
final RecoveryCleanupWorkCollector workCollector = RecoveryCleanupWorkCollector.ignore();
DatabaseExtensions extensions = life.add(instantiateExtensions(databaseLayout, fileSystem, config, new SimpleLogService(logProvider), pageCache, jobScheduler, workCollector, // We use TOOL context because it's true, and also because it uses the 'single' operational mode, which is important.
TOOL, monitors, tokenHolders, pageCacheTracer, readOnlyChecker));
DefaultIndexProviderMap indexes = life.add(new DefaultIndexProviderMap(extensions, config));
try (NeoStores neoStores = factory.openAllNeoStores()) {
long lastCommittedTransactionId = neoStores.getMetaDataStore().getLastCommittedTransactionId();
CountsStoreManager countsStoreManager = life.add(new CountsStoreManager(pageCache, fileSystem, databaseLayout, pageCacheTracer, memoryTracker, lastCommittedTransactionId));
RelationshipGroupDegreesStoreManager groupDegreesStoreManager = life.add(new RelationshipGroupDegreesStoreManager(pageCache, fileSystem, databaseLayout, pageCacheTracer, memoryTracker, lastCommittedTransactionId));
// Load tokens before starting extensions, etc.
try (var cursorContext = new CursorContext(pageCacheTracer.createPageCursorTracer(CONSISTENCY_TOKEN_READER_TAG))) {
tokenHolders.setInitialTokens(StoreTokens.allReadableTokens(neoStores), cursorContext);
}
life.start();
IndexStatisticsStore indexStatisticsStore = new IndexStatisticsStore(pageCache, databaseLayout, workCollector, readOnlyChecker, pageCacheTracer);
life.add(indexStatisticsStore);
int numberOfThreads = defaultConsistencyCheckThreadsNumber();
DirectStoreAccess stores = new DirectStoreAccess(neoStores, indexes, tokenHolders, indexStatisticsStore, idGeneratorFactory);
double memoryLimitLeewayFactor = config.get(GraphDatabaseInternalSettings.consistency_check_memory_limit_factor);
FullCheck check = new FullCheck(progressFactory, numberOfThreads, consistencyFlags, config, debugContext, NodeBasedMemoryLimiter.defaultWithLeeway(memoryLimitLeewayFactor));
summary = check.execute(pageCache, stores, countsStoreManager, groupDegreesStoreManager, null, pageCacheTracer, memoryTracker, log);
} finally {
life.shutdown();
reportLogProvider.close();
}
if (!summary.isConsistent()) {
log.warn("See '%s' for a detailed consistency report.", reportFile);
return Result.failure(reportFile, summary);
}
return Result.success(reportFile, summary);
}
use of org.neo4j.scheduler.JobScheduler in project neo4j by neo4j.
the class HttpTransactionManagerTest method shouldSetupJobScheduler.
@Test
void shouldSetupJobScheduler() {
var managementService = mock(DatabaseManagementService.class);
JobScheduler jobScheduler = mock(JobScheduler.class);
AssertableLogProvider logProvider = new AssertableLogProvider(true);
new HttpTransactionManager(managementService, mock(MemoryPool.class), jobScheduler, Clocks.systemClock(), Duration.ofMinutes(1), logProvider);
long runEvery = Math.round(Duration.ofMinutes(1).toMillis() / 2.0);
verify(jobScheduler).scheduleRecurring(eq(Group.SERVER_TRANSACTION_TIMEOUT), any(JobMonitoringParams.class), any(), eq(runEvery), eq(TimeUnit.MILLISECONDS));
}
use of org.neo4j.scheduler.JobScheduler in project neo4j by neo4j.
the class HttpTransactionManagerTest method shouldCreateTransactionHandleRegistry.
@Test
void shouldCreateTransactionHandleRegistry() {
var managementService = mock(DatabaseManagementService.class);
JobScheduler jobScheduler = mock(JobScheduler.class);
AssertableLogProvider logProvider = new AssertableLogProvider(true);
var manager = new HttpTransactionManager(managementService, mock(MemoryPool.class), jobScheduler, Clocks.systemClock(), Duration.ofMinutes(1), logProvider);
assertNotNull(manager.getTransactionHandleRegistry());
}
Aggregations