use of org.neo4j.scheduler.JobScheduler in project neo4j by neo4j.
the class IdContextFactoryBuilderTest method createContextWithCustomIdGeneratorFactoryWhenProvided.
@Test
void createContextWithCustomIdGeneratorFactoryWhenProvided() throws IOException {
IdGeneratorFactory idGeneratorFactory = mock(IdGeneratorFactory.class);
Config config = defaults();
IdContextFactory contextFactory = IdContextFactoryBuilder.of(fs, jobScheduler, config, PageCacheTracer.NULL).withIdGenerationFactoryProvider(any -> idGeneratorFactory).build();
DatabaseIdContext idContext = contextFactory.createIdContext(databaseIdRepository.getByName("database").get());
IdGeneratorFactory bufferedGeneratorFactory = idContext.getIdGeneratorFactory();
assertThat(idContext.getIdController()).isInstanceOf(BufferedIdController.class);
assertThat(bufferedGeneratorFactory).isInstanceOf(BufferingIdGeneratorFactory.class);
((BufferingIdGeneratorFactory) bufferedGeneratorFactory).initialize(() -> mock(KernelTransactionsSnapshot.class));
Path file = testDirectory.file("a");
IdType idType = IdType.NODE;
LongSupplier highIdSupplier = () -> 0;
int maxId = 100;
idGeneratorFactory.open(pageCache, file, idType, highIdSupplier, maxId, writable(), config, NULL, immutable.empty());
verify(idGeneratorFactory).open(pageCache, file, idType, highIdSupplier, maxId, writable(), config, NULL, immutable.empty());
}
use of org.neo4j.scheduler.JobScheduler in project neo4j by neo4j.
the class IdContextFactoryBuilderTest method createContextWithFactoryWrapper.
@Test
void createContextWithFactoryWrapper() {
IdGeneratorFactory idGeneratorFactory = mock(IdGeneratorFactory.class);
Function<IdGeneratorFactory, IdGeneratorFactory> factoryWrapper = ignored -> idGeneratorFactory;
IdContextFactory contextFactory = IdContextFactoryBuilder.of(fs, jobScheduler, defaults(), PageCacheTracer.NULL).withFactoryWrapper(factoryWrapper).build();
DatabaseIdContext idContext = contextFactory.createIdContext(databaseIdRepository.getByName("database").get());
assertSame(idGeneratorFactory, idContext.getIdGeneratorFactory());
}
use of org.neo4j.scheduler.JobScheduler in project neo4j by neo4j.
the class BatchingNeoStoresTest method shouldNotOpenStoreWithNodesOrRelationshipsInIt.
@Test
void shouldNotOpenStoreWithNodesOrRelationshipsInIt() throws Throwable {
Config config = Config.defaults();
// GIVEN
someDataInTheDatabase(config);
// WHEN
DirectoryNotEmptyException exception = assertThrows(DirectoryNotEmptyException.class, () -> {
try (JobScheduler jobScheduler = new ThreadPoolJobScheduler()) {
RecordFormats recordFormats = selectForConfig(Config.defaults(), NullLogProvider.getInstance());
try (BatchingNeoStores store = batchingNeoStores(fileSystem, databaseLayout, recordFormats, Configuration.DEFAULT, NullLogService.getInstance(), EMPTY, Config.defaults(), jobScheduler, PageCacheTracer.NULL, INSTANCE)) {
store.createNew();
}
}
});
assertThat(exception.getMessage()).contains("already contains");
}
use of org.neo4j.scheduler.JobScheduler in project neo4j by neo4j.
the class BatchingNeoStoresTest method shouldRespectDbConfig.
@Test
void shouldRespectDbConfig() throws Exception {
// GIVEN
int size = 10;
Config config = Config.newBuilder().set(GraphDatabaseInternalSettings.array_block_size, size).set(GraphDatabaseInternalSettings.string_block_size, size).build();
// WHEN
RecordFormats recordFormats = LATEST_RECORD_FORMATS;
int headerSize = recordFormats.dynamic().getRecordHeaderSize();
try (JobScheduler jobScheduler = new ThreadPoolJobScheduler();
BatchingNeoStores store = batchingNeoStores(fileSystem, databaseLayout, recordFormats, Configuration.DEFAULT, NullLogService.getInstance(), EMPTY, config, jobScheduler, PageCacheTracer.NULL, INSTANCE)) {
store.createNew();
// THEN
assertEquals(size + headerSize, store.getPropertyStore().getArrayStore().getRecordSize());
assertEquals(size + headerSize, store.getPropertyStore().getStringStore().getRecordSize());
}
}
use of org.neo4j.scheduler.JobScheduler in project neo4j by neo4j.
the class ConsistencyCheckWithCorruptGBPTreeIT method corruptIndexes.
private List<Path> corruptIndexes(FileSystemAbstraction fs, DatabaseReadOnlyChecker readOnlyChecker, CorruptionInject corruptionInject, LayoutBootstrapper layoutBootstrapper, Path... targetFiles) throws Exception {
List<Path> treeFiles = new ArrayList<>();
try (JobScheduler jobScheduler = createInitialisedScheduler();
GBPTreeBootstrapper bootstrapper = new GBPTreeBootstrapper(fs, jobScheduler, layoutBootstrapper, readOnlyChecker, NULL)) {
for (Path file : targetFiles) {
GBPTreeBootstrapper.Bootstrap bootstrap = bootstrapper.bootstrapTree(file, NO_FLUSH_ON_CLOSE);
if (bootstrap.isTree()) {
treeFiles.add(file);
try (GBPTree<?, ?> gbpTree = bootstrap.getTree()) {
InspectingVisitor<?, ?> visitor = gbpTree.visit(new InspectingVisitor<>(), CursorContext.NULL);
corruptionInject.corrupt(gbpTree, visitor.get());
}
}
}
}
return treeFiles;
}
Aggregations