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());
}
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());
}
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);
}
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());
}
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);
}
Aggregations