Examples of ReplicationListener


Examples of org.jboss.cache.util.internals.ReplicationListener

   public void testValidationFailCommit2Instances() throws Exception
   {
      groupIncreaser++;
      CacheSPI<Object, Object> cache = createAsyncReplicatedCache();
      ReplicationListener replListener = new ReplicationListener(cache);
      CacheSPI<Object, Object> cache2 = createAsyncReplicatedCache();
      LockManager lockManager = TestingUtil.extractLockManager(cache);

      TransactionManager mgr = cache.getConfiguration().getRuntimeConfig().getTransactionManager();
      assertNull(mgr.getTransaction());
View Full Code Here

Examples of org.jboss.cache.util.internals.ReplicationListener

      log("creating cache2");

      cache2 = createCache("TestCache");

      replListener1 = new ReplicationListener(cache1);
      replListener2 = new ReplicationListener(cache2);
      addr = new Address();
      addr.setCity("San Jose");
      ben = new Person();
      ben.setName("Ben");
      ben.setAddress(addr);
View Full Code Here

Examples of org.jboss.cache.util.internals.ReplicationListener

      c1.getConfiguration().setUseRegionBasedMarshalling(true);
      c1.start();

      c2 = new UnitTestCacheFactory<Object, Object>().createCache(c1.getConfiguration().clone());
      replListener2 = new ReplicationListener(c2);

      TestingUtil.blockUntilViewsReceived(60000, c1, c2);
   }
View Full Code Here

