use of org.apache.geode.cache.client.PoolFactory in project geode by apache.
the class ConnectionProxyJUnitTest method testDuplicateSeqIdLesserThanCurrentSeqIdBeingIgnored.
@Test
public void testDuplicateSeqIdLesserThanCurrentSeqIdBeingIgnored() {
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);
proxy = (PoolImpl) pf.create("clientPool");
EventID eid1 = new EventID(new byte[0], 1, 5);
if (proxy.verifyIfDuplicate(eid1)) {
fail(" eid1 can never be duplicate, it is being created for the first time! ");
}
EventID eid2 = new EventID(new byte[0], 1, 2);
if (!proxy.verifyIfDuplicate(eid2)) {
fail(" eid2 should be duplicate, seqId is less than highest (5)");
}
EventID eid3 = new EventID(new byte[0], 1, 3);
if (!proxy.verifyIfDuplicate(eid3)) {
fail(" eid3 should be duplicate, seqId is less than highest (5)");
}
assertTrue(!proxy.getThreadIdToSequenceIdMap().isEmpty());
proxy.destroy();
} catch (Exception ex) {
ex.printStackTrace();
fail("Failed to initialize client");
}
} finally {
if (server != null) {
server.stop();
}
}
}
use of org.apache.geode.cache.client.PoolFactory 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.PoolFactory in project geode by apache.
the class InterestListFailoverDUnitTest method getClientPool.
private Pool getClientPool(String host, int redundancyLevel) {
PoolFactory pf = PoolManager.createFactory();
pf.addServer(host, PORT1).addServer(host, PORT2).setSubscriptionEnabled(true).setReadTimeout(500).setSocketBufferSize(32768).setMinConnections(4).setSubscriptionRedundancy(redundancyLevel);
return ((PoolFactoryImpl) pf).getPoolAttributes();
}
use of org.apache.geode.cache.client.PoolFactory in project geode by apache.
the class InterestListDUnitTest method createClientCache.
private static DistributedMember createClientCache(String host, int port, int port2) throws Exception {
Properties props = new Properties();
props.setProperty(MCAST_PORT, "0");
props.setProperty(LOCATORS, "");
props.setProperty(DELTA_PROPAGATION, "false");
new InterestListDUnitTest().createCache(props);
PoolFactory pfactory = PoolManager.createFactory().addServer(host, port).setThreadLocalConnections(true).setMinConnections(3).setSubscriptionEnabled(true).setSubscriptionRedundancy(-1).setReadTimeout(10000).setSocketBufferSize(32768);
// .setRetryAttempts(5)
if (port2 > 0) {
pfactory.addServer(host, port2);
}
Pool p = pfactory.create("InterestListDUnitTestPool");
AttributesFactory factory = new AttributesFactory();
factory.setScope(Scope.DISTRIBUTED_ACK);
factory.setPoolName(p.getName());
RegionAttributes attrs = factory.create();
cache.createRegion(REGION_NAME, attrs);
return cache.getDistributedSystem().getDistributedMember();
}
use of org.apache.geode.cache.client.PoolFactory in project geode by apache.
the class DurableClientQueueSizeDUnitTest method createClientCache.
@SuppressWarnings("deprecation")
public static void createClientCache(Host host, Integer[] ports, String timeoutSeconds, Boolean durable, Boolean multiPool, CacheListener cacheListener) throws Exception {
if (multiPool) {
System.setProperty(DistributionConfig.GEMFIRE_PREFIX + "SPECIAL_DURABLE", "true");
}
Properties props = new Properties();
if (durable) {
props.setProperty(DURABLE_CLIENT_ID, MY_DURABLE_CLIENT);
props.setProperty(DURABLE_CLIENT_TIMEOUT, timeoutSeconds);
}
DistributedSystem ds = new DurableClientQueueSizeDUnitTest().getSystem(props);
ds.disconnect();
ClientCacheFactory ccf = new ClientCacheFactory(props);
ccf.setPoolSubscriptionEnabled(true);
ccf.setPoolSubscriptionAckInterval(50);
ccf.setPoolSubscriptionRedundancy(1);
ccf.setPoolMaxConnections(1);
for (int port : ports) {
ccf.addPoolServer(host.getHostName(), port);
}
cache = (GemFireCacheImpl) ccf.create();
ClientRegionFactory<String, String> crf = cache.createClientRegionFactory(ClientRegionShortcut.CACHING_PROXY);
if (cacheListener != null) {
crf.addCacheListener(cacheListener);
}
crf.setPoolName(cache.getDefaultPool().getName());
crf.create(REGION_NAME);
if (multiPool) {
String poolName = POOL_NAME;
PoolFactory pf = PoolManager.createFactory();
for (int port : ports) {
pf.addServer(host.getHostName(), port);
}
pf.setSubscriptionEnabled(true);
pf.create(poolName);
crf.setPoolName(poolName);
crf.create(NEW_REGION);
}
}
Aggregations