Examples of TreeCache


Examples of org.jboss.cache.TreeCache

      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

Examples of org.jboss.cache.TreeCache

      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

Examples of org.jboss.cache.TreeCache

      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

Examples of org.jboss.cache.TreeCache

      throws Exception
   {
      if (caches.get(cacheID) != null)
         throw new IllegalStateException(cacheID + " already created");
     
      TreeCacheMBean tree=new TreeCache();
      PropertyConfigurator config=new PropertyConfigurator();
      String configFile = sync ? "META-INF/replSync-service.xml"
                               : "META-INF/replAsync-service.xml";
      config.configure(tree, configFile); // read in generic replAsync xml
      tree.setClusterName("VersionedTestBase");
      tree.setReplicationVersion(getReplicationVersion());
      // Use a long timeout to facilitate setting debugger breakpoints
      tree.setInitialStateRetrievalTimeout(60000);
      if (useMarshalling) {
         tree.setUseRegionBasedMarshalling(true);
         tree.setInactiveOnStartup(true);
      }
      if (useCacheLoader) {
         configureCacheLoader(tree, cacheID, useMarshalling, cacheLoaderAsync);
      }
     
View Full Code Here

Examples of org.jboss.cache.TreeCache

*/
public class OptimisticAsyncInvalidationTest extends OptimisticSyncInvalidationTest
{
   protected TreeCache createCache() throws Exception
   {
      TreeCache c = new TreeCache();
      c.setCacheMode(TreeCache.INVALIDATION_ASYNC); // only use sync.
      c.setTransactionManagerLookupClass("org.jboss.cache.DummyTransactionManagerLookup");
      c.setNodeLockingScheme("OPTIMISTIC");
      c.startService();
      return c;
   }
View Full Code Here

Examples of org.jboss.cache.TreeCache

        super(name);
    }

    public void testConcurrentReadsLocal() throws Exception
    {
        TreeCache cache = createCacheUnstarted();
        cache.setCacheMode("INVALIDATION_ASYNC");
        cache.startService();
       
        Processor[] processors = new Processor[NUM_THREADS];
        for (int i=0; i<NUM_THREADS; i++)
        {
            processors[i] = new Processor(cache, "Processor-" + i);
            processors[i].start();
        }

        cache.put(FQN, "key", "value");
        latch.release();

        for (int i=0; i<NUM_THREADS; i++)
            processors[i].join();
View Full Code Here

Examples of org.jboss.cache.TreeCache

   private static final int serverPort = 7500;
   private static final String serverHost = "127.0.0.1";

   protected void setUp() throws Exception
   {
      cache = new TreeCache();
      cache.setCacheLoaderConfiguration(getSingleCacheLoaderConfig("", "org.jboss.cache.loader.tcp.TcpDelegatingCacheLoader", "port=" + serverPort + "\nhost=" + serverHost, false, false, false));
   }
View Full Code Here

Examples of org.jboss.cache.TreeCache

    private static Log log = LogFactory.getLog(InvalidationInterceptorTest.class);

    public void testPessimisticNonTransactional() throws Exception
    {
        TreeCache cache1 = createCache(false);
        TreeCache cache2 = createCache(false);

        Fqn fqn = Fqn.fromString("/a/b");
        cache1.put(fqn, "key", "value");

        // test that this has NOT replicated, but rather has been invalidated:
        Assert.assertEquals("value", cache1.get(fqn, "key"));
        Assert.assertNull("Should NOT have replicated!", cache2.get(fqn));

        log.info("***** Node not replicated, as expected.");

        // now make sure cache2 is in sync with cache1:
        cache2.put(fqn, "key", "value");
        Assert.assertNull("Should be null", cache1.get(fqn));
        Assert.assertEquals("value", cache2.get(fqn, "key"));

        // now test the invalidation:
        cache1.put(fqn, "key2", "value2");
        Assert.assertEquals("value2", cache1.get(fqn, "key2"));
        Assert.assertNull("Should have been invalidated!", cache2.get(fqn));

        // clean up.
        cache1.stopService();
        cache2.stopService();
        cache1 = null;
        cache2 = null;
    }
View Full Code Here

Examples of org.jboss.cache.TreeCache

        cache2 = null;
    }

    public void testUnnecessaryEvictions() throws Exception
    {
        TreeCache cache1 = createCache(false);
        TreeCache cache2 = createCache(false);

        Fqn fqn1 = Fqn.fromString("/a/b/c");
        Fqn fqn2 = Fqn.fromString("/a/b/d");

        cache1.put(fqn1, "hello", "world");

        assertEquals("world", cache1.get(fqn1, "hello"));
        assertNull(cache2.get(fqn1, "hello"));

        cache2.put(fqn2, "hello", "world");
        assertEquals("world", cache1.get(fqn1, "hello"));
        assertNull(cache2.get(fqn1, "hello"));
        assertEquals("world", cache2.get(fqn2, "hello"));
        assertNull(cache1.get(fqn2, "hello"));

        cache2.put(fqn1, "hello", "world");
        assertEquals("world", cache2.get(fqn1, "hello"));
        assertEquals("world", cache2.get(fqn2, "hello"));
        assertNull(cache1.get(fqn1, "hello"));
        assertNull(cache1.get(fqn2, "hello"));

        cache1.stopService();
        cache2.stopService();
        cache1 = null;
        cache2 = null;

    }
View Full Code Here

Examples of org.jboss.cache.TreeCache

*/
public class BuddyReplicationConfigTest extends TestCase
{
    public void testNullConfig() throws Exception
    {
        TreeCache cache = new TreeCache();
        cache.setBuddyReplicationConfig(null);
        assertNull(cache.getBuddyManager());
    }
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.