Package org.jboss.cache

Examples of org.jboss.cache.CacheSPI


   public void testInjectCacheJmxWrapper() throws Exception
   {
      createTcpCacheServer();
      Configuration conf = UnitTestConfigurationFactory.createConfiguration(Configuration.CacheMode.LOCAL, true);
      CacheSPI cacheSPI = (CacheSPI) new UnitTestCacheFactory<Object, Object>().createCache(conf, getClass());
      CacheJmxWrapper wrapper = new CacheJmxWrapper<Object, Object>(cacheSPI);
      wrapper.start();
      cache_server.setCacheJmxWrapper(wrapper);
      startTcpCacheServer();
      createCacheAndLoader();
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

      assert ((DefaultDataVersion) observerNode.getVersion()).getRawVersion() == 10 : "Version should be updated";
   }

   public void testTombstoneVersioningFailure() throws Exception
   {
      CacheSPI modifierImpl = (CacheSPI) modifier;
      CacheSPI observerImpl = (CacheSPI) observer;

      modifier.put(parent, K, V);


      // test that this exists in the (shared) loader
      assert loader.get(parent) != null;
      assert loader.get(parent).size() > 0;

      modifier.removeNode(parent);

      // assert that tombstones exist on both instances
      assert modifierImpl.peek(parent, true, true) != null;
      assert observerImpl.peek(parent, true, true) != null;
      assert modifierImpl.peek(parent, false, false) == null;
      assert observerImpl.peek(parent, false, false) == null;

      // make sure this does not exist in the loader; since it HAS been removed
      assert loader.get(parent) == null;

      NodeSPI observerNode = (NodeSPI) observer.getRoot().getChild(parent);
      assert observerNode == null : "Should be removed";

      // now try a put on a with a newer data version; should work
      modifier.getInvocationContext().getOptionOverrides().setDataVersion(new DefaultDataVersion(1));
      try
      {
         modifier.put(parent, K, V);
         assert false : "Should have barfed!";
      }
      catch (RuntimeException expected)
      {

      }

      NodeSPI modifierNode = (NodeSPI) modifier.getRoot().getChild(parent);
      assert modifierNode == null : "Should be null";

      observerNode = (NodeSPI) observer.getRoot().getChild(parent);
      assert observerNode == null : "Should be null";

      NodeSPI modifierTombstone = modifierImpl.peek(parent, true, true);
      NodeSPI observerTombstone = observerImpl.peek(parent, true, true);

      assert modifierTombstone != null : "Tombstone should still exist";
      assert observerTombstone != null : "Tombstone should still exist";

      assert !modifierTombstone.isValid() : "Should not be valid";
View Full Code Here

      // disable state transfer!!
      cache.getConfiguration().setFetchInMemoryState(false);

      cache.start();

      CacheSPI spi = (CacheSPI) cache;

      loader = (DummySharedInMemoryCacheLoader) spi.getCacheLoaderManager().getCacheLoader();

      return cache;
   }
View Full Code Here

   {     
      Configuration conf = UnitTestConfigurationFactory.getEmptyConfiguration();
      conf.setCacheMode(Configuration.CacheMode.REPL_SYNC);
      conf.setNodeLockingScheme(Configuration.NodeLockingScheme.PESSIMISTIC);
      conf.setFetchInMemoryState(false);
      CacheSPI c = (CacheSPI) new UnitTestCacheFactory<Object, Object>().createCache(conf, false, getClass());
      if (!notifying)
      {
         c.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.transaction.DummyTransactionManagerLookup");
      }
      else
      {
         c.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.transaction.NotifyingTransactionManager");
      }
      c.start();
      return c;
   }
View Full Code Here

      EvictionConfig evictionConfig = new EvictionConfig();
      evictionConfig.setWakeupInterval(-1);
      c.setEvictionConfig(evictionConfig);
      EvictionRegionConfig erc = new EvictionRegionConfig(fqn, config);
      c.getEvictionConfig().addEvictionRegionConfig(erc);
      CacheSPI mockCache = EasyMock.createNiceMock(CacheSPI.class);
      EasyMock.replay(mockCache);
      ((RegionManagerImpl) regionManager).injectDependencies(mockCache, c, null, null, null, new RegionRegistry());
      Region r = regionManager.getRegion(fqn, Region.Type.EVICTION, true);
      r.setEvictionRegionConfig(erc);
View Full Code Here

   protected CacheSPI createCache() throws Exception
   {
      UnitTestCacheFactory factory = new UnitTestCacheFactory();
      Configuration cfg = UnitTestConfigurationFactory.createConfiguration(CacheMode.LOCAL);
      cfg.setIsolationLevel(IsolationLevel.REPEATABLE_READ);     
      CacheSPI cache = (CacheSPI) factory.createCache(cfg, true, getClass());
      return cache;
   }
View Full Code Here

      assertEquals(nbWriters, get());
   }

   public void testConcurrentUpdatesWriteSkew(Method m) throws Exception {
      final int nbWriters = 10;
      CacheSPI cache = null;
      try {
         log.debug(m.getName());
         UnitTestCacheFactory factory = new UnitTestCacheFactory();
         Configuration cfg = UnitTestConfigurationFactory.createConfiguration(CacheMode.LOCAL);
         cfg.setIsolationLevel(IsolationLevel.REPEATABLE_READ);
         cfg.setWriteSkewCheck(true);
         cache = (CacheSPI) factory.createCache(cfg, false, getClass());
         cache.start();        
         assert cache.getConfiguration().isWriteSkewCheck();
         init();
         CyclicBarrier barrier = new CyclicBarrier(nbWriters + 1);
         List<Future<Void>> futures = new ArrayList<Future<Void>>(nbWriters);
         for (int i = 0; i < nbWriters; i++) {
            log.debug("Schedule execution");
View Full Code Here

      return getClass().getSimpleName() + " [ fqn=" + getFqn() + " " + sb + "ver=" + version + " " + (isVersioningImplicit() ? "implicit" : "explicit") + "]";
   }

   public Node<K, V> addChild(Fqn f)
   {
      CacheSPI cache = getCache();
      Node<K, V> newNode = this;
      GlobalTransaction gtx = cache.getInvocationContext().getGlobalTransaction();

      if (f.size() == 1)
      {
         newNode = createChild(f.get(0), node, getCache(), version);
      }
View Full Code Here

      return getClass().getSimpleName() + " [ fqn=" + getFqn() + " " + sb + "ver=" + version + " " + (versioningImplicit ? "implicit" : "explicit") + "]";
   }

   public Node<K, V> addChild(Fqn f)
   {
      CacheSPI cache = getCache();
      Node<K, V> newNode = this;
      GlobalTransaction gtx = cache.getInvocationContext().getGlobalTransaction();

      if (f.size() == 1)
      {
         newNode = createChild(f.get(0), node, getCache(), version);
      }
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.