use of org.neo4j.kernel.impl.api.index.inmemory.InMemoryIndexProvider 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());
RecordStorageEngine storageEngine = storageEngineRule.getWith(fileSystemRule.get(), pageCacheRule.getPageCache(fileSystemRule.get())).storeDirectory(directory.directory()).indexProvider(new InMemoryIndexProvider()).build();
storageEngine.apply(tx(asList(createIndexRule(InMemoryIndexProviderFactory.PROVIDER_DESCRIPTOR, 1, SchemaBoundary.map(descriptor)))), TransactionApplicationMode.EXTERNAL);
Dependencies dependencies = new Dependencies();
storageEngine.satisfyDependencies(dependencies);
IndexProxy index = dependencies.resolveDependency(IndexingService.class).getIndexProxy(descriptor);
awaitOnline(index);
// 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(RuntimeException.class);
}
use of org.neo4j.kernel.impl.api.index.inmemory.InMemoryIndexProvider in project neo4j by neo4j.
the class TestRecoveryScenarios method shouldRecoverTransactionWherePropertyIsRemovedInTheFuture.
@Test
public void shouldRecoverTransactionWherePropertyIsRemovedInTheFuture() throws Exception {
// GIVEN
createIndex(label, "key");
Node node = createNodeWithProperty("key", "value");
checkPoint();
addLabel(node, label);
InMemoryIndexProvider outdatedIndexProvider = indexProvider.snapshot();
removeProperty(node, "key");
flush.flush(db);
// WHEN
crashAndRestart(outdatedIndexProvider);
// -- really the problem was that recovery threw exception, so mostly assert that.
try (Transaction tx = db.beginTx()) {
assertEquals("Updates not propagated correctly during recovery", Collections.<Node>emptyList(), Iterators.asList(db.findNodes(label, "key", "value")));
tx.success();
}
}
use of org.neo4j.kernel.impl.api.index.inmemory.InMemoryIndexProvider in project neo4j by neo4j.
the class TestRecoveryScenarios method shouldRecoverTransactionWhereManyLabelsAreRemovedInTheFuture.
@Test
public void shouldRecoverTransactionWhereManyLabelsAreRemovedInTheFuture() throws Exception {
// GIVEN
createIndex(label, "key");
Label[] labels = new Label[16];
for (int i = 0; i < labels.length; i++) {
labels[i] = label("Label" + Integer.toHexString(i));
}
Node node;
try (Transaction tx = db.beginTx()) {
node = db.createNode(labels);
node.addLabel(label);
tx.success();
}
checkPoint();
InMemoryIndexProvider outdatedIndexProvider = indexProvider.snapshot();
setProperty(node, "key", "value");
removeLabels(node, labels);
flush.flush(db);
// WHEN
crashAndRestart(outdatedIndexProvider);
// -- really the problem was that recovery threw exception, so mostly assert that.
try (Transaction tx = db.beginTx()) {
assertEquals(node, db.findNode(label, "key", "value"));
tx.success();
}
}
use of org.neo4j.kernel.impl.api.index.inmemory.InMemoryIndexProvider in project neo4j by neo4j.
the class IndexPopulationJobTest method inMemoryPopulator.
private IndexPopulator inMemoryPopulator(boolean constraint) throws TransactionFailureException {
IndexSamplingConfig samplingConfig = new IndexSamplingConfig(Config.empty());
NewIndexDescriptor descriptor = indexDescriptor(FIRST, name, constraint);
return new InMemoryIndexProvider().getPopulator(21, descriptor, samplingConfig);
}
Aggregations