use of org.apache.geode.cache.client.PoolFactory in project geode by apache.
the class DurableClientStatsDUnitTest method getClientPool.
private Pool getClientPool(String host, int server1Port, boolean establishCallbackConnection, int redundancyLevel) {
PoolFactory pf = PoolManager.createFactory();
pf.addServer(host, server1Port).setSubscriptionEnabled(establishCallbackConnection).setSubscriptionRedundancy(redundancyLevel);
return ((PoolFactoryImpl) pf).getPoolAttributes();
}
use of org.apache.geode.cache.client.PoolFactory in project geode by apache.
the class ConnectionProxyJUnitTest method testCleanCloseOfThreadIdToSeqId.
@Test
public void testCleanCloseOfThreadIdToSeqId() {
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, 2);
if (proxy.verifyIfDuplicate(eid1)) {
fail(" eid can never be duplicate, it is being created for the first time! ");
}
EventID eid2 = new EventID(new byte[0], 1, 3);
if (proxy.verifyIfDuplicate(eid2)) {
fail(" eid can never be duplicate, since sequenceId is greater ");
}
if (!proxy.verifyIfDuplicate(eid2)) {
fail(" eid had to be a duplicate, since sequenceId is equal ");
}
EventID eid3 = new EventID(new byte[0], 1, 1);
if (!proxy.verifyIfDuplicate(eid3)) {
fail(" eid had to be a duplicate, since sequenceId is lesser ");
}
} catch (Exception ex) {
ex.printStackTrace();
fail("Failed to initialize client");
}
} finally {
if (server != null) {
try {
Thread.sleep(500);
} catch (InterruptedException ie) {
fail("interrupted");
}
server.stop();
}
}
}
use of org.apache.geode.cache.client.PoolFactory in project geode by apache.
the class ConnectionProxyJUnitTest method testThreadIdToSequenceIdMapConcurrency.
@Test
public void testThreadIdToSequenceIdMapConcurrency() {
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(5000);
pf.setSubscriptionAckInterval(2000);
proxy = (PoolImpl) pf.create("clientPool");
// why 10,000?
final int EVENT_ID_COUNT = 10000;
EventID[] eid = new EventID[EVENT_ID_COUNT];
for (int i = 0; i < EVENT_ID_COUNT; i++) {
eid[i] = new EventID(new byte[0], i, i);
if (proxy.verifyIfDuplicate(eid[i])) {
fail(" eid can never be duplicate, it is being created for the first time! ");
}
}
verifyExpiry(30 * 1000);
for (int i = 0; i < EVENT_ID_COUNT; i++) {
if (proxy.verifyIfDuplicate(eid[i])) {
fail(" eid can not be found to be duplicate since the entry should have expired! " + i);
}
}
} 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 testThreadIdToSequenceIdMapCreation.
@Test
public void testThreadIdToSequenceIdMapCreation() {
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);
proxy = (PoolImpl) pf.create("clientPool");
if (proxy.getThreadIdToSequenceIdMap() == null) {
fail(" ThreadIdToSequenceIdMap is null. ");
}
} catch (Exception ex) {
ex.printStackTrace();
fail("Failed to initialize client");
}
} finally {
if (server != null) {
try {
Thread.sleep(500);
} catch (InterruptedException ie) {
fail("interrupted");
}
server.stop();
}
}
}
use of org.apache.geode.cache.client.PoolFactory in project geode by apache.
the class ConnectionProxyJUnitTest method testThreadIdToSequenceIdMapExpiryNegative.
@Test
public void testThreadIdToSequenceIdMapExpiryNegative() {
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(10000);
proxy = (PoolImpl) pf.create("clientPool");
final EventID eid = new EventID(new byte[0], 1, 1);
if (proxy.verifyIfDuplicate(eid)) {
fail(" eid should not be duplicate as it is a new entry");
}
WaitCriterion ev = new WaitCriterion() {
public boolean done() {
return proxy.verifyIfDuplicate(eid);
}
public String description() {
return null;
}
};
Wait.waitForCriterion(ev, 20 * 1000, 200, true);
} catch (Exception ex) {
ex.printStackTrace();
fail("Failed to initialize client");
}
} finally {
if (server != null) {
server.stop();
}
}
}
Aggregations