Search in sources :

Example 1 with SingleFileStoreConfigurationBuilder

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

the class TargetStoreFactory method getInitializedStoreBuilder.

private static StoreConfigurationBuilder getInitializedStoreBuilder(StoreProperties props) {
    PersistenceConfigurationBuilder persistenceBuilder = new ConfigurationBuilder().persistence();
    StoreType storeType = StoreType.valueOf(props.get(TYPE).toUpperCase());
    switch(storeType) {
        case LEVELDB:
        case JDBC_BINARY:
        case JDBC_MIXED:
            throw new CacheConfigurationException(String.format("%s cannot be a target store as it no longer exists", storeType));
        case JDBC_STRING:
            return JdbcConfigurationUtil.configureStore(props, new JdbcStringBasedStoreConfigurationBuilder(persistenceBuilder));
        case ROCKSDB:
            props.required(LOCATION);
            String location = props.get(LOCATION);
            RocksDBStoreConfigurationBuilder builder = new RocksDBStoreConfigurationBuilder(persistenceBuilder);
            builder.location(location).expiredLocation(location + "-expired-");
            String compressionType = props.get(COMPRESSION);
            if (compressionType != null)
                builder.compressionType(CompressionType.valueOf(compressionType.toUpperCase()));
            return builder;
        case SINGLE_FILE_STORE:
            props.required(LOCATION);
            return new SingleFileStoreConfigurationBuilder(persistenceBuilder).location(props.get(LOCATION));
        case SOFT_INDEX_FILE_STORE:
            props.required(LOCATION);
            props.required(INDEX_LOCATION);
            return new SoftIndexFileStoreConfigurationBuilder(persistenceBuilder).dataLocation(props.get(LOCATION)).indexLocation(props.get(INDEX_LOCATION));
        default:
            throw new CacheConfigurationException(String.format("Unknown store type '%s'", storeType));
    }
}
Also used : ConfigurationBuilder(org.infinispan.configuration.cache.ConfigurationBuilder) SoftIndexFileStoreConfigurationBuilder(org.infinispan.persistence.sifs.configuration.SoftIndexFileStoreConfigurationBuilder) StoreConfigurationBuilder(org.infinispan.configuration.cache.StoreConfigurationBuilder) JdbcStringBasedStoreConfigurationBuilder(org.infinispan.persistence.jdbc.configuration.JdbcStringBasedStoreConfigurationBuilder) RocksDBStoreConfigurationBuilder(org.infinispan.persistence.rocksdb.configuration.RocksDBStoreConfigurationBuilder) SingleFileStoreConfigurationBuilder(org.infinispan.configuration.cache.SingleFileStoreConfigurationBuilder) PersistenceConfigurationBuilder(org.infinispan.configuration.cache.PersistenceConfigurationBuilder) RocksDBStoreConfigurationBuilder(org.infinispan.persistence.rocksdb.configuration.RocksDBStoreConfigurationBuilder) SoftIndexFileStoreConfigurationBuilder(org.infinispan.persistence.sifs.configuration.SoftIndexFileStoreConfigurationBuilder) CacheConfigurationException(org.infinispan.commons.CacheConfigurationException) PersistenceConfigurationBuilder(org.infinispan.configuration.cache.PersistenceConfigurationBuilder) JdbcStringBasedStoreConfigurationBuilder(org.infinispan.persistence.jdbc.configuration.JdbcStringBasedStoreConfigurationBuilder) SingleFileStoreConfigurationBuilder(org.infinispan.configuration.cache.SingleFileStoreConfigurationBuilder)

Example 2 with SingleFileStoreConfigurationBuilder

use of org.infinispan.configuration.cache.SingleFileStoreConfigurationBuilder in project xwiki-commons by xwiki.

the class InfinispanConfigurationLoader method completeFilesystem.

/**
 * Add missing location for filesystem based cache.
 *
 * @param builder the configuration builder
 * @param configuration the configuration
 */
private void completeFilesystem(ConfigurationBuilder builder, Configuration configuration) {
    PersistenceConfigurationBuilder persistence = builder.persistence();
    if (containsIncompleteFileLoader(configuration)) {
        for (StoreConfigurationBuilder<?, ?> store : persistence.stores()) {
            if (store instanceof SingleFileStoreConfigurationBuilder) {
                SingleFileStoreConfigurationBuilder singleFileStore = (SingleFileStoreConfigurationBuilder) store;
                singleFileStore.location(createTempDir());
            }
        }
    }
}
Also used : PersistenceConfigurationBuilder(org.infinispan.configuration.cache.PersistenceConfigurationBuilder) SingleFileStoreConfigurationBuilder(org.infinispan.configuration.cache.SingleFileStoreConfigurationBuilder)

