@Override public <K, V> ConcurrentMap<K, V> getReplicatedCache(final String name) { return cacheManager.getCache(name, REPLICATED_CONFIGURATION_NAME); }
@Override public <K, V> ConcurrentMap<K, V> getCache(final String name) { return cacheManager.getCache(name); }
@Bean @Qualifier("RateLimit") public ReadWriteMap<String, GridBucketState> map() { DefaultCacheManager cacheManager = new DefaultCacheManager(); cacheManager.defineConfiguration("rateLimit", new ConfigurationBuilder().build()); AdvancedCache<String, GridBucketState> cache = cacheManager.<String, GridBucketState>getCache("rateLimit").getAdvancedCache(); FunctionalMapImpl<String, GridBucketState> functionalMap = FunctionalMapImpl.create(cache); return ReadWriteMapImpl.create(functionalMap); }
protected ServerCache getXmlCache(Configurable configurable) { String path = (String)configurable.getConfiguration().getProperty("server.request.cache.infinispan.config.file"); if (path == null) path = getConfigProperty("server.request.cache.infinispan.config.file"); if (path == null) return null; String name = (String)configurable.getConfiguration().getProperty("server.request.cache.infinispan.cache.name"); if (name == null) name = getConfigProperty("server.request.cache.infinispan.cache.name"); if (name == null) throw new RuntimeException(Messages.MESSAGES.needToSpecifyCacheName()); try { Cache<Object, Object> c = new DefaultCacheManager(path).getCache(name); return new InfinispanCache(c); } catch (IOException e) { throw new RuntimeException(e); } } }
@Override public Cache<String, Object> call() { return finalCacheManager.getCache(SYSTEM_CACHE_NAME); } });
@Override public Cache<String, DataVersionHolder> call() { return finalCacheManager.getCache(DOMAIN_CACHE_NAME); } });
private <K, V> Cache<K, V> getCache(String name) { try { return new DefaultCacheManager("bayes-cache.xml").getCache(name, true); } catch (IOException e) { throw new RuntimeException(e); } }
/** * {@inheritDoc} * @see org.infinispan.manager.DefaultCacheManager#getCache(java.lang.String) */ @Override public <K, V> Cache<K, V> getCache(String name) { return this.cacheName.equals(name) ? super.<K, V>getCache(CacheContainer.DEFAULT_CACHE_NAME) : this.parent.<K, V>getCache(name); }
public Object read(ObjectInputStream is) throws IOException, ClassNotFoundException { Object id = is.readObject(); DefaultCacheManager cm = (DefaultCacheManager) env.get(EnvironmentName.ENTITY_MANAGER_FACTORY); Cache<?, ?> cache = cm.getCache("jbpm-configured-cache"); return cache.get(id); }
public Schema retrieveSchema(String name) throws IOException, InterruptedException, ClassNotFoundException { if (!knownSchemas.containsKey(name)) { byte[] key = marshaller.objectToByteBuffer(name); byte[] value = (byte[]) cacheManager.getCache(Support.AVRO_METADATA_CACHE_NAME).get(key); if (value==null) throw new IOException(name+" not found in the metadata cache"); Schema schema = (Schema) marshaller.objectFromByteBuffer(value); knownSchemas.put(name, schema); log.info("adding schama "+name+" to metadata cache"); } return knownSchemas.get(name); }
public Object unmarshal(Context context, ObjectInputStream ois, byte[] object, ClassLoader classloader) throws IOException, ClassNotFoundException { DroolsObjectInputStream is = new DroolsObjectInputStream( new ByteArrayInputStream( object ), classloader ); Object id = is.readObject(); DefaultCacheManager cm = (DefaultCacheManager) env.get(EnvironmentName.ENTITY_MANAGER_FACTORY); Cache<?, ?> cache = cm.getCache("jbpm-configured-cache"); return cache.get(id); }
DefaultCacheManager manager = new DefaultCacheManager(); Configuration c = new ConfigurationBuilder().persistence() .addSingleFileStore() .location("/tmp/myDataStore") .maxEntries(5000); manager.defineConfiguration("myCache", c); Cache<Object, Object> cache = manager.getCache("myCache");
private AdvancedLoadWriteStore getAdvancedLoadWriteStore() { cache = dcm.getCache("customLoaderCache"); return (AdvancedLoadWriteStore) TestingUtil.getFirstLoader(cache); }
private void mockRehashInProgress(String cacheName, Cache mockedCache, AdvancedCache mockedAdvancedCache, DistributionManager mockedDistributionManager) { when(mockedCacheManager.getCache(cacheName, false)).thenReturn(mockedCache); when(mockedCache.getAdvancedCache()).thenReturn(mockedAdvancedCache); when(mockedCache.getStatus()).thenReturn(INSTANTIATED); when(mockedAdvancedCache.getDistributionManager()).thenReturn(mockedDistributionManager); when(mockedDistributionManager.isRehashInProgress()).thenReturn(true); }
@BeforeMethod public void beforeTest() throws IOException { for (int i = 0; i < NUM_NODES; i++) { DefaultCacheManager node = new DefaultCacheManager(CONFIGURATION); node.start(); //Start all its caches: node.getCache("index_metadata").start(); node.getCache("index_data").start(); node.getCache("index_locks").start(); cacheManagers.put(i, node); } }
private Cache<Object, Object> createManagerAndGetCache(int startFailures) { GlobalConfiguration globalConfiguration = new GlobalConfigurationBuilder().globalJmxStatistics().allowDuplicateDomains(true).build(); ConfigurationBuilder cb = TestCacheManagerFactory.getDefaultCacheConfiguration(false); Configuration config = cb.persistence() .addStore(DummyInMemoryStoreConfigurationBuilder.class) .startFailures(startFailures) .build(); return new DefaultCacheManager(globalConfiguration, config).getCache(); }
private Cache<Object, Object> createManagerAndGetCache(boolean failSilently, int queueSize) { GlobalConfiguration globalConfiguration = new GlobalConfigurationBuilder().globalJmxStatistics().allowDuplicateDomains(true).build(); ConfigurationBuilder cb = TestCacheManagerFactory.getDefaultCacheConfiguration(false); Configuration config = cb.persistence().availabilityInterval(AVAILABILITY_INTERVAL) .addStore(DummyInMemoryStoreConfigurationBuilder.class) .async().enable().modificationQueueSize(queueSize).failSilently(failSilently) .build(); return new DefaultCacheManager(globalConfiguration, config).getCache(); }
public void testDefaultEnlistment() { ConfigurationBuilder builder = getLocalBuilder(); builder.transaction().transactionMode(TransactionMode.TRANSACTIONAL); dcm = new DefaultCacheManager(getGlobalConfig(), builder.build()); Cache<Object,Object> cache = dcm.getCache(); assertFalse(cache.getCacheConfiguration().transaction().useSynchronization()); assertFalse(cache.getCacheConfiguration().transaction().recovery().enabled()); cache.put("k", "v"); assertEquals("v", cache.get("k")); }
public void testXAEnlistmentNoRecovery() { ConfigurationBuilder builder = getLocalBuilder(); builder.transaction() .transactionMode(TransactionMode.TRANSACTIONAL) .useSynchronization(false) .recovery().disable(); dcm = new DefaultCacheManager(getGlobalConfig(), builder.build()); Cache<Object,Object> cache = dcm.getCache(); assertFalse(cache.getCacheConfiguration().transaction().useSynchronization()); assertFalse(cache.getCacheConfiguration().transaction().recovery().enabled()); }
public void testXAEnlistment() { ConfigurationBuilder builder = getLocalBuilder(); builder.transaction() .transactionMode(TransactionMode.TRANSACTIONAL) .useSynchronization(false); dcm = new DefaultCacheManager(getGlobalConfig(), builder.build()); Cache<Object,Object> cache = dcm.getCache(); assertFalse(cache.getCacheConfiguration().transaction().useSynchronization()); assertFalse(cache.getCacheConfiguration().transaction().recovery().enabled()); cache.put("k", "v"); assertEquals("v", cache.get("k")); }