@Override protected void compareStoreConfiguration(String name, StoreConfiguration beforeStore, StoreConfiguration afterStore) { super.compareStoreConfiguration(name, beforeStore, afterStore); RemoteStoreConfiguration before = (RemoteStoreConfiguration) beforeStore; RemoteStoreConfiguration after = (RemoteStoreConfiguration) afterStore; AssertJUnit.assertEquals("Wrong connection pool for " + name + " configuration.", before.connectionPool(), after.connectionPool()); } }
static CrossDCAwareCacheFactory getFactory(Cache<String, Serializable> workCache, Set<RemoteStore> remoteStores) { if (remoteStores.isEmpty()) { logger.debugf("No configured remoteStore available. Cross-DC scenario is not used"); return new InfinispanCacheWrapperFactory(workCache); } else { logger.debugf("RemoteStore is available. Cross-DC scenario will be used"); if (remoteStores.size() > 1) { logger.warnf("More remoteStores configured for work cache. Will use just the first one"); } // For cross-DC scenario, we need to return underlying remoteCache for atomic operations to work properly RemoteStore remoteStore = remoteStores.iterator().next(); RemoteCache remoteCache = remoteStore.getRemoteCache(); if (remoteCache == null) { String cacheName = remoteStore.getConfiguration().remoteCacheName(); throw new IllegalStateException("Remote cache '" + cacheName + "' is not available."); } return new RemoteCacheWrapperFactory(remoteCache); } }
public void testRemoteCacheStore() throws Exception { String config = TestingUtil.wrapXMLWithSchema( "<cache-container default-cache=\"default\">" + " <local-cache name=\"default\">\n" + " <persistence>\n" + " <remote-store xmlns=\"urn:infinispan:config:store:remote:"+ Version.getSchemaVersion() + "\" >\n" + " <remote-server host=\"one\" />\n" + " <remote-server host=\"two\" />\n" + " <connection-pool max-active=\"10\" exhausted-action=\"CREATE_NEW\" />\n" + " <async-executor>\n" + " <property name=\"maxThreads\">4</property>" + " </async-executor>\n" + " <write-behind/>\n" + " </remote-store>\n" + " </persistence>\n" + " </local-cache>\n" + "</cache-container>" ); RemoteStoreConfiguration store = (RemoteStoreConfiguration) buildCacheManagerWithCacheStore(config); assert store.servers().size() == 2; assert store.connectionPool().exhaustedAction() == ExhaustedAction.CREATE_NEW; assert store.asyncExecutorFactory().properties().getIntProperty("maxThreads", 0) == 4; assert store.async().enabled(); }