Package org.jboss.web.tomcat.service.session.persistent

Examples of org.jboss.web.tomcat.service.session.persistent.DataSourcePersistentManager


   {
      String warname = String.valueOf(++testId);
     
      // A war with a maxInactive of 30 mins maxUnreplicated of 0
      DataSourcePersistentManager[] mgrs = getCacheManagers(warname, 1800, 1);
      DataSourcePersistentManager mgr0 = mgrs[0];
      DataSourcePersistentManager mgr1 = mgrs[1];
     
      assertTrue(mgr0.getNotificationPolicy() instanceof MockClusteredSessionNotificationPolicy);
      MockClusteredSessionNotificationPolicy mcsnp0 = (MockClusteredSessionNotificationPolicy) mgr0.getNotificationPolicy();
      assertNotNull("capability set", mcsnp0.getClusteredSessionNotificationCapability());
      mcsnp0.setResponse(notify);
     
      assertTrue(mgr1.getNotificationPolicy() instanceof MockClusteredSessionNotificationPolicy);
      MockClusteredSessionNotificationPolicy mcsnp1 = (MockClusteredSessionNotificationPolicy) mgr1.getNotificationPolicy();
      assertNotNull("capability set", mcsnp1.getClusteredSessionNotificationCapability());
      mcsnp1.setResponse(notify);
     
      MockHttpSessionListener hsl0 = new MockHttpSessionListener();
      MockHttpSessionAttributeListener hsal0 = new MockHttpSessionAttributeListener();     
      Context ctx = (Context) mgr0.getContainer();
      ctx.setApplicationSessionLifecycleListeners(new Object[]{ hsl0 })
      ctx.setApplicationEventListeners(new Object[]{ hsal0 })
     
      MockHttpSessionListener hsl1 = new MockHttpSessionListener();
      MockHttpSessionAttributeListener hsal1 = new MockHttpSessionAttributeListener();     
      ctx = (Context) mgr1.getContainer();
      ctx.setApplicationSessionLifecycleListeners(new Object[]{ hsl1 })
      ctx.setApplicationEventListeners(new Object[]{ hsal1 });
     
      // Initial request
      SetAttributesRequestHandler setHandler = new SetAttributesRequestHandler(attributes, false);
      SessionTestUtil.invokeRequest(mgr0, setHandler, null);
     
      validateNewSession(setHandler);
      String sessionId = setHandler.getSessionId();
     
      if (!notify)
      {
         validateNoNotifications(hsl0, hsal0, hsl1, hsal1);
      }
      else
      {
         assertEquals(1, hsl0.invocations.size());
         assertEquals(MockHttpSessionListener.Type.CREATED, hsl0.invocations.get(0));
         assertEquals(1, hsal0.invocations.size());
         assertEquals(MockHttpSessionAttributeListener.Type.ADDED, hsal0.invocations.get(0));
         assertEquals(2, SessionSpecListenerAttribute.invocations.size());
         assertEquals(SessionSpecListenerAttribute.Type.BOUND, SessionSpecListenerAttribute.invocations.get(0));
         assertEquals(SessionSpecListenerAttribute.Type.PASSIVATED, SessionSpecListenerAttribute.invocations.get(1));
        
         validateNoNotifications(null, null, hsl1, hsal1, null);
         clearNotifications(hsl0, hsal0, null, null, SessionSpecListenerAttribute.invocations);
      }
     
      // Modify attribute request
      setHandler = new SetAttributesRequestHandler(newAttributes, false);
      SessionTestUtil.invokeRequest(mgr0, setHandler, sessionId);
     
      if (!notify)
      {
         validateNoNotifications(hsl0, hsal0, hsl1, hsal1);
      }
      else
      {
         assertEquals(1, hsal0.invocations.size());
         assertEquals(MockHttpSessionAttributeListener.Type.REPLACED, hsal0.invocations.get(0));
         assertEquals(4, SessionSpecListenerAttribute.invocations.size());
         assertEquals(SessionSpecListenerAttribute.Type.ACTIVATING, SessionSpecListenerAttribute.invocations.get(0));
         assertEquals(SessionSpecListenerAttribute.Type.BOUND, SessionSpecListenerAttribute.invocations.get(1));
         assertEquals(SessionSpecListenerAttribute.Type.UNBOUND, SessionSpecListenerAttribute.invocations.get(2));
         assertEquals(SessionSpecListenerAttribute.Type.PASSIVATED, SessionSpecListenerAttribute.invocations.get(3));
        
         validateNoNotifications(hsl0, null, hsl1, hsal1, null);
         clearNotifications(null, hsal0, null, null, SessionSpecListenerAttribute.invocations);
      }
     
      // Passivate
      Thread.sleep(1100);
     
      mgr0.backgroundProcess();
      mgr1.backgroundProcess();
     
      if (!notify)
      {
         validateNoNotifications(hsl0, hsal0, hsl1, hsal1);
      }
      else
      {
         assertEquals(1, SessionSpecListenerAttribute.invocations.size());
         assertEquals(SessionSpecListenerAttribute.Type.PASSIVATED, SessionSpecListenerAttribute.invocations.get(0));
        
         validateNoNotifications(hsl0, hsal0, hsl1, hsal1, null);
         clearNotifications(null, null, null, null, SessionSpecListenerAttribute.invocations);
      }
     
      // Remove attribute request
      RemoveAttributesRequestHandler removeHandler = new RemoveAttributesRequestHandler(newAttributes.keySet(), false);
      SessionTestUtil.invokeRequest(mgr0, removeHandler, sessionId);
     
      if (!notify)
      {
         validateNoNotifications(hsl0, hsal0, hsl1, hsal1);
      }
      else
      {
         assertEquals(1, hsal0.invocations.size());
         assertEquals(MockHttpSessionAttributeListener.Type.REMOVED, hsal0.invocations.get(0));
         assertEquals(3, SessionSpecListenerAttribute.invocations.size());
         assertEquals(SessionSpecListenerAttribute.Type.ACTIVATING, SessionSpecListenerAttribute.invocations.get(0));
         assertEquals(SessionSpecListenerAttribute.Type.ACTIVATING, SessionSpecListenerAttribute.invocations.get(1));
         assertEquals(SessionSpecListenerAttribute.Type.UNBOUND, SessionSpecListenerAttribute.invocations.get(2));
        
         validateNoNotifications(hsl0, null, hsl1, hsal1, null);
         clearNotifications(null, hsal0, null, null, SessionSpecListenerAttribute.invocations);
      }
     
      // Failover request
      setHandler = new SetAttributesRequestHandler(attributes, false);
      SessionTestUtil.invokeRequest(mgr1, setHandler, sessionId);
     
      if (!notify)
      {
         validateNoNotifications(hsl0, hsal0, hsl1, hsal1);
      }
      else
      {
         assertEquals(1, hsl1.invocations.size());
         assertEquals(MockHttpSessionListener.Type.CREATED, hsl1.invocations.get(0));
         assertEquals(1, hsal1.invocations.size());
         assertEquals(MockHttpSessionAttributeListener.Type.ADDED, hsal1.invocations.get(0));
         assertEquals(2, SessionSpecListenerAttribute.invocations.size());
         assertEquals(SessionSpecListenerAttribute.Type.BOUND, SessionSpecListenerAttribute.invocations.get(0));
         assertEquals(SessionSpecListenerAttribute.Type.PASSIVATED, SessionSpecListenerAttribute.invocations.get(1));
        
         validateNoNotifications(hsl0, hsal0, null, null, null);
         clearNotifications(null, null, hsl1, hsal1, SessionSpecListenerAttribute.invocations);
      }
     
      // Passivate
      Thread.sleep(1100);
     
      mgr0.backgroundProcess();
      mgr1.backgroundProcess();
     
      if (!notify)
      {
         validateNoNotifications(hsl0, hsal0, hsl1, hsal1);
      }
View Full Code Here


   {
      String warname = String.valueOf(++testId);
     
      // A war with a maxInactive of 2 secs and a maxIdle of 1
      DataSourcePersistentManager[] mgrs = getCacheManagers(warname, 2, 1);
      DataSourcePersistentManager mgr0 = mgrs[0];
      DataSourcePersistentManager mgr1 = mgrs[1];
     
      assertTrue(mgr0.getNotificationPolicy() instanceof MockClusteredSessionNotificationPolicy);
      MockClusteredSessionNotificationPolicy mcsnp0 = (MockClusteredSessionNotificationPolicy) mgr0.getNotificationPolicy();
      assertNotNull("capability set", mcsnp0.getClusteredSessionNotificationCapability());
      mcsnp0.setResponse(notify);
     
      assertTrue(mgr1.getNotificationPolicy() instanceof MockClusteredSessionNotificationPolicy);
      MockClusteredSessionNotificationPolicy mcsnp1 = (MockClusteredSessionNotificationPolicy) mgr1.getNotificationPolicy();
      assertNotNull("capability set", mcsnp1.getClusteredSessionNotificationCapability());
      mcsnp1.setResponse(notify);
     
      MockHttpSessionListener hsl0 = new MockHttpSessionListener();
      MockHttpSessionAttributeListener hsal0 = new MockHttpSessionAttributeListener();     
      Context ctx = (Context) mgr0.getContainer();
      ctx.setApplicationSessionLifecycleListeners(new Object[]{ hsl0 })
      ctx.setApplicationEventListeners(new Object[]{ hsal0 });
     
      MockHttpSessionListener hsl1 = new MockHttpSessionListener();
      MockHttpSessionAttributeListener hsal1 = new MockHttpSessionAttributeListener();     
      ctx = (Context) mgr1.getContainer();
      ctx.setApplicationSessionLifecycleListeners(new Object[]{ hsl1 })
      ctx.setApplicationEventListeners(new Object[]{ hsal1 });
     
      // Initial request
      SetAttributesRequestHandler setHandler = new SetAttributesRequestHandler(attributes, false);
      SessionTestUtil.invokeRequest(mgr0, setHandler, null);
     
      validateNewSession(setHandler);
     
      String sessionId = setHandler.getSessionId();
     
      if (!notify)
      {
         validateNoNotifications(hsl0, hsal0, hsl1, hsal1);
      }
      else
      {
         assertEquals(1, hsl0.invocations.size());
         assertEquals(MockHttpSessionListener.Type.CREATED, hsl0.invocations.get(0));
         assertEquals(1, hsal0.invocations.size());
         assertEquals(MockHttpSessionAttributeListener.Type.ADDED, hsal0.invocations.get(0));
         assertEquals(2, SessionSpecListenerAttribute.invocations.size());
         assertEquals(SessionSpecListenerAttribute.Type.BOUND, SessionSpecListenerAttribute.invocations.get(0));
         assertEquals(SessionSpecListenerAttribute.Type.PASSIVATED, SessionSpecListenerAttribute.invocations.get(1));
        
         validateNoNotifications(null, null, hsl1, hsal1, null);
         clearNotifications(hsl0, hsal0, null, null, SessionSpecListenerAttribute.invocations);        
      }
     
      // Failover request
      setHandler = new SetAttributesRequestHandler(newAttributes, false);
      SessionTestUtil.invokeRequest(mgr1, setHandler, sessionId);
     
      if (!notify)
      {
         validateNoNotifications(hsl0, hsal0, hsl1, hsal1);
      }
      else
      {
         assertEquals(1, hsl1.invocations.size());
         assertEquals(MockHttpSessionListener.Type.CREATED, hsl1.invocations.get(0));
         assertEquals(1, hsal1.invocations.size());
         assertEquals(MockHttpSessionAttributeListener.Type.REPLACED, hsal1.invocations.get(0));
         assertEquals(4, SessionSpecListenerAttribute.invocations.size());
         assertEquals(SessionSpecListenerAttribute.Type.ACTIVATING, SessionSpecListenerAttribute.invocations.get(0));
         assertEquals(SessionSpecListenerAttribute.Type.BOUND, SessionSpecListenerAttribute.invocations.get(1));
         assertEquals(SessionSpecListenerAttribute.Type.UNBOUND, SessionSpecListenerAttribute.invocations.get(2));
         assertEquals(SessionSpecListenerAttribute.Type.PASSIVATED, SessionSpecListenerAttribute.invocations.get(3));
        
         validateNoNotifications(hsl0, hsal0, null, null, null);
         clearNotifications(null, null, hsl1, hsal1, SessionSpecListenerAttribute.invocations);        
      }
     
      // Passivate
      Thread.sleep(1100);
     
      log.info("passivating mgr0");
      mgr0.backgroundProcess();
      log.info("passivating mgr1");
      mgr1.backgroundProcess();
     
      if (!notify)
      {
         validateNoNotifications(hsl0, hsal0, hsl1, hsal1);
      }
      else
      {
         assertEquals(2, SessionSpecListenerAttribute.invocations.size());
         assertEquals(SessionSpecListenerAttribute.Type.PASSIVATED, SessionSpecListenerAttribute.invocations.get(0));
         assertEquals(SessionSpecListenerAttribute.Type.PASSIVATED, SessionSpecListenerAttribute.invocations.get(1));
        
         validateNoNotifications(hsl0, hsal0, hsl1, hsal1, null);
         clearNotifications(null, null, null, null, SessionSpecListenerAttribute.invocations);
      }
     
      // Expire
      Thread.sleep(1000);
     
      log.info("expiring mgr0");
      mgr0.backgroundProcess();
      log.info("expiring mgr1");
      mgr1.backgroundProcess();
     
      if (!notify)
      {
         validateNoNotifications(hsl0, hsal0, hsl1, hsal1);
      }
View Full Code Here

   {
      String warname = String.valueOf(++testId);
     
      // A war with a maxInactive of 30 mins and no maxIdle
      DataSourcePersistentManager[] mgrs = getCacheManagers(warname, 1800, -1);
      DataSourcePersistentManager mgr0 = mgrs[0];
      DataSourcePersistentManager mgr1 = mgrs[1];
     
      assertTrue(mgr0.getNotificationPolicy() instanceof MockClusteredSessionNotificationPolicy);
      MockClusteredSessionNotificationPolicy mcsnp0 = (MockClusteredSessionNotificationPolicy) mgr0.getNotificationPolicy();
      assertNotNull("capability set", mcsnp0.getClusteredSessionNotificationCapability());
      mcsnp0.setResponse(notify);
     
      assertTrue(mgr1.getNotificationPolicy() instanceof MockClusteredSessionNotificationPolicy);
      MockClusteredSessionNotificationPolicy mcsnp1 = (MockClusteredSessionNotificationPolicy) mgr1.getNotificationPolicy();
      assertNotNull("capability set", mcsnp1.getClusteredSessionNotificationCapability());
      mcsnp1.setResponse(notify);
     
      MockHttpSessionListener hsl0 = new MockHttpSessionListener();
      MockHttpSessionAttributeListener hsal0 = new MockHttpSessionAttributeListener();     
      Context ctx = (Context) mgr0.getContainer();
      ctx.setApplicationSessionLifecycleListeners(new Object[]{ hsl0 })
      ctx.setApplicationEventListeners(new Object[]{ hsal0 })
     
      MockHttpSessionListener hsl1 = new MockHttpSessionListener();
      MockHttpSessionAttributeListener hsal1 = new MockHttpSessionAttributeListener();     
      ctx = (Context) mgr1.getContainer();
      ctx.setApplicationSessionLifecycleListeners(new Object[]{ hsl1 })
      ctx.setApplicationEventListeners(new Object[]{ hsal1 });
     
      // Initial request
      SetAttributesRequestHandler setHandler = new SetAttributesRequestHandler(attributes, false);
      SessionTestUtil.invokeRequest(mgr0, setHandler, null);
     
      validateNewSession(setHandler);
     
      if (!notify)
      {
         validateNoNotifications(hsl0, hsal0, hsl1, hsal1);
      }
      else
      {
         assertEquals(1, hsl0.invocations.size());
         assertEquals(MockHttpSessionListener.Type.CREATED, hsl0.invocations.get(0));
         assertEquals(1, hsal0.invocations.size());
         assertEquals(MockHttpSessionAttributeListener.Type.ADDED, hsal0.invocations.get(0));
         assertEquals(2, SessionSpecListenerAttribute.invocations.size());
         assertEquals(SessionSpecListenerAttribute.Type.BOUND, SessionSpecListenerAttribute.invocations.get(0));
         assertEquals(SessionSpecListenerAttribute.Type.PASSIVATED, SessionSpecListenerAttribute.invocations.get(1));
        
         validateNoNotifications(null, null, hsl1, hsal1, null);
         clearNotifications(hsl0, hsal0, null, null, SessionSpecListenerAttribute.invocations);
        
      }
     
      mgr0.stop();
     
      if (!notify)
      {
         validateNoNotifications(hsl0, hsal0, hsl1, hsal1);
      }
      else
      {
         assertEquals(1, hsl0.invocations.size());
         assertEquals(MockHttpSessionListener.Type.DESTROYED, hsl0.invocations.get(0));
         assertEquals(1, hsal0.invocations.size());
         assertEquals(MockHttpSessionAttributeListener.Type.REMOVED, hsal0.invocations.get(0));
         assertEquals(1, SessionSpecListenerAttribute.invocations.size());
         assertEquals(SessionSpecListenerAttribute.Type.UNBOUND, SessionSpecListenerAttribute.invocations.get(0));
        
         validateNoNotifications(null, null, hsl1, hsal1, null);
         clearNotifications(hsl0, hsal0, null, null, SessionSpecListenerAttribute.invocations);
        
        
      }
     
      mgr1.stop();
     
      if (!notify)
      {
         validateNoNotifications(hsl0, hsal0, hsl1, hsal1);
      }
View Full Code Here

   }
  
   protected DataSourcePersistentManager[] getCacheManagers(String warname, int maxInactive, int maxIdle)
      throws Exception
   {
      DataSourcePersistentManager mgr0 = PersistentSessionTestUtil.createManager(warname, maxInactive, null);
      PersistentSessionTestUtil.configureManager(mgr0, getReplicationGranularity(), getReplicationTrigger(), -1, maxIdle > 0, maxIdle, -1 ,false, 0);
      mgr0.setSessionNotificationPolicyClass(MockClusteredSessionNotificationPolicy.class.getName());
      this.managers.add(mgr0);
      mgr0.start();
     
      DataSourcePersistentManager mgr1 = PersistentSessionTestUtil.createManager(warname, maxInactive, null);
      PersistentSessionTestUtil.configureManager(mgr1, getReplicationGranularity(), getReplicationTrigger(), -1, true, maxIdle, -1 ,false, 0);
      mgr1.setSessionNotificationPolicyClass(MockClusteredSessionNotificationPolicy.class.getName());
      this.managers.add(mgr1);
      mgr1.start();
     
      return new DataSourcePersistentManager[]{mgr0, mgr1};
   }
View Full Code Here

   }
  
   public static DataSourcePersistentManager createManager(String warName, int maxInactiveInterval,
                                                 String jvmRoute)
   {     
      DataSourcePersistentManager mgr = new DataSourcePersistentManager(getDataSource());
      mgr.setSnapshotMode(SnapshotMode.INSTANT);
     
      MockEngine engine = new MockEngine();
      engine.setJvmRoute(jvmRoute);
      MockHost host = new MockHost();
      host.setName("localhost");
      engine.addChild(host);
      StandardContext container = new StandardContext();
      container.setName(warName);
      host.addChild(container);
      container.setManager(mgr);
     
      // Do this after assigning the manager to the container, or else
      // the container's setting will override ours
      // Can't just set the container as their config is per minute not per second
      mgr.setMaxInactiveInterval(maxInactiveInterval);
  
      return mgr;     
   }
View Full Code Here

      log.info("++++ Starting testSessionLifecycle ++++");
      String warname = String.valueOf(++testId);
     
      // A war with a maxInactive of 30 mins maxUnreplicated of 0
      DataSourcePersistentManager[] mgrs = getCacheManagers(warname, 1800, 1);
      DataSourcePersistentManager mgr0 = mgrs[0];
      DataSourcePersistentManager mgr1 = mgrs[1];
     
     
      // Initial request
      SetAttributesRequestHandler setHandler = new SetAttributesRequestHandler(getAttributeMap(), false);
      log.info("initial request");
      SessionTestUtil.invokeRequest(mgr0, setHandler, null);     
     
      String sessionId = setHandler.getSessionId();
      WeakReference<Session> session0A = new WeakReference<Session>(mgr0.findSession(sessionId));     
      SessionTestUtil.cleanupPipeline(mgr0);
      assertNotNull(session0A.get());
     
      // Modify attribute request
      setHandler = new SetAttributesRequestHandler(getAttributeMap(), false);
      log.info("Modify attribute request");
      SessionTestUtil.invokeRequest(mgr0, setHandler, sessionId);     
      SessionTestUtil.cleanupPipeline(mgr0);
     
      cleanHeap();
      assertAttributeCount(1);
     
      // Passivate
      Thread.sleep(1100);
     
      log.info("passivate node 0");
      mgr0.backgroundProcess();
      log.info("passivate node 1");
      mgr1.backgroundProcess();
     
      cleanHeap();
      assertAttributeCount(0);
      assertNullReference(session0A);
     
      // Remove attribute request
      RemoveAttributesRequestHandler removeHandler = new RemoveAttributesRequestHandler(KEYS, false);
      log.info("remove request");
      SessionTestUtil.invokeRequest(mgr0, removeHandler, sessionId);
     
      WeakReference<Session> session0B = new WeakReference<Session>(mgr0.findSession(sessionId));
      SessionTestUtil.cleanupPipeline(mgr0);
      cleanHeap();
      assertAttributeCount(0);
      assertNotNull(session0B.get());
     
      // Failover request
      setHandler = new SetAttributesRequestHandler(getAttributeMap(), false);
      log.info("failover request");
      SessionTestUtil.invokeRequest(mgr1, setHandler, sessionId);
     
      WeakReference<Session> session1A = new WeakReference<Session>(mgr1.findSession(sessionId));
      SessionTestUtil.cleanupPipeline(mgr1);
      assertNotNull(session1A.get());
      assertAttributeCount(1);
     
      // Passivate
      Thread.sleep(1100);
     
      log.info("passivate node 0");
      mgr0.backgroundProcess();
      log.info("passivate node 1");
      mgr1.backgroundProcess();
     
      cleanHeap();
      assertAttributeCount(0);
      assertNullReference(session0B);
      assertNullReference(session1A);
     
      // Reactivate
      BasicRequestHandler getHandler = new BasicRequestHandler(KEYS, false);
      log.info("activate node 1");
      SessionTestUtil.invokeRequest(mgr1, getHandler, sessionId);
     
      WeakReference<Session> session1B = new WeakReference<Session>(mgr1.findSession(sessionId));
      SessionTestUtil.cleanupPipeline(mgr1);
      assertNotNull(session1B.get());
      assertAttributeCount(1);     
     
      // Fail back
View Full Code Here

      log.info("++++ Starting testSessionExpiration ++++");
      String warname = String.valueOf(++testId);
     
      // A war with a maxInactive of 2 secs and a maxIdle of 10 (don't passivate)
      DataSourcePersistentManager[] mgrs = getCacheManagers(warname, 2, 10);
      DataSourcePersistentManager mgr0 = mgrs[0];
      DataSourcePersistentManager mgr1 = mgrs[1];
     
      // Initial request
      SetAttributesRequestHandler setHandler = new SetAttributesRequestHandler(getAttributeMap(), false);
      log.info("initial request");
      SessionTestUtil.invokeRequest(mgr0, setHandler, null);
      assertAttributeCount(1);       
     
      String sessionId = setHandler.getSessionId();
      WeakReference<Session> session0A = new WeakReference<Session>(mgr0.findSession(sessionId));
      SessionTestUtil.cleanupPipeline(mgr0);
      assertNotNull(session0A.get());
      assertAttributeCount(1);       
     
      // Failover request
      setHandler = new SetAttributesRequestHandler(getAttributeMap(), false);
      log.info("fail over request");
      SessionTestUtil.invokeRequest(mgr1, setHandler, sessionId);
      assertNotNull(setHandler.getCheckedAttributes().get(KEY));
      assertEquals(Attribute.COUNT -1, ((Attribute) setHandler.getCheckedAttributes().get(KEY)).getCount());
     
      WeakReference<Session> session1A = new WeakReference<Session>(mgr1.findSession(sessionId));
      SessionTestUtil.cleanupPipeline(mgr1);
     
      cleanHeap();
      assertNotNull(session1A.get());
      assertAttributeCount(2);
     
      // Expire
      Thread.sleep(2100);
     
      log.info("expire node 0");
      mgr0.backgroundProcess();
      log.info("expire node 1");
      mgr1.backgroundProcess();
     
      cleanHeap();
      assertNullReference(session0A);
      assertNullReference(session1A);
      assertAttributeCount(0);
View Full Code Here

      log.info("++++ Starting testUndeploy ++++");
      String warname = String.valueOf(++testId);
     
      // A war with a maxInactive of 30 mins and no maxIdle
      DataSourcePersistentManager[] mgrs = getCacheManagers(warname, 1800, -1);
      DataSourcePersistentManager mgr0 = mgrs[0];
      DataSourcePersistentManager mgr1 = mgrs[1];
     
      // Initial request
      SetAttributesRequestHandler setHandler = new SetAttributesRequestHandler(getAttributeMap(), false);
      SessionTestUtil.invokeRequest(mgr0, setHandler, null);
      assertAttributeCount(1)
     
      String sessionId = setHandler.getSessionId();
      WeakReference<Session> session0A = new WeakReference<Session>(mgr0.findSession(sessionId));
      SessionTestUtil.cleanupPipeline(mgr0);
      assertNotNull(session0A.get());
     
      mgr0.stop();        
      mgr1.stop();   
     
      cleanHeap();
      assertNull(session0A.get());
      assertAttributeCount(0);
   }
