Package org.infinispan.loaders

Examples of org.infinispan.loaders.CacheStore


      c1.clear();
      for (Cache<Object, String> c : caches) assert c.isEmpty();
      for (int i = 0; i < 5; i++) {
         String key = "k" + i;
         for (Cache<Object, String> c : caches) {
            CacheStore store = TestingUtil.extractComponent(c, CacheLoaderManager.class).getCacheStore();
            assert !store.containsKey(key);
         }
      }
   }
View Full Code Here


   public void testClearWithFlag() throws Exception {
      prepareClearTest();
      c1.getAdvancedCache().withFlags(Flag.SKIP_CACHE_STORE).clear();
      for (Cache<Object, String> c : caches) {
         assert c.isEmpty() : "Data container " + c + " should be empty, instead it contains keys " + c.keySet();
         CacheStore store = TestingUtil.extractComponent(c, CacheLoaderManager.class).getCacheStore();
         for (int i = 0; i < 5; i++) {
            String key = "k" + i;
            if (isOwner(c, key)) {
               assert store.containsKey(key);
            }
         }
      }
   }
View Full Code Here

      }
      // this will fill up L1 as well
      for (int i = 0; i < 5; i++) assertOnAllCachesAndOwnership("k" + i, "value" + i);
      for (Cache<Object, String> c : caches) {
         assert !c.isEmpty();
         CacheStore store = TestingUtil.extractComponent(c, CacheLoaderManager.class).getCacheStore();
         for (int i = 0; i < 5; i++) {
            String key = "k" + i;
            if (isOwner(c, key)) {
               assert store.containsKey(key) : "Cache store " + c + " does not contain key " + key;
            }
         }
      }
   }
View Full Code Here

   public void testPutFromNonOwner() throws Exception {
      String key = "k4", value = "value4";
      for (Cache<Object, String> c : caches) assert c.isEmpty();
      Cache<Object, String> nonOwner = getFirstNonOwner(key);
      CacheStore nonOwnerStore = TestingUtil.extractComponent(nonOwner, CacheLoaderManager.class).getCacheStore();
      assert !nonOwnerStore.containsKey(key);
      Object retval = nonOwner.put(key, value);
      asyncWait(key, PutKeyValueCommand.class, getSecondNonOwner(key));

      Cache[] owners = getOwners(key);
      CacheStore store = TestingUtil.extractComponent(owners[0], CacheLoaderManager.class).getCacheStore();
      assertIsInContainerImmortal(owners[0], key);
      assert store.containsKey(key);

      for (int i = 1; i < owners.length; i++) {
         store = TestingUtil.extractComponent(owners[i], CacheLoaderManager.class).getCacheStore();
         assertIsInContainerImmortal(owners[i], key);
         assert store.containsKey(key);
      }

      for (Cache<Object, String> c : caches) {
         store = TestingUtil.extractComponent(c, CacheLoaderManager.class).getCacheStore();
         assert store.containsKey(key);
         assertNumberOfInvocations(store, "store", 1);
      }

      if (testRetVals) assert retval == null;
      assertOnAllCachesAndOwnership(key, value);
View Full Code Here

      String key = "k5", value = "value5";
      for (Cache<Object, String> c : caches) assert c.isEmpty();
      Cache[] owners = getOwners(key);
      Object retval = owners[0].put(key, value);
      asyncWait(key, PutKeyValueCommand.class, getNonOwners(key));
      CacheStore store = TestingUtil.extractComponent(owners[0], CacheLoaderManager.class).getCacheStore();
      assertIsInContainerImmortal(owners[0], key);
      assert store.containsKey(key);

      for (int i = 1; i < owners.length; i++) {
         store = TestingUtil.extractComponent(owners[i], CacheLoaderManager.class).getCacheStore();
         assertIsInContainerImmortal(owners[i], key);
         assert store.containsKey(key);
      }

      for (Cache<Object, String> c : caches) {
         store = TestingUtil.extractComponent(c, CacheLoaderManager.class).getCacheStore();
         if (isOwner(c, key)) {
            assertIsInContainerImmortal(c, key);
         }
         assert store.containsKey(key);
         assertNumberOfInvocations(store, "store", 1);
      }

      if (testRetVals) assert retval == null;
      assertOnAllCachesAndOwnership(key, value);
View Full Code Here

      data.put(k4, v4);

      c1.putAll(data);
      for (String key : keys) {
         for (Cache<Object, String> c : caches) {
            CacheStore store = TestingUtil.extractComponent(c, CacheLoaderManager.class).getCacheStore();
            if (isFirstOwner(c, key)) {
               assertIsInContainerImmortal(c, key);
            }
            log.debug("Testing " + c);
            assertNumberOfInvocations(store, "store", 4);
            assert store.containsKey(key);
         }
      }
   }
