Search in sources :

Example 1 with Indexer

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

the class ReindexCacheTest method wipeIndexes.

private void wipeIndexes() {
    Cache<?, ?> cache = cacheManager.getCache(USER_CACHE);
    Indexer indexer = org.infinispan.query.Search.getIndexer(cache);
    CompletionStages.join(indexer.remove());
}
Also used : Indexer(org.infinispan.query.Indexer)

Example 2 with Indexer

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

the class MultipleIndexedCacheTest method reindex.

private void reindex(String cacheName) {
    Cache<?, ?> cache = cacheManagers.get(0).getCache(cacheName);
    Indexer indexer = org.infinispan.query.Search.getIndexer(cache);
    CompletionStages.join(indexer.run());
}
Also used : Indexer(org.infinispan.query.Indexer)

Example 3 with Indexer

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

the class LocalMassIndexingTest method testReindexing.

public void testReindexing() throws Exception {
    final Indexer indexer0 = Search.getIndexer(cache(0));
    final Indexer indexer1 = Search.getIndexer(cache(1));
    final Indexer indexer2 = Search.getIndexer(cache(2));
    join(indexer0.run());
    assertAllIndexed();
    clearIndexes();
    // Local indexing should not touch the indexes of other caches
    join(indexer0.runLocal());
    assertOnlyIndexed(0);
    clearIndexes();
    join(indexer1.runLocal());
    assertOnlyIndexed(1);
    clearIndexes();
    join(indexer2.runLocal());
    assertOnlyIndexed(2);
}
Also used : Indexer(org.infinispan.query.Indexer)

Example 4 with Indexer

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

the class IndexedCacheNonIndexedEntityTest method shouldPreventNonIndexedEntities.

@Test
public void shouldPreventNonIndexedEntities() {
    CompletionStage<RestResponse> response = client.schemas().post("customer", SCHEMA);
    ResponseAssertion.assertThat(response).isOk();
    ConfigurationBuilder configurationBuilder = getDefaultStandaloneCacheConfig(false);
    configurationBuilder.statistics().enable();
    configurationBuilder.encoding().mediaType(APPLICATION_PROTOSTREAM_TYPE).indexing().enable().storage(LOCAL_HEAP).addIndexedEntity("NonIndexed");
    String config = cacheConfigToJson(CACHE_NAME, configurationBuilder.build());
    RestEntity configEntity = RestEntity.create(MediaType.APPLICATION_JSON, config);
    RestCacheClient cacheClient = client.cache(CACHE_NAME);
    response = cacheClient.createWithConfiguration(configEntity, VOLATILE);
    // The SearchMapping is started lazily, creating and starting the cache will not throw errors
    ResponseAssertion.assertThat(response).isOk();
    // Force initialization of the SearchMapping
    response = cacheClient.query("FROM NonIndexed");
    ResponseAssertion.assertThat(response).isBadRequest();
    String errorText = "The configured indexed-entity type 'NonIndexed' must be indexed. Please annotate it with @Indexed";
    ResponseAssertion.assertThat(response).containsReturnedText(errorText);
    // Call Indexer operations
    response = cacheClient.clearIndex();
    ResponseAssertion.assertThat(response).containsReturnedText(errorText);
    // The Indexer should not have "running" status
    Indexer indexer = Search.getIndexer(cacheManager.getCache(CACHE_NAME));
    assertFalse(indexer.isRunning());
}
Also used : ConfigurationBuilder(org.infinispan.configuration.cache.ConfigurationBuilder) GlobalConfigurationBuilder(org.infinispan.configuration.global.GlobalConfigurationBuilder) RestClientConfigurationBuilder(org.infinispan.client.rest.configuration.RestClientConfigurationBuilder) Indexer(org.infinispan.query.Indexer) RestEntity(org.infinispan.client.rest.RestEntity) RestResponse(org.infinispan.client.rest.RestResponse) RestCacheClient(org.infinispan.client.rest.RestCacheClient) SingleCacheManagerTest(org.infinispan.test.SingleCacheManagerTest) Test(org.testng.annotations.Test)

Example 5 with Indexer

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

the class LifecycleManager method cacheStarted.

@Override
public void cacheStarted(ComponentRegistry cr, String cacheName) {
    Configuration configuration = cr.getComponent(Configuration.class);
    IndexingConfiguration indexingConfiguration = configuration.indexing();
    if (!indexingConfiguration.enabled()) {
        if (verifyChainContainsQueryInterceptor(cr)) {
            throw new IllegalStateException("It was NOT expected to find the Query interceptor registered in the InterceptorChain as indexing was disabled, but it was found");
        }
        return;
    }
    if (!verifyChainContainsQueryInterceptor(cr)) {
        throw new IllegalStateException("It was expected to find the Query interceptor registered in the InterceptorChain but it wasn't found");
    }
    SearchMapping searchMapping = cr.getComponent(SearchMapping.class);
    if (searchMapping != null) {
        checkIndexableClasses(searchMapping, indexingConfiguration.indexedEntities());
    }
    AdvancedCache<?, ?> cache = cr.getComponent(Cache.class).getAdvancedCache();
    Indexer massIndexer = ComponentRegistryUtils.getIndexer(cache);
    InfinispanQueryStatisticsInfo stats = new InfinispanQueryStatisticsInfo(Search.getSearchStatistics(cache), SecurityActions.getCacheComponentRegistry(cache).getComponent(Authorizer.class));
    cr.registerComponent(stats, InfinispanQueryStatisticsInfo.class);
    registerQueryMBeans(cr, massIndexer, stats);
    registerMetrics(cr, stats);
}
Also used : DistributedExecutorMassIndexer(org.infinispan.query.impl.massindex.DistributedExecutorMassIndexer) Indexer(org.infinispan.query.Indexer) GlobalConfiguration(org.infinispan.configuration.global.GlobalConfiguration) Configuration(org.infinispan.configuration.cache.Configuration) IndexingConfiguration(org.infinispan.configuration.cache.IndexingConfiguration) SearchMapping(org.infinispan.search.mapper.mapping.SearchMapping) Authorizer(org.infinispan.security.impl.Authorizer) IndexingConfiguration(org.infinispan.configuration.cache.IndexingConfiguration) Cache(org.infinispan.Cache) QueryCache(org.infinispan.query.core.impl.QueryCache) AdvancedCache(org.infinispan.AdvancedCache)

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