use of org.infinispan.configuration.cache.SingleFileStoreConfiguration in project xwiki-commons by xwiki.
the class InfinispanConfigTest method createCacheWhenFileCachePath.
@Test
void createCacheWhenFileCachePath() throws Exception {
CacheConfiguration configuration = new LRUCacheConfiguration("file-cache-path", 42);
Cache<String, String> cache = createCache(configuration);
List<StoreConfiguration> stores = cache.getCacheConfiguration().persistence().stores();
assertEquals(1, stores.size());
String location = ((SingleFileStoreConfiguration) stores.get(0)).location();
assertEquals(System.getProperty("java.io.tmpdir"), location);
}
use of org.infinispan.configuration.cache.SingleFileStoreConfiguration in project xwiki-commons by xwiki.
the class InfinispanConfigTest method createCacheWhenFileCacheNoPath.
@Test
void createCacheWhenFileCacheNoPath() throws Exception {
CacheConfiguration configuration = new LRUCacheConfiguration("file-cache-nopath", 42);
Cache<String, String> cache = createCache(configuration);
List<StoreConfiguration> stores = cache.getCacheConfiguration().persistence().stores();
assertEquals(1, stores.size());
String location = ((SingleFileStoreConfiguration) stores.get(0)).location();
assertEquals(this.environment.getTemporaryDirectory().toString() + "/cache", location);
}
use of org.infinispan.configuration.cache.SingleFileStoreConfiguration in project infinispan by infinispan.
the class SFSToSIFSStore method createAndStartSingleFileStore.
CompletionStage<NonBlockingStore<K, V>> createAndStartSingleFileStore(InitializationContext ctx, String location, boolean segmented) {
AttributeSet sfsAttributes = SingleFileStoreConfiguration.attributeDefinitionSet();
sfsAttributes.attribute(SingleFileStoreConfiguration.LOCATION).set(location);
sfsAttributes.attribute(AbstractStoreConfiguration.SEGMENTED).set(segmented);
sfsAttributes.attribute(AbstractStoreConfiguration.READ_ONLY).set(Boolean.TRUE);
return createAndStartStore(ctx, new SingleFileStoreConfiguration(sfsAttributes.protect(), new AsyncStoreConfiguration(AsyncStoreConfiguration.attributeDefinitionSet().protect())));
}
use of org.infinispan.configuration.cache.SingleFileStoreConfiguration in project xwiki-commons by xwiki.
the class InfinispanConfigurationLoader method containsIncompleteFileLoader.
/**
* @param configuration the configuration to check
* @return true if one of the loader is an incomplete {@link SingleFileStoreConfiguration}
*/
private boolean containsIncompleteFileLoader(Configuration configuration) {
PersistenceConfiguration persistenceConfiguration = configuration.persistence();
for (StoreConfiguration storeConfiguration : persistenceConfiguration.stores()) {
if (storeConfiguration instanceof SingleFileStoreConfiguration) {
SingleFileStoreConfiguration singleFileStoreConfiguration = (SingleFileStoreConfiguration) storeConfiguration;
String location = singleFileStoreConfiguration.location();
if (StringUtils.isBlank(location)) {
return true;
}
}
}
return false;
}
use of org.infinispan.configuration.cache.SingleFileStoreConfiguration in project infinispan by infinispan.
the class SingleFileStoreFunctionalTest method testParsingElement.
public void testParsingElement() throws Exception {
String config = TestingUtil.wrapXMLWithoutSchema("<cache-container default-cache=\"default\">" + " <local-cache name=\"default\">\n" + " <persistence passivation=\"false\"> \n" + " <single-file-store path=\"other-location\" segmented=\"false\" max-entries=\"100\" shared=\"false\" preload=\"true\" fragmentation-factor=\"0.75\"/> \n" + " </persistence>\n" + " </local-cache>\n" + "</cache-container>");
InputStream is = new ByteArrayInputStream(config.getBytes());
ConfigurationBuilderHolder holder = new ParserRegistry().parse(config);
List<StoreConfiguration> storeConfigs = holder.getDefaultConfigurationBuilder().build().persistence().stores();
assertEquals(1, storeConfigs.size());
SingleFileStoreConfiguration fileStoreConfig = (SingleFileStoreConfiguration) storeConfigs.get(0);
assertEquals("other-location", fileStoreConfig.location());
assertEquals(100, fileStoreConfig.maxEntries());
assertEquals(0.75f, fileStoreConfig.fragmentationFactor(), 0f);
Util.recursiveFileRemove("other-location");
}
Aggregations