use of org.apache.geode.cache.client.PoolFactory in project geode by apache.
the class CQListGIIDUnitTest method createClientCache.
public static void createClientCache(Integer port1, Integer port2, Integer port3, String rLevel, Boolean addListener) throws Exception {
CacheServerTestUtil.disableShufflingOfEndpoints();
String host = NetworkUtils.getIPLiteral();
Properties props = new Properties();
props.setProperty(MCAST_PORT, "0");
props.setProperty(LOCATORS, "");
new CQListGIIDUnitTest().createCache(props);
PoolFactory pf = PoolManager.createFactory();
int endPointCount = 1;
pf.addServer(host, port1);
if (port2.intValue() != -1) {
pf.addServer(host, port2);
endPointCount++;
}
if (port3.intValue() != -1) {
pf.addServer(host, port3);
endPointCount++;
}
pf.setRetryAttempts(5);
pf.setReadTimeout(2500);
pf.setSocketBufferSize(32768);
pf.setPingInterval(1000);
pf.setMinConnections(endPointCount * 2);
pf.setSubscriptionRedundancy(Integer.parseInt(rLevel));
pf.setSubscriptionEnabled(true).create("clientPool");
try {
cache.getQueryService();
} catch (Exception cqe) {
Assert.fail("Failed to getCQService.", cqe);
}
AttributesFactory factory = new AttributesFactory();
factory.setScope(Scope.LOCAL);
factory.setPoolName("clientPool");
RegionAttributes attrs = factory.create();
createRegion(regions[0], "root", attrs);
createRegion(regions[1], "root", attrs);
logger = cache.getLogger();
}
use of org.apache.geode.cache.client.PoolFactory in project geode by apache.
the class QueryUsingPoolDUnitTest method createPool.
public void createPool(final String poolName, final String[] servers, final int[] ports, final boolean subscriptionEnabled) {
// Create Cache.
getCache(true);
PoolFactory poolFactory = PoolManager.createFactory();
poolFactory.setSubscriptionEnabled(subscriptionEnabled);
for (int i = 0; i < servers.length; i++) {
logger.info("### Adding to Pool. ### Server : " + servers[i] + " Port : " + ports[i]);
poolFactory.addServer(servers[i], ports[i]);
}
poolFactory.setMinConnections(1);
poolFactory.setMaxConnections(5);
poolFactory.setRetryAttempts(5);
poolFactory.create(poolName);
}
use of org.apache.geode.cache.client.PoolFactory in project geode by apache.
the class CacheXml66DUnitTest method testExplicitConnectionPool.
/**
* test for enabling PRsingleHop feature. Test for enabling multiuser-authentication attribute.
*/
@Test
public void testExplicitConnectionPool() throws Exception {
getSystem();
CacheCreation cache = new CacheCreation();
PoolFactory f = cache.createPoolFactory();
f.addServer(ALIAS2, 3777).addServer(ALIAS1, 3888);
f.setFreeConnectionTimeout(12345).setLoadConditioningInterval(12345).setSocketBufferSize(12345).setThreadLocalConnections(true).setPRSingleHopEnabled(true).setReadTimeout(12345).setMinConnections(12346).setMaxConnections(12347).setRetryAttempts(12348).setIdleTimeout(12349).setPingInterval(12350).setStatisticInterval(12351).setServerGroup("mygroup").setSubscriptionRedundancy(12345).setSubscriptionMessageTrackingTimeout(12345).setSubscriptionAckInterval(333).setMultiuserAuthentication(true);
f.create("mypool");
RegionAttributesCreation attrs = new RegionAttributesCreation(cache);
attrs.setPoolName("mypool");
// required for multiuser mode
attrs.setDataPolicy(DataPolicy.EMPTY);
cache.createVMRegion("rootNORMAL", attrs);
IgnoredException.addIgnoredException("Connection refused: connect");
testXml(cache);
Cache c = getCache();
assertNotNull(c);
Region r = c.getRegion("rootNORMAL");
assertNotNull(r);
assertEquals("mypool", r.getAttributes().getPoolName());
Pool cp = PoolManager.find("mypool");
assertNotNull(cp);
assertEquals(0, cp.getLocators().size());
assertEquals(2, cp.getServers().size());
assertEquals(createINSA(ALIAS2, 3777), cp.getServers().get(0));
assertEquals(createINSA(ALIAS1, 3888), cp.getServers().get(1));
assertEquals(12345, cp.getFreeConnectionTimeout());
assertEquals(12345, cp.getLoadConditioningInterval());
assertEquals(12345, cp.getSocketBufferSize());
assertEquals(true, cp.getThreadLocalConnections());
assertEquals(true, cp.getPRSingleHopEnabled());
assertEquals(12345, cp.getReadTimeout());
assertEquals(12346, cp.getMinConnections());
assertEquals(12347, cp.getMaxConnections());
assertEquals(12348, cp.getRetryAttempts());
assertEquals(12349, cp.getIdleTimeout());
assertEquals(12350, cp.getPingInterval());
assertEquals(12351, cp.getStatisticInterval());
assertEquals("mygroup", cp.getServerGroup());
// TODO: commented this out until queues are implemented
// assertIndexDetailsEquals(true, cp.getQueueEnabled());
assertEquals(12345, cp.getSubscriptionRedundancy());
assertEquals(12345, cp.getSubscriptionMessageTrackingTimeout());
assertEquals(333, cp.getSubscriptionAckInterval());
assertEquals(true, cp.getMultiuserAuthentication());
}
use of org.apache.geode.cache.client.PoolFactory in project geode by apache.
the class LauncherLifecycleCommandsDUnitTest method setupClientCache.
private ClientCache setupClientCache(final String durableClientId, final int serverPort) {
ClientCache clientCache = new ClientCacheFactory().set(DURABLE_CLIENT_ID, durableClientId).create();
PoolFactory poolFactory = PoolManager.createFactory();
poolFactory.setMaxConnections(10);
poolFactory.setMinConnections(1);
poolFactory.setReadTimeout(5000);
poolFactory.addServer("localhost", serverPort);
Pool pool = poolFactory.create("serverConnectionPool");
assertNotNull("The 'serverConnectionPool' was not properly configured and initialized!", pool);
ClientRegionFactory<Long, String> regionFactory = clientCache.createClientRegionFactory(ClientRegionShortcut.PROXY);
regionFactory.setPoolName(pool.getName());
regionFactory.setKeyConstraint(Long.class);
regionFactory.setValueConstraint(String.class);
Region<Long, String> exampleProxy = regionFactory.create("Example");
assertNotNull("The 'Example' Client Region was not properly configured and initialized", exampleProxy);
return clientCache;
}
use of org.apache.geode.cache.client.PoolFactory in project geode by apache.
the class CacheXmlParser method startPool.
/**
* @since GemFire 5.7
*/
private void startPool(Attributes atts) {
PoolFactory f = this.cache.createPoolFactory();
String name = atts.getValue(NAME).trim();
stack.push(name);
stack.push(f);
String v;
v = atts.getValue(FREE_CONNECTION_TIMEOUT);
if (v != null) {
f.setFreeConnectionTimeout(parseInt(v));
}
v = atts.getValue(LOAD_CONDITIONING_INTERVAL);
if (v != null) {
f.setLoadConditioningInterval(parseInt(v));
}
v = atts.getValue(MIN_CONNECTIONS);
if (v != null) {
f.setMinConnections(parseInt(v));
}
v = atts.getValue(MAX_CONNECTIONS);
if (v != null) {
f.setMaxConnections(parseInt(v));
}
v = atts.getValue(RETRY_ATTEMPTS);
if (v != null) {
f.setRetryAttempts(parseInt(v));
}
v = atts.getValue(IDLE_TIMEOUT);
if (v != null) {
f.setIdleTimeout(parseLong(v));
}
v = atts.getValue(PING_INTERVAL);
if (v != null) {
f.setPingInterval(parseLong(v));
}
v = atts.getValue(SUBSCRIPTION_ENABLED);
if (v != null) {
f.setSubscriptionEnabled(parseBoolean(v));
}
v = atts.getValue(PR_SINGLE_HOP_ENABLED);
if (v != null) {
f.setPRSingleHopEnabled(parseBoolean(v));
}
v = atts.getValue(SUBSCRIPTION_MESSAGE_TRACKING_TIMEOUT);
if (v != null) {
f.setSubscriptionMessageTrackingTimeout(parseInt(v));
}
v = atts.getValue(SUBSCRIPTION_ACK_INTERVAL);
if (v != null) {
f.setSubscriptionAckInterval(parseInt(v));
}
v = atts.getValue(SUBSCRIPTION_REDUNDANCY);
if (v != null) {
f.setSubscriptionRedundancy(parseInt(v));
}
v = atts.getValue(READ_TIMEOUT);
if (v != null) {
f.setReadTimeout(parseInt(v));
}
v = atts.getValue(SERVER_GROUP);
if (v != null) {
f.setServerGroup(v.trim());
}
v = atts.getValue(SOCKET_BUFFER_SIZE);
if (v != null) {
f.setSocketBufferSize(parseInt(v));
}
v = atts.getValue(STATISTIC_INTERVAL);
if (v != null) {
f.setStatisticInterval(parseInt(v));
}
v = atts.getValue(THREAD_LOCAL_CONNECTIONS);
if (v != null) {
f.setThreadLocalConnections(parseBoolean(v));
}
v = atts.getValue(MULTIUSER_SECURE_MODE_ENABLED);
if (v != null) {
f.setMultiuserAuthentication(parseBoolean(v));
}
}
Aggregations