use of org.apache.geode.cache.client.internal.PoolImpl in project geode by apache.
the class ClientCommandsDUnitTest method startNonSubscribedClient.
private void startNonSubscribedClient(VM client, final VM server, final int port) {
client.invoke("Start client", () -> {
Cache cache = GemFireCacheImpl.getInstance();
if (cache == null) {
Properties props = getNonDurableClientProps();
props.setProperty(LOG_FILE, "client_" + OSProcess.getId() + ".log");
props.setProperty(LOG_LEVEL, "fine");
props.setProperty(STATISTIC_ARCHIVE_FILE, "client_" + OSProcess.getId() + ".gfs");
props.setProperty(STATISTIC_SAMPLING_ENABLED, "true");
getSystem(props);
final ClientCacheFactory ccf = new ClientCacheFactory(props);
ccf.addPoolServer(getServerHostName(server.getHost()), port);
ccf.setPoolSubscriptionEnabled(false);
ccf.setPoolPingInterval(1);
ccf.setPoolStatisticInterval(1);
ccf.setPoolSubscriptionRedundancy(1);
ccf.setPoolMinConnections(1);
ClientCache clientCache = (ClientCache) getClientCache(ccf);
// Create region
if (clientCache.getRegion(Region.SEPARATOR + regionName) == null && clientCache.getRegion(regionName) == null) {
ClientRegionFactory regionFactory = clientCache.createClientRegionFactory(ClientRegionShortcut.LOCAL).setPoolName(clientCache.getDefaultPool().getName());
Region dataRegion = regionFactory.create(regionName);
assertNotNull(dataRegion);
dataRegion.put("k1", "v1");
dataRegion.put("k2", "v2");
}
} else {
String poolName = "new_pool_" + System.currentTimeMillis();
try {
PoolImpl p = (PoolImpl) PoolManager.createFactory().addServer(getServerHostName(server.getHost()), port).setThreadLocalConnections(true).setMinConnections(1).setSubscriptionEnabled(false).setPingInterval(1).setStatisticInterval(1).setMinConnections(1).setSubscriptionRedundancy(1).create(poolName);
cache.getLogger().info("Created new pool pool " + poolName);
assertNotNull(p);
} catch (Exception eee) {
cache.getLogger().info("Exception in creating pool " + poolName + " Exception ==" + CliUtil.stackTraceAsString(eee));
}
}
});
}
Aggregations