Search in sources :

Example 1 with DefaultCacheManager

use of org.infinispan.manager.DefaultCacheManager in project camel by apache.

the class InfinispanLocalAggregationRepository method doStart.

@Override
protected void doStart() throws Exception {
    if (maximumRedeliveries < 0) {
        throw new IllegalArgumentException("Maximum redelivery retries must be zero or a positive integer.");
    }
    if (recoveryInterval < 0) {
        throw new IllegalArgumentException("Recovery interval must be zero or a positive integer.");
    }
    if (ObjectHelper.isEmpty(configuration)) {
        manager = new DefaultCacheManager();
        manager.start();
    } else {
        manager = new DefaultCacheManager(configuration);
        manager.start();
    }
    if (ObjectHelper.isEmpty(cacheName)) {
        cache = manager.getCache();
    } else {
        cache = manager.getCache(cacheName);
    }
}
Also used : DefaultCacheManager(org.infinispan.manager.DefaultCacheManager)

Example 2 with DefaultCacheManager

use of org.infinispan.manager.DefaultCacheManager in project camel by apache.

the class InfinispanConfigurationTestIT method embeddedCacheWithFlagsTest.

@Test
public void embeddedCacheWithFlagsTest() throws Exception {
    InfinispanConfiguration configuration = new InfinispanConfiguration();
    configuration.setHost("localhost");
    configuration.setCacheName("misc_cache");
    configuration.setCacheContainer(new DefaultCacheManager(true));
    configuration.setFlags(org.infinispan.context.Flag.SKIP_CACHE_LOAD, org.infinispan.context.Flag.SKIP_CACHE_STORE);
    InfinispanManager manager = new InfinispanManager(configuration);
    manager.start();
    BasicCache<Object, Object> cache = manager.getCache();
    assertNotNull(cache);
    assertTrue(cache instanceof DecoratedCache);
    DecoratedCache<Object, Object> decoratedCache = (DecoratedCache<Object, Object>) cache;
    assertTrue(decoratedCache.getFlags().contains(org.infinispan.context.Flag.SKIP_CACHE_LOAD));
    assertTrue(decoratedCache.getFlags().contains(org.infinispan.context.Flag.SKIP_CACHE_STORE));
    manager.getCacheContainer().stop();
    manager.stop();
}
Also used : DefaultCacheManager(org.infinispan.manager.DefaultCacheManager) DecoratedCache(org.infinispan.cache.impl.DecoratedCache) Test(org.junit.Test)

Example 3 with DefaultCacheManager

use of org.infinispan.manager.DefaultCacheManager in project hibernate-orm by hibernate.

the class InfinispanRegionFactoryTestCase method testTimestampValidation.

@Test(expected = CacheException.class)
public void testTimestampValidation() {
    final String timestamps = "org.hibernate.cache.spi.UpdateTimestampsCache";
    Properties p = createProperties();
    InputStream configStream = FileLookupFactory.newInstance().lookupFile(InfinispanRegionFactory.DEF_INFINISPAN_CONFIG_RESOURCE, getClass().getClassLoader());
    ConfigurationBuilderHolder cbh = new ParserRegistry().parse(configStream);
    DefaultCacheManager manager = new DefaultCacheManager(cbh, true);
    ConfigurationBuilder builder = new ConfigurationBuilder();
    builder.clustering().cacheMode(CacheMode.INVALIDATION_SYNC);
    manager.defineConfiguration(DEF_TIMESTAMPS_RESOURCE, builder.build());
    try {
        InfinispanRegionFactory factory = createRegionFactory(manager, p, null);
        factory.start(CacheTestUtil.sfOptionsForStart(), p);
        TimestampsRegionImpl region = (TimestampsRegionImpl) factory.buildTimestampsRegion(timestamps, p);
        fail("Should have failed saying that invalidation is not allowed for timestamp caches.");
    } finally {
        TestingUtil.killCacheManagers(manager);
    }
}
Also used : TimestampsRegionImpl(org.hibernate.cache.infinispan.timestamp.TimestampsRegionImpl) DefaultCacheManager(org.infinispan.manager.DefaultCacheManager) ConfigurationBuilder(org.infinispan.configuration.cache.ConfigurationBuilder) ClusteringConfigurationBuilder(org.infinispan.configuration.cache.ClusteringConfigurationBuilder) GlobalConfigurationBuilder(org.infinispan.configuration.global.GlobalConfigurationBuilder) ConfigurationBuilderHolder(org.infinispan.configuration.parsing.ConfigurationBuilderHolder) InfinispanRegionFactory(org.hibernate.cache.infinispan.InfinispanRegionFactory) InputStream(java.io.InputStream) ParserRegistry(org.infinispan.configuration.parsing.ParserRegistry) Properties(java.util.Properties) Test(org.junit.Test)

