Package org.jboss.test.cluster.web.mocks

Examples of org.jboss.test.cluster.web.mocks.SetAttributesRequestHandler


      ctx = (Context) jbcm1.getContainer();
      ctx.setApplicationLifecycleListeners(new Object[]{ hsl1 })
      ctx.setApplicationEventListeners(new Object[]{ hsal1 });
     
      // Initial request
      SetAttributesRequestHandler setHandler = new SetAttributesRequestHandler(attributes, false);
      SessionTestUtil.invokeRequest(jbcm0, setHandler, null);
     
      validateNewSession(setHandler);
     
      if (!notify)
View Full Code Here


      JBossCacheManager jbcm0 = mgrs[0];
      JBossCacheManager jbcm1 = mgrs[1];
     
     
      // Initial request
      SetAttributesRequestHandler setHandler = new SetAttributesRequestHandler(getAttributeMap(), false);
      log.info("initial request");
      SessionTestUtil.invokeRequest(jbcm0, setHandler, null);     
     
      String sessionId = setHandler.getSessionId();
      WeakReference<Session> session0A = new WeakReference<Session>(jbcm0.findSession(sessionId));     
      SessionTestUtil.cleanupPipeline(jbcm0);
      assertNotNull(session0A.get());
     
      // Modify attribute request
      setHandler = new SetAttributesRequestHandler(getAttributeMap(), false);
      log.info("Modify attribute request");
      SessionTestUtil.invokeRequest(jbcm0, setHandler, sessionId);     
      SessionTestUtil.cleanupPipeline(jbcm0);
     
      System.gc();
      System.runFinalization();
      assertEquals(1, Attribute.attributeCount());
     
      // Passivate
      Thread.sleep(1100);
     
      log.info("passivate node 0");
      jbcm0.backgroundProcess();
      log.info("passivate node 1");
      jbcm1.backgroundProcess();
     
      System.gc();
      System.runFinalization();
      assertEquals(0, Attribute.attributeCount());
      assertNull(session0A.get());
     
      // Remove attribute request
      RemoveAttributesRequestHandler removeHandler = new RemoveAttributesRequestHandler(KEYS, false);
      log.info("remove request");
      SessionTestUtil.invokeRequest(jbcm0, removeHandler, sessionId);
     
      WeakReference<Session> session0B = new WeakReference<Session>(jbcm0.findSession(sessionId));
      SessionTestUtil.cleanupPipeline(jbcm0);
      System.gc();
      System.runFinalization();
      assertEquals(0, Attribute.attributeCount());
      assertNotNull(session0B.get());
     
      // Failover request
      setHandler = new SetAttributesRequestHandler(getAttributeMap(), false);
      log.info("failover request");
      SessionTestUtil.invokeRequest(jbcm1, setHandler, sessionId);
     
      WeakReference<Session> session1A = new WeakReference<Session>(jbcm1.findSession(sessionId));
      SessionTestUtil.cleanupPipeline(jbcm1);
View Full Code Here

      JBossCacheManager[] mgrs = getCacheManagers(warname, 2, 10);
      JBossCacheManager jbcm0 = mgrs[0];
      JBossCacheManager jbcm1 = mgrs[1];
     
      // Initial request
      SetAttributesRequestHandler setHandler = new SetAttributesRequestHandler(getAttributeMap(), false);
      log.info("initial request");
      SessionTestUtil.invokeRequest(jbcm0, setHandler, null);
      assertEquals(1, Attribute.attributeCount());       
     
      String sessionId = setHandler.getSessionId();
      WeakReference<Session> session0A = new WeakReference<Session>(jbcm0.findSession(sessionId));
      SessionTestUtil.cleanupPipeline(jbcm0);
      assertNotNull(session0A.get());
      assertEquals(1, Attribute.attributeCount());       
     
      // Failover request
      setHandler = new SetAttributesRequestHandler(getAttributeMap(), false);
      log.info("fail over request");
      SessionTestUtil.invokeRequest(jbcm1, setHandler, sessionId);
      assertNotNull(setHandler.getCheckedAttributes().get(KEY));
      assertEquals(Attribute.COUNT -1, ((Attribute) setHandler.getCheckedAttributes().get(KEY)).getCount());
     
      WeakReference<Session> session1A = new WeakReference<Session>(jbcm1.findSession(sessionId));
      SessionTestUtil.cleanupPipeline(jbcm1);
     
      System.gc();
View Full Code Here

      JBossCacheManager[] mgrs = getCacheManagers(warname, 1800, -1);
      JBossCacheManager jbcm0 = mgrs[0];
      JBossCacheManager jbcm1 = mgrs[1];
     
      // Initial request
      SetAttributesRequestHandler setHandler = new SetAttributesRequestHandler(getAttributeMap(), false);
      SessionTestUtil.invokeRequest(jbcm0, setHandler, null);
      assertEquals(1, Attribute.attributeCount())
     
      String sessionId = setHandler.getSessionId();
      WeakReference<Session> session0A = new WeakReference<Session>(jbcm0.findSession(sessionId));
      SessionTestUtil.cleanupPipeline(jbcm0);
      assertNotNull(session0A.get());
     
      jbcm0.stop();        
