Search in sources :

Example 1 with SoftIndexFileStoreConfigurationBuilder

use of org.infinispan.persistence.sifs.configuration.SoftIndexFileStoreConfigurationBuilder 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 SoftIndexFileStoreConfigurationBuilder

use of org.infinispan.persistence.sifs.configuration.SoftIndexFileStoreConfigurationBuilder in project infinispan by infinispan.

the class PersistenceConfigurationBuilder method addSoftIndexFileStore.

/**
 * Adds a soft index file cache store.
 * @return the configuration for a soft index file store
 */
public SoftIndexFileStoreConfigurationBuilder addSoftIndexFileStore() {
    SoftIndexFileStoreConfigurationBuilder builder = new SoftIndexFileStoreConfigurationBuilder(this);
    this.stores.add(builder);
    return builder;
}
Also used : SoftIndexFileStoreConfigurationBuilder(org.infinispan.persistence.sifs.configuration.SoftIndexFileStoreConfigurationBuilder)

Example 3 with SoftIndexFileStoreConfigurationBuilder

use of org.infinispan.persistence.sifs.configuration.SoftIndexFileStoreConfigurationBuilder in project infinispan by infinispan.

the class CacheParser method parseFileStore.

protected void parseFileStore(ConfigurationReader reader, ConfigurationBuilderHolder holder) {
    SoftIndexFileStoreConfigurationBuilder fileStoreBuilder = null;
    PersistenceConfigurationBuilder persistence = holder.getCurrentConfigurationBuilder().persistence();
    AbstractStoreConfigurationBuilder<?, ?> actualStoreConfig;
    int majorSchema = reader.getSchema().getMajor();
    boolean legacyFileStore = false;
    if (majorSchema < 13) {
        parseSingleFileStore(reader, holder);
        return;
    } else if (majorSchema == 13) {
        fileStoreBuilder = persistence.addStore(SFSToSIFSConfigurationBuilder.class);
        actualStoreConfig = fileStoreBuilder;
        legacyFileStore = true;
    } else {
        fileStoreBuilder = persistence.addSoftIndexFileStore();
        actualStoreConfig = fileStoreBuilder;
    }
    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:
                {
                    fileStoreBuilder.dataLocation(value);
                    fileStoreBuilder.indexLocation(value);
                    break;
                }
            case FRAGMENTATION_FACTOR:
            case MAX_ENTRIES:
                {
                    if (legacyFileStore) {
                        ignoreAttribute(reader, i);
                    } else {
                        throw ParseUtils.attributeRemoved(reader, i);
                    }
                    break;
                }
            case OPEN_FILES_LIMIT:
                if (fileStoreBuilder != null) {
                    fileStoreBuilder.openFilesLimit(Integer.parseInt(value));
                } else {
                    throw ParseUtils.unexpectedAttribute(reader, i);
                }
                break;
            case COMPACTION_THRESHOLD:
                if (fileStoreBuilder != null) {
                    fileStoreBuilder.compactionThreshold(Double.parseDouble(value));
                } else {
                    throw ParseUtils.unexpectedAttribute(reader, i);
                }
                break;
            case PURGE:
                {
                    actualStoreConfig.purgeOnStartup(Boolean.parseBoolean(value));
                    break;
                }
            default:
                {
                    parseStoreAttribute(reader, i, actualStoreConfig);
                }
        }
    }
    while (reader.inTag()) {
        Element element = Element.forName(reader.getLocalName());
        switch(element) {
            case DATA:
                if (fileStoreBuilder != null) {
                    parseData(reader, fileStoreBuilder);
                } else {
                    throw ParseUtils.unexpectedElement(reader);
                }
                break;
            case INDEX:
                if (fileStoreBuilder != null) {
                    parseIndex(reader, fileStoreBuilder);
                } else {
                    throw ParseUtils.unexpectedElement(reader);
                }
                break;
            default:
                parseStoreElement(reader, actualStoreConfig);
        }
    }
}
Also used : SoftIndexFileStoreConfigurationBuilder(org.infinispan.persistence.sifs.configuration.SoftIndexFileStoreConfigurationBuilder) ParseUtils.ignoreAttribute(org.infinispan.configuration.parsing.ParseUtils.ignoreAttribute) ParseUtils.ignoreElement(org.infinispan.configuration.parsing.ParseUtils.ignoreElement) PersistenceConfigurationBuilder(org.infinispan.configuration.cache.PersistenceConfigurationBuilder)

Aggregations

SoftIndexFileStoreConfigurationBuilder (org.infinispan.persistence.sifs.configuration.SoftIndexFileStoreConfigurationBuilder)3 PersistenceConfigurationBuilder (org.infinispan.configuration.cache.PersistenceConfigurationBuilder)2 CacheConfigurationException (org.infinispan.commons.CacheConfigurationException)1 ConfigurationBuilder (org.infinispan.configuration.cache.ConfigurationBuilder)1 SingleFileStoreConfigurationBuilder (org.infinispan.configuration.cache.SingleFileStoreConfigurationBuilder)1 StoreConfigurationBuilder (org.infinispan.configuration.cache.StoreConfigurationBuilder)1 ParseUtils.ignoreAttribute (org.infinispan.configuration.parsing.ParseUtils.ignoreAttribute)1 ParseUtils.ignoreElement (org.infinispan.configuration.parsing.ParseUtils.ignoreElement)1 JdbcStringBasedStoreConfigurationBuilder (org.infinispan.persistence.jdbc.configuration.JdbcStringBasedStoreConfigurationBuilder)1 RocksDBStoreConfigurationBuilder (org.infinispan.persistence.rocksdb.configuration.RocksDBStoreConfigurationBuilder)1