use of org.neo4j.internal.batchimport.cache.idmapping.string.Workers in project neo4j by neo4j.
the class IndexWorkSyncTransactionApplicationStressIT method shouldApplyIndexUpdatesInWorkSyncedBatches.
@Test
public void shouldApplyIndexUpdatesInWorkSyncedBatches() throws Exception {
// GIVEN
long duration = parseTimeMillis.apply(System.getProperty(getClass().getName() + ".duration", "2s"));
int numThreads = Integer.getInteger(getClass().getName() + ".numThreads", Runtime.getRuntime().availableProcessors());
DefaultFileSystemAbstraction fs = fileSystemRule.get();
PageCache pageCache = pageCacheRule.getPageCache(fs);
CollectingIndexUpdateListener index = new CollectingIndexUpdateListener();
RecordStorageEngine storageEngine = storageEngineRule.getWith(fs, pageCache, DatabaseLayout.ofFlat(directory.directory(DEFAULT_DATABASE_NAME))).indexUpdateListener(index).build();
storageEngine.apply(tx(singletonList(Commands.createIndexRule(DESCRIPTOR, 1, descriptor))), EXTERNAL);
// WHEN
Workers<Worker> workers = new Workers<>(getClass().getSimpleName());
final AtomicBoolean end = new AtomicBoolean();
for (int i = 0; i < numThreads; i++) {
workers.start(new Worker(i, end, storageEngine, 10, index));
}
// let the threads hammer the storage engine for some time
Thread.sleep(duration);
end.set(true);
// THEN (assertions as part of the workers applying transactions)
workers.awaitAndThrowOnError();
}
use of org.neo4j.internal.batchimport.cache.idmapping.string.Workers in project neo4j by neo4j.
the class InternalTransactionCommitProcessIT method commitDuringContinuousCheckpointing.
@Test
@Timeout(value = 5, unit = TimeUnit.MINUTES)
void commitDuringContinuousCheckpointing() throws Exception {
final AtomicBoolean done = new AtomicBoolean();
Workers<Runnable> workers = new Workers<>(getClass().getSimpleName());
try {
for (int i = 0; i < TOTAL_ACTIVE_THREADS; i++) {
workers.start(new Runnable() {
private final ThreadLocalRandom random = ThreadLocalRandom.current();
@Override
public void run() {
while (!done.get()) {
try (Transaction tx = db.beginTx()) {
tx.createNode();
tx.commit();
}
randomSleep();
}
}
private void randomSleep() {
try {
Thread.sleep(random.nextInt(50));
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}
});
}
Thread.sleep(SECONDS.toMillis(2));
} finally {
done.set(true);
}
workers.awaitAndThrowOnError();
assertThat(countsStore.txId()).as("Count store should be rotated once at least").isGreaterThan(0L);
long lastRotationTx = checkPointer.forceCheckPoint(new SimpleTriggerInfo("test"));
assertEquals(transactionIdStore.getLastClosedTransactionId(), lastRotationTx, "NeoStore last closed transaction id should be equal last count store rotation transaction id.");
assertEquals(transactionIdStore.getLastClosedTransactionId(), countsStore.txId(), "Last closed transaction should be last rotated tx in count store");
}
Aggregations