Example 3 with SingleFileStoreConfigurationBuilder

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

the class SingleFileStoreTest method createCacheStoreConfig.

protected SingleFileStoreConfigurationBuilder createCacheStoreConfig(PersistenceConfigurationBuilder lcb) {
    SingleFileStoreConfigurationBuilder cfg = lcb.addStore(SingleFileStoreConfigurationBuilder.class);
    cfg.segmented(segmented);
    cfg.location(tmpDirectory);
    cfg.fragmentationFactor(0.5f);
    return cfg;
}
Also used : SingleFileStoreConfigurationBuilder(org.infinispan.configuration.cache.SingleFileStoreConfigurationBuilder)

Example 4 with SingleFileStoreConfigurationBuilder

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

the class CacheParser method parseCustomStore.

private void parseCustomStore(final ConfigurationReader reader, final ConfigurationBuilderHolder holder) {
    ConfigurationBuilder builder = holder.getCurrentConfigurationBuilder();
    Boolean fetchPersistentState = null;
    Boolean ignoreModifications = null;
    Boolean purgeOnStartup = null;
    Boolean preload = null;
    Boolean shared = null;
    Boolean transactional = null;
    Boolean segmented = null;
    Object store = null;
    for (int i = 0; i < reader.getAttributeCount(); i++) {
        ParseUtils.requireNoNamespaceAttribute(reader, i);
        String value = reader.getAttributeValue(i);
        Attribute attribute = Attribute.forName(reader.getAttributeName(i));
        switch(attribute) {
            case CLASS:
                store = Util.getInstance(value, holder.getClassLoader());
                break;
            case FETCH_STATE:
                fetchPersistentState = Boolean.valueOf(value);
                break;
            case READ_ONLY:
                ignoreModifications = Boolean.valueOf(value);
                break;
            case PURGE:
                purgeOnStartup = Boolean.valueOf(value);
                break;
            case PRELOAD:
                preload = Boolean.parseBoolean(value);
                break;
            case SHARED:
                shared = Boolean.parseBoolean(value);
                break;
            case SINGLETON:
                if (reader.getSchema().since(10, 0)) {
                    throw ParseUtils.attributeRemoved(reader, i);
                } else {
                    ignoreAttribute(reader, i);
                }
                break;
            case TRANSACTIONAL:
                transactional = Boolean.parseBoolean(value);
                break;
            case SEGMENTED:
                segmented = Boolean.parseBoolean(value);
                break;
            default:
                throw ParseUtils.unexpectedAttribute(reader, i);
        }
    }
    if (store != null) {
        if (store instanceof SingleFileStore) {
            SingleFileStoreConfigurationBuilder sfs = builder.persistence().addSingleFileStore();
            if (fetchPersistentState != null)
                sfs.fetchPersistentState(fetchPersistentState);
            if (ignoreModifications != null)
                sfs.ignoreModifications(ignoreModifications);
            if (purgeOnStartup != null)
                sfs.purgeOnStartup(purgeOnStartup);
            if (preload != null)
                sfs.preload(preload);
            if (shared != null)
                sfs.shared(shared);
            if (transactional != null)
                sfs.transactional(transactional);
            if (segmented != null)
                sfs.segmented(segmented);
            parseStoreElements(reader, sfs);
        } else if (store instanceof ClusterLoader) {
            ClusterLoaderConfigurationBuilder cscb = builder.persistence().addClusterLoader();
            parseStoreElements(reader, cscb);
        } else {
            ConfiguredBy annotation = store.getClass().getAnnotation(ConfiguredBy.class);
            Class<? extends StoreConfigurationBuilder> builderClass = null;
            if (annotation != null) {
                Class<?> configuredBy = annotation.value();
                if (configuredBy != null) {
                    BuiltBy builtBy = configuredBy.getAnnotation(BuiltBy.class);
                    builderClass = builtBy.value().asSubclass(StoreConfigurationBuilder.class);
                }
            }
            StoreConfigurationBuilder configBuilder;
            // If they don't specify a builder just use the custom configuration builder and set the class
            if (builderClass == null) {
                configBuilder = builder.persistence().addStore(CustomStoreConfigurationBuilder.class).customStoreClass(store.getClass());
            } else {
                configBuilder = builder.persistence().addStore(builderClass);
            }
            if (fetchPersistentState != null)
                configBuilder.fetchPersistentState(fetchPersistentState);
            if (ignoreModifications != null)
                configBuilder.ignoreModifications(ignoreModifications);
            if (purgeOnStartup != null)
                configBuilder.purgeOnStartup(purgeOnStartup);
            if (preload != null)
                configBuilder.preload(preload);
            if (shared != null)
                configBuilder.shared(shared);
            if (transactional != null)
                configBuilder.transactional(transactional);
            if (segmented != null)
                configBuilder.segmented(segmented);
            parseStoreElements(reader, configBuilder);
        }
    }
}
Also used : ConfigurationBuilder(org.infinispan.configuration.cache.ConfigurationBuilder) IndexMergeConfigurationBuilder(org.infinispan.configuration.cache.IndexMergeConfigurationBuilder) SoftIndexFileStoreConfigurationBuilder(org.infinispan.persistence.sifs.configuration.SoftIndexFileStoreConfigurationBuilder) CustomStoreConfigurationBuilder(org.infinispan.configuration.cache.CustomStoreConfigurationBuilder) SecurityConfigurationBuilder(org.infinispan.configuration.cache.SecurityConfigurationBuilder) GroupsConfigurationBuilder(org.infinispan.configuration.cache.GroupsConfigurationBuilder) InterceptorConfigurationBuilder(org.infinispan.configuration.cache.InterceptorConfigurationBuilder) SingleFileStoreConfigurationBuilder(org.infinispan.configuration.cache.SingleFileStoreConfigurationBuilder) IndexWriterConfigurationBuilder(org.infinispan.configuration.cache.IndexWriterConfigurationBuilder) ClusterLoaderConfigurationBuilder(org.infinispan.configuration.cache.ClusterLoaderConfigurationBuilder) AuthorizationConfigurationBuilder(org.infinispan.configuration.cache.AuthorizationConfigurationBuilder) StoreConfigurationBuilder(org.infinispan.configuration.cache.StoreConfigurationBuilder) MemoryConfigurationBuilder(org.infinispan.configuration.cache.MemoryConfigurationBuilder) ClusteringConfigurationBuilder(org.infinispan.configuration.cache.ClusteringConfigurationBuilder) BackupConfigurationBuilder(org.infinispan.configuration.cache.BackupConfigurationBuilder) PartitionHandlingConfigurationBuilder(org.infinispan.configuration.cache.PartitionHandlingConfigurationBuilder) AbstractStoreConfigurationBuilder(org.infinispan.configuration.cache.AbstractStoreConfigurationBuilder) EncodingConfigurationBuilder(org.infinispan.configuration.cache.EncodingConfigurationBuilder) ContentTypeConfigurationBuilder(org.infinispan.configuration.cache.ContentTypeConfigurationBuilder) PersistenceConfigurationBuilder(org.infinispan.configuration.cache.PersistenceConfigurationBuilder) AsyncStoreConfigurationBuilder(org.infinispan.configuration.cache.AsyncStoreConfigurationBuilder) ConfiguredBy(org.infinispan.commons.configuration.ConfiguredBy) ParseUtils.ignoreAttribute(org.infinispan.configuration.parsing.ParseUtils.ignoreAttribute) BuiltBy(org.infinispan.commons.configuration.BuiltBy) SoftIndexFileStoreConfigurationBuilder(org.infinispan.persistence.sifs.configuration.SoftIndexFileStoreConfigurationBuilder) CustomStoreConfigurationBuilder(org.infinispan.configuration.cache.CustomStoreConfigurationBuilder) SingleFileStoreConfigurationBuilder(org.infinispan.configuration.cache.SingleFileStoreConfigurationBuilder) StoreConfigurationBuilder(org.infinispan.configuration.cache.StoreConfigurationBuilder) AbstractStoreConfigurationBuilder(org.infinispan.configuration.cache.AbstractStoreConfigurationBuilder) AsyncStoreConfigurationBuilder(org.infinispan.configuration.cache.AsyncStoreConfigurationBuilder) ClusterLoaderConfigurationBuilder(org.infinispan.configuration.cache.ClusterLoaderConfigurationBuilder) SingleFileStoreConfigurationBuilder(org.infinispan.configuration.cache.SingleFileStoreConfigurationBuilder) ClusterLoader(org.infinispan.persistence.cluster.ClusterLoader) SingleFileStore(org.infinispan.persistence.file.SingleFileStore) CustomStoreConfigurationBuilder(org.infinispan.configuration.cache.CustomStoreConfigurationBuilder)

