use of org.apache.geode.modules.session.catalina.ClientServerCacheLifecycleListener 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);
}
Aggregations