use of org.neo4j.scheduler.JobScheduler in project neo4j by neo4j.
the class Recovery method isRecoveryRequired.
/**
* Check if recovery is required for a store described by provided layout.
* Custom root location for transaction logs can be provided using {@link GraphDatabaseSettings#transaction_logs_root_path} config setting value.
*
* @param fs database filesystem
* @param databaseLayout layout of database to check for recovery
* @param config custom configuration
* @return true if recovery is required, false otherwise.
* @throws IOException on any unexpected I/O exception encountered during recovery.
*/
public static boolean isRecoveryRequired(FileSystemAbstraction fs, DatabaseLayout databaseLayout, Config config, MemoryTracker memoryTracker) throws Exception {
requireNonNull(databaseLayout);
requireNonNull(config);
requireNonNull(fs);
try (JobScheduler jobScheduler = JobSchedulerFactory.createInitialisedScheduler();
PageCache pageCache = getPageCache(config, fs, jobScheduler)) {
StorageEngineFactory storageEngineFactory = StorageEngineFactory.defaultStorageEngine();
return isRecoveryRequired(fs, pageCache, databaseLayout, storageEngineFactory, config, Optional.empty(), memoryTracker);
}
}
use of org.neo4j.scheduler.JobScheduler in project neo4j by neo4j.
the class Recovery method instantiateRecoveryExtensions.
private static DatabaseExtensions instantiateRecoveryExtensions(DatabaseLayout databaseLayout, FileSystemAbstraction fileSystem, Config config, LogService logService, PageCache pageCache, JobScheduler jobScheduler, DbmsInfo dbmsInfo, Monitors monitors, TokenHolders tokenHolders, RecoveryCleanupWorkCollector recoveryCleanupCollector, DatabaseReadOnlyChecker readOnlyChecker, Iterable<ExtensionFactory<?>> extensionFactories, PageCacheTracer pageCacheTracer) {
List<ExtensionFactory<?>> recoveryExtensions = stream(extensionFactories).filter(extension -> extension.getClass().isAnnotationPresent(RecoveryExtension.class)).collect(toList());
Dependencies deps = new Dependencies();
NonListenableMonitors nonListenableMonitors = new NonListenableMonitors(monitors, logService.getInternalLogProvider());
deps.satisfyDependencies(fileSystem, config, logService, pageCache, nonListenableMonitors, jobScheduler, tokenHolders, recoveryCleanupCollector, pageCacheTracer, databaseLayout, readOnlyChecker);
DatabaseExtensionContext extensionContext = new DatabaseExtensionContext(databaseLayout, dbmsInfo, deps);
return new DatabaseExtensions(extensionContext, recoveryExtensions, deps, ExtensionFailureStrategies.fail());
}
use of org.neo4j.scheduler.JobScheduler in project neo4j by neo4j.
the class GlobalModule method createJobScheduler.
private JobScheduler createJobScheduler() {
JobScheduler jobScheduler = JobSchedulerFactory.createInitialisedScheduler(globalClock);
jobScheduler.setParallelism(Group.INDEX_SAMPLING, globalConfig.get(GraphDatabaseInternalSettings.index_sampling_parallelism));
jobScheduler.setParallelism(Group.INDEX_POPULATION, globalConfig.get(GraphDatabaseInternalSettings.index_population_parallelism));
jobScheduler.setParallelism(Group.PAGE_CACHE_PRE_FETCHER, globalConfig.get(GraphDatabaseSettings.pagecache_scan_prefetch));
return jobScheduler;
}
use of org.neo4j.scheduler.JobScheduler in project neo4j by neo4j.
the class NodeImporterTest method shouldHandleLargeAmountsOfLabels.
@Test
void shouldHandleLargeAmountsOfLabels() throws IOException {
// given
IdMapper idMapper = mock(IdMapper.class);
JobScheduler scheduler = new ThreadPoolJobScheduler();
try (Lifespan life = new Lifespan(scheduler);
BatchingNeoStores stores = BatchingNeoStores.batchingNeoStoresWithExternalPageCache(fs, pageCache, NULL, layout, Standard.LATEST_RECORD_FORMATS, Configuration.DEFAULT, NullLogService.getInstance(), AdditionalInitialIds.EMPTY, Config.defaults(), INSTANCE)) {
stores.createNew();
// when
int numberOfLabels = 50;
long nodeId = 0;
try (NodeImporter importer = new NodeImporter(stores, idMapper, new DataImporter.Monitor(), NULL, INSTANCE)) {
importer.id(nodeId);
String[] labels = new String[numberOfLabels];
for (int i = 0; i < labels.length; i++) {
labels[i] = "Label" + i;
}
importer.labels(labels);
importer.endOfEntity();
}
// then
NodeStore nodeStore = stores.getNodeStore();
NodeRecord record = nodeStore.getRecord(nodeId, nodeStore.newRecord(), RecordLoad.NORMAL, CursorContext.NULL);
long[] labels = NodeLabelsField.parseLabelsField(record).get(nodeStore, CursorContext.NULL);
assertEquals(numberOfLabels, labels.length);
}
}
use of org.neo4j.scheduler.JobScheduler in project neo4j by neo4j.
the class LabelsAcceptanceTest method oversteppingMaxNumberOfLabelsShouldFailGracefully.
@Test
void oversteppingMaxNumberOfLabelsShouldFailGracefully() throws IOException {
JobScheduler scheduler = JobSchedulerFactory.createScheduler();
try (EphemeralFileSystemAbstraction fileSystem = new EphemeralFileSystemAbstraction();
Lifespan lifespan = new Lifespan(scheduler);
PageCache pageCache = new MuninnPageCache(swapper(fileSystem), scheduler, MuninnPageCache.config(1_000))) {
// Given
Dependencies dependencies = new Dependencies();
dependencies.satisfyDependencies(createIdContextFactoryWithMaxedOutLabelTokenIds(fileSystem, scheduler));
DatabaseManagementService managementService = new TestDatabaseManagementServiceBuilder().setFileSystem(fileSystem).noOpSystemGraphInitializer().setExternalDependencies(dependencies).impermanent().build();
GraphDatabaseService graphDatabase = managementService.database(DEFAULT_DATABASE_NAME);
// When
try (Transaction tx = graphDatabase.beginTx()) {
assertThrows(ConstraintViolationException.class, () -> tx.createNode().addLabel(Labels.MY_LABEL));
}
managementService.shutdown();
}
}
Aggregations