Search in sources :

Example 1 with IndexingConfiguration

use of org.infinispan.configuration.cache.IndexingConfiguration in project infinispan by infinispan.

the class EngineConfigTest method resolveIndexingProperties.

private Map<String, Object> resolveIndexingProperties(GlobalConfigurationBuilder gcb, ConfigurationBuilder builder) {
    cacheManager = TestCacheManagerFactory.createCacheManager(gcb, builder);
    GlobalConfiguration globalConfiguration = cacheManager.getCacheManagerConfiguration();
    IndexingConfiguration indexingConfiguration = cacheManager.getCache().getCacheConfiguration().indexing();
    return extractProperties(globalConfiguration, indexingConfiguration, this.getClass().getClassLoader());
}
Also used : GlobalConfiguration(org.infinispan.configuration.global.GlobalConfiguration) IndexingConfiguration(org.infinispan.configuration.cache.IndexingConfiguration)

Example 2 with IndexingConfiguration

use of org.infinispan.configuration.cache.IndexingConfiguration in project infinispan by infinispan.

the class ProgrammaticAutoConfigTest method testOverride.

@Test
public void testOverride() {
    String override = "hibernate.search.default.exclusive_index_use";
    IndexingConfiguration cfg = new ConfigurationBuilder().indexing().enable().autoConfig(true).addProperty(override, "false").create();
    assertEquals(cfg.properties().get(override), "false");
}
Also used : ConfigurationBuilder(org.infinispan.configuration.cache.ConfigurationBuilder) IndexingConfiguration(org.infinispan.configuration.cache.IndexingConfiguration) Test(org.testng.annotations.Test)

Example 3 with IndexingConfiguration

use of org.infinispan.configuration.cache.IndexingConfiguration 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)

Example 4 with IndexingConfiguration

use of org.infinispan.configuration.cache.IndexingConfiguration in project infinispan by infinispan.

the class LazySearchMapping method createMapping.

private SearchMapping createMapping() {
    IndexingConfiguration indexingConfiguration = cache.getCacheConfiguration().indexing();
    Set<String> indexedEntityTypes = indexingConfiguration.indexedEntityTypes();
    DataConversion valueDataConversion = cache.getAdvancedCache().getValueDataConversion();
    SearchMapping searchMapping = null;
    if (commonBuilding != null) {
        SearchMappingBuilder builder = SerializationContextSearchMapping.createBuilder(commonBuilding, entityLoader, indexedEntityTypes, serCtx);
        searchMapping = builder != null ? builder.build() : null;
    }
    if (indexingConfiguration.enabled()) {
        if (valueDataConversion.getStorageMediaType().match(APPLICATION_PROTOSTREAM)) {
            // Try to resolve the indexed type names to protobuf type names.
            Set<String> knownTypes = protobufMetadataManager.getSerializationContext().getGenericDescriptors().keySet();
            for (String typeName : indexedEntityTypes) {
                if (!knownTypes.contains(typeName)) {
                    if (searchMapping != null)
                        searchMapping.close();
                    throw log.unknownType(typeName);
                }
                if (searchMapping == null || searchMapping.indexedEntity(typeName) == null) {
                    if (searchMapping != null)
                        searchMapping.close();
                    throw log.typeNotIndexed(typeName);
                }
            }
        }
    }
    return searchMapping;
}
Also used : DataConversion(org.infinispan.encoding.DataConversion) SearchMappingBuilder(org.infinispan.search.mapper.mapping.SearchMappingBuilder) SearchMapping(org.infinispan.search.mapper.mapping.SearchMapping) SerializationContextSearchMapping(org.infinispan.query.remote.impl.mapping.SerializationContextSearchMapping) IndexingConfiguration(org.infinispan.configuration.cache.IndexingConfiguration)

Example 5 with IndexingConfiguration

use of org.infinispan.configuration.cache.IndexingConfiguration in project infinispan by infinispan.

the class CoreConfigurationSerializer method writeIndexing.

