Package org.jboss.cache

Examples of org.jboss.cache.TreeCacheMBean


    */
   private TreeCacheMBean initializeSender(String isolationLevel,
                                           boolean replSync,
                                           boolean useMarshalling) throws Exception
   {
      TreeCacheMBean sender = createCache("sender", isolationLevel, replSync, useMarshalling, true);
     
      if (useMarshalling)
         sender.activateRegion("/");
     
      sender.put("/OK", "KEY", "X");
     
      return sender;    
   }
View Full Code Here


    * @throws Exception
    */
   public void testHungThread() throws Exception
   {
      // Create the cache from which state will be requested
      TreeCacheMBean sender = initializeSender("REPEATABLE_READ", false, false);
     
      // Start threads that will do operations on the cache and then hang
      String[] values = { "A", "B", "C" };
      HangThreadRunner[] runners = initializeHangThreadRunners(values, sender, "/LOCK");
     
      // Create and start the cache that requests a state transfer
      TreeCacheMBean receiver = startReceiver("REPEATABLE_READ", false, false);
     
      // Confirm the receiver got the expected state and the threads are OK
      checkResults(receiver, runners, true);     
   }
View Full Code Here

    *
    * @throws Exception
    */
   private void synchronizationTest(boolean hangBefore) throws Exception
   {
      TreeCacheMBean sender = initializeSender("REPEATABLE_READ", false, false);
     
      String[] values = { "A", "B", "C" };
      SynchronizationTxRunner[] runners =
         initializeSynchronizationTxRunners(values, sender, "/LOCK", hangBefore);
     
      TreeCacheMBean receiver = startReceiver("REPEATABLE_READ", false, false);
     
      checkResults(receiver, runners, !hangBefore);
   }
View Full Code Here

   private void multipleProblemTest(String isolationLevel,
                                    String rootFqn,
                                    boolean replSync,
                                    boolean useMarshalling) throws Exception
   {
      TreeCacheMBean sender = initializeSender(isolationLevel, replSync, useMarshalling);
     
      // Do the "after" nodes first, otherwise if there is a /LOCK parent
      // node, the rollback of a tx will remove it causing the test to fail
      // since the child node created by it will be gone as well.
      // This is really a REPEATABLE_READ bug that this test isn't intended
      // to catch; will create a separate locking test that shows it
      String[] val1 = { "A", "B", "C" };
      SynchronizationTxRunner[] after =
         initializeSynchronizationTxRunners(val1, sender, rootFqn, false);
     
      String[] val2 = { "D", "E", "F" };
      SynchronizationTxRunner[] before =
         initializeSynchronizationTxRunners(val2, sender, rootFqn, true);
     
      String[] val3 = { "G", "H", "I" };
      TxRunner[] active =
         initializeTransactionRunners(val3, sender, rootFqn, false);
     
      String[] val4 = { "J", "K", "L" };
      TxRunner[] rollback =
         initializeTransactionRunners(val4, sender, rootFqn, true);
     
      String[] val5 = { "M", "N", "O" };
      HangThreadRunner[] threads =
         initializeHangThreadRunners(val5, sender, rootFqn);
     
      TreeCacheMBean receiver = startReceiver(isolationLevel, replSync, useMarshalling);
     
      checkResults(receiver, active, false);
      checkResults(receiver, rollback, false);
      checkResults(receiver, before, false);
      checkResults(receiver, after, true);
View Full Code Here

    */
   private TreeCacheMBean startReceiver(String isolationLevel,
                                        boolean replSync,
                                        boolean useMarshalling) throws Exception
   {
      TreeCacheMBean receiver = createCache("receiver", isolationLevel, replSync, useMarshalling, false);
   
      // Start the cache in a separate thread so we can kill the
      // thread if the cache doesn't start properly
      CacheStarter starter = new CacheStarter(receiver, useMarshalling);
     
View Full Code Here

                                      boolean replSync,
                                      boolean useMarshalling,
                                      boolean startCache)
      throws Exception
   {
      TreeCacheMBean result = super.createCache(cacheID, replSync,
                                                useMarshalling, false, false, false);
      result.setInitialStateRetrievalTimeout(0);
      result.setLockAcquisitionTimeout(1000);
      result.setIsolationLevel(isolationLevel);
     
      if (startCache)
         result.start();
     
      return result;
   }
View Full Code Here

      assertNull("No replication to inactive backup region", caches[1].get(fqn, "name"));
   }
  
   public void testBuddyBackupInactivation() throws Exception
   {
      TreeCacheMBean cache1 = createCache("cache1", true, true, true);
     
      cache1.activateRegion("/a");
     
      Option option = new Option();
      option.setCacheModeLocal(true);
     
      Fqn fqn = new Fqn(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, "test");
      fqn = new Fqn(fqn, A_B);
      cache1.put(fqn, "name", JOE, option);
     
      assertEquals("Put OK", JOE, cache1.get(fqn, "name"));
     
      cache1.inactivateRegion("/a");
     
      assertNull("Inactivation cleared region", cache1.get(fqn, "name"));
     
   }
