Search in sources :

Example 6 with SECONDS

use of java.util.concurrent.TimeUnit.SECONDS in project neo4j by neo4j.

the class DatabaseIndexAccessorTest method shouldStopSamplingWhenIndexIsDropped.

@Test
public void shouldStopSamplingWhenIndexIsDropped() throws Exception {
    // given
    updateAndCommit(asList(add(nodeId, value), add(nodeId2, value2)));
    // when
    // needs to be acquired before drop() is called
    IndexReader indexReader = accessor.newReader();
    IndexSampler indexSampler = indexReader.createSampler();
    Future<Void> drop = threading.executeAndAwait((IOFunction<Void, Void>) nothing -> {
        accessor.drop();
        return nothing;
    }, null, waitingWhileIn(TaskCoordinator.class, "awaitCompletion"), 3, SECONDS);
    try (IndexReader reader = indexReader) /* do not inline! */
    {
        indexSampler.sampleIndex();
        fail("expected exception");
    } catch (IndexNotFoundKernelException e) {
        assertEquals("Index dropped while sampling.", e.getMessage());
    } finally {
        drop.get();
    }
}
Also used : DirectoryFactory(org.neo4j.kernel.api.impl.index.storage.DirectoryFactory) Arrays(java.util.Arrays) EphemeralFileSystemRule(org.neo4j.test.rule.fs.EphemeralFileSystemRule) Iterators.asSet(org.neo4j.helpers.collection.Iterators.asSet) RunWith(org.junit.runner.RunWith) IndexNotFoundKernelException(org.neo4j.kernel.api.exceptions.index.IndexNotFoundKernelException) PrimitiveLongIterator(org.neo4j.collection.primitive.PrimitiveLongIterator) TaskCoordinator(org.neo4j.helpers.TaskCoordinator) Assert.assertThat(org.junit.Assert.assertThat) Future(java.util.concurrent.Future) IndexEntryConflictException(org.neo4j.kernel.api.exceptions.index.IndexEntryConflictException) IndexUpdater(org.neo4j.kernel.api.index.IndexUpdater) Arrays.asList(java.util.Arrays.asList) After(org.junit.After) IndexQuery.exact(org.neo4j.kernel.api.schema_new.IndexQuery.exact) Assert.fail(org.junit.Assert.fail) IndexUpdateMode(org.neo4j.kernel.impl.api.index.IndexUpdateMode) ClassRule(org.junit.ClassRule) Parameterized(org.junit.runners.Parameterized) Before(org.junit.Before) PrimitiveLongCollections(org.neo4j.collection.primitive.PrimitiveLongCollections) IndexQuery(org.neo4j.kernel.api.schema_new.IndexQuery) Collection(java.util.Collection) IndexEntryUpdate(org.neo4j.kernel.api.index.IndexEntryUpdate) NewIndexDescriptorFactory(org.neo4j.kernel.api.schema_new.index.NewIndexDescriptorFactory) Test(org.junit.Test) IOException(java.io.IOException) IndexQuery.range(org.neo4j.kernel.api.schema_new.IndexQuery.range) NewIndexDescriptor(org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor) IOFunction(org.neo4j.function.IOFunction) IndexReader(org.neo4j.storageengine.api.schema.IndexReader) File(java.io.File) List(java.util.List) Rule(org.junit.Rule) ThreadingRule(org.neo4j.test.rule.concurrent.ThreadingRule) IndexSampler(org.neo4j.storageengine.api.schema.IndexSampler) Iterators.emptySetOf(org.neo4j.helpers.collection.Iterators.emptySetOf) ThreadingRule.waitingWhileIn(org.neo4j.test.rule.concurrent.ThreadingRule.waitingWhileIn) SECONDS(java.util.concurrent.TimeUnit.SECONDS) Assert.assertEquals(org.junit.Assert.assertEquals) IndexReader(org.neo4j.storageengine.api.schema.IndexReader) TaskCoordinator(org.neo4j.helpers.TaskCoordinator) IndexNotFoundKernelException(org.neo4j.kernel.api.exceptions.index.IndexNotFoundKernelException) IndexSampler(org.neo4j.storageengine.api.schema.IndexSampler) Test(org.junit.Test)

Aggregations

SECONDS (java.util.concurrent.TimeUnit.SECONDS)6 TaskInfo (com.facebook.presto.execution.TaskInfo)3 TaskStatus (com.facebook.presto.execution.TaskStatus)3 Duration (io.airlift.units.Duration)3 NodeVersion (com.facebook.presto.client.NodeVersion)2 PRESTO_MAX_WAIT (com.facebook.presto.client.PrestoHeaders.PRESTO_MAX_WAIT)2 PRESTO_TASK_INSTANCE_ID (com.facebook.presto.client.PrestoHeaders.PRESTO_TASK_INSTANCE_ID)2 NodeTaskMap (com.facebook.presto.execution.NodeTaskMap)2 QueryManagerConfig (com.facebook.presto.execution.QueryManagerConfig)2 TaskManager (com.facebook.presto.execution.TaskManager)2 SessionPropertyManager (com.facebook.presto.metadata.SessionPropertyManager)2 BoundedExecutor (io.airlift.concurrent.BoundedExecutor)2 DataSize (io.airlift.units.DataSize)2 File (java.io.File)2 IOException (java.io.IOException)2 Collection (java.util.Collection)2 List (java.util.List)2 Objects.requireNonNull (java.util.Objects.requireNonNull)2 Optional (java.util.Optional)2 Set (java.util.Set)2