View Full Code Here

      String warname = String.valueOf(++testId);
     
      // A war with a maxInactive of 30 mins and a maxIdle of 1
      JBossCacheManager[] mgrs = getCacheManagers(warname, 1800000, 1, -1);
     
      SetAttributesRequestHandler setHandler = new SetAttributesRequestHandler(Collections.singletonMap("count", getAttributeValue(0)), false);
      invokeRequest(mgrs[3], setHandler, null);
     
      String id = setHandler.getSessionId();    
     
      setHandler = new SetAttributesRequestHandler(Collections.singletonMap("count", getAttributeValue(1)), false);
      invokeRequest(mgrs[3], setHandler, id);     
      assertEquals(getAttributeValue(0), setHandler.getCheckedAttributes().get("count"));
     
      sleepThread(1100);
     
      mgrs[0].backgroundProcess()
      mgrs[1].backgroundProcess();
      mgrs[2].backgroundProcess();
      mgrs[3].backgroundProcess();
     
      setHandler = new SetAttributesRequestHandler(Collections.singletonMap("count", getAttributeValue(2)), false);
      invokeRequest(mgrs[3], setHandler, id);     
      assertEquals(getAttributeValue(1), setHandler.getCheckedAttributes().get("count"));
     
      setHandler = new SetAttributesRequestHandler(Collections.singletonMap("count", getAttributeValue(3)), false);
      invokeRequest(mgrs[3], setHandler, id);     
      assertEquals(getAttributeValue(2), setHandler.getCheckedAttributes().get("count"));
     
      // Invalidate on the failover request
      InvalidateSessionRequestHandler invalidationHandler = new InvalidateSessionRequestHandler(Collections.singleton("count"), false);
      invokeRequest(mgrs[0], invalidationHandler, id);     
      assertEquals(getAttributeValue(3), invalidationHandler.getCheckedAttributes().get("count"));
     
      setHandler = new SetAttributesRequestHandler(Collections.singletonMap("count", getAttributeValue(0)), false);
      invokeRequest(mgrs[0], invalidationHandler, id);     
      assertNull(setHandler.getCheckedAttributes().get("count"));
   }
View Full Code Here

      // A war with a maxInactive of 30 mins and no maxIdle
      JBossCacheManager[] mgrs = getCacheManagers(warname, 1800000, -1, -1);
     
      log.info("managers created");
      log.info("creating session");
      SetAttributesRequestHandler setHandler = new SetAttributesRequestHandler(Collections.singletonMap("count", getAttributeValue(0)), false);
      invokeRequest(mgrs[0], setHandler, null);
     
      String id = setHandler.getSessionId();    
     
      // Modify
      log.info("modifying session");
      setHandler = new SetAttributesRequestHandler(Collections.singletonMap("count", getAttributeValue(1)), false);
      invokeRequest(mgrs[0], setHandler, id);     
      assertEquals(getAttributeValue(0), setHandler.getCheckedAttributes().get("count"));   
     
      // Failover and modify
      log.info("failing over");
      setHandler = new SetAttributesRequestHandler(Collections.singletonMap("count", getAttributeValue(2)), false);
      invokeRequest(mgrs[3], setHandler, id);     
      assertEquals(getAttributeValue(1), setHandler.getCheckedAttributes().get("count"));      
     
      // Modify
      log.info("modifying session");
      setHandler = new SetAttributesRequestHandler(Collections.singletonMap("count", getAttributeValue(3)), false);
      invokeRequest(mgrs[3], setHandler, id);     
      assertEquals(getAttributeValue(2), setHandler.getCheckedAttributes().get("count"));    
     
      // Failback and modify
      log.info("failing back");
      setHandler = new SetAttributesRequestHandler(Collections.singletonMap("count", getAttributeValue(4)), false);
      invokeRequest(mgrs[0], setHandler, id);     
      assertEquals(getAttributeValue(3), setHandler.getCheckedAttributes().get("count"))
     
      // Invalidate
      log.info("invalidating");
      InvalidateSessionRequestHandler invalidationHandler = new InvalidateSessionRequestHandler(Collections.singleton("count"), false);
      invokeRequest(mgrs[0], invalidationHandler, id);     
      assertEquals(getAttributeValue(4), invalidationHandler.getCheckedAttributes().get("count"));
     
      // Reestablish
      log.info("re-establishing");
      setHandler = new SetAttributesRequestHandler(Collections.singletonMap("count", getAttributeValue(0)), false);
      invokeRequest(mgrs[0], invalidationHandler, id);     
      assertNull(setHandler.getCheckedAttributes().get("count"));     
   }