Example 5 with SingleFileStoreConfigurationBuilder

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

the class CacheParser method parseSingleFileStore.

protected void parseSingleFileStore(ConfigurationReader reader, ConfigurationBuilderHolder holder) {
    SingleFileStoreConfigurationBuilder storeBuilder = holder.getCurrentConfigurationBuilder().persistence().addSingleFileStore();
    for (int i = 0; i < reader.getAttributeCount(); i++) {
        String value = reader.getAttributeValue(i);
        Attribute attribute = Attribute.forName(reader.getAttributeName(i));
        switch(attribute) {
            case RELATIVE_TO:
                {
                    if (reader.getSchema().since(11, 0))
                        throw ParseUtils.attributeRemoved(reader, i);
                    ignoreAttribute(reader, i);
                    break;
                }
            case PATH:
                {
                    storeBuilder.location(value);
                    break;
                }
            case MAX_ENTRIES:
                {
                    storeBuilder.maxEntries(Integer.parseInt(value));
                    break;
                }
            case FRAGMENTATION_FACTOR:
                {
                    storeBuilder.fragmentationFactor(Float.parseFloat(value));
                    break;
                }
            default:
                {
                    parseStoreAttribute(reader, i, storeBuilder);
                }
        }
    }
    this.parseStoreElements(reader, storeBuilder);
}
Also used : ParseUtils.ignoreAttribute(org.infinispan.configuration.parsing.ParseUtils.ignoreAttribute) SingleFileStoreConfigurationBuilder(org.infinispan.configuration.cache.SingleFileStoreConfigurationBuilder)

