/** * Test for issue #49: Sessions not associated with a memcached node don't get associated as soon * as a memcached is available * * @throws InterruptedException * @throws IOException * @throws TimeoutException * @throws ExecutionException */ @Test(enabled = true) public void testNotAssociatedSessionGetsAssociatedIssue49() throws InterruptedException, IOException, ExecutionException, TimeoutException { _daemon.stop(); final SessionManager manager = _tomcat1.getManager(); manager.setMaxInactiveInterval(5); manager.setSticky(true); final SessionIdFormat sessionIdFormat = new SessionIdFormat(); final Session session = manager.createSession(null); assertNull(sessionIdFormat.extractMemcachedId(session.getId())); _daemon.start(); // Wait so that the daemon will be available and the client can reconnect (async get didn't do // the trick) Thread.sleep(4000); final String newSessionId = manager.getMemcachedSessionService().changeSessionIdOnMemcachedFailover(session.getId()); assertNotNull(newSessionId); assertEquals(newSessionId, session.getId()); assertEquals(sessionIdFormat.extractMemcachedId(newSessionId), _memcachedNodeId); }
/** Test for issue #60 (Add possibility to disable msm at runtime): disable msm */ @Test(enabled = true) public void testDisableMsmAtRuntime() throws InterruptedException, IOException, ExecutionException, TimeoutException, LifecycleException, HttpException { final SessionManager manager = _tomcat1.getManager(); manager.setSticky(true); // disable msm, shutdown our server and our client manager.setEnabled(false); _memcached.shutdown(); _daemon.stop(); checkSessionFunctionalityWithMsmDisabled(); }
private void setStickyness(final SessionAffinityMode sessionAffinity) { if (!sessionAffinity.isSticky()) { _tomcat1.getEngine().setJvmRoute(null); } final SessionManager manager = _tomcat1.getManager(); manager.setSticky(sessionAffinity.isSticky()); try { waitForReconnect(manager.getMemcachedSessionService().getMemcached(), 1, 500); } catch (final InterruptedException e) { Thread.currentThread().interrupt(); throw new RuntimeException(e); } }