Package org.jboss.cache

Examples of org.jboss.cache.TreeCacheMBean


      CacheProperties cacheProperties = new CacheProperties(properties);
     
      try
      {
         ObjectName mbeanObjectName = new ObjectName(cacheProperties.getCacheObjectName());
         TreeCacheMBean mbean = (TreeCacheMBean) MBeanProxyExt.create(TreeCacheMBean.class, mbeanObjectName, MBeanServerLocator.locateJBoss());
         cache = mbean.getInstance();
         if ("OPTIMISTIC".equals(cache.getNodeLockingScheme()))
         {
            optimistic = true;
            log.debug("JBoss Cache is configured for optimistic locking; " +
                    "provided Cache implementations will also implement OptimisticCache");
View Full Code Here


      caches = new HashMap();
   }

   public void testInterop() throws Exception
   {     
      TreeCacheMBean cache = createCache("driver");
     
      TestingUtil.blockUntilViewReceived(cache, 2, 10000);
     
      cache.put("/put", "key", "value");
     
      Map map = new HashMap();
      map.put("0", new Integer(0));
      map.put("1", new Integer(1));
      cache.put("/put/map", map);
     
      cache.put("/remove", "key", "value");
      cache.remove("/remove");
     
      cache.put("/txremove", "key", "value");
     
      TransactionManager tm = cache.getTransactionManager();     
      tm.begin();
      Transaction tx = tm.getTransaction();
      cache.put("/txput", "key", "value");
      cache.remove("/txremove");
      tx.commit();
     
      cache.put("/rbremove", "key", "value");
     
      tm.begin();
      tx = tm.getTransaction();
     
      cache.put("/rbput", "key", "value");
      cache.remove("/rbremove");
     

      tx.registerSynchronization(new RollbackSync(tx));
      try
      {
         tx.commit();
      }
      catch (Exception ignored) {}
     
      stopCache("driver");
     
      cache = createCache("recipient");
     
      TestingUtil.blockUntilViewReceived(cache, 2, 10000);
     
      assertEquals("value", cache.get("/put", "key"));
      assertEquals(new Integer(0), cache.get("/put/map", "0"));
      assertEquals(new Integer(1), cache.get("/put/map", "1"));
      assertNull(cache.get("/remove", "key"));
      assertEquals("value", cache.get("/txput", "key"));
      assertNull(cache.get("/txremove", "key"));
      assertNull(cache.get("/rbput", "key"));
      assertEquals("value", cache.get("/rbremove", "key"));
   }
View Full Code Here

    * @throws Exception
    */
   public void testPutTE() throws Exception
   {    
     
      TreeCacheMBean cache = createCache("driver");
     
      TestingUtil.blockUntilViewReceived(cache, 2, 10000);
   
      HashMap hm = new HashMap();
      hm.put("te", new TimeoutException("test", new RuntimeException()));
      ConfigureException ce = null;
      try
      {
         ce = new ConfigureException("test", new RuntimeException());
      }
      catch (Throwable t)
      {
         // Above signature not valid if cache is 123
         ce = new ConfigureException("123");
      }
      hm.put("ce", ce);
      cache.put("/TestTE", "TE", hm);
     
      stopCache("driver");
     
      cache = createCache("recipient");
     
      TestingUtil.blockUntilViewReceived(cache, 2, 10000);
     
      hm = (HashMap) cache.get("/TestTE", "TE");
      assertTrue("not null", hm != null);
      assertTrue("correct type", hm.get("te") instanceof TimeoutException);
      assertTrue("correct type", hm.get("ce") instanceof ConfigureException);
   }
View Full Code Here

   protected TreeCacheMBean createCache(String cacheID) throws Exception
   {
      if (caches.get(cacheID) != null)
      throw new IllegalStateException(cacheID + " already created");
     
      TreeCacheMBean tree=new TreeCache();
      PropertyConfigurator config=new PropertyConfigurator();
      config.configure(tree, configFile);
     
      tree.createService();
      tree.startService();
     
      caches.put(cacheID, tree);
     
      return tree;
   }
View Full Code Here

      return "1.4.0.GA";
   }

   public void testBuddyBackupExclusion() throws Exception
   {
      TreeCacheMBean cache1 = createCache("cache1", false, false, false, false, false);
  
      cache1.setBuddyReplicationConfig(getBuddyConfig());
     
      cache1.startService();
     
      Fqn backup = new Fqn(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, "test");
      // force this to be a LOCAL MODE put to prevent breakage
      Option o = new Option();
      o.setCacheModeLocal(true);
      cache1.put(backup, "name", JOE, o);
      cache1.put("/a/b", "age", TWENTY);
     
      TreeCacheMBean cache2 = createCache("cache2", false, false, false);
     
      // Pause to give caches time to see each other
      TestingUtil.blockUntilViewsReceived(new TreeCacheMBean[] { cache1, cache2 }, 60000);
     
      assertNull("_buddy_backup_ not transferred", cache2.get(backup, "name"));
      assertEquals("Correct age for /a/b", TWENTY, cache2.get("/a/b", "age"));
   }
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("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

public class FailedStateTransferTest extends StateTransferTestBase
{
  
   public void testFailedStateTransfer() throws Exception
   {
      TreeCacheMBean tree =new SecretiveStateCache();
      PropertyConfigurator config=new PropertyConfigurator();
      config.configure(tree, "META-INF/replAsync-service.xml");
      tree.setClusterName("VersionedTestBase");
      tree.setReplicationVersion(getReplicationVersion());
      // Use a long timeout to facilitate setting debugger breakpoints
      tree.setInitialStateRetrievalTimeout(60000);
     
      // Put the cache in the map before starting, so if it fails in
      // start it can still be destroyed later
      caches.put("secretive", tree);
     
      tree.createService();
      tree.startService();
     
      TreeCacheMBean recipient = createCache("recipient", false, false, false, false, false);
      try
      {
         recipient.startService();
         fail("startService() should throw an exception");
      }
      catch (CacheException good)
      {
         // this is what we want
View Full Code Here

   protected TreeCacheMBean createCache(String cacheID) throws Exception
   {
      if (caches.get(cacheID) != null)
      throw new IllegalStateException(cacheID + " already created");
     
      TreeCacheMBean tree=new TreeCache();
      PropertyConfigurator config=new PropertyConfigurator();
      config.configure(tree, "META-INF/replSync-service.xml");
     
      tree.createService();
      tree.startService();
     
      caches.put(cacheID, tree);
     
      return tree;
   }
View Full Code Here

      caches = new HashMap();
   }
  
   public void testBreakDeadMemberLocks() throws Exception
   {
      TreeCacheMBean cacheA = createCache("A");
     
      cacheA.put("/1/A", "1", "A");
      cacheA.put("/1/A", "2", "A");
      cacheA.put("/2/A", "1", "A");
      cacheA.put("/2/A", "2", "A");
      cacheA.put("/1/A/I", "1", "A");
      cacheA.put("/1/A/I", "2", "A");
     
      TreeCacheMBean cacheB = createCache("B");
     
      // Pause to give caches time to see each other
      TestingUtil.blockUntilViewsReceived(new TreeCacheMBean[] { cacheA, cacheB }, 60000);
     
      final TransactionManager tm = cacheB.getTransactionManager();
      tm.begin();
      final Transaction tx = tm.getTransaction();
     
      cacheB.put("/1/A", "1", "B");
      cacheB.put("/1/A", "2", "B");
      cacheB.put("/2/A", "1", "B");
      cacheB.put("/2/A", "2", "B");
      cacheB.put("/1/A/I", "1", "B");
      cacheB.put("/1/A/I", "2", "B");
      cacheB.put("/EXISTS", "KEY", "B");
     
      Object monitor = new Object();
      HangSync sync = new HangSync(monitor);
      tx.registerSynchronization(sync);
     
      Thread t = new Thread() {
        public void run() {
           try
           {
              tm.resume(tx);
              tx.commit();
           }
           catch (Exception e) {}
        }
      };
     
      synchronized (monitor)
      {
         t.start();
     
         while (!sync.hung)
            monitor.wait(500);
      }
     
      tm.suspend();
     
      // Confirm that B's tx replicated
      assertTrue(cacheA.exists("/EXISTS"));
     
      cacheB.stopService();
      cacheB.destroyService();
     
      while (cacheA.getMembers().size() > 1)
      {
         try
         {
View Full Code Here

   private void transactionTest(String[] values,
                                boolean rollback,
                                String isolationLevel) throws Exception
   {
      // Create the cache from which state will be requested
      TreeCacheMBean sender = initializeSender(isolationLevel, false, false);
     
      // Start threads that will do operations on the cache and then hang
      TxRunner[] runners =
            initializeTransactionRunners(values, sender, "/LOCK", rollback);
     
      // Create and start the cache that requests a state transfer
      TreeCacheMBean receiver = startReceiver(isolationLevel, false, false);
     
      // Confirm the receiver got the expected state and the threads are OK
      checkResults(receiver, runners, false);
   }
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.