Aggregations

SingleFileStoreConfigurationBuilder (org.infinispan.configuration.cache.SingleFileStoreConfigurationBuilder)5 PersistenceConfigurationBuilder (org.infinispan.configuration.cache.PersistenceConfigurationBuilder)3 ConfigurationBuilder (org.infinispan.configuration.cache.ConfigurationBuilder)2 StoreConfigurationBuilder (org.infinispan.configuration.cache.StoreConfigurationBuilder)2 ParseUtils.ignoreAttribute (org.infinispan.configuration.parsing.ParseUtils.ignoreAttribute)2 SoftIndexFileStoreConfigurationBuilder (org.infinispan.persistence.sifs.configuration.SoftIndexFileStoreConfigurationBuilder)2 CacheConfigurationException (org.infinispan.commons.CacheConfigurationException)1 BuiltBy (org.infinispan.commons.configuration.BuiltBy)1 ConfiguredBy (org.infinispan.commons.configuration.ConfiguredBy)1 AbstractStoreConfigurationBuilder (org.infinispan.configuration.cache.AbstractStoreConfigurationBuilder)1 AsyncStoreConfigurationBuilder (org.infinispan.configuration.cache.AsyncStoreConfigurationBuilder)1 AuthorizationConfigurationBuilder (org.infinispan.configuration.cache.AuthorizationConfigurationBuilder)1 BackupConfigurationBuilder (org.infinispan.configuration.cache.BackupConfigurationBuilder)1 ClusterLoaderConfigurationBuilder (org.infinispan.configuration.cache.ClusterLoaderConfigurationBuilder)1 ClusteringConfigurationBuilder (org.infinispan.configuration.cache.ClusteringConfigurationBuilder)1 ContentTypeConfigurationBuilder (org.infinispan.configuration.cache.ContentTypeConfigurationBuilder)1 CustomStoreConfigurationBuilder (org.infinispan.configuration.cache.CustomStoreConfigurationBuilder)1 EncodingConfigurationBuilder (org.infinispan.configuration.cache.EncodingConfigurationBuilder)1 GroupsConfigurationBuilder (org.infinispan.configuration.cache.GroupsConfigurationBuilder)1 IndexMergeConfigurationBuilder (org.infinispan.configuration.cache.IndexMergeConfigurationBuilder)1