View Full Code Here

      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("Test");
      if (useMarshalling) {
         tree.setUseRegionBasedMarshalling(true);
         tree.setInactiveOnStartup(true);
      }
      tree.setBuddyReplicationConfig(getBuddyConfig());
     
      // Call the hook that allows testing with the multiplexer
      configureMultiplexer(tree);
     
      // Put the cache in the map before starting, so if it fails in
      // start it can still be destroyed later
      caches.put(cacheID, tree);
     
      if (startCache)
      {
         tree.createService();
         tree.startService();
        
         validateMultiplexer(tree);
      }
     
      return tree;
View Full Code Here

   private static final int SUBTREE_SIZE = 10;
  
  
   public void testInitialStateTransfer() throws Exception
   {
      TreeCacheMBean cache1 = createCache("cache1", false, false, false);
     
      cache1.put("/a/b", "name", JOE);
      cache1.put("/a/b", "age", TWENTY);
      cache1.put("/a/c", "name", BOB);
      cache1.put("/a/c", "age", FORTY);
     
      TreeCacheMBean cache2 = createCache("cache2", false, false, false);
     
      // Pause to give caches time to see each other
      TestingUtil.blockUntilViewsReceived(new TreeCacheMBean[] { cache1, cache2 }, 60000);
     
      assertEquals("Incorrect name for /a/b", JOE, cache2.get("/a/b", "name"));
      assertEquals("Incorrect age for /a/b", TWENTY, cache2.get("/a/b", "age"));
      assertEquals("Incorrect name for /a/c", BOB, cache2.get("/a/c", "name"));
      assertEquals("Incorrect age for /a/c", FORTY, cache2.get("/a/c", "age"));
   }
View Full Code Here

      initialStateTferWithLoaderTest(true);
   }
  
   private void initialStateTferWithLoaderTest(boolean asyncLoader) throws Exception
   {
      TreeCacheMBean cache1 = createCache("cache1", false, false, true);
     
      cache1.put("/a/b", "name", JOE);
      cache1.put("/a/b", "age", TWENTY);
      cache1.put("/a/c", "name", BOB);
      cache1.put("/a/c", "age", FORTY);
     
      TreeCacheMBean cache2 = createCache("cache2", false, false, true, asyncLoader, false);
     
      cache2.startService();
     
      // Pause to give caches time to see each other
      TestingUtil.blockUntilViewsReceived(new TreeCacheMBean[] { cache1, cache2 }, 60000);
     
      if (asyncLoader)
          TestingUtil.sleepThread((long)100);
     
      CacheLoader loader = cache2.getCacheLoader();
     
      Map ab = loader.get(A_B);
      assertNotNull("Loader transferred /a/b", ab);
      assertEquals("Incorrect loader name for /a/b", JOE, ab.get("name"));
      assertEquals("Incorrect loader age for /a/b", TWENTY, ab.get("age"));

      Map ac = loader.get(A_C);
      assertNotNull("Loader transferred /a/c", ac);
      assertEquals("Incorrect loader name for /a/c", BOB, ac.get("name"));
      assertEquals("Incorrect loader age for /a/c", FORTY, ac.get("age"));
     
      assertEquals("Incorrect name for /a/b", JOE, cache2.get("/a/b", "name"));
      assertEquals("Incorrect age for /a/b", TWENTY, cache2.get("/a/b", "age"));
      assertEquals("Incorrect name for /a/c", BOB, cache2.get("/a/c", "name"));
      assertEquals("Incorrect age for /a/c", FORTY, cache2.get("/a/c", "age"));
   }
View Full Code Here

TOP

Related Classes of org.jboss.cache.TreeCacheMBean

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.