Search in sources :

Example 1 with SingleFileStoreConfiguration

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);
}
Also used : SingleFileStoreConfiguration(org.infinispan.configuration.cache.SingleFileStoreConfiguration) StoreConfiguration(org.infinispan.configuration.cache.StoreConfiguration) SingleFileStoreConfiguration(org.infinispan.configuration.cache.SingleFileStoreConfiguration) CacheConfiguration(org.xwiki.cache.config.CacheConfiguration) LRUCacheConfiguration(org.xwiki.cache.config.LRUCacheConfiguration) LRUCacheConfiguration(org.xwiki.cache.config.LRUCacheConfiguration) Test(org.junit.jupiter.api.Test) ComponentTest(org.xwiki.test.junit5.mockito.ComponentTest)

Example 2 with SingleFileStoreConfiguration

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);
}
Also used : SingleFileStoreConfiguration(org.infinispan.configuration.cache.SingleFileStoreConfiguration) StoreConfiguration(org.infinispan.configuration.cache.StoreConfiguration) SingleFileStoreConfiguration(org.infinispan.configuration.cache.SingleFileStoreConfiguration) CacheConfiguration(org.xwiki.cache.config.CacheConfiguration) LRUCacheConfiguration(org.xwiki.cache.config.LRUCacheConfiguration) LRUCacheConfiguration(org.xwiki.cache.config.LRUCacheConfiguration) Test(org.junit.jupiter.api.Test) ComponentTest(org.xwiki.test.junit5.mockito.ComponentTest)

Example 3 with SingleFileStoreConfiguration

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())));
}
Also used : SingleFileStoreConfiguration(org.infinispan.configuration.cache.SingleFileStoreConfiguration) AsyncStoreConfiguration(org.infinispan.configuration.cache.AsyncStoreConfiguration) AttributeSet(org.infinispan.commons.configuration.attributes.AttributeSet)

Example 4 with SingleFileStoreConfiguration

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;
}
Also used : SingleFileStoreConfiguration(org.infinispan.configuration.cache.SingleFileStoreConfiguration) PersistenceConfiguration(org.infinispan.configuration.cache.PersistenceConfiguration) StoreConfiguration(org.infinispan.configuration.cache.StoreConfiguration) SingleFileStoreConfiguration(org.infinispan.configuration.cache.SingleFileStoreConfiguration)

Example 5 with SingleFileStoreConfiguration

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");
}
Also used : SingleFileStoreConfiguration(org.infinispan.configuration.cache.SingleFileStoreConfiguration) ConfigurationBuilderHolder(org.infinispan.configuration.parsing.ConfigurationBuilderHolder) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) StoreConfiguration(org.infinispan.configuration.cache.StoreConfiguration) SingleFileStoreConfiguration(org.infinispan.configuration.cache.SingleFileStoreConfiguration) ParserRegistry(org.infinispan.configuration.parsing.ParserRegistry)

Aggregations

SingleFileStoreConfiguration (org.infinispan.configuration.cache.SingleFileStoreConfiguration)6 StoreConfiguration (org.infinispan.configuration.cache.StoreConfiguration)5 ConfigurationBuilderHolder (org.infinispan.configuration.parsing.ConfigurationBuilderHolder)2 ParserRegistry (org.infinispan.configuration.parsing.ParserRegistry)2 Test (org.junit.jupiter.api.Test)2 CacheConfiguration (org.xwiki.cache.config.CacheConfiguration)2 LRUCacheConfiguration (org.xwiki.cache.config.LRUCacheConfiguration)2 ComponentTest (org.xwiki.test.junit5.mockito.ComponentTest)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 InputStream (java.io.InputStream)1 AttributeSet (org.infinispan.commons.configuration.attributes.AttributeSet)1 AsyncStoreConfiguration (org.infinispan.configuration.cache.AsyncStoreConfiguration)1 PersistenceConfiguration (org.infinispan.configuration.cache.PersistenceConfiguration)1