Search in sources :

Example 1 with InMemoryIndexProvider

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);
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) Workers(org.neo4j.unsafe.impl.batchimport.cache.idmapping.string.Workers) RecordStorageEngine(org.neo4j.kernel.impl.storageengine.impl.recordstorage.RecordStorageEngine) IndexingService(org.neo4j.kernel.impl.api.index.IndexingService) InMemoryIndexProvider(org.neo4j.kernel.impl.api.index.inmemory.InMemoryIndexProvider) IndexProxy(org.neo4j.kernel.impl.api.index.IndexProxy) Dependencies(org.neo4j.kernel.impl.util.Dependencies) Test(org.junit.Test)

Example 2 with InMemoryIndexProvider

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();
    }
}
Also used : Transaction(org.neo4j.graphdb.Transaction) Node(org.neo4j.graphdb.Node) InMemoryIndexProvider(org.neo4j.kernel.impl.api.index.inmemory.InMemoryIndexProvider) Test(org.junit.Test)

Example 3 with InMemoryIndexProvider

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();
    }
}
Also used : Transaction(org.neo4j.graphdb.Transaction) Node(org.neo4j.graphdb.Node) Label(org.neo4j.graphdb.Label) InMemoryIndexProvider(org.neo4j.kernel.impl.api.index.inmemory.InMemoryIndexProvider) Test(org.junit.Test)

Example 4 with InMemoryIndexProvider

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);
}
Also used : IndexSamplingConfig(org.neo4j.kernel.impl.api.index.sampling.IndexSamplingConfig) NewIndexDescriptor(org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor) InMemoryIndexProvider(org.neo4j.kernel.impl.api.index.inmemory.InMemoryIndexProvider)

Aggregations

InMemoryIndexProvider (org.neo4j.kernel.impl.api.index.inmemory.InMemoryIndexProvider)4 Test (org.junit.Test)3 Node (org.neo4j.graphdb.Node)2 Transaction (org.neo4j.graphdb.Transaction)2 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 Label (org.neo4j.graphdb.Label)1 NewIndexDescriptor (org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor)1 IndexProxy (org.neo4j.kernel.impl.api.index.IndexProxy)1 IndexingService (org.neo4j.kernel.impl.api.index.IndexingService)1 IndexSamplingConfig (org.neo4j.kernel.impl.api.index.sampling.IndexSamplingConfig)1 RecordStorageEngine (org.neo4j.kernel.impl.storageengine.impl.recordstorage.RecordStorageEngine)1 Dependencies (org.neo4j.kernel.impl.util.Dependencies)1 Workers (org.neo4j.unsafe.impl.batchimport.cache.idmapping.string.Workers)1