use of org.neo4j.test.scheduler.ThreadPoolJobScheduler in project neo4j by neo4j.
the class NumberArrayPageCacheTestSupport method prepareDirectoryAndPageCache.
static Fixture prepareDirectoryAndPageCache(Class<?> testClass) throws IOException {
DefaultFileSystemAbstraction fileSystem = new DefaultFileSystemAbstraction();
TestDirectory testDirectory = TestDirectory.testDirectory(testClass, fileSystem);
Path dir = testDirectory.prepareDirectoryForTest("test");
ThreadPoolJobScheduler scheduler = new ThreadPoolJobScheduler();
PageCache pageCache = StandalonePageCacheFactory.createPageCache(fileSystem, scheduler, PageCacheTracer.NULL);
return new Fixture(pageCache, fileSystem, dir, scheduler);
}
use of org.neo4j.test.scheduler.ThreadPoolJobScheduler in project neo4j by neo4j.
the class GBPTreeBootstrapperTest method shouldBootstrapTreeOfDifferentPageSizes.
@ParameterizedTest
@MethodSource("testSetupStream")
void shouldBootstrapTreeOfDifferentPageSizes(TestSetup testSetup) throws Exception {
setupTest(testSetup);
ZipUtils.unzipResource(getClass(), zipName, storeFile);
LayoutBootstrapper layoutBootstrapper = (indexFile, pageCache, meta) -> layout;
try (JobScheduler scheduler = new ThreadPoolJobScheduler();
GBPTreeBootstrapper bootstrapper = new GBPTreeBootstrapper(fs, scheduler, layoutBootstrapper, readOnly(), PageCacheTracer.NULL)) {
GBPTreeBootstrapper.Bootstrap bootstrap = bootstrapper.bootstrapTree(storeFile);
assertTrue(bootstrap.isTree());
try (GBPTree<?, ?> tree = bootstrap.getTree()) {
assertTrue(tree.consistencyCheck(CursorContext.NULL));
}
}
}
use of org.neo4j.test.scheduler.ThreadPoolJobScheduler in project neo4j by neo4j.
the class BatchingMultipleIndexPopulatorTest method populatorMarkedAsFailed.
@Test
void populatorMarkedAsFailed() throws Exception {
Update update1 = nodeUpdate(1, propertyId, "aaa", labelId);
Update update2 = nodeUpdate(1, propertyId, "bbb", labelId);
IndexStoreView storeView = newStoreView(update1, update2);
RuntimeException batchFlushError = new RuntimeException("Batch failed");
IndexPopulator populator;
ExecutorService executor = Executors.newSingleThreadExecutor();
ThreadPoolJobScheduler jobScheduler = new ThreadPoolJobScheduler(executor);
try {
MultipleIndexPopulator batchingPopulator = new MultipleIndexPopulator(storeView, NullLogProvider.getInstance(), EntityType.NODE, mock(SchemaState.class), jobScheduler, tokens, NULL, INSTANCE, "", AUTH_DISABLED, Config.defaults(GraphDatabaseInternalSettings.index_population_batch_max_byte_size, 1L));
populator = addPopulator(batchingPopulator, index1);
List<IndexEntryUpdate<IndexDescriptor>> expected = forUpdates(index1, update1, update2);
doThrow(batchFlushError).when(populator).add(eq(expected), any());
batchingPopulator.createStoreScan(NULL).run(NO_EXTERNAL_UPDATES);
} finally {
jobScheduler.shutdown();
executor.awaitTermination(1, TimeUnit.MINUTES);
}
verify(populator).markAsFailed(failure(batchFlushError).asString());
}
use of org.neo4j.test.scheduler.ThreadPoolJobScheduler in project neo4j by neo4j.
the class MultipleIndexPopulationStressIT method createRandomData.
private void createRandomData(long nodeCount, long relCount) throws Exception {
Config config = Config.defaults(neo4j_home, directory.homePath());
RecordFormats recordFormats = RecordFormatSelector.selectForConfig(config, NullLogProvider.getInstance());
try (RandomDataInput input = new RandomDataInput(nodeCount, relCount);
JobScheduler jobScheduler = new ThreadPoolJobScheduler()) {
DatabaseLayout layout = Neo4jLayout.of(directory.homePath()).databaseLayout(DEFAULT_DATABASE_NAME);
IndexImporterFactory indexImporterFactory = new IndexImporterFactoryImpl(config);
BatchImporter importer = new ParallelBatchImporter(layout, fileSystemAbstraction, PageCacheTracer.NULL, DEFAULT, NullLogService.getInstance(), ExecutionMonitor.INVISIBLE, EMPTY, config, recordFormats, NO_MONITOR, jobScheduler, Collector.EMPTY, TransactionLogInitializer.getLogFilesInitializer(), indexImporterFactory, INSTANCE);
importer.doImport(input);
}
}
use of org.neo4j.test.scheduler.ThreadPoolJobScheduler in project neo4j by neo4j.
the class NodeImporterTest method tracePageCacheAccessOnNodeImport.
@Test
void tracePageCacheAccessOnNodeImport() throws IOException {
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();
int numberOfLabels = 50;
long nodeId = 0;
var cacheTracer = new DefaultPageCacheTracer();
try (NodeImporter importer = new NodeImporter(stores, IdMappers.actual(), new DataImporter.Monitor(), cacheTracer, 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.property("a", randomAscii(10));
importer.property("b", randomAscii(100));
importer.property("c", randomAscii(1000));
importer.endOfEntity();
}
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);
assertThat(cacheTracer.faults()).isEqualTo(2);
assertThat(cacheTracer.pins()).isEqualTo(13);
assertThat(cacheTracer.unpins()).isEqualTo(13);
assertThat(cacheTracer.hits()).isEqualTo(11);
}
}
Aggregations