View Full Code Here

   public void testRemoveFromNonOwner() throws Exception {
      String key = "k1", value = "value";
      initAndTest();

      for (Cache<Object, String> c : caches) {
         CacheStore store = TestingUtil.extractComponent(c, CacheLoaderManager.class).getCacheStore();
         if (isFirstOwner(c, key)) {
            assertIsInContainerImmortal(c, key);
            assert store.load(key).getValue().equals(value);
         }
      }

      Object retval = getFirstNonOwner(key).remove(key);
      asyncWait("k1", RemoveCommand.class, getSecondNonOwner("k1"));
      if (testRetVals) assert value.equals(retval);
      for (Cache<Object, String> c : caches) {
         CacheStore store = TestingUtil.extractComponent(c, CacheLoaderManager.class).getCacheStore();
         assert !store.containsKey(key);
         assertNumberOfInvocations(store, "remove", 1);
      }
   }
View Full Code Here

   public void testReplaceFromNonOwner() throws Exception {
      String key = "k1", value = "value", value2 = "v2";
      initAndTest();

      for (Cache<Object, String> c : caches) {
         CacheStore store = TestingUtil.extractComponent(c, CacheLoaderManager.class).getCacheStore();
         if (isFirstOwner(c, key)) {
            assertIsInContainerImmortal(c, key);
            assert store.load(key).getValue().equals(value);
         }
      }

      Object retval = getFirstNonOwner(key).replace(key, value2);
      asyncWait(key, ReplaceCommand.class, getSecondNonOwner(key));
      if (testRetVals) assert value.equals(retval);
      for (Cache<Object, String> c : caches) {
         CacheStore store = TestingUtil.extractComponent(c, CacheLoaderManager.class).getCacheStore();
         if (isFirstOwner(c, key)) {
            assertIsInContainerImmortal(c, key);
         }
         assert store.load(key).getValue().equals(value2);
         assertNumberOfInvocations(store, "store", 2);
      }
   }
View Full Code Here

      /* We only check c1 because on a shared situation, no matter where the clear is called,
       * it should clear the whole store regardless. Bear in mind that in the test, even though
       * the cache store is shared, each cache has each own cache store, that allows for checking
       * who execute puts, removes...etc. */
      CacheStore store = TestingUtil.extractComponent(c1, CacheLoaderManager.class).getCacheStore();
      for (int i = 0; i < 5; i++) {
         String key = "k" + i;
         assert !store.containsKey(key);
         assertNumberOfInvocations(store, "clear", 1);
      }
   }
View Full Code Here

            Mapper<String, String, String, Integer> mapper, Reducer<String, Integer> reducer, boolean useCombiner)
            throws Exception {
      Cache cache1 = cache(0, cacheName());
      Cache cache2 = cache(1, cacheName());

      CacheStore c1 = getStore(cache1);
      CacheStore c2 = getStore(cache2);

      //store each entry into each cache store directly
      c1.store(toEntry("1", "Hello world here I am"));
      c2.store(toEntry("1", "Hello world here I am"));
      c1.store(toEntry("2", "Infinispan rules the world"));
      c2.store(toEntry("2", "Infinispan rules the world"));
      c1.store(toEntry("3", "JUDCon is in Boston"));
      c2.store(toEntry("3", "JUDCon is in Boston"));
      c1.store(toEntry("4", "JBoss World is in Boston as well"));
      c2.store(toEntry("4", "JBoss World is in Boston as well"));
      c1.store(toEntry("12","JBoss Application Server"));
      c2.store(toEntry("12","JBoss Application Server"));
      c1.store(toEntry("15", "Hello world"));
      c2.store(toEntry("15", "Hello world"));
      c1.store(toEntry("14", "Infinispan community"));
      c2.store(toEntry("14", "Infinispan community"));

      c1.store(toEntry("111", "Infinispan open source"));
      c2.store(toEntry("111", "Infinispan open source"));
      c1.store(toEntry("112", "Boston is close to Toronto"));
      c2.store(toEntry("112", "Boston is close to Toronto"));
      c1.store(toEntry("113", "Toronto is a capital of Ontario"));
      c2.store(toEntry("113", "Toronto is a capital of Ontario"));
      c1.store(toEntry("114", "JUDCon is cool"));
      c2.store(toEntry("114", "JUDCon is cool"));
      c1.store(toEntry("211", "JBoss World is awesome"));
      c2.store(toEntry("211", "JBoss World is awesome"));
      c1.store(toEntry("212", "JBoss rules"));
      c2.store(toEntry("212", "JBoss rules"));
      c1.store(toEntry("213", "JBoss division of RedHat "));
      c2.store(toEntry("213", "JBoss division of RedHat "));
      c1.store(toEntry("214", "RedHat community"));
      c2.store(toEntry("214", "RedHat community"));

      MapReduceTask<String, String, String, Integer> task = createMapReduceTask(cache1);
      task.mappedWith(mapper).reducedWith(reducer);
      if(useCombiner)
         task.combinedWith(reducer);
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.