Package org.jboss.cache

Examples of org.jboss.cache.CacheSPI


{
   public void testNoTransactionCRUDMethod() throws Exception
   {

      TestListener listener = new TestListener();
      final CacheSPI cache = createCacheWithListener(listener);

      Interceptor interceptor = new OptimisticCreateIfNotExistsInterceptor();
      Interceptor nodeInterceptor = new OptimisticNodeInterceptor();
      MockInterceptor dummy = new MockInterceptor();

      interceptor.setNext(nodeInterceptor);
      nodeInterceptor.setNext(dummy);

      TestingUtil.replaceInterceptorChain(cache, interceptor);

      try
      {
         cache.put("/one/two", "key1", new Object());
         fail();
      }
      catch (Throwable t)
      {

         assertTrue(true);
      }
      assertEquals(null, dummy.getCalled());
      cache.stop();
   }
View Full Code Here


   public void testNoTransactionGetMethod() throws Exception
   {

      TestListener listener = new TestListener();
      final CacheSPI cache = createCacheWithListener(listener);

      Interceptor interceptor = new OptimisticCreateIfNotExistsInterceptor();
      Interceptor nodeInterceptor = new OptimisticNodeInterceptor();
      MockInterceptor dummy = new MockInterceptor();

      interceptor.setNext(nodeInterceptor);
      nodeInterceptor.setNext(dummy);

      TestingUtil.replaceInterceptorChain(cache, interceptor);

      boolean fail = false;
      try
      {
         assertEquals(null, cache.get("/one/two", "key1"));
      }
      catch (Exception e)
      {
         fail = true;
      }
      assertTrue(fail);
      assertEquals(null, dummy.getCalled());
      cache.stop();
   }
View Full Code Here

   protected Map<String, Cache> caches;
   private ClassLoader orig_TCL;

   public void testBuddyBackupActivation() throws Exception
   {
      CacheSPI cache1 = createCache("cache1", true, true, true);
      CacheSPI cache2 = createCache("cache2", true, true, true);
      Fqn A = Fqn.fromString("/a");
      TestingUtil.blockUntilViewsReceived(VIEW_BLOCK_TIMEOUT, cache1, cache2);

      // create the regions on the two caches first
      Region c1 = cache1.getRegionManager().getRegion(A, Region.Type.MARSHALLING, true);
      Region c2 = cache2.getRegionManager().getRegion(A, Region.Type.MARSHALLING, true);

      assertFalse(c1.isActive());
      assertFalse(c2.isActive());

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

      TestingUtil.sleepThread(getSleepTimeout());

      System.out.println("Cache dump BEFORE activation");
      System.out.println("cache1 " + CachePrinter.printCacheDetails(cache1));
      System.out.println("cache2 " + CachePrinter.printCacheDetails(cache2));

      c2.activate();

      System.out.println("Cache dump AFTER activation");
      System.out.println("cache1 " + CachePrinter.printCacheDetails(cache1));
      System.out.println("cache2 " + CachePrinter.printCacheDetails(cache2));

      Fqn fqn = BuddyManager.getBackupFqn(cache1.getLocalAddress(), A_B);

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

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

   public void testReplToInactiveRegion() throws Exception
   {
      CacheSPI cache1 = createCache("cache1", true, true, true);
      CacheSPI cache2 = createCache("cache2", true, true, true);

      TestingUtil.blockUntilViewsReceived(VIEW_BLOCK_TIMEOUT, cache1, cache2);
      Fqn backupFqn = BuddyManager.getBackupFqn(cache1.getLocalAddress(), A_B);
      Fqn<String> 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);

      TestingUtil.sleepThread(getSleepTimeout());
      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 = createCache("cache1", true, true, true);
      Fqn<String> A = Fqn.fromString("/a");
      Region regionA = cache1.getRegion(A, true);
      regionA.registerContextClassLoader(getClass().getClassLoader());
      regionA.activate();

      Fqn<String> fqn = new Fqn<String>(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, "test");
      fqn = new Fqn<String>(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

      assert ((DefaultDataVersion) observerNode.getVersion()).getRawVersion() == 10 : "Version should be updated";
   }

   public void testTombstoneVersioningFailure() throws Exception
   {
      CacheSPI modifierImpl = (CacheSPI) modifier;
      CacheSPI observerImpl = (CacheSPI) observer;

      modifier.put(parent, K, V);

      // test that this exists in the (shared) loader
      assert loader.get(parent) != null;
      assert loader.get(parent).size() > 0;

      modifier.removeNode(parent);

      // assert that tombstones exist on both instances
      assert modifierImpl.peek(parent, true, true) != null;
      assert observerImpl.peek(parent, true, true) != null;
      assert modifierImpl.peek(parent, false, false) == null;
      assert observerImpl.peek(parent, false, false) == null;

      // make sure this does not exist in the loader; since it HAS been removed
      assert loader.get(parent) == null;

      NodeSPI observerNode = (NodeSPI) observer.getRoot().getChild(parent);
      assert observerNode == null : "Should be removed";

      // now try a put on a with a newer data version; should work
      modifier.getInvocationContext().getOptionOverrides().setDataVersion(new DefaultDataVersion(1));
      try
      {
         modifier.put(parent, K, V);
         assert false : "Should have barfed!";
      }
      catch (RuntimeException expected)
      {

      }

      NodeSPI modifierNode = (NodeSPI) modifier.getRoot().getChild(parent);
      assert modifierNode == null : "Should be null";

      observerNode = (NodeSPI) observer.getRoot().getChild(parent);
      assert observerNode == null : "Should be null";

      NodeSPI modifierTombstone = modifierImpl.peek(parent, true, true);
      NodeSPI observerTombstone = observerImpl.peek(parent, true, true);

      assert modifierTombstone != null : "Tombstone should still exist";
      assert observerTombstone != null : "Tombstone should still exist";

      assert !modifierTombstone.isValid() : "Should not be valid";
View Full Code Here

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

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

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

      clc.addIndividualCacheLoaderConfig(iclc);
      cache.getConfiguration().setCacheLoaderConfig(clc);

      cache.start();

      CacheSPI spi = (CacheSPI) cache;

      loader = (DummyInMemoryCacheLoader) spi.getCacheLoaderManager().getCacheLoader();

      return cache;
   }
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.