Package org.jboss.cache

Examples of org.jboss.cache.CacheSPI


      assertEquals("State transferred with activation", JOE, cache2.get(fqn, "name"));
   }

   public void testReplToInactiveRegion() throws Exception
   {
      CacheSPI cache1 = caches.get(0);
      CacheSPI cache2 = caches.get(1);

      TestingUtil.blockUntilViewsReceived(VIEW_BLOCK_TIMEOUT, cache1, cache2);
      Fqn backupFqn = fqnTransformer.getBackupFqn(cache1.getLocalAddress(), A_B);
      Fqn A = Fqn.fromString("/a");

      Region regionA = cache1.getRegion(A, true);
      regionA.registerContextClassLoader(getClass().getClassLoader());
      regionA.activate();

      // Activate the buddy backup subtree in the recipient so any
      // repl message doesn't get rejected due to that tree being inactive
      cache2.getRegionManager().activate(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN);
      cache2.getRegionManager().deactivate(A);

      cache1.put(A_B, "name", JOE);

      assertNull("Should be no replication to inactive region", cache2.get(A_B, "name"));

      assertNull("Should be no replication to inactive backup region", cache2.get(backupFqn, "name"));
   }
View Full Code Here


      assertNull("Should be no replication to inactive backup region", cache2.get(backupFqn, "name"));
   }

   public void testBuddyBackupInactivation() throws Exception
   {
      CacheSPI cache1 = caches.get(0);
      Fqn A = Fqn.fromString("/a");
      Region regionA = cache1.getRegion(A, true);
      regionA.registerContextClassLoader(getClass().getClassLoader());
      regionA.activate();

      Fqn fqn = Fqn.fromRelativeElements(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, "test");
      fqn = Fqn.fromRelativeFqn(fqn, A_B);
      cache1.getInvocationContext().getOptionOverrides().setCacheModeLocal(true);
      cache1.put(fqn, "name", JOE);

      assertEquals("Put should have been OK", JOE, cache1.get(fqn, "name"));

      regionA.deactivate();

      assertNull("Inactivation should have cleared region", cache1.get(fqn, "name"));
   }
View Full Code Here

   }

   public void testStaleRegionOnDataOwner() throws Exception
   {
      // add some stuff on the primary
      CacheSPI first = caches.get(0);
      CacheSPI second = caches.get(1);
      CacheSPI third = caches.get(2);

      first.put(fqn, key, value);

      assert first.peek(fqn, false) != null : "Should have data";
      assert first.peek(Fqn.fromRelativeElements(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, fqnTransformer.getGroupNameFromAddress(third.getLocalAddress())), false) != null : "Should have backup node for second";
      assert first.peek(Fqn.fromRelativeElements(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, fqnTransformer.getGroupNameFromAddress(first.getLocalAddress())), false) == null : "Should NOT have backup node for self!";

      assert second.peek(fqn, false) == null : "Should not have data";
      assert second.peek(Fqn.fromRelativeElements(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, fqnTransformer.getGroupNameFromAddress(second.getLocalAddress())), false) == null : "Should NOT have backup node for self!";
      assert second.peek(Fqn.fromRelativeElements(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, fqnTransformer.getGroupNameFromAddress(first.getLocalAddress())), false) != null : "Should have backup node for second";
      assert second.peek(fqnTransformer.getBackupFqn(first.getLocalAddress(), fqn), false) != null : "Should have backup data";

      inReplicationListeners(listeners).dataWillGravitateFrom(0).to(1);
      // now do a gravitate call.
      assert second.get(fqn, key).equals(value) : "Data should have gravitated!";
      // gravitation cleanup calls are async.
      expectGravitation();

      assert second.peek(fqn, false) != null : "Should have data";
      assert second.peek(Fqn.fromRelativeElements(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, fqnTransformer.getGroupNameFromAddress(first.getLocalAddress())), false) != null : "Should have backup node for second";
      assert second.peek(Fqn.fromRelativeElements(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, fqnTransformer.getGroupNameFromAddress(second.getLocalAddress())), false) == null : "Should NOT have backup node for self!";

      assert third.peek(fqn, false) == null : "Should not have data";
      assert third.peek(Fqn.fromRelativeElements(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, fqnTransformer.getGroupNameFromAddress(third.getLocalAddress())), false) == null : "Should NOT have backup node for self!";
      assert third.peek(Fqn.fromRelativeElements(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, fqnTransformer.getGroupNameFromAddress(second.getLocalAddress())), false) != null : "Should have backup node for second";
      assert third.peek(fqnTransformer.getBackupFqn(second.getLocalAddress(), fqn), false) != null : "Should have backup data";
   }
