Examples of CacheSPI


Examples of org.jboss.cache.CacheSPI

   {
      List<CacheSPI<Object, Object>> caches = createCaches(1, 2, false, true, optimistic);
      cachesTL.set(caches);

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

      dataOwner.put(fqn, key, value);

      System.out.println("dataOwner: " + CachePrinter.printCacheDetails(dataOwner));
      System.out.println("buddy: " + CachePrinter.printCacheDetails(buddy));

      assert dataOwner.peek(fqn, false) != null : "Should have data";
      assert dataOwner.peek(Fqn.fromRelativeElements(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, fqnTransformer.getGroupNameFromAddress(buddy.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 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";

      // now do a gravitate call.
      assert buddy.get(fqn, key).equals(value) : "Data should have gravitated!";
      // gravitation cleanup calls are async.
      cleanupDelay();

      System.out.println("dataOwner: " + CachePrinter.printCacheDetails(dataOwner));
      System.out.println("buddy: " + CachePrinter.printCacheDetails(buddy));

      assert buddy.peek(fqn, false) != null : "Should have data";
      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(Fqn.fromRelativeElements(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, fqnTransformer.getGroupNameFromAddress(buddy.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(buddy.getLocalAddress())), false) != null : "Should have backup node for buddy";
      assert dataOwner.peek(fqnTransformer.getBackupFqn(buddy.getLocalAddress(), fqn), false) != null : "Should have backup data";
   }
View Full Code Here

Examples of org.jboss.cache.CacheSPI

   {
      List<CacheSPI<Object, Object>> caches = createCaches(1, 3, false, true, optimistic);
      cachesTL.set(caches);

      // 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);

      System.out.println("dataOwner: " + CachePrinter.printCacheLockingInfo(dataOwner));
      System.out.println("buddy: " + CachePrinter.printCacheLockingInfo(buddy));
      System.out.println("thirdInstance: " + CachePrinter.printCacheLockingInfo(thirdInstance));

      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";

      // now do a gravitate call.
      assert thirdInstance.get(fqn, key).equals(value) : "Data should have gravitated!";

      // gravitation cleanup calls are async.
      cleanupDelay();

      System.out.println("dataOwner: " + CachePrinter.printCacheLockingInfo(dataOwner));
      System.out.println("buddy: " + CachePrinter.printCacheLockingInfo(buddy));
      System.out.println("thirdInstance: " + CachePrinter.printCacheLockingInfo(thirdInstance));

      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

Examples of org.jboss.cache.CacheSPI

   private Configuration c;

   @BeforeMethod(alwaysRun = true)
   public void setUp() throws Exception
   {
      CacheSPI cache = (CacheSPI) new UnitTestCacheFactory<Object, Object>().createCache();
      r = cache.getRegionManager();
      c = cache.getConfiguration();
   }
View Full Code Here

Examples of org.jboss.cache.CacheSPI

      Configuration c = UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.REPL_ASYNC);
      //c.setClusterName("VersionedTestBase");
      c.setReplVersionString(getReplicationVersion());
      // Use a long timeout to facilitate setting debugger breakpoints
      c.setStateRetrievalTimeout(60000);
      CacheSPI cache = (CacheSPI) new UnitTestCacheFactory<Object, Object>().createCache(c, false);

      // Put the cache in the map before starting, so if it fails in
      // start it can still be destroyed later
      caches.put("secretive", cache);

      // inject our own message listener and re-wire deps
      ComponentRegistry cr = TestingUtil.extractComponentRegistry(cache);
//      cr.unregisterComponent(ChannelMessageListener.class);
      cr.registerComponent(new SecretiveStateCacheMessageListener(), ChannelMessageListener.class);
//      cr.updateDependencies();

      cache.start();


      c= UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.REPL_ASYNC);
      //c.setClusterName("VersionedTestBase");
      c.setReplVersionString(getReplicationVersion());
      // Use a long timeout to facilitate setting debugger breakpoints
      c.setStateRetrievalTimeout(60000);
      CacheSPI recipient = (CacheSPI) new UnitTestCacheFactory<Object, Object>().createCache(c, false);

      //Put the cache in the map before starting, so if it fails in
      // start it can still be destroyed later
      caches.put("secretive2", recipient);

      // inject our own message listener and re-wire deps
      cr = TestingUtil.extractComponentRegistry(recipient);
      cr.registerComponent(new SecretiveStateCacheMessageListener(), ChannelMessageListener.class);

      try
      {
         recipient.start();
         fail("start() should throw an exception");
      }
      catch (CacheException good)
      {
         // this is what we want
View Full Code Here

Examples of org.jboss.cache.CacheSPI

      cache1.put(A_B, "name", JOE);
      cache1.put(A_B, "age", TWENTY);
      cache1.put(A_C, "name", BOB);
      cache1.put(A_C, "age", FORTY);

      CacheSPI cache2 = null;
      try
      {
         cache2 = createCache("cache2", false, false, true, false, false, true);
         cache2.create();
         cache2.start();

         //Vladimir  October 5th 2007
         //failure of integration of persistent state is not considered to be fatal
         //to revisit with Manik
         //fail("Should have caused an exception");
      }
      catch (Exception e)
      {
      }

      //when persistent transfer fails as in this case state recipient cacheloader should be wiped clean
      assertFalse("/a/b is not in cache loader ", cache2.getCacheLoaderManager().getCacheLoader().exists(A_B));
   }
View Full Code Here

Examples of org.jboss.cache.CacheSPI

      return o instanceof MarshalledValue ? ((MarshalledValue) o).get() : o;
   }

   public void testStalePersistentState() throws Exception
   {
      CacheSPI c1 = createCache("1", true, false, true, true);
      c1.put(A, "K", "V");

      assert c1.get(A, "K").equals("V");
      CacheLoader l1 = c1.getCacheLoaderManager().getCacheLoader();
      assert l1 != null;

      assert l1.exists(A);
      assert l1.get(A).get("K").equals("V");

      // test persistence
      c1.stop();

      assert l1.exists(A);
      assert l1.get(A).get("K").equals("V");

      Cache c2 = createCache("2", true, false, true, true);

      c2.put(B, "K", "V");

      assert c1.getConfiguration().isFetchInMemoryState();
      assert c1.getConfiguration().getCacheLoaderConfig().isFetchPersistentState();
      c1.start();

      assert c1.get(B, "K").equals("V");
      assert c1.get(A, "K") == null;
      assert !l1.exists(A);
   }
View Full Code Here

Examples of org.jboss.cache.CacheSPI

   public void testInjectConfigFilePath() throws Exception
   {
      createTcpCacheServer();
      Configuration conf = UnitTestCacheConfigurationFactory.createConfiguration(Configuration.CacheMode.LOCAL, true);
      CacheSPI cacheSPI = (CacheSPI) new DefaultCacheFactory<Object, Object>().createCache(conf);
      cache_server.setCache(cacheSPI);
      startTcpCacheServer();
      createCacheAndLoader();
      cacheCheck();
      usabilityCheck();
View Full Code Here

Examples of org.jboss.cache.CacheSPI

   public void testInjectCache() throws Exception
   {
      createTcpCacheServer();
      Configuration conf = UnitTestCacheConfigurationFactory.createConfiguration(Configuration.CacheMode.LOCAL, true);
      CacheSPI cacheSPI = (CacheSPI) new DefaultCacheFactory<Object, Object>().createCache(conf);
      cache_server.setCache(cacheSPI);
      startTcpCacheServer();
      createCacheAndLoader();
      cacheCheck();
      usabilityCheck();
View Full Code Here

Examples of org.jboss.cache.CacheSPI

   public void testInjectCacheJmxWrapper() throws Exception
   {
      createTcpCacheServer();
      Configuration conf = UnitTestCacheConfigurationFactory.createConfiguration(Configuration.CacheMode.LOCAL, true);
      CacheSPI cacheSPI = (CacheSPI) new DefaultCacheFactory<Object, Object>().createCache(conf);
      CacheJmxWrapper wrapper = new CacheJmxWrapper<Object, Object>(cacheSPI);
      wrapper.start();
      cache_server.setCacheJmxWrapper(wrapper);
      startTcpCacheServer();
      createCacheAndLoader();
View Full Code Here

Examples of org.jboss.cache.CacheSPI

      cache = null;
   }

   private void assertNoStaleLocks()
   {
      CacheSPI spi = (CacheSPI) cache;
      assert spi.getNumberOfLocksHeld() == 0 : "Should have no stale locks!";
   }
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.