use of org.apache.geode.cache.client.ClientCacheFactory in project geode by apache.
the class ClassNotFoundExceptionDUnitTest method createClientRegion.
private void createClientRegion(final VM vm, final int port) {
SerializableCallable createRegion = new SerializableCallable() {
public Object call() throws Exception {
disconnectFromDS();
ClientCacheFactory cf = new ClientCacheFactory();
cf.addPoolServer(NetworkUtils.getServerHostName(vm.getHost()), port);
cf.setPoolSubscriptionEnabled(true);
ClientCache cache = getClientCache(cf);
cache.createClientRegionFactory(ClientRegionShortcut.CACHING_PROXY).create("testSimplePdx");
return null;
}
};
vm.invoke(createRegion);
}
use of org.apache.geode.cache.client.ClientCacheFactory in project geode by apache.
the class UpdatePropagationDUnitTest method createClientCache.
private void createClientCache(String host, Integer port1, Integer port2) throws Exception {
ClientCache cache;
try {
System.setProperty(DistributionConfig.GEMFIRE_PREFIX + "PoolImpl.DISABLE_RANDOM", "true");
int PORT1 = port1.intValue();
int PORT2 = port2.intValue();
Properties props = new Properties();
props.setProperty(MCAST_PORT, "0");
props.setProperty(LOCATORS, "");
ClientCacheFactory cf = new ClientCacheFactory();
cf.addPoolServer(host, PORT1).addPoolServer(host, PORT2).setPoolSubscriptionEnabled(true).setPoolSubscriptionRedundancy(-1).setPoolMinConnections(4).setPoolSocketBufferSize(1000).setPoolReadTimeout(2000).setPoolPingInterval(300);
cache = getClientCache(cf);
} finally {
System.setProperty(DistributionConfig.GEMFIRE_PREFIX + "PoolImpl.DISABLE_RANDOM", "false");
CacheServerTestUtil.enableShufflingOfEndpoints();
}
cache.createClientRegionFactory(ClientRegionShortcut.CACHING_PROXY).addCacheListener(new EventTrackingCacheListener()).create(REGION_NAME);
}
use of org.apache.geode.cache.client.ClientCacheFactory in project geode by apache.
the class FunctionServiceClientBase method createServersAndClient.
public ClientCache createServersAndClient(int numberOfServers) {
int[] ports = new int[numberOfServers];
Host host = Host.getHost(0);
for (int i = 0; i < numberOfServers; i++) {
VM vm = host.getVM(i);
ports[i] = createServer(vm);
}
ClientCacheFactory clientCacheFactory = new ClientCacheFactory();
Arrays.stream(ports).forEach(port -> {
clientCacheFactory.addPoolServer("localhost", port);
});
configureClient(clientCacheFactory);
return getClientCache(clientCacheFactory);
}
use of org.apache.geode.cache.client.ClientCacheFactory in project geode by apache.
the class CacheServerTestUtil method createCacheClientFromXml.
public static void createCacheClientFromXml(URL url, String poolName, String durableClientId, int timeout, Boolean addControlListener) {
ClientCacheFactory ccf = new ClientCacheFactory();
try {
File cacheXmlFile = new File(url.toURI().getPath());
ccf.set(CACHE_XML_FILE, cacheXmlFile.toURI().getPath());
} catch (URISyntaxException e) {
throw new ExceptionInInitializerError(e);
}
ccf.set(MCAST_PORT, "0");
ccf.set(DURABLE_CLIENT_ID, durableClientId);
ccf.set(DURABLE_CLIENT_TIMEOUT, String.valueOf(timeout));
cache = (Cache) ccf.create();
expected = IgnoredException.addIgnoredException("java.net.ConnectionException||java.net.SocketException");
pool = (PoolImpl) PoolManager.find(poolName);
}
use of org.apache.geode.cache.client.ClientCacheFactory in project geode by apache.
the class CacheServerTestUtil method createClientCache.
public static void createClientCache(Pool poolAttr, String regionName, Properties dsProperties) throws Exception {
ClientCacheFactory ccf = new ClientCacheFactory(dsProperties);
if (poolAttr != null) {
ccf.setPoolFreeConnectionTimeout(poolAttr.getFreeConnectionTimeout()).setPoolLoadConditioningInterval(poolAttr.getLoadConditioningInterval()).setPoolSocketBufferSize(poolAttr.getSocketBufferSize()).setPoolMinConnections(poolAttr.getMinConnections()).setPoolMaxConnections(poolAttr.getMaxConnections()).setPoolIdleTimeout(poolAttr.getIdleTimeout()).setPoolPingInterval(poolAttr.getPingInterval()).setPoolStatisticInterval(poolAttr.getStatisticInterval()).setPoolRetryAttempts(poolAttr.getRetryAttempts()).setPoolThreadLocalConnections(poolAttr.getThreadLocalConnections()).setPoolReadTimeout(poolAttr.getReadTimeout()).setPoolSubscriptionEnabled(poolAttr.getSubscriptionEnabled()).setPoolPRSingleHopEnabled(poolAttr.getPRSingleHopEnabled()).setPoolSubscriptionRedundancy(poolAttr.getSubscriptionRedundancy()).setPoolSubscriptionMessageTrackingTimeout(poolAttr.getSubscriptionMessageTrackingTimeout()).setPoolSubscriptionAckInterval(poolAttr.getSubscriptionAckInterval()).setPoolServerGroup(poolAttr.getServerGroup()).setPoolMultiuserAuthentication(poolAttr.getMultiuserAuthentication());
for (InetSocketAddress locator : poolAttr.getLocators()) {
ccf.addPoolLocator(locator.getHostName(), locator.getPort());
}
for (InetSocketAddress server : poolAttr.getServers()) {
ccf.addPoolServer(server.getHostName(), server.getPort());
}
}
new CacheServerTestUtil().createClientCache(dsProperties, ccf);
ClientCache cc = (ClientCache) cache;
cc.createClientRegionFactory(ClientRegionShortcut.CACHING_PROXY).create(regionName);
pool = (PoolImpl) ((GemFireCacheImpl) cc).getDefaultPool();
}
Aggregations