Package org.jboss.cache

Examples of org.jboss.cache.TreeCache


      }
   }
  
   protected void stopCache(String id)
   {
      TreeCache cache = (TreeCache) caches.get(id);
      if (cache != null)
      {
         try {
            cache.stopService();
            cache.destroyService();
            caches.remove(id);
         }
         catch (Exception e) {
            System.out.println("Exception stopping cache " + e.getMessage());
            e.printStackTrace(System.out);
View Full Code Here


   }

   TreeCache createCache(IsolationLevel level) throws Exception
   {
      TreeCache cache = new TreeCache();
      PropertyConfigurator config = new PropertyConfigurator();
      config.configure(cache, "META-INF/replAsync-service.xml");
      cache.setIsolationLevel(level);
      System.out.println("cache isolation level is " + cache.getIsolationLevel());
      return cache;
   }
View Full Code Here

public class LocalPessimisticTest extends OptimisticPerfTestBase
{
    protected void configure() throws Exception
    {
        testName = "localPessimisticTest";
        cache = new TreeCache();
        cache.setCacheMode(TreeCache.LOCAL);
        cache.startService();
    }
View Full Code Here

  
   private void startCache() throws Exception
   {
      if (cache_ == null)
      {
         cache_ = new TreeCache();
         PropertyConfigurator config = new PropertyConfigurator();
         config.configure(cache_, configFile_);
        
         cache_.create();
         cache_.start();
View Full Code Here

public class LocalTest extends OptimisticPerfTestBase
{
    protected void configure() throws Exception
    {
        testName = "localTest";
        cache = new TreeCache();
        cache.setTransactionManagerLookupClass("org.jboss.cache.DummyTransactionManagerLookup");
        cache.setNodeLockingScheme("OPTIMISTIC");
        cache.setCacheMode(TreeCache.LOCAL);
        cache.setLockAcquisitionTimeout(2000l);
        System.out.println("TO " + cache.getLockAcquisitionTimeout());
View Full Code Here

public class LocalPessimisticCLTest extends OptimisticPerfTestBase
{
    protected void configure() throws Exception
    {
        testName = "localPessimisticCLTest";
        cache = new TreeCache();
        cache.setCacheMode(TreeCache.LOCAL);
        cache.setCacheLoaderClass("org.jboss.cache.loader.FileCacheLoader");
        Properties p = new Properties();
        p.put("location", "/tmp/JBossCache-perf/" + testName);
        cache.setCacheLoaderConfig(p);
View Full Code Here

public class LocalCLTest extends OptimisticPerfTestBase
{
    protected void configure() throws Exception
    {
        testName = "localCLTest";
        cache = new TreeCache();
        cache.setLockAcquisitionTimeout(2000l);
        cache.setTransactionManagerLookupClass("org.jboss.cache.DummyTransactionManagerLookup");
        cache.setNodeLockingScheme("OPTIMISTIC");
        cache.setCacheMode(TreeCache.LOCAL);
        cache.setCacheLoaderClass("org.jboss.cache.loader.FileCacheLoader");
View Full Code Here

      String tmpLocation = System.getProperty("java.io.tmpdir", "/tmp");
      tmpLocation = tmpLocation + File.separator + "JBossCacheBRWithCacheLoaderTest";

      try
      {
         TreeCache cache1 = createCacheWithCacheLoader(tmpLocation + File.separator + "1", true, true, passivation, true, false);
         configureEviction(cache1);
         TreeCache cache0 = createCacheWithCacheLoader(tmpLocation + File.separator + "2", true, true, passivation, true, false);
         configureEviction(cache0);

         caches = new TreeCache[2];
         caches[0] = cache0;
         caches[1] = cache1;

         cache0.start();
         cache1.start();

         TestingUtil.blockUntilViewsReceived(caches, VIEW_BLOCK_TIMEOUT * caches.length);
         TestingUtil.sleepThread(getSleepTimeout());


         Fqn foo = Fqn.fromString("/foo");        
         Fqn backupFoo = BuddyManager.getBackupFqn(cache0.getLocalAddress(), foo);
         cache0.put(foo, "key", "value");

         assertTrue("Data should exist in data owner", cache0.exists(foo));
         assertTrue("Buddy should have data", cache1.exists(backupFoo));

         // Sleep long enough for eviction to run twice plus a bit
         TestingUtil.sleepThread(3050);

         // test that the data we're looking for has been evicted in both the data owner and the buddy.
         assertFalse("Data should have evicted in data owner", cache0.exists(foo));
         assertFalse("Buddy should have data evicted", cache1.exists(backupFoo));

         // now test that this exists in both loaders.
         assertNotNull("Should exist in data owner's cache loader", cache0.getCacheLoader().get(foo));
         assertNotNull("Should exist in buddy's loader", cache1.getCacheLoader().get(backupFoo));

         // a local gravitation should occur since cache1 has foo in it's backup tree.
         assertEquals("Passivated value available from buddy", "value", cache1.get(foo, "key"));
      }
View Full Code Here

      String tmpLocation = System.getProperty("java.io.tmpdir", "/tmp");
      tmpLocation = tmpLocation + File.separator + "JBossCacheBRWithCacheLoaderTest";

      try
      {
         TreeCache cache0 = createCacheWithCacheLoader(tmpLocation + File.separator + "0", true, true, passivation, true, false);
         configureEviction(cache0);
         TreeCache cache1 = createCacheWithCacheLoader(tmpLocation + File.separator + "1", true, true, passivation, true, false);
         configureEviction(cache1);
         TreeCache cache2 = createCacheWithCacheLoader(tmpLocation + File.separator + "2", true, true, passivation, true, false);
         configureEviction(cache2);

         caches = new TreeCache[3];
         caches[0] = cache0;
         caches[1] = cache1;
         caches[2] = cache2;

         cache0.start();
         cache1.start();
         cache2.start();

         TestingUtil.blockUntilViewsReceived(caches, 600000);
         TestingUtil.sleepThread(getSleepTimeout());


         assertTrue("Cache1 should be cache0's buddy!", cache0.getBuddyManager().getBuddyAddresses().contains(cache1.getLocalAddress()));

         Fqn foo = Fqn.fromString("/foo");
         Fqn backupFoo = BuddyManager.getBackupFqn(cache0.getLocalAddress(), foo);
         cache0.put(foo, "key", "value");

         // test that the data exists in both the data owner and the buddy
         assertTrue("Data should exist in data owner", cache0.exists(foo));
         assertTrue("Buddy should have data", cache1.exists(backupFoo));

         // Sleep long enough for eviction to run twice plus a bit
         TestingUtil.sleepThread(3050);

         // test that the data we're looking for has been evicted in both the data owner and the buddy.
         assertFalse("Data should have evicted in data owner", cache0.exists(foo));
         assertFalse("Buddy should have data evicted", cache1.exists(backupFoo));

         // now test that this exists in both loaders.
         assertNotNull("Should exist in data owner's loader", cache0.getCacheLoader().get(foo));
         assertNotNull("Should exist in buddy's loader", cache1.getCacheLoader().get(backupFoo));

         // doing a get on cache2 will guarantee a remote data gravitation.
         assertEquals("Passivated value available from buddy", "value", cache2.get(foo, "key"));
      }
      finally
      {
         cleanup(caches);
         TestingUtil.recursiveRemove(new File(tmpLocation));
View Full Code Here

      assertEquals("Correct age for /a/b", TWENTY, cache2.get("/a/b", "age"));
   }

   public void testBuddyIntegration() throws Exception
   {
      TreeCache cache1 = (TreeCache) createCache("cache1", false, false, false, false, false);
  
      cache1.setBuddyReplicationConfig(getBuddyConfig());
     
      cache1.startService();
     
      TreeCache cache2 = (TreeCache) createCache("cache2", false, false, false);
     
      // Pause to give caches time to see each other
      TestingUtil.blockUntilViewsReceived(new TreeCacheMBean[] { cache1, cache2 }, 60000);
     
      Option option = new Option();
      option.setCacheModeLocal(true);
     
      Fqn backup = Fqn.fromString(BuddyManager.BUDDY_BACKUP_SUBTREE);
      backup = new Fqn(backup, "a");
      cache1.put(backup, null, option);
      DataNode target = cache1.get(backup);
     
      Fqn abc = Fqn.fromString("/a/b/c");
      cache2.put(abc, "name", JOE, option);
      Fqn ad = Fqn.fromString("/a/d");
      cache2.put(ad, "name", JANE, option);
     
      Object[] sources = cache1.getMembers().toArray();
      ClassLoader cl = Thread.currentThread().getContextClassLoader();
      Fqn a = Fqn.fromString("/a");
      cache1._loadState(a, target, sources, cl);
View Full Code Here

TOP

Related Classes of org.jboss.cache.TreeCache

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.