Package org.jboss.cache

Examples of org.jboss.cache.CacheSPI


   @BeforeMethod
   public void clearCacheLoader() throws Exception
   {
      for (CacheManager mgr: getCacheManagers())
      {
         CacheSPI cache = (CacheSPI) mgr.getCache(getCacheConfigName(), false);
         CacheLoader cl = cache.getCacheLoaderManager().getCacheLoader();
         cl.remove(Fqn.ROOT);
      }
   }
View Full Code Here


   @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

   private Configuration c;

   @BeforeMethod(alwaysRun = true)
   public void setUp() throws Exception
   {
      CacheSPI cache = (CacheSPI) new UnitTestCacheFactory<Object, Object>().createCache(getClass());
      r = cache.getRegionManager();
      c = cache.getConfiguration();
   }
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

      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

   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, getClass());
      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

      Configuration c = UnitTestConfigurationFactory.createConfiguration(CacheMode.REPL_ASYNC);
      //c.setClusterName("VersionedTestBase");
      c.setReplVersionString(getReplicationVersion());
      // Use a long timeout to facilitate setting debugger breakpoints
      c.setStateRetrievalTimeout(60000);
      CacheSPI cache = (CacheSPI) new UnitTestCacheFactory<Object, Object>().createCache(c, false, getClass());

      // Put the cache in the map before starting, so if it fails in
      // start it can still be destroyed later
      caches.put("secretive", cache);

      // inject our own message listener and re-wire deps
      ComponentRegistry cr = TestingUtil.extractComponentRegistry(cache);
//      cr.unregisterComponent(ChannelMessageListener.class);
      cr.registerComponent(new SecretiveStateCacheMessageListener(), ChannelMessageListener.class);
//      cr.updateDependencies();

      cache.start();


      c= UnitTestConfigurationFactory.createConfiguration(CacheMode.REPL_ASYNC);
      //c.setClusterName("VersionedTestBase");
      c.setReplVersionString(getReplicationVersion());
      // Use a long timeout to facilitate setting debugger breakpoints
      c.setStateRetrievalTimeout(60000);
      CacheSPI recipient = (CacheSPI) new UnitTestCacheFactory<Object, Object>().createCache(c, false, getClass());

      //Put the cache in the map before starting, so if it fails in
      // start it can still be destroyed later
      caches.put("secretive2", recipient);

      // inject our own message listener and re-wire deps
      cr = TestingUtil.extractComponentRegistry(recipient);
      cr.registerComponent(new SecretiveStateCacheMessageListener(), ChannelMessageListener.class);

      try
      {
         recipient.start();
         fail("start() should throw an exception");
      }
      catch (CacheException good)
      {
         // this is what we want
View Full Code Here

public class OptimisticWithCacheLoaderTest extends AbstractOptimisticTestCase
{

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

      // test the cache loader independently first ...
      loader.remove(fqn);
      assert loader.get(fqn) == null;
      loader.put(fqn, key, value);
View Full Code Here

               cacheServer.setBindAddress(TCP_CACHE_SERVER_HOST);
               cacheServer.setPort(TCP_CACHE_SERVER_PORT);
               Configuration config = UnitTestConfigurationFactory.createConfiguration(Configuration.CacheMode.LOCAL, true);
               // disable eviction!!
               config.setEvictionConfig(null);
               CacheSPI cache = (CacheSPI) new UnitTestCacheFactory<Object, Object>().createCache(config, getClass());
               cacheServer.setCache(cache);
               cacheServer.create();
               cacheServer.start();
               START_COUNT++;
               startedSignal.countDown();
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.