View Full Code Here

   {
      Fqn fqn = Fqn.fromString("/a/b/c");
      Object key = "key", value = "value";

      // add some stuff on the primary
      CacheSPI dataOwner = caches.get(0);
      CacheSPI buddy = caches.get(1);
      CacheSPI thirdInstance = caches.get(2);

      assertIsBuddy(dataOwner, buddy, true);
      assertIsBuddy(buddy, thirdInstance, true);
      assertIsBuddy(thirdInstance, dataOwner, true);

      dataOwner.put(fqn, key, value);

      assert dataOwner.peek(fqn, false) != null : "Should have data";
      assert dataOwner.peek(Fqn.fromRelativeElements(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, fqnTransformer.getGroupNameFromAddress(thirdInstance.getLocalAddress())), false) != null : "Should have backup node for buddy";
      assert dataOwner.peek(Fqn.fromRelativeElements(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, fqnTransformer.getGroupNameFromAddress(dataOwner.getLocalAddress())), false) == null : "Should NOT have backup node for self!";
      assert dataOwner.peek(Fqn.fromRelativeElements(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, fqnTransformer.getGroupNameFromAddress(buddy.getLocalAddress())), false) == null : "Should NOT have backup node for 2nd instance!";

      assert buddy.peek(fqn, false) == null : "Should not have data";
      assert buddy.peek(Fqn.fromRelativeElements(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, fqnTransformer.getGroupNameFromAddress(buddy.getLocalAddress())), false) == null : "Should NOT have backup node for self!";
      assert buddy.peek(Fqn.fromRelativeElements(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, fqnTransformer.getGroupNameFromAddress(dataOwner.getLocalAddress())), false) != null : "Should have backup node for buddy";
      assert buddy.peek(fqnTransformer.getBackupFqn(dataOwner.getLocalAddress(), fqn), false) != null : "Should have backup data";

      inReplicationListeners(listeners).dataWillGravitateFrom(0).to(2);
      // now do a gravitate call.
      assert thirdInstance.get(fqn, key).equals(value) : "Data should have gravitated!";
      expectGravitation();
     
      assert thirdInstance.peek(fqn, false) != null : "Should have data";
      assert thirdInstance.peek(Fqn.fromRelativeElements(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, fqnTransformer.getGroupNameFromAddress(buddy.getLocalAddress())), false) != null : "Should have backup node for buddy";
      assert thirdInstance.peek(Fqn.fromRelativeElements(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, fqnTransformer.getGroupNameFromAddress(thirdInstance.getLocalAddress())), false) == null : "Should NOT have backup node for self!";

      assert dataOwner.peek(fqn, false) == null : "Should not have data";
      assert dataOwner.peek(Fqn.fromRelativeElements(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, fqnTransformer.getGroupNameFromAddress(dataOwner.getLocalAddress())), false) == null : "Should NOT have backup node for self!";
      assert dataOwner.peek(Fqn.fromRelativeElements(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, fqnTransformer.getGroupNameFromAddress(thirdInstance.getLocalAddress())), false) != null : "Should have backup node for buddy";
      assert dataOwner.peek(fqnTransformer.getBackupFqn(thirdInstance.getLocalAddress(), fqn), false) != null : "Should have backup data";
      assert buddy.peek(fqn, false) == null : "Should not have data";
      assert buddy.peek(fqn.getParent(), false) == null : "Should not have any part of the data";
      assert buddy.peek(fqnTransformer.getBackupFqn(dataOwner.getLocalAddress(), fqn), false) == null : "Should NOT have backup data";
   }
View Full Code Here

      c.setStateRetrievalTimeout(5000);
      c.setCacheMode(Configuration.CacheMode.REPL_SYNC);
      c.setIsolationLevel(IsolationLevel.REPEATABLE_READ);
      c.setTransactionManagerLookupClass("org.jboss.cache.transaction.DummyTransactionManagerLookup");

      CacheSPI cache = (CacheSPI) new UnitTestCacheFactory<Object, Object>().createCache(c, false, getClass());

      cache.create();
      cache.start();


      return cache;
   }
