Package org.jboss.cache

Examples of org.jboss.cache.TreeCache


   private TransactionManager tm;
   private Fqn fqn = Fqn.fromString("/a/b/c");

   protected void setUp() throws Exception
   {
      cache = new TreeCache();
      cache.setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
      cache.start();
      tm = cache.getTransactionManager();
   }
View Full Code Here


   private TreeCache cache;
   private TransactionManager tm;

   protected void setUp() throws Exception
   {
      cache = new TreeCache();
      cache.setTransactionManagerLookupClass("org.jboss.cache.DummyTransactionManagerLookup");
      // reduce LAT so the test runs faster
      cache.setLockAcquisitionTimeout(500);

      cache.startService();
View Full Code Here

       super.setUp();

       String tmpLoc = System.getProperty("java.io.tmpdir", "/tmp");
       String location = tmpLoc + File.separator + "TxCacheLoaderTest1";

       cache1=new TreeCache();
       cache1.setCacheMode("repl_sync");
       cache1.setTransactionManagerLookupClass("org.jboss.cache.DummyTransactionManagerLookup");

       cache1.setCacheLoaderConfiguration(getSingleCacheLoaderConfig("", "org.jboss.cache.loader.FileCacheLoader", "location=" + location, false, false, false));
       // cache1.setReplQueueInterval(3000);
       cache1.createService();
       cache1.startService();

       location = tmpLoc + File.separator + "TxCacheLoaderTest2";

       cache2=new TreeCache();
       cache2.setCacheMode("repl_sync");
       cache2.setTransactionManagerLookupClass("org.jboss.cache.DummyTransactionManagerLookup");
       cache2.setCacheLoaderConfiguration(getSingleCacheLoaderConfig("", "org.jboss.cache.loader.FileCacheLoader", "location=" + location, false, false, false));
       cache2.setLockAcquisitionTimeout(2000);
       // cache2.setReplQueueInterval(3000);
View Full Code Here

   }

   public void testCacheContentionOnRoot() throws Exception
    {
       final int threads = 10, loops = 100;
       TreeCache cache = null;
       try
       {
          cache = new TreeCache();
          cache.startService();
          final DataNode root = cache.getRoot();
          final List exceptions = new ArrayList();
          final List timeouts = new ArrayList();


          // get a hold of the WL first
          root.acquire(Thread.currentThread(), 10, DataNode.LOCK_TYPE_WRITE);

          Thread[] t = new Thread[threads];

          for (int i=0; i<t.length; i++)
          {
             t[i] = new Thread()
             {
                public void run()
                {
                   for (int i=0; i<loops; i++)
                   {
                      try
                      {
                         root.acquire(Thread.currentThread(), 10, DataNode.LOCK_TYPE_WRITE);
                      }
                      catch (TimeoutException te)
                      {
                         // expected
                         timeouts.add( te );
                      }
                      catch (Exception ex)
                      {
                         ex.printStackTrace();
                         exceptions.add(ex);
                      }
                   }
                }
             };

             t[i].start();
          }

          for (int i=0; i<t.length; i++) t[i].join();
          root.releaseAll(Thread.currentThread());

          // we should have 0 exceptions
          assertEquals(0, exceptions.size());
       }
       finally
       {
          if (cache != null) cache.stopService();
       }
    }
View Full Code Here


    public void testCacheContentionOnNode() throws Exception
    {
       final int threads = 10, loops = 100;
       TreeCache cache = null;
       try
       {
          cache = new TreeCache();
          cache.startService();
          cache.put("/test/node", null);
          final DataNode node = cache.get("/test/node");
          final List exceptions = new ArrayList();
          final List timeouts = new ArrayList();


          // get a hold of the WL first
          node.acquire(Thread.currentThread(), 10, DataNode.LOCK_TYPE_WRITE);

          Thread[] t = new Thread[threads];

          for (int i=0; i<t.length; i++)
          {
             t[i] = new Thread()
             {
                public void run()
                {
                   for (int i=0; i<loops; i++)
                   {
                      try
                      {
                         node.acquire(Thread.currentThread(), 10, DataNode.LOCK_TYPE_WRITE);
                      }
                      catch (TimeoutException te)
                      {
                         // expected
                         timeouts.add( te );
                      }
                      catch (Exception ex)
                      {
                         ex.printStackTrace();
                         exceptions.add(ex);
                      }
                   }
                }
             };

             t[i].start();
          }

          for (int i=0; i<t.length; i++) t[i].join();
          node.releaseAll(Thread.currentThread());

          // we should have 0 exceptions
          assertEquals(0, exceptions.size());
       }
       finally
       {
          if (cache != null) cache.stopService();
       }
    }
View Full Code Here

   private static void help() {
      System.out.println("RpcDelegatingCacheLoadeTest [client / server]");
   }

   private void start(boolean client) throws Exception {
      cache=new TreeCache("test-cluster", null, 3000);
      cache.setCacheMode(TreeCache.REPL_ASYNC);
      cache.setFetchInMemoryState(true);
      cache.setCacheLoaderConfiguration(getCacheLoaderConfig());
      cache.setTransactionManagerLookupClass("org.jboss.cache.DummyTransactionManagerLookup");
      cache.startService();
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

    }

    protected void setUp() throws Exception
    {
        if (cache != null) tearDown();
        cache = new TreeCache();
        cache.setCacheLoaderConfiguration(getSingleCacheLoaderConfig("", DummyCacheLoader.class.getName(), "", false, false, false));
        cache.startService();
        dummyLoader = (DummyCacheLoader) cache.getCacheLoader();
    }
View Full Code Here

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

      if (p == null) {
         p = new Properties();
         p.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.cache.transaction.DummyContextFactory");
      }

      cache = new TreeCache();

      PropertyConfigurator config = new PropertyConfigurator();
      config.configure(cache, "META-INF/local-lru-eviction-service.xml");

      // XML file above only sets REPEATABLE-READ
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.