View Full Code Here

   }
  
   protected DataSourcePersistentManager[] getCacheManagers(String warname, int maxInactive, int maxIdle)
      throws Exception
   {
      DataSourcePersistentManager mgr0 = PersistentSessionTestUtil.createManager(warname, maxInactive, null);
      PersistentSessionTestUtil.configureManager(mgr0, getReplicationGranularity(), getReplicationTrigger(), -1, maxIdle > 0, maxIdle, -1 ,false, 0);
      this.managers.add(mgr0);
      mgr0.start();
     
      DataSourcePersistentManager mgr1 = PersistentSessionTestUtil.createManager(warname, maxInactive, null);
      PersistentSessionTestUtil.configureManager(mgr1, getReplicationGranularity(), getReplicationTrigger(), -1, true, maxIdle, -1 ,false, 0);
      this.managers.add(mgr1);
      mgr1.start();
     
      return new DataSourcePersistentManager[]{mgr0, mgr1};
   }
View Full Code Here

   public void testReplicatedMaxSessionsWithMinIdle() throws Exception
   {
      log.info("Enter testReplicatedMaxSessionsWithMinIdle");
     
      ++testCount;
      DataSourcePersistentManager mgr0 = PersistentSessionTestUtil.createManager("test" + testCount, 5, null);
      PersistentSessionTestUtil.configureManager(mgr0, 1, true, 3, 1);
     
      mgr0.start();
     
      assertTrue("Passivation is enabled", mgr0.isPassivationEnabled());
      assertEquals("Correct max active count", 1, mgr0.getMaxActiveAllowed());
      assertEquals("Correct max idle time", 3, mgr0.getPassivationMaxIdleTime());
      assertEquals("Correct min idle time", 1, mgr0.getPassivationMinIdleTime());
     
      DataSourcePersistentManager mgr1 = PersistentSessionTestUtil.createManager("test" + testCount, 5, null);
      PersistentSessionTestUtil.configureManager(mgr1, 1, true, 3, 1);
     
      mgr1.start();
     
      assertTrue("Passivation is enabled", mgr1.isPassivationEnabled());
      assertEquals("Correct max active count", 1, mgr1.getMaxActiveAllowed());
      assertEquals("Correct max idle time", 3, mgr1.getPassivationMaxIdleTime());
      assertEquals("Correct min idle time", 1, mgr1.getPassivationMinIdleTime());
     
      // Set up a session
      createAndUseSession(mgr0, "1", true, true);
     
      assertEquals("Session count correct", 1, mgr0.getActiveSessionCount());
      assertEquals("Local session count correct", 1, mgr0.getLocalActiveSessionCount());
      assertEquals("Passivated session count correct", 0, mgr0.getPassivatedSessionCount());     
      assertEquals("Session count correct", 0, mgr1.getActiveSessionCount());
      assertEquals("Local session count correct", 0, mgr1.getLocalActiveSessionCount());
      assertEquals("Passivated session count correct", 0, mgr0.getPassivatedSessionCount());
     
      // Get it in-memory on mgr1 as well
      useSession(mgr1, "1");
     
      // A 2nd session should fail
      createAndUseSession(mgr0, "2", false, false);
      createAndUseSession(mgr1, "2", false, false);
     
      // Sleep past minIdleTime     
      SessionTestUtil.sleepThread(1100);       
     
      assertEquals("Passivated session count correct", 0, mgr1.getPassivatedSessionCount());
      
      createAndUseSession(mgr1, "2", true, true);  
      createAndUseSession(mgr0, "3", true, true);   
      
      assertEquals("Session count correct", 1, mgr0.getActiveSessionCount());
      assertEquals("Local session count correct", 1, mgr0.getLocalActiveSessionCount());
      assertEquals("Created session count correct", 2, mgr0.getCreatedSessionCount());
      assertEquals("Expired session count correct", 0, mgr0.getExpiredSessionCount())
      assertEquals("Passivated session count correct", 1, mgr0.getPassivatedSessionCount());   
      
      assertEquals("Session count correct", 1, mgr1.getActiveSessionCount());
      assertEquals("Local session count correct", 1, mgr1.getLocalActiveSessionCount());
      assertEquals("Created session count correct", 1, mgr1.getCreatedSessionCount());
      assertEquals("Expired session count correct", 0, mgr1.getExpiredSessionCount());
      assertEquals("Passivated session count correct", 1, mgr1.getPassivatedSessionCount());    
     
   }
View Full Code Here

TOP

Related Classes of org.jboss.web.tomcat.service.session.persistent.DataSourcePersistentManager

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.