Search in sources :

Example 1 with RocksDBStoreConfigurationBuilder

use of org.infinispan.persistence.rocksdb.configuration.RocksDBStoreConfigurationBuilder 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 RocksDBStoreConfigurationBuilder

use of org.infinispan.persistence.rocksdb.configuration.RocksDBStoreConfigurationBuilder in project infinispan by infinispan.

the class RocksDBStoreFunctionalTest method testUnknownProperties.

public void testUnknownProperties() {
    ConfigurationBuilder cb = getDefaultCacheConfiguration();
    new File(tmpDirectory).mkdirs();
    RocksDBStoreConfigurationBuilder storeConfigurationBuilder = createStoreBuilder(cb.persistence());
    storeConfigurationBuilder.addProperty(RocksDBStore.DATABASE_PROPERTY_NAME_WITH_SUFFIX + "unknown", "some_value");
    Configuration c = cb.build();
    String cacheName = "rocksdb-unknown-properties";
    TestingUtil.defineConfiguration(cacheManager, cacheName, c);
    try {
        cacheManager.getCache(cacheName);
    } catch (Throwable t) {
        Throwable cause;
        while ((cause = t.getCause()) != null) {
            t = cause;
        }
        Exceptions.assertException(CacheConfigurationException.class, ".*unknown\\ property$", t);
    }
    // Stop the cache manager early, otherwise cleanup won't work properly
    TestingUtil.killCacheManagers(cacheManager);
}
Also used : ConfigurationBuilder(org.infinispan.configuration.cache.ConfigurationBuilder) PersistenceConfigurationBuilder(org.infinispan.configuration.cache.PersistenceConfigurationBuilder) RocksDBStoreConfigurationBuilder(org.infinispan.persistence.rocksdb.configuration.RocksDBStoreConfigurationBuilder) RocksDBStoreConfigurationBuilder(org.infinispan.persistence.rocksdb.configuration.RocksDBStoreConfigurationBuilder) Configuration(org.infinispan.configuration.cache.Configuration) CacheConfigurationException(org.infinispan.commons.CacheConfigurationException) File(java.io.File)

Example 3 with RocksDBStoreConfigurationBuilder

use of org.infinispan.persistence.rocksdb.configuration.RocksDBStoreConfigurationBuilder in project infinispan by infinispan.

the class RocksDBStoreFunctionalTest method testKnownProperties.

public void testKnownProperties() {
    ConfigurationBuilder cb = getDefaultCacheConfiguration();
    new File(tmpDirectory).mkdirs();
    RocksDBStoreConfigurationBuilder storeConfigurationBuilder = createStoreBuilder(cb.persistence());
    String dbOptionName = "max_background_compactions";
    String dbOptionValue = "2";
    storeConfigurationBuilder.addProperty(RocksDBStore.DATABASE_PROPERTY_NAME_WITH_SUFFIX + dbOptionName, dbOptionValue);
    String columnFamilyOptionName = "write_buffer_size";
    String columnFamilyOptionValue = "96MB";
    storeConfigurationBuilder.addProperty(RocksDBStore.COLUMN_FAMILY_PROPERTY_NAME_WITH_SUFFIX + columnFamilyOptionName, columnFamilyOptionValue);
    Configuration c = cb.build();
    String cacheName = "rocksdb-known-properties";
    TestingUtil.defineConfiguration(cacheManager, cacheName, c);
    // No easy way to ascertain if options are set, however if cache starts up it must have applied them,
    // since otherwise this will fail like the unkonwn properties method
    assertNotNull(cacheManager.getCache(cacheName));
}
Also used : ConfigurationBuilder(org.infinispan.configuration.cache.ConfigurationBuilder) PersistenceConfigurationBuilder(org.infinispan.configuration.cache.PersistenceConfigurationBuilder) RocksDBStoreConfigurationBuilder(org.infinispan.persistence.rocksdb.configuration.RocksDBStoreConfigurationBuilder) RocksDBStoreConfigurationBuilder(org.infinispan.persistence.rocksdb.configuration.RocksDBStoreConfigurationBuilder) Configuration(org.infinispan.configuration.cache.Configuration) File(java.io.File)

Example 4 with RocksDBStoreConfigurationBuilder

use of org.infinispan.persistence.rocksdb.configuration.RocksDBStoreConfigurationBuilder in project infinispan by infinispan.

the class RocksDBStoreTest method createCacheStoreConfig.

protected RocksDBStoreConfigurationBuilder createCacheStoreConfig(PersistenceConfigurationBuilder lcb) {
    RocksDBStoreConfigurationBuilder cfg = lcb.addStore(RocksDBStoreConfigurationBuilder.class);
    cfg.segmented(segmented);
    cfg.location(tmpDirectory);
    cfg.expiredLocation(tmpDirectory);
    cfg.clearThreshold(2);
    return cfg;
}
Also used : RocksDBStoreConfigurationBuilder(org.infinispan.persistence.rocksdb.configuration.RocksDBStoreConfigurationBuilder)

Example 5 with RocksDBStoreConfigurationBuilder

use of org.infinispan.persistence.rocksdb.configuration.RocksDBStoreConfigurationBuilder in project infinispan by infinispan.

the class RocksDBMultiCacheStoreFunctionalTest method buildCacheStoreConfig.

@Override
protected RocksDBStoreConfigurationBuilder buildCacheStoreConfig(PersistenceConfigurationBuilder p, String discriminator) {
    RocksDBStoreConfigurationBuilder store = p.addStore(RocksDBStoreConfigurationBuilder.class);
    store.location(Paths.get(tmpDir.getAbsolutePath(), "rocksdb", "data" + discriminator).toString());
    store.expiredLocation(Paths.get(tmpDir.getAbsolutePath(), "rocksdb", "expired-data-" + discriminator).toString());
    return store;
}
Also used : RocksDBStoreConfigurationBuilder(org.infinispan.persistence.rocksdb.configuration.RocksDBStoreConfigurationBuilder)

Aggregations

RocksDBStoreConfigurationBuilder (org.infinispan.persistence.rocksdb.configuration.RocksDBStoreConfigurationBuilder)5 ConfigurationBuilder (org.infinispan.configuration.cache.ConfigurationBuilder)3 PersistenceConfigurationBuilder (org.infinispan.configuration.cache.PersistenceConfigurationBuilder)3 File (java.io.File)2 CacheConfigurationException (org.infinispan.commons.CacheConfigurationException)2 Configuration (org.infinispan.configuration.cache.Configuration)2 SingleFileStoreConfigurationBuilder (org.infinispan.configuration.cache.SingleFileStoreConfigurationBuilder)1 StoreConfigurationBuilder (org.infinispan.configuration.cache.StoreConfigurationBuilder)1 JdbcStringBasedStoreConfigurationBuilder (org.infinispan.persistence.jdbc.configuration.JdbcStringBasedStoreConfigurationBuilder)1 SoftIndexFileStoreConfigurationBuilder (org.infinispan.persistence.sifs.configuration.SoftIndexFileStoreConfigurationBuilder)1