use of org.apache.geode.cache.client.PoolFactory in project geode by apache.
the class Tomcat8SessionsClientServerDUnitTest method setupServer.
// Set up the servers we need
public void setupServer(DeltaSessionManager manager) throws Exception {
Host host = Host.getHost(0);
vm0 = host.getVM(1);
String hostName = vm0.getHost().getHostName();
int cacheServerPort = vm0.invoke(() -> {
Properties props = new Properties();
CacheFactory cf = new CacheFactory(props);
Cache cache = cf.create();
CacheServer server = cache.addCacheServer();
server.start();
return server.getPort();
});
port = AvailablePortHelper.getRandomAvailableTCPPort();
server = new EmbeddedTomcat8("/test", port, "JVM-1");
ClientServerCacheLifecycleListener listener = new ClientServerCacheLifecycleListener();
listener.setProperty(MCAST_PORT, "0");
listener.setProperty(LOG_LEVEL, "config");
server.addLifecycleListener(listener);
sessionManager = manager;
sessionManager.setEnableCommitValve(true);
server.getRootContext().setManager(sessionManager);
servlet = server.addServlet("/test/*", "default", CommandServlet.class.getName());
server.startContainer();
PoolFactory pf = PoolManager.createFactory();
pf.addServer(hostName, cacheServerPort);
pf.create("Pool Connecting to Cache Server");
/*
* Can only retrieve the region once the container has started up (and the cache has started
* too).
*/
region = sessionManager.getSessionCache().getSessionRegion();
sessionManager.getTheContext().setSessionTimeout(30);
}
use of org.apache.geode.cache.client.PoolFactory in project geode by apache.
the class Bug37805DUnitTest 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 Bug36829DUnitTest 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 CqDataUsingPoolDUnitTest method getClientPool.
private Pool getClientPool(String host, int serverPort) {
PoolFactory pf = PoolManager.createFactory();
pf.addServer(host, serverPort).setSubscriptionAckInterval(1).setSubscriptionEnabled(true);
return ((PoolFactoryImpl) pf).getPoolAttributes();
}
use of org.apache.geode.cache.client.PoolFactory in project geode by apache.
the class CqDataUsingPoolDUnitTest method testCQWithEstablishCallBackConnection.
/**
* Test for CQ with establishCallBackConnection.
*/
@Test
public void testCQWithEstablishCallBackConnection() throws Exception {
final Host host = Host.getHost(0);
VM server1 = host.getVM(0);
VM client = host.getVM(1);
cqDUnitTest.createServer(server1, 0, false, MirrorType.KEYS_VALUES);
final int port1 = server1.invoke(() -> CqQueryUsingPoolDUnitTest.getCacheServerPort());
final String serverHost = NetworkUtils.getServerHostName(server1.getHost());
final String poolName = "testCQWithEstablishCallBackConnection";
client.invoke(new CacheSerializableRunnable("createPool :" + poolName) {
@Override
public void run2() throws CacheException {
// Create Cache.
getCache();
PoolFactory cpf = PoolManager.createFactory();
cpf.setSubscriptionEnabled(false);
cpf.addServer(serverHost, port1);
cpf.create(poolName);
}
});
// Create CQs.
cqDUnitTest.createCQ(client, poolName, "testCQWithEstablishCallBackConnection_0", cqDUnitTest.cqs[0]);
// This should fail.
try {
cqDUnitTest.executeCQ(client, "testCQWithEstablishCallBackConnection_0", false, "CqException");
fail("Test should have failed with connection with establishCallBackConnection not found.");
} catch (Exception expected) {
// Expected.
}
// Close.
cqDUnitTest.closeClient(client);
cqDUnitTest.closeServer(server1);
}
Aggregations