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