Examples of org.jboss.cache.util.internals.ReplicationListener

   }

   public void testPessAsyncRepl() throws Exception
   {
      createCaches(false, false);
      ReplicationListener replListener = new ReplicationListener(cache2);

      mgr1.begin();
      cache1.put(fqn, key, "value");

      assertEquals("value", cache1.get(fqn, key));
      assertNull(cache2.get(fqn, key));
      assertNull(loader1.get(fqn));
      assertNull(loader2.get(fqn));

      replListener.expect(PrepareCommand.class);
      mgr1.commit();
      replListener.waitForReplicationToOccur(500);

      assertEquals("value", cache1.get(fqn, key));
      assertEquals("value", cache2.get(fqn, key));
      assertEquals("value", loader1.get(fqn).get(key));
      assertEquals("value", loader2.get(fqn).get(key));
View Full Code Here

Examples of org.jboss.cache.util.internals.ReplicationListener

   public void testOptAsyncRepl() throws Exception
   {
      createCaches(false, true);

      ReplicationListener replListener = new ReplicationListener(cache2);

      mgr1.begin();
      replListener.expect(CommitCommand.class);
      cache1.put(fqn, key, "value");

      assertEquals("value", cache1.get(fqn, key));
      assertNull(cache2.get(fqn, key));
      assertNull(loader1.get(fqn));
      assertNull(loader2.get(fqn));

      mgr1.commit();

      replListener.waitForReplicationToOccur(500);

      assertEquals("value", cache1.get(fqn, key));
      assertEquals("value", cache2.get(fqn, key));
      assertEquals("value", loader1.get(fqn).get(key));
      assertEquals("value", loader2.get(fqn).get(key));
View Full Code Here

Examples of org.jboss.cache.util.internals.replicationlisteners.ReplicationListener

     
      String contextHostName = mgr0.getContextHostName();

      // Create the session
      SetAttributesServlet sas = new SetAttributesServlet(Collections.singletonMap(KEY, getAttributeValue(attr++)));
      ReplicationListener replListener0 = replListeners[0];
      replListener0.expectWithTx(PutDataMapCommand.class);
     
      Request req = new Request(mgr3, null, sas);
      req.execute();     
      replListener0.waitForReplicationToOccur();     
     
      String sessionId = sas.getSessionId();
      assert sessionId != null : "session id is null";
      // validate cache contents
      BuddyReplicationAssertions.assertBuddyBackup(contextHostName, sessionId, mgr3.getCache(), mgr0.getCache());
     
      // Modify the session
      sas = new SetAttributesServlet(Collections.singletonMap(KEY, getAttributeValue(attr++)));
      replListener0.expectWithTx(PutDataMapCommand.class);
     
      req = new Request(mgr3, sessionId, sas);
      req.execute();     
      replListener0.waitForReplicationToOccur();     

      // Passivate the session
      mgr0.passivate(sessionId);
      mgr1.passivate(sessionId);
      mgr2.passivate(sessionId);
      mgr3.passivate(sessionId);  
     
      // Reactivate the session
      sas = new SetAttributesServlet(Collections.singletonMap(KEY, getAttributeValue(attr++)));
      replListener0.expectWithTx(PutDataMapCommand.class);
     
      req = new Request(mgr3, sessionId, sas);
      req.execute();
      replListener0.waitForReplicationToOccur();     

      // Invalidate the session
      sas = new SetAttributesServlet(Collections.singletonMap(KEY, getAttributeValue(attr++)));
      InvalidationServlet invs = new InvalidationServlet();
      MultipleActionServlet mas = new MultipleActionServlet(sas, invs);
      ReplicationListener replListener1 = replListeners[1];
      replListener1.expectWithTx(PutDataMapCommand.class, RemoveNodeCommand.class);
      replListener1.expect(DataGravitationCleanupCommand.class);

      req = new Request(mgr0, sessionId, mas);
      req.execute();     
      replListener1.waitForReplicationToOccur();

      TestingUtil.dumpCacheContents(mgr0.getCache(), mgr1.getCache(), mgr2.getCache(), mgr3.getCache());

      BuddyReplicationAssertions.assertUnrelated(contextHostName, sessionId, mgr0.getCache());
      BuddyReplicationAssertions.assertUnrelated(contextHostName, sessionId, mgr1.getCache());
View Full Code Here

Examples of org.jboss.cache.util.internals.replicationlisteners.ReplicationListener

   }

   public void testPessAsyncRepl() throws Exception
   {
      createCaches(false, false);
      ReplicationListener replListener = ReplicationListener.getReplicationListener(cache2);

      mgr1.begin();
      cache1.put(fqn, key, "value");

      assertEquals("value", cache1.get(fqn, key));
      assertNull(cache2.get(fqn, key));
      assertNull(loader1.get(fqn));
      assertNull(loader2.get(fqn));

      replListener.expectWithTx(PutKeyValueCommand.class);
      mgr1.commit();
      replListener.waitForReplicationToOccur();

      assertEquals("value", cache1.get(fqn, key));
      assertEquals("value", cache2.get(fqn, key));
      assertEquals("value", loader1.get(fqn).get(key));
      assertEquals("value", loader2.get(fqn).get(key));
View Full Code Here

Examples of org.jboss.cache.util.internals.replicationlisteners.ReplicationListener

   public void testOptAsyncRepl() throws Exception
   {
      createCaches(false, true);

      ReplicationListener replListener = ReplicationListener.getReplicationListener(cache2);

      mgr1.begin();
      replListener.expectWithTx(PutKeyValueCommand.class);
      cache1.put(fqn, key, "value");

      assertEquals("value", cache1.get(fqn, key));
      assertNull(cache2.get(fqn, key));
      assertNull(loader1.get(fqn));
      assertNull(loader2.get(fqn));

      mgr1.commit();

      replListener.waitForReplicationToOccur();

      assertEquals("value", cache1.get(fqn, key));
      assertEquals("value", cache2.get(fqn, key));
      assertEquals("value", loader1.get(fqn).get(key));
      assertEquals("value", loader2.get(fqn).get(key));
View Full Code Here

Examples of org.jboss.cache.util.internals.replicationlisteners.ReplicationListener

      assertTrue(!caches.get(2).exists(backupFqn2));

      assertNoLocks(caches);

      // gravitate to 2:
      ReplicationListener replListener0 = ReplicationListener.getReplicationListener(caches.get(0));
      ReplicationListener replListener1 = ReplicationListener.getReplicationListener(caches.get(1));
      replListener0.expect(DataGravitationCleanupCommand.class);
      replListener1.expect(DataGravitationCleanupCommand.class);
      caches.get(2).getNode(fqn)// expectWithTx entire subtree to gravitate.
      replListener0.waitForReplicationToOccur(); // cleanup commands are async
      replListener1.waitForReplicationToOccur(); // also wait untill the backup is cleaned

      Fqn newBackupFqn = fqnTransformer.getBackupFqn(caches.get(2).getLocalAddress(), fqn);
      Fqn newBackupFqn2 = fqnTransformer.getBackupFqn(caches.get(2).getLocalAddress(), fqn2);

      assertEquals(value, caches.get(2).get(fqn, key));
View Full Code Here

Examples of org.jboss.cache.util.internals.replicationlisteners.ReplicationListener

      Fqn fqn = Fqn.fromString("/test");
      Fqn backupFqn = fqnTransformer.getBackupFqn(caches.get(2).getLocalAddress(), fqn);

      TestingUtil.dumpCacheContents(caches);

      ReplicationListener replListener0 = ReplicationListener.getReplicationListener(caches.get(0));

      replListener0.expect(PutKeyValueCommand.class);
      caches.get(2).put(fqn, key, value);
      replListener0.waitForReplicationToOccur();


      TestingUtil.dumpCacheContents(caches);

      assertEquals("Value should exist", value, caches.get(2).get(fqn, key));

      TestingUtil.dumpCacheContents(caches);

      // use exists instead of get() to prevent going up the interceptor stack
      assertTrue("Should be false", !caches.get(0).exists(fqn));
      assertTrue("Should be false", !caches.get(1).exists(fqn));

      assertTrue("Value be true", caches.get(0).exists(backupFqn));
      assertFalse("Should be false", caches.get(1).exists(backupFqn));
      assertFalse("Should be false", caches.get(2).exists(backupFqn));

      Address cache2Addr = caches.get(2).getLocalAddress();
      // forcefully kill data owner.
      caches.get(2).stop();
      caches.get(2).destroy();
      TestingUtil.blockUntilViewsReceived(10000, caches.get(0), caches.get(1));
      waitForSingleBuddy(caches.get(0), caches.get(1));

//      TestingUtil.dumpCacheContents(cachePool);
      // assert that the remaining cachePool have picked new buddies.  Cache 1 should have cache 2's backup data.
      assert caches.get(0).peek(fqnTransformer.getBackupRoot(caches.get(1).getLocalAddress()), false) != null : "Should have new buddy's backup root.";
      assert caches.get(1).peek(fqnTransformer.getBackupRoot(caches.get(1).getLocalAddress()), false) == null : "Should not have self as a backup root.";
      assert caches.get(0).peek(fqnTransformer.getBackupRoot(cache2Addr), false) == null : "Should not have dead node as a backup root.";
      assert caches.get(0).peek(Fqn.fromRelativeElements(fqnTransformer.getDeadBackupRoot(cache2Addr), 1), false) != null : "Should have dead node as a defunct backup root.";

      assert caches.get(1).peek(fqnTransformer.getBackupRoot(caches.get(1).getLocalAddress()), false) == null : "Should not have self as a backup root.";
      assert caches.get(1).peek(fqnTransformer.getBackupRoot(caches.get(0).getLocalAddress()), false) != null : "Should have new buddy's backup root.";
      assert caches.get(1).peek(fqnTransformer.getBackupRoot(cache2Addr), false) == null : "Should not have dead node as a backup root.";
      assert caches.get(1).peek(Fqn.fromRelativeElements(fqnTransformer.getDeadBackupRoot(cache2Addr), 1), false) == null : "Should not have dead node as a defunct backup root.";


      replListener0.expect(DataGravitationCleanupCommand.class);

      // according to data gravitation, a call to *any* cache should retrieve the data, and move the data to the new cache.
      assertEquals("Value should have gravitated", value, caches.get(1).get(fqn, key));
      replListener0.waitForReplicationToOccur();

      // use exists instead of get() to prevent going up the interceptor stack
      assert caches.get(0).peek(fqnTransformer.getBackupRoot(caches.get(1).getLocalAddress()), false) != null : "Should have new buddy's backup root.";
      assert caches.get(0).peek(fqnTransformer.getBackupRoot(caches.get(0).getLocalAddress()), false) == null : "Should not have self as a backup root.";
      assert caches.get(0).peek(fqnTransformer.getBackupRoot(cache2Addr), false) == null : "Should not have dead node as a backup root.";
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.