use of org.apache.geode.cache.client.internal.PoolImpl in project geode by apache.
the class ConnectionProxyJUnitTest method testTwoClientsHavingDifferentThreadIdMaps.
@Test
public void testTwoClientsHavingDifferentThreadIdMaps() {
int port3 = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
CacheServer server = null;
try {
try {
server = this.cache.addCacheServer();
server.setMaximumTimeBetweenPings(10000);
server.setPort(port3);
server.start();
} catch (Exception e) {
e.printStackTrace();
fail("Failed to create server");
}
try {
PoolFactory pf = PoolManager.createFactory();
pf.addServer("localhost", port3);
pf.setSubscriptionEnabled(true);
pf.setSubscriptionRedundancy(-1);
pf.setSubscriptionMessageTrackingTimeout(100000);
PoolImpl proxy1 = (PoolImpl) pf.create("clientPool1");
try {
PoolImpl proxy2 = (PoolImpl) pf.create("clientPool2");
try {
Map map1 = proxy1.getThreadIdToSequenceIdMap();
Map map2 = proxy2.getThreadIdToSequenceIdMap();
assertTrue(!(map1 == map2));
} finally {
proxy2.destroy();
}
} finally {
proxy1.destroy();
}
} catch (Exception ex) {
ex.printStackTrace();
fail("Failed to initialize client");
}
} finally {
if (server != null) {
server.stop();
}
}
}
use of org.apache.geode.cache.client.internal.PoolImpl in project geode by apache.
the class InterestListEndpointDUnitTest method testInterestListEndpointAfterFailover.
@Test
public void testInterestListEndpointAfterFailover() throws Exception {
final long maxWaitTime = 20000;
client1.invoke(() -> createEntriesK1andK2());
server2.invoke(() -> createEntriesK1andK2());
server1.invoke(() -> createEntriesK1andK2());
client1.invoke(() -> registerKey1());
boolean firstIsPrimary = isVm0Primary();
VM primary = firstIsPrimary ? server1 : server2;
primary.invoke(() -> stopILEndpointServer());
Wait.pause(5000);
// Since the loadbalancing policy is roundrobin & there are two servers so
// do two dumb puts, which will ensure that fail over happens from the
// interest list end point in case Live ServerMonitor is not working
client1.invoke(new CacheSerializableRunnable("Ensure that the failover from ILEP occurs") {
public void run2() throws CacheException {
Region r = cache.getRegion("/" + REGION_NAME);
String poolName = r.getAttributes().getPoolName();
assertNotNull(poolName);
final PoolImpl pool = (PoolImpl) PoolManager.find(poolName);
assertNotNull(pool);
pool.acquireConnection();
try {
// Used in the case where we don't have a LiveServerMonitorThread
r.put("ping", "pong1");
} catch (CacheWriterException itsOK) {
}
try {
// Used in the case where we don't have a LiveServerMonitorThread
r.put("ping", "pong2");
} catch (CacheWriterException itsOK) {
}
WaitCriterion ev = new WaitCriterion() {
public boolean done() {
return pool.getConnectedServerCount() != 2;
}
public String description() {
return null;
}
};
Wait.waitForCriterion(ev, maxWaitTime, 200, true);
}
});
// put on stopped server
primary.invoke(() -> put());
client1.invoke(() -> verifyPut());
}
use of org.apache.geode.cache.client.internal.PoolImpl in project geode by apache.
the class InterestListFailoverDUnitTest method registerInterestList.
public static Integer registerInterestList() {
try {
Region r = CacheServerTestUtil.getCache().getRegion("/" + REGION_NAME);
assertNotNull(r);
r.registerInterest("key-1");
r.registerInterest("key-2");
r.registerInterest("key-3");
r.registerInterest("key-4");
r.registerInterest("key-5");
// now return the port of the primary.
PoolImpl p = (PoolImpl) PoolManager.find(r.getAttributes().getPoolName());
return new Integer(p.getPrimaryPort());
} catch (Exception ex) {
Assert.fail("failed while registering keys k1 to k5", ex);
return null;
}
}
use of org.apache.geode.cache.client.internal.PoolImpl in project geode by apache.
the class InterestListRecoveryDUnitTest method createClientCache.
public static void createClientCache(String host, Integer port1, Integer port2) throws Exception {
InterestListRecoveryDUnitTest test = new InterestListRecoveryDUnitTest();
Properties props = new Properties();
props.setProperty(MCAST_PORT, "0");
props.setProperty(LOCATORS, "");
cache = test.createCache(props);
PoolImpl p = (PoolImpl) PoolManager.createFactory().addServer(host, port1.intValue()).addServer(host, port2.intValue()).setSubscriptionEnabled(true).setSubscriptionRedundancy(-1).setReadTimeout(250).setThreadLocalConnections(true).setSocketBufferSize(32768).setMinConnections(4).create("InterestListRecoveryDUnitTestPool");
AttributesFactory factory = new AttributesFactory();
factory.setScope(Scope.DISTRIBUTED_ACK);
factory.setPoolName(p.getName());
RegionAttributes attrs = factory.create();
cache.createRegion(REGION_NAME, attrs);
pool = p;
}
use of org.apache.geode.cache.client.internal.PoolImpl in project geode by apache.
the class Bug39079DUnitTest method createClientCache.
private void createClientCache(String host, Integer port1) {
Properties props = new Properties();
props.setProperty(MCAST_PORT, "0");
props.setProperty(LOCATORS, "");
createCache(props);
PoolImpl pool = (PoolImpl) PoolManager.createFactory().addServer(host, port1.intValue()).setSubscriptionEnabled(true).setSubscriptionRedundancy(0).setThreadLocalConnections(true).setMinConnections(0).setReadTimeout(20000).setRetryAttempts(1).create(getClass().getSimpleName());
AttributesFactory factory = new AttributesFactory();
factory.setScope(Scope.DISTRIBUTED_ACK);
factory.setPoolName(pool.getName());
RegionAttributes attrs = factory.create();
Region region = getCache().createRegion(REGION_NAME_testBridgeServerStoppingInSynchPersistOnlyForIOExceptionCase, attrs);
region.registerInterest("ALL_KEYS");
}
Aggregations