Examples of CacheSPI


Examples of org.jboss.cache.CacheSPI

   }

   @Override
   public NodeSPI<K, V> addChildDirect(Fqn f)
   {
      CacheSPI cache = getCache();
      NodeSPI<K, V> newNode = null;
      GlobalTransaction gtx = cache.getInvocationContext().getGlobalTransaction();

      if (f.size() == 1)
      {
         newNode = createChild(f.get(0), node, getCache(), version);
      }
View Full Code Here

Examples of org.jboss.cache.CacheSPI

   protected ThreadLocal<Map<String, Cache>> cachesTL = new ThreadLocal<Map<String, Cache>>();
   private ThreadLocal<ClassLoader> orig_TCL_TL = new ThreadLocal<ClassLoader>();

   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 = fqnTransformer.getBackupFqn(cache1.getLocalAddress(), A_B);

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

Examples of org.jboss.cache.CacheSPI

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

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

Examples of org.jboss.cache.CacheSPI

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

Examples of org.jboss.cache.CacheSPI

@Test(groups = {"functional"})
public class RemoveRootBuddyTest extends BuddyReplicationTestsBase
{
   public void testRemoveRootNode() throws Exception
   {
      CacheSPI cache1 = createCache(false, 1, "myBuddyPoolReplicationGroup", false, true, true);
      CacheSPI cache2 = createCache(false, 1, "myBuddyPoolReplicationGroup", false, true, true);
      List<CacheSPI<Object, Object>> caches = new ArrayList<CacheSPI<Object, Object>>(2);
      cachesTL.set(caches);
      caches.add(cache1);
      caches.add(cache2);
      int opCount = 10;
View Full Code Here

Examples of org.jboss.cache.CacheSPI

      return caches;
   }

   protected CacheSPI createCacheWithCacheLoader(boolean useDataGravitation, boolean removeOnFind, boolean passivation, boolean fetchPersistent, boolean start) throws Exception
   {
      CacheSPI cache = createCache(1, null, useDataGravitation, removeOnFind, false);

      CacheLoaderConfig config = new CacheLoaderConfig();
      IndividualCacheLoaderConfig iclc = new IndividualCacheLoaderConfig();
      iclc.setClassName(DummyInMemoryCacheLoader.class.getName());
      iclc.setFetchPersistentState(fetchPersistent);
      config.addIndividualCacheLoaderConfig(iclc);
      config.setShared(false);
      config.setPassivation(passivation);
      cache.getConfiguration().setCacheLoaderConfig(config);
      if (start)
      {
         cache.start();
      }

      return cache;
   }
View Full Code Here

Examples of org.jboss.cache.CacheSPI

public class OptimisticWithCacheLoaderTest extends AbstractOptimisticTestCase
{

   public void testLoaderIndependently() throws Exception
   {
      CacheSPI cache = createCacheWithLoader();
      CacheLoader loader = cache.getCacheLoaderManager().getCacheLoader();

      // test the cache loader independently first ...
      loader.remove(fqn);
      assert loader.get(fqn) == null;
      loader.put(fqn, key, value);
View Full Code Here

Examples of org.jboss.cache.CacheSPI

      Fqn fqn = Fqn.fromString(fqnString);
      Configuration c = new Configuration();
      c.setEvictionConfig(new EvictionConfig());
      EvictionRegionConfig erc = new EvictionRegionConfig(fqn, config);
      c.getEvictionConfig().addEvictionRegionConfig(erc);
      CacheSPI mockCache = EasyMock.createNiceMock(CacheSPI.class);
      EasyMock.replay(mockCache);
      ((RegionManagerImpl) regionManager).injectDependencies(mockCache, c, null, null, null, new RegionRegistry());
      Region r = regionManager.getRegion(fqn, Region.Type.EVICTION, true);
      r.setEvictionRegionConfig(erc);
View Full Code Here

Examples of org.jboss.cache.CacheSPI

      cr2 = TestingUtil.extractComponentRegistry(cache2);
      assert cr1 != cr2;
      assert cr1.getComponent(Notifier.class) != cr2.getComponent(Notifier.class);
      assert eventLog1 != eventLog2;
      assert cache1.getLocalAddress() != cache2.getLocalAddress();
      CacheSPI spi1, spi2;
      spi1 = (CacheSPI) cache1;
      spi2 = (CacheSPI) cache2;

      assert spi1.getRPCManager() != spi2.getRPCManager();
      assert TestingUtil.extractField(spi1.getRPCManager(), "channel") != TestingUtil.extractField(spi2.getRPCManager(), "channel");
   }
View Full Code Here

Examples of org.jboss.cache.CacheSPI

      Configuration conf = new Configuration();
      conf.setCacheMode("REPL_SYNC");
      conf.setNodeLockingScheme(Configuration.NodeLockingScheme.PESSIMISTIC);
      conf.setClusterConfig(getJGroupsStack());
      conf.setFetchInMemoryState(false);
      CacheSPI c = (CacheSPI) new UnitTestCacheFactory<Object, Object>().createCache(conf, false);
      if (!notifying)
      {
         c.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.transaction.DummyTransactionManagerLookup");
      }
      else
      {
         c.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.transaction.NotifyingTransactionManager");
      }
      c.start();
      return c;
   }
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.