use of org.apache.geode.cache.client.PoolFactory in project geode by apache.
the class ForceInvalidateEvictionDUnitTest method createClient.
private void createClient(VM vm, final int port) {
final String name = getUniqueName();
final Host host = Host.getHost(0);
vm.invoke(new SerializableRunnable() {
public void run() {
Cache cache = getCache();
PoolFactory pf = PoolManager.createFactory();
pf.addServer(NetworkUtils.getServerHostName(host), port);
pf.setSubscriptionEnabled(true);
pf.create(name);
RegionFactory rf = new RegionFactory();
rf.setOffHeap(isOffHeapEnabled());
rf.setScope(Scope.LOCAL);
rf.setPoolName(name);
Region region = rf.create(name);
region.registerInterest("ALL_KEYS");
}
});
}
use of org.apache.geode.cache.client.PoolFactory in project geode by apache.
the class PdxClientServerDUnitTest method testExceptionWithPoolAfterTypeRegistryCreation.
/**
* Test that we throw an exception if someone tries to create a pool after we were forced to use a
* peer type registry.
*/
@Test
public void testExceptionWithPoolAfterTypeRegistryCreation() {
Host host = Host.getHost(0);
final VM vm0 = host.getVM(0);
VM vm1 = host.getVM(1);
final int port = vm0.invoke(() -> createServerRegion(SimpleClass.class));
SerializableCallable createRegion = new SerializableCallable() {
public Object call() throws Exception {
Properties props = new Properties();
props.setProperty(MCAST_PORT, "0");
props.setProperty(LOCATORS, "");
getSystem(props);
Cache cache = getCache();
HeapDataOutputStream out = new HeapDataOutputStream(Version.CURRENT);
DataSerializer.writeObject(new SimpleClass(57, (byte) 3), out);
PoolFactory pf = PoolManager.createFactory();
pf.addServer(NetworkUtils.getServerHostName(vm0.getHost()), port);
try {
pf.create("pool");
fail("should have received an exception");
} catch (PdxInitializationException expected) {
// do nothing
}
return null;
}
};
vm1.invoke(createRegion);
}
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