private void writeIndexing(ConfigurationWriter writer, Configuration configuration) {
    IndexingConfiguration indexing = configuration.indexing();
    AttributeSet attributes = indexing.attributes();
    if (attributes.isModified()) {
        writer.writeStartElement(Element.INDEXING);
        attributes.write(writer, IndexingConfiguration.AUTO_CONFIG, Attribute.AUTO_CONFIG);
        attributes.write(writer, IndexingConfiguration.ENABLED, Attribute.ENABLED);
        attributes.write(writer, IndexingConfiguration.STORAGE, Attribute.STORAGE);
        attributes.write(writer, IndexingConfiguration.PATH, Attribute.PATH);
        long refreshInterval = indexing.reader().getRefreshInterval();
        if (refreshInterval != 0) {
            writer.writeStartElement(Element.INDEX_READER);
            writer.writeAttribute(Attribute.REFRESH_INTERVAL, Long.toString(refreshInterval));
            writer.writeEndElement();
        }
        IndexWriterConfiguration indexWriter = indexing.writer();
        IndexMergeConfiguration indexMerge = indexWriter.merge();
        AttributeSet writerAttributes = indexWriter.attributes();
        AttributeSet mergeAttributes = indexMerge.attributes();
        boolean indexWriterModified = writerAttributes.isModified();
        boolean indexMergeModified = mergeAttributes.isModified();
        if (indexWriterModified || indexMergeModified) {
            writer.writeStartElement(Element.INDEX_WRITER);
            writerAttributes.write(writer, IndexWriterConfiguration.INDEX_COMMIT_INTERVAL, Attribute.COMMIT_INTERVAL);
            writerAttributes.write(writer, IndexWriterConfiguration.INDEX_LOW_LEVEL_TRACE, Attribute.LOW_LEVEL_TRACE);
            writerAttributes.write(writer, IndexWriterConfiguration.INDEX_MAX_BUFFERED_ENTRIES, Attribute.MAX_BUFFERED_ENTRIES);
            writerAttributes.write(writer, IndexWriterConfiguration.INDEX_QUEUE_COUNT, Attribute.QUEUE_COUNT);
            writerAttributes.write(writer, IndexWriterConfiguration.INDEX_QUEUE_SIZE, Attribute.QUEUE_SIZE);
            writerAttributes.write(writer, IndexWriterConfiguration.INDEX_THREAD_POOL_SIZE, Attribute.THREAD_POOL_SIZE);
            writerAttributes.write(writer, IndexWriterConfiguration.INDEX_RAM_BUFFER_SIZE, Attribute.RAM_BUFFER_SIZE);
            if (indexMergeModified) {
                writer.writeStartElement(Element.INDEX_MERGE);
                mergeAttributes.write(writer, IndexMergeConfiguration.CALIBRATE_BY_DELETES, Attribute.CALIBRATE_BY_DELETES);
                mergeAttributes.write(writer, IndexMergeConfiguration.FACTOR, Attribute.FACTOR);
                mergeAttributes.write(writer, IndexMergeConfiguration.MAX_ENTRIES, Attribute.MAX_ENTRIES);
                mergeAttributes.write(writer, IndexMergeConfiguration.MIN_SIZE, Attribute.MIN_SIZE);
                mergeAttributes.write(writer, IndexMergeConfiguration.MAX_SIZE, Attribute.MAX_SIZE);
                mergeAttributes.write(writer, IndexMergeConfiguration.MAX_FORCED_SIZE, Attribute.MAX_FORCED_SIZE);
                writer.writeEndElement();
            }
            writer.writeEndElement();
        }
        writer.writeArrayElement(Element.INDEXED_ENTITIES, Element.INDEXED_ENTITY, null, indexing.indexedEntityTypes());
        if (!indexing.keyTransformers().isEmpty()) {
            writer.writeStartListElement(Element.KEY_TRANSFORMERS, true);
            for (Map.Entry<Class<?>, Class<?>> e : indexing.keyTransformers().entrySet()) {
                writer.writeStartElement(Element.KEY_TRANSFORMER);
                writer.writeAttribute(Attribute.KEY, e.getKey().getName());
                writer.writeAttribute(Attribute.TRANSFORMER, e.getValue().getName());
                writer.writeEndElement();
            }
            writer.writeEndListElement();
        }
        attributes.write(writer, GlobalJmxConfiguration.PROPERTIES);
        writer.writeEndElement();
    }
}
Also used : AttributeSet(org.infinispan.commons.configuration.attributes.AttributeSet) IndexMergeConfiguration(org.infinispan.configuration.cache.IndexMergeConfiguration) IndexingConfiguration(org.infinispan.configuration.cache.IndexingConfiguration) IndexWriterConfiguration(org.infinispan.configuration.cache.IndexWriterConfiguration) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) ConcurrentMap(java.util.concurrent.ConcurrentMap)

Aggregations

IndexingConfiguration (org.infinispan.configuration.cache.IndexingConfiguration)8 ConfigurationBuilder (org.infinispan.configuration.cache.ConfigurationBuilder)4 Test (org.testng.annotations.Test)4 GlobalConfiguration (org.infinispan.configuration.global.GlobalConfiguration)2 SearchMapping (org.infinispan.search.mapper.mapping.SearchMapping)2 Map (java.util.Map)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 ConcurrentMap (java.util.concurrent.ConcurrentMap)1 AdvancedCache (org.infinispan.AdvancedCache)1 Cache (org.infinispan.Cache)1 AttributeSet (org.infinispan.commons.configuration.attributes.AttributeSet)1 Configuration (org.infinispan.configuration.cache.Configuration)1 IndexMergeConfiguration (org.infinispan.configuration.cache.IndexMergeConfiguration)1 IndexWriterConfiguration (org.infinispan.configuration.cache.IndexWriterConfiguration)1 DataConversion (org.infinispan.encoding.DataConversion)1 Indexer (org.infinispan.query.Indexer)1 QueryCache (org.infinispan.query.core.impl.QueryCache)1 DistributedExecutorMassIndexer (org.infinispan.query.impl.massindex.DistributedExecutorMassIndexer)1 SerializationContextSearchMapping (org.infinispan.query.remote.impl.mapping.SerializationContextSearchMapping)1 SearchMappingBuilder (org.infinispan.search.mapper.mapping.SearchMappingBuilder)1