Package org.jboss.cache

Examples of org.jboss.cache.CacheSPI


   @BeforeMethod
   public void setUp()
   {
      notifier = new NotifierImpl();
      CacheSPI cacheSPI = createNiceMock(CacheSPI.class);
      expect(cacheSPI.getInvocationContext()).andStubReturn(new MVCCInvocationContext());
      replay(cacheSPI);
      notifier.injectDependencies(cacheSPI, new Configuration());
      notifier.start();
      ctx = new MVCCInvocationContext();
      allEventsListener = new AllEventsListener();
View Full Code Here


            "", false, false, false, false, false);
   }

   private CacheSPI createLocalCache() throws Exception
   {
      CacheSPI cache = createCacheUnstarted(true);
      cache.getConfiguration().setCacheLoaderConfig(getCacheLoaderConfig());

      cache.create();
      cache.start();
      return cache;
   }
View Full Code Here

   {
      Configuration config = new Configuration();
      config.setCacheMode(Configuration.CacheMode.LOCAL);
      config.setNodeLockingScheme(Configuration.NodeLockingScheme.MVCC);
      CacheFactory cacheFactory2 = new UnitTestCacheFactory<Object, Object>();
      CacheSPI tmpCacheSPI = (CacheSPI) cacheFactory2.createCache(config);
      defaultInterceptroCount = tmpCacheSPI.getInterceptorChain().size();
      tmpCacheSPI.stop();

      CacheFactory cacheFactory = new UnitTestCacheFactory<Object, Object>();
      config.setCustomInterceptors(interceptorConfig);
      cache = (CacheSPI) cacheFactory.createCache(config, true);
   }
View Full Code Here

   }

   private void test2CachesSync(boolean optimistic) throws Exception
   {
      caches = new CacheSPI[2];
      CacheSPI cache0 = createCache(optimistic);
      CacheSPI cache1 = createCache(optimistic);
      caches[0] = cache0;
      caches[1] = cache1;

      TestingUtil.blockUntilViewsReceived(caches, 2000);
View Full Code Here

      return cache;
   }

   public void testPassivationLocal() throws Exception
   {
      CacheSPI cache = createLocalCache();
      CacheLoader loader = cache.getCacheLoaderManager().getCacheLoader();

      // clean up
      cache.removeNode(fqn);
      loader.remove(fqn);

      assertNull(loader.get(fqn));

      DummyTransactionManager mgr = DummyTransactionManager.getInstance();

      // put something in the cache
      mgr.begin();
      cache.put(fqn, key, value);
      mgr.commit();

      // should be nothing in the loader
      assertEquals(value, cache.get(fqn, key));
      assertNull(loader.get(fqn));

      // evict from cache
      mgr.begin();
      cache.evict(fqn);
      mgr.commit();

      mgr.begin();
      // should now be passivated in the loader
      // don't do a cache.get() first as this will activate this node from the loader again!
      // assertNull( cache.get( fqn ) );
      assertEquals(value, loader.get(fqn).get(key));

      // now do a cache.get()...
      assertEquals(value, cache.get(fqn, key));

      // and the object should now be removed from the loader
      assertNull(loader.get(fqn));
      mgr.commit();

      // clean up
      mgr.begin();
      cache.removeNode(fqn);
      loader.remove(fqn);
      mgr.commit();

   }
View Full Code Here

      c.setStateRetrievalTimeout(5000);
      c.setCacheMode(Configuration.CacheMode.REPL_SYNC);
      c.setIsolationLevel(IsolationLevel.REPEATABLE_READ);
      c.setTransactionManagerLookupClass("org.jboss.cache.transaction.DummyTransactionManagerLookup");

      CacheSPI cache = (CacheSPI) new UnitTestCacheFactory<Object, Object>().createCache(c, false);

      cache.create();
      cache.start();


      return cache;
   }
View Full Code Here

      c.setCacheMode(Configuration.CacheMode.LOCAL);
      c.setIsolationLevel(IsolationLevel.REPEATABLE_READ);
      c.setTransactionManagerLookupClass("org.jboss.cache.transaction.DummyTransactionManagerLookup");

      CacheSPI cache = (CacheSPI) new UnitTestCacheFactory<Object, Object>().createCache(false);
      cache.create();
      cache.start();


      return cache;
   }
View Full Code Here

   protected abstract void assertLocked(Fqn fqn, CacheSPI cache, boolean writeLocked);

   protected TransactionWorkspace extractTransactionWorkspace(Cache c)
   {
      CacheSPI cs = (CacheSPI) c;
      try
      {
         GlobalTransaction gtx = cs.getTransactionTable().get(cs.getTransactionManager().getTransaction());
         OptimisticTransactionContext entry = (OptimisticTransactionContext) cs.getTransactionTable().get(gtx);
         return entry.getTransactionWorkSpace();
      }
      catch (SystemException e)
      {
         e.printStackTrace();
View Full Code Here

   ThreadLocal<CacheSPI> delegating_cacheTL = new ThreadLocal<CacheSPI>();
   //ThreadLocal<CacheLoader> cache_loaderTL = new ThreadLocal<CacheLoader>();

   protected void configureCache() throws Exception
   {
      CacheSPI delegating_cache = (CacheSPI) new UnitTestCacheFactory<Object, Object>().createCache(false);
      delegating_cache.getConfiguration().setCacheMode(Configuration.CacheMode.LOCAL);
      delegating_cache.create();
      delegating_cache.start();
      delegating_cacheTL.set(delegating_cache);

      LocalDelegatingCacheLoaderConfig cfg = new LocalDelegatingCacheLoaderConfig();
      cfg.setDelegate(delegating_cache);
      cfg.setAsync(false);
View Full Code Here

   @AfterMethod(alwaysRun = true)
   public void tearDown() throws Exception
   {
      super.tearDown();
      CacheSPI delegating_cache = delegating_cacheTL.get();
      delegating_cacheTL.set(null);
      TestingUtil.killCaches(delegating_cache);
      delegating_cache = null;
     
   }
View Full Code Here

TOP

Related Classes of org.jboss.cache.CacheSPI

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.