Package org.infinispan.loaders

Examples of org.infinispan.loaders.CacheStore


   public void testPutFromNonOwner() throws Exception {
      String key = "k2", value = "value2";
      for (Cache<Object, String> c : caches) assert c.isEmpty();
      Cache<Object, String> nonOwner = getFirstNonOwner(key);
      Cache<Object, String> owner = getFirstOwner(key);
      CacheStore nonOwnerStore = TestingUtil.extractComponent(nonOwner, CacheLoaderManager.class).getCacheStore();
      CacheStore ownerStore = TestingUtil.extractComponent(owner, CacheLoaderManager.class).getCacheStore();
      assert !nonOwnerStore.containsKey(key);
      assert !ownerStore.containsKey(key);
      Object retval = nonOwner.put(key, value);
      assert !nonOwnerStore.containsKey(key);
      assert ownerStore.containsKey(key);
      if (testRetVals) assert retval == null;
      assertOnAllCachesAndOwnership(key, value);
   }
View Full Code Here


   public void testGetFromNonOwnerWithFlags() throws Exception {
      String key = "k2", value = "value2";
      for (Cache<Object, String> c : caches) assert c.isEmpty();
      Cache<Object, String> nonOwner = getFirstNonOwner(key);
      Cache<Object, String> owner = getFirstOwner(key);
      CacheStore ownerStore = TestingUtil.extractComponent(owner, CacheLoaderManager.class).getCacheStore();
      owner.put(key, value);
      assert value.equals(ownerStore.load(key).getValue());
      owner.getAdvancedCache().withFlags(Flag.SKIP_CACHE_STORE).clear();
      assert value.equals(ownerStore.load(key).getValue());
      assert owner.getAdvancedCache().withFlags(Flag.SKIP_CACHE_STORE).get(key) == null;
      assert nonOwner.getAdvancedCache().withFlags(Flag.SKIP_CACHE_STORE).get(key) == null;
      assert value.equals(nonOwner.get(key));
      // need to do the get() on all the owners first to load the values, otherwise assertOwnershipAndNonOwnership might fail
      assertOnAllCaches(key, value);
View Full Code Here

   public void testPutFromNonOwnerWithFlags() throws Exception {
      String key = "k2", value = "value2";
      for (Cache<Object, String> c : caches) assert c.isEmpty();
      Cache<Object, String> nonOwner = getFirstNonOwner(key);
      Cache<Object, String> owner = getFirstOwner(key);
      CacheStore nonOwnerStore = TestingUtil.extractComponent(nonOwner, CacheLoaderManager.class).getCacheStore();
      CacheStore ownerStore = TestingUtil.extractComponent(owner, CacheLoaderManager.class).getCacheStore();
      assert !nonOwnerStore.containsKey(key);
      assert !ownerStore.containsKey(key);
      Object retval = nonOwner.getAdvancedCache().withFlags(Flag.SKIP_CACHE_STORE).put(key, value);
      assert !nonOwnerStore.containsKey(key);
      assert !ownerStore.containsKey(key);
      if (testRetVals) assert retval == null;
      assertOnAllCachesAndOwnership(key, value);
   }
View Full Code Here

   public void testPutFromOwner() throws Exception {
      String key = "k3", value = "value3";
      for (Cache<Object, String> c : caches) assert c.isEmpty();
      getOwners(key)[0].put(key, value);
      for (Cache<Object, String> c : caches) {
         CacheStore store = TestingUtil.extractComponent(c, CacheLoaderManager.class).getCacheStore();
         if (isOwner(c, key)) {
            assertIsInContainerImmortal(c, key);
            assert store.containsKey(key);
         } else {
            assertIsNotInL1(c, key);
            assert !store.containsKey(key);
         }
      }
   }
View Full Code Here

                private CacheStoreConfig createCacheLoaderConfig(ModelNode store, List<Map.Entry<String, Injector<String>>> injectors) {
                    if (store.hasDefined(ModelKeys.CLASS)) {
                        String className = store.get(ModelKeys.CLASS).asString();
                        try {
                            CacheStore cacheStore = Class.forName(className).asSubclass(CacheStore.class).newInstance();
                            return cacheStore.getConfigurationClass().asSubclass(CacheStoreConfig.class).newInstance();
                        } catch (Exception e) {
                            throw new IllegalArgumentException(String.format("%s is not a valid cache store", className), e);
                        }
                    }
                    // If no class, we assume it's a file cache store
View Full Code Here

         if (shouldTransferOwnershipToJoinNode(k)) {           
             state.put(k, ice.toInternalCacheValue());
         }
      }

      CacheStore cacheStore = distributionManager.getCacheStoreForRehashing();
      if (cacheStore != null) {
         for (Object k: cacheStore.loadAllKeys(new ReadOnlyDataContainerBackedKeySet(dataContainer))) {
            if (!state.containsKey(k) && shouldTransferOwnershipToJoinNode(k)) {               
               InternalCacheValue v = loadValue(cacheStore, k);              
               if (v != null) state.put(k, v);
            }
         }
View Full Code Here

         if (shouldTransferOwnershipFromLeftNodes(k)) {
            state.put(k, ice.toInternalCacheValue());
         }
      }

      CacheStore cacheStore = distributionManager.getCacheStoreForRehashing();
      if (cacheStore != null) {
         for (Object k : cacheStore.loadAllKeys(new ReadOnlyDataContainerBackedKeySet(dataContainer))) {
            if (!state.containsKey(k) && shouldTransferOwnershipFromLeftNodes(k)) {
               InternalCacheValue v = loadValue(cacheStore, k);              
               if (v != null)
                  state.put(k, v);
            }
View Full Code Here

   @Override
   public Object perform(InvocationContext ctx) throws Throwable {
      // To avoid reliance of a thread local flag, get a reference for the
      // cache store to be able to clear it after cache has stopped.
      CacheStore store = cacheLoaderManager.getCacheStore();
      cacheManager.getCache(cacheName).stop();

      // After stopping the cache, clear it
      if (store != null)
         store.clear();

      registry.removeCache(cacheName);
      return null;
   }
View Full Code Here

      }

      @Override
      public void onEntryRemoved(Object key) {
         try {
            CacheStore cacheStore = clm.getCacheStore();
            if (cacheStore != null)
               cacheStore.remove(key);
         } catch (CacheLoaderException e) {
            throw new CacheException(e);
         }
      }
View Full Code Here

   }

   private void parseStore(final XMLExtendedStreamReader reader, final ConfigurationBuilderHolder holder) throws XMLStreamException {
      ConfigurationBuilder builder = holder.getCurrentConfigurationBuilder();
      CacheStore store = null;
      Boolean fetchPersistentState = null;
      Boolean ignoreModifications = null;
      Boolean purgeOnStartup = null;
      Integer purgerThreads = null;
      Boolean purgeSynchronously = null;
View Full Code Here

TOP

Related Classes of org.infinispan.loaders.CacheStore

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.