Search in sources :

Example 11 with Indexer

use of org.infinispan.query.Indexer in project infinispan by infinispan.

the class MassIndexingTest method testOverlappingMassIndexers.

@Test
public void testOverlappingMassIndexers() {
    Cache<Integer, Car> cache = cache(0);
    IntStream.range(0, 10).forEach(i -> cache.put(i, new Car("whatever", "whatever", 0)));
    Indexer massIndexer = Search.getIndexer(cache);
    CountDownLatch latch = new CountDownLatch(1);
    instrumentIndexer(massIndexer, latch);
    CompletionStage<Void> first = massIndexer.run();
    CompletionStage<Void> second = massIndexer.run();
    latch.countDown();
    assertTrue(isSuccess(second) && isError(first) || isSuccess(first) && isError(second));
    assertFalse(massIndexer.isRunning());
    CompletionStage<Void> third = massIndexer.run();
    assertTrue(isSuccess(third));
}
Also used : Indexer(org.infinispan.query.Indexer) Car(org.infinispan.query.queries.faceting.Car) CountDownLatch(java.util.concurrent.CountDownLatch) Test(org.testng.annotations.Test)

Aggregations

Indexer (org.infinispan.query.Indexer)11 AdvancedCache (org.infinispan.AdvancedCache)3 Cache (org.infinispan.Cache)2 Configuration (org.infinispan.configuration.cache.Configuration)2 QueryCache (org.infinispan.query.core.impl.QueryCache)2 DistributedExecutorMassIndexer (org.infinispan.query.impl.massindex.DistributedExecutorMassIndexer)2 Test (org.testng.annotations.Test)2 HttpResponseStatus (io.netty.handler.codec.http.HttpResponseStatus)1 BAD_REQUEST (io.netty.handler.codec.http.HttpResponseStatus.BAD_REQUEST)1 INTERNAL_SERVER_ERROR (io.netty.handler.codec.http.HttpResponseStatus.INTERNAL_SERVER_ERROR)1 MULTIPLE_CHOICES (io.netty.handler.codec.http.HttpResponseStatus.MULTIPLE_CHOICES)1 NOT_FOUND (io.netty.handler.codec.http.HttpResponseStatus.NOT_FOUND)1 NO_CONTENT (io.netty.handler.codec.http.HttpResponseStatus.NO_CONTENT)1 OK (io.netty.handler.codec.http.HttpResponseStatus.OK)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 CompletableFuture.completedFuture (java.util.concurrent.CompletableFuture.completedFuture)1 CompletionStage (java.util.concurrent.CompletionStage)1