View Full Code Here

      JBossCacheManager[] mgrs = getCacheManagers(warname, 1800000, 1, -1);
      JBossCacheManager jbcm0 = mgrs[0];
      JBossCacheManager jbcm1 = mgrs[1];
     
      Object value = "0";
      SetAttributesRequestHandler setHandler = new SetAttributesRequestHandler(Collections.singletonMap("count", value), false);
      SessionTestUtil.invokeRequest(jbcm0, setHandler, null);
     
      String id = setHandler.getSessionId();
     
      SessionTestUtil.sleepThread(1100);
     
      jbcm0.backgroundProcess();
      jbcm1.backgroundProcess();    
     
      value = "1";
      setHandler = new SetAttributesRequestHandler(Collections.singletonMap("count", value), false);
      SessionTestUtil.invokeRequest(jbcm0, setHandler, id);
     
      assertEquals("0", setHandler.getCheckedAttributes().get("count"));
     
      value = "2";
      setHandler = new SetAttributesRequestHandler(Collections.singletonMap("count", value), false);
      SessionTestUtil.invokeRequest(jbcm1, setHandler, id);
     
      assertEquals("1", setHandler.getCheckedAttributes().get("count"));
   }
View Full Code Here

      JBossCacheManager[] mgrs = getCacheManagers(warname, 1800000, 1, -1);
      JBossCacheManager jbcm0 = mgrs[0];
      JBossCacheManager jbcm1 = mgrs[1];
     
      Object value = "0";
      SetAttributesRequestHandler setHandler = new SetAttributesRequestHandler(Collections.singletonMap("count", value), false);
      SessionTestUtil.invokeRequest(jbcm0, setHandler, null);
     
      String id = setHandler.getSessionId();
     
      SessionTestUtil.sleepThread(1100);
     
      jbcm0.backgroundProcess();
      jbcm1.backgroundProcess();    
     
      value = "1";
      setHandler = new SetAttributesRequestHandler(Collections.singletonMap("count", value), false);
      SessionTestUtil.invokeRequest(jbcm1, setHandler, id);
     
      assertEquals("0", setHandler.getCheckedAttributes().get("count"));
   }
View Full Code Here

      // A war with a maxInactive of 3 secs and a maxUnreplicated of 1
      JBossCacheManager[] mgrs = getCacheManagers(warname, 3, 1);
      JBossCacheManager jbcm0 = mgrs[0];
      JBossCacheManager jbcm1 = mgrs[1];
     
      SetAttributesRequestHandler setHandler = new SetAttributesRequestHandler(allAttributes, false);
      SessionTestUtil.invokeRequest(jbcm0, setHandler, null);
     
      validateNewSession(setHandler);
     
      Thread.sleep(250);
     
      // Now make a request that will not trigger replication but keeps the jbcm0 session alive
      BasicRequestHandler getHandler = new BasicRequestHandler(immutables.keySet(), false);
      SessionTestUtil.invokeRequest(jbcm0, getHandler, setHandler.getSessionId());
     
      validateExpectedAttributes(immutables, getHandler);
     
      // Sleep long enough that the session will be expired on other server
      // if it doesn't have a maxUnreplicatedInterval grace period
      Thread.sleep(2800);
     
      // jbcm1 considers the session unmodified for > 3 sec maxInactiveInterval.
      // Try to drive the session out of the jbcm1 cache     
      jbcm1.backgroundProcess();
     
      // Replicate just one attribute; see if the other is still in jbcm1
      SetAttributesRequestHandler modifyHandler = new SetAttributesRequestHandler(mutables, false);
      SessionTestUtil.invokeRequest(jbcm0, modifyHandler, setHandler.getSessionId());
     
      // Fail over and confirm all is well. If the session was removed,
      // the last replication of just one attribute won't restore all
      // attributes and we'll have a failure
View Full Code Here

      // A war with a maxInactive of 2 secs and a maxUnreplicated of -1
      JBossCacheManager[] mgrs = getCacheManagers(warname, 2, -1);
      JBossCacheManager jbcm0 = mgrs[0];
      JBossCacheManager jbcm1 = mgrs[1];
     
      SetAttributesRequestHandler setHandler = new SetAttributesRequestHandler(allAttributes, false);
      SessionTestUtil.invokeRequest(jbcm0, setHandler, null);
     
      validateNewSession(setHandler);
     
      Thread.sleep(250);
     
      SetAttributesRequestHandler modifyHandler = new SetAttributesRequestHandler(mutables, false);
      SessionTestUtil.invokeRequest(jbcm0, modifyHandler, setHandler.getSessionId());
     
      Thread.sleep(1760);
     
      // Fail over and confirm all is well
View Full Code Here

TOP

Related Classes of org.jboss.test.cluster.web.mocks.SetAttributesRequestHandler

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.