View Full Code Here

      c.setCacheMode(Configuration.CacheMode.LOCAL);
      c.setIsolationLevel(IsolationLevel.REPEATABLE_READ);
      c.setTransactionManagerLookupClass("org.jboss.cache.transaction.DummyTransactionManagerLookup");

      CacheSPI cache = (CacheSPI) new UnitTestCacheFactory<Object, Object>().createCache(false, getClass());
      cache.create();
      cache.start();


      return cache;
   }
View Full Code Here

   /**
    * UT for https://jira.jboss.org/jira/browse/JBCACHE-1445.
    */
   public void testDataGravitationCleanup1Pc() throws Exception
   {
      CacheSPI cache0 = createCache(1, null, true, false);
      cache0.getConfiguration().setCacheMode(Configuration.CacheMode.REPL_ASYNC);
      CacheSPI cache1 = createCache(1, null, true, false);
      cache1.getConfiguration().setCacheMode(Configuration.CacheMode.REPL_ASYNC);
      cache0.start();
      cache1.start();
      try
      {
         waitForSingleBuddy(cache0, cache1);

         Fqn fqn = Fqn.fromString("/a/b/c");

         assert  null == cache0.get(fqn, "k");
         cache0.put(fqn, "key", "val");

         ReplicationListener replicationListener = ReplicationListener.getReplicationListener(cache0);
         replicationListener.expect(DataGravitationCleanupCommand.class);
         TransactionManager transactionManager = cache1.getTransactionManager();

         transactionManager.begin();
         assert cache1.get(fqn, "key").equals("val");
         transactionManager.commit();
         replicationListener.waitForReplicationToOccur(1000);

         assert !cache0.exists(fqn);

View Full Code Here

      // one of the other two should be shutting down, and the other should be slow to respond
      // so that the illegal cache state exception is propagated to the caller
      // this encapsulates what is seen in JBCACHE-1528

      List<CacheSPI<Object, Object>> caches = createCaches(2, 4, false, true, false, true);
      final CacheSPI c1 = caches.get(0), c2 = caches.get(1), c3 = caches.get(2), c4 = caches.get(3);

      c1.put("/a/b/c", "k", "v");

      System.out.println("BEFORE: " + CachePrinter.printCacheDetails(c1, c2, c3, c4));

      // kill c1
      c1.stop();

      log.error("** Stopped C1!");

      // now stop c2, but make sure it takes time to shut down.
      final StopListener sl = new StopListener();
View Full Code Here

   {
      Configuration config = new Configuration();
      config.setCacheMode(Configuration.CacheMode.LOCAL);
      config.setNodeLockingScheme(Configuration.NodeLockingScheme.MVCC);
      UnitTestCacheFactory cacheFactory2 = new UnitTestCacheFactory<Object, Object>();
      CacheSPI tmpCacheSPI = (CacheSPI) cacheFactory2.createCache(config, getClass());
      defaultInterceptroCount = tmpCacheSPI.getInterceptorChain().size();
      tmpCacheSPI.stop();

      UnitTestCacheFactory cacheFactory = new UnitTestCacheFactory<Object, Object>();
      config.setCustomInterceptors(interceptorConfig);
      cache = (CacheSPI) cacheFactory.createCache(config, true, getClass());
   }
View Full Code Here

      return isCacheViewComplete(c, memberCount, true);
   }

   public static boolean isCacheViewComplete(Cache c, int memberCount, boolean barfIfTooManyMembers)
   {
      CacheSPI cache = (CacheSPI) c;
      List members = cache.getMembers();
      if (members == null || memberCount > members.size())
      {
         return false;
      }
      else if (memberCount < members.size())
      {
         if (barfIfTooManyMembers)
         {
            // This is an exceptional condition
            StringBuilder sb = new StringBuilder("Cache at address ");
            sb.append(cache.getLocalAddress());
            sb.append(" had ");
            sb.append(members.size());
            sb.append(" members; expecting ");
            sb.append(memberCount);
            sb.append(". Members were (");
View Full Code Here

TOP

Related Classes of org.jboss.cache.CacheSPI

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.