Example 4 with DefaultCacheManager

use of org.infinispan.manager.DefaultCacheManager in project hibernate-orm by hibernate.

the class JndiRegionFactoryTest method afterStandardServiceRegistryBuilt.

@Override
protected void afterStandardServiceRegistryBuilt(StandardServiceRegistry ssr) {
    if (bindToJndi) {
        try {
            // Create an in-memory jndi
            namingServer = new SingletonNamingServer();
            namingMain = new Main();
            namingMain.setInstallGlobalService(true);
            namingMain.setPort(-1);
            namingMain.start();
            props = new Properties();
            props.put("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
            props.put("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");
            final String cfgFileName = (String) ssr.getService(ConfigurationService.class).getSettings().get(InfinispanRegionFactory.INFINISPAN_CONFIG_RESOURCE_PROP);
            manager = new DefaultCacheManager(cfgFileName == null ? InfinispanRegionFactory.DEF_INFINISPAN_CONFIG_RESOURCE : cfgFileName, false);
            Context ctx = new InitialContext(props);
            bind(JNDI_NAME, manager, EmbeddedCacheManager.class, ctx);
        } catch (Exception e) {
            throw new RuntimeException("Failure to set up JNDI", e);
        }
    }
}
Also used : Context(javax.naming.Context) InitialContext(javax.naming.InitialContext) DefaultCacheManager(org.infinispan.manager.DefaultCacheManager) SingletonNamingServer(org.jnp.server.SingletonNamingServer) ConfigurationService(org.hibernate.engine.config.spi.ConfigurationService) Properties(java.util.Properties) Main(org.jnp.server.Main) InitialContext(javax.naming.InitialContext) NameNotFoundException(javax.naming.NameNotFoundException)

Example 5 with DefaultCacheManager

use of org.infinispan.manager.DefaultCacheManager in project indy by Commonjava.

the class ContentControllerTest method setupClass.

@BeforeClass
public static void setupClass() {
    cacheManager = new DefaultCacheManager(new ConfigurationBuilder().simpleCache(true).build());
    contentMetadata = cacheManager.getCache("content-metadata", true);
}
Also used : DefaultCacheManager(org.infinispan.manager.DefaultCacheManager) ConfigurationBuilder(org.infinispan.configuration.cache.ConfigurationBuilder) BeforeClass(org.junit.BeforeClass)

Aggregations

DefaultCacheManager (org.infinispan.manager.DefaultCacheManager)18 ConfigurationBuilder (org.infinispan.configuration.cache.ConfigurationBuilder)7 BeforeClass (org.junit.BeforeClass)5 Before (org.junit.Before)4 File (java.io.File)3 InputStream (java.io.InputStream)3 EmbeddedCacheManager (org.infinispan.manager.EmbeddedCacheManager)3 IOException (java.io.IOException)2 Properties (java.util.Properties)2 GlobalConfigurationBuilder (org.infinispan.configuration.global.GlobalConfigurationBuilder)2 Test (org.junit.Test)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 FileInputStream (java.io.FileInputStream)1 WeakReference (java.lang.ref.WeakReference)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 Consumer (java.util.function.Consumer)1 Function (java.util.function.Function)1 Supplier (java.util.function.Supplier)1 PostConstruct (javax.annotation.PostConstruct)1