use of org.infinispan.configuration.cache.PersistenceConfigurationBuilder 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.PersistenceConfigurationBuilder 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.PersistenceConfigurationBuilder in project infinispan by infinispan.
the class ClassLoaderManagerDisablingTest method testDisableWithMultipleStores.
public void testDisableWithMultipleStores() {
ConfigurationBuilder builder = TestCacheManagerFactory.getDefaultCacheConfiguration(false);
PersistenceConfigurationBuilder p = builder.persistence();
p.addStore(DummyInMemoryStoreConfigurationBuilder.class).fetchPersistentState(true);
// Just add this one as it is simple and we need different types
p.addStore(UnnecessaryLoadingTest.CountingStoreConfigurationBuilder.class);
EmbeddedCacheManager cacheManager = null;
try {
cacheManager = TestCacheManagerFactory.createCacheManager(builder);
Cache<Object, Object> cache = cacheManager.getCache();
PersistenceManager pm = TestingUtil.extractComponent(cache, PersistenceManager.class);
// Get all types of stores
Set<Object> stores = pm.getStores(Object.class);
// Should have 2 before we disable
assertEquals(2, stores.size());
pm.disableStore(UnnecessaryLoadingTest.CountingStore.class.getName());
stores = pm.getStores(Object.class);
assertEquals(1, stores.size());
DummyInMemoryStore store = (DummyInMemoryStore) stores.iterator().next();
assertTrue(store.getConfiguration().fetchPersistentState());
} finally {
TestingUtil.killCacheManagers(cacheManager);
}
}
use of org.infinispan.configuration.cache.PersistenceConfigurationBuilder 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);
}
}
}
use of org.infinispan.configuration.cache.PersistenceConfigurationBuilder in project meveo by meveo-org.
the class CachesInitializer method init.
@PostConstruct
protected void init() {
try {
InitialContext initialContext = new InitialContext();
cacheContainer = (EmbeddedCacheManager) initialContext.lookup("java:jboss/infinispan/container/meveo");
} catch (Exception e) {
log.error("Cannot instantiate cache container", e);
}
log.info("Initializing ontology caches");
PersistenceConfigurationBuilder confBuilder = new ConfigurationBuilder().persistence().passivation(false);
Configuration configuration = confBuilder.build();
if (!cacheContainer.cacheExists(CustomFieldsCacheContainerProvider.MEVEO_CFT_CACHE)) {
cacheContainer.defineConfiguration(CustomFieldsCacheContainerProvider.MEVEO_CFT_CACHE, configuration);
}
if (!cacheContainer.cacheExists(CustomFieldsCacheContainerProvider.MEVEO_CET_CACHE)) {
cacheContainer.defineConfiguration(CustomFieldsCacheContainerProvider.MEVEO_CET_CACHE, configuration);
}
if (!cacheContainer.cacheExists(CustomFieldsCacheContainerProvider.MEVEO_CRT_CACHE)) {
cacheContainer.defineConfiguration(CustomFieldsCacheContainerProvider.MEVEO_CRT_CACHE, configuration);
}
log.info("Finished initializing ontology caches");
}
Aggregations