Search in sources :

Example 6 with Car

use of org.infinispan.query.queries.faceting.Car in project infinispan by infinispan.

the class DistributedMassIndexingTest method testReindexing.

public void testReindexing() throws Exception {
    cache(0).put(key("F1NUM"), new Car("megane", "white", 300));
    verifyFindsCar(1, "megane");
    cache(1).put(key("F2NUM"), new Car("megane", "blue", 300));
    verifyFindsCar(2, "megane");
    // add an entry without indexing it:
    cache(1).getAdvancedCache().withFlags(Flag.SKIP_INDEXING).put(key("F3NUM"), new Car("megane", "blue", 300));
    verifyFindsCar(2, "megane");
    // re-sync datacontainer with indexes:
    rebuildIndexes();
    verifyFindsCar(3, "megane");
    // verify we cleanup old stale index values by deleting an entry without deleting the corresponding index value
    cache(2).getAdvancedCache().withFlags(Flag.SKIP_INDEXING).remove(key("F2NUM"));
    assertIndexedEntities(3, Car.class, cache(2));
    // re-sync
    rebuildIndexes();
    assertIndexedEntities(2, Car.class, cache(2));
    verifyFindsCar(2, "megane");
}
Also used : Car(org.infinispan.query.queries.faceting.Car)

Example 7 with Car

use of org.infinispan.query.queries.faceting.Car in project infinispan by infinispan.

the class ManualIndexingTest method assertNumberOfCars.

private void assertNumberOfCars(int expectedCount, String carMake) {
    for (Cache<?, ?> cache : caches) {
        QueryFactory queryFactory = Search.getQueryFactory(cache);
        Query<Car> query = queryFactory.create(String.format("FROM %s where make:'%s'", Car.class.getName(), carMake));
        QueryResult<Car> queryResult = query.execute();
        assertEquals("Expected count not met on cache " + cache, expectedCount, queryResult.hitCount().orElse(-1));
        assertEquals("Expected count not met on cache " + cache, expectedCount, queryResult.list().size());
    }
}
Also used : QueryFactory(org.infinispan.query.dsl.QueryFactory) Car(org.infinispan.query.queries.faceting.Car)

Example 8 with Car

use of org.infinispan.query.queries.faceting.Car in project infinispan by infinispan.

the class ManualIndexingTest method createCacheManagers.

@Override
protected void createCacheManagers() throws Throwable {
    for (int i = 0; i < NUM_NODES; i++) {
        EmbeddedCacheManager cacheManager = TestCacheManagerFactory.fromXml("manual-indexing-distribution.xml");
        registerCacheManager(cacheManager);
        Cache<String, Car> cache = cacheManager.getCache();
        caches.add(cache);
    }
    waitForClusterToForm("default");
}
Also used : Car(org.infinispan.query.queries.faceting.Car) EmbeddedCacheManager(org.infinispan.manager.EmbeddedCacheManager)

Example 9 with Car

use of org.infinispan.query.queries.faceting.Car in project infinispan by infinispan.

the class ManualIndexingTest method testManualIndexing.

public void testManualIndexing() {
    caches.get(0).put("car A", new Car("ford", "blue", 400));
    caches.get(0).put("car B", new Car("megane", "white", 300));
    caches.get(0).put("car C", new Car("megane", "red", 500));
    assertNumberOfCars(0, "megane");
    assertNumberOfCars(0, "ford");
    // rebuild index
    join(Search.getIndexer(caches.get(0)).run());
    assertNumberOfCars(2, "megane");
    assertNumberOfCars(1, "ford");
}
Also used : Car(org.infinispan.query.queries.faceting.Car)

Example 10 with Car

use of org.infinispan.query.queries.faceting.Car in project infinispan by infinispan.

the class ReplRamMassIndexingTest method testReindexing.

@Override
public void testReindexing() throws Exception {
    final int NUM_CARS = 100;
    for (int i = 0; i < NUM_CARS; ++i) {
        cache(i % NUM_NODES).put("car" + i, new Car("skoda", "white", 42));
    }
    for (Cache cache : caches()) {
        assertEquals(cache.size(), NUM_CARS);
        verifyFindsCar(cache, NUM_CARS, "skoda");
    }
    rebuildIndexes();
    for (int i = 0; i < NUM_CARS; ++i) {
        String key = "car" + i;
        for (Cache cache : caches()) {
            assertNotNull(cache.get(key));
        }
    }
    verifyFindsCar(NUM_CARS, "skoda");
}
Also used : Car(org.infinispan.query.queries.faceting.Car) Cache(org.infinispan.Cache)

Aggregations

Car (org.infinispan.query.queries.faceting.Car)15 EmbeddedCacheManager (org.infinispan.manager.EmbeddedCacheManager)2 QueryFactory (org.infinispan.query.dsl.QueryFactory)2 Test (org.testng.annotations.Test)2 CountDownLatch (java.util.concurrent.CountDownLatch)1 Cache (org.infinispan.Cache)1 ConfigurationBuilder (org.infinispan.configuration.cache.ConfigurationBuilder)1 Indexer (org.infinispan.query.Indexer)1 NotIndexedType (org.infinispan.query.api.NotIndexedType)1 StaticTestingErrorHandler (org.infinispan.query.helper.StaticTestingErrorHandler)1 Person (org.infinispan.query.test.Person)1 MultipleCacheManagersTest (org.infinispan.test.MultipleCacheManagersTest)1