Examples of CacheStore


Examples of com.volantis.mcs.cache.CacheStore

        cacheTime.expects.getTimeInMillis().returns(210);
        cacheTime.expects.getTimeInMillis().returns(220);
        cacheTime.expects.getTimeInMillis().returns(Integer.MAX_VALUE);

        // Create a new DefaultCacheStore with a TTL of 100
        CacheStore defaultCacheStore = new DefaultCacheStore(cacheTime,100);

        CacheEntry entry1 = new CSSCacheEntry(writableCSSEntityMock1);
        CacheEntry entry2 = new CSSCacheEntry(writableCSSEntityMock2, 50);
        CacheEntry entry3 = new CSSCacheEntry(writableCSSEntityMock2, 150);

        // We add the first identity which should get a cacheTime of 0,
        // expiresTime of 100 and a sequence number of 0
        CacheIdentity identity1 = defaultCacheStore.store(entry1);
        assertEquals("T1", identity1.getCreateTime(),0);
        assertEquals("T2", identity1.getExpiresTime(),100);
        assertEquals("T3", identity1.getSequenceNo(),0);

        // We add the second identity which should get a cacheTime of 10,
        // expiresTime of max(10+50,10+100)=110 and a sequence number of 1
        CacheIdentity identity2 = defaultCacheStore.store(entry2);
        assertEquals("T4", identity2.getCreateTime(),10);
        assertEquals("T5", identity2.getExpiresTime(),110);
        assertEquals("T6", identity2.getSequenceNo(),1);

        // We add the third identity which should get a cacheTime of 20,
        // expiresTime of max(20+150,20+100)=170 and a sequence number of 2
        CacheIdentity identity3 = defaultCacheStore.store(entry3);
        assertEquals("T7", identity3.getCreateTime(),20);
        assertEquals("T8", identity3.getExpiresTime(),170);
        assertEquals("T9", identity3.getSequenceNo(),2);

        // Retrieve expired identities that are as old or older
        // than 25 - TTL (should be none).
        assertNull("T10", defaultCacheStore.retrieveOldestExpiredIdentity());

        // Remove entries that are as old or older
        // than 30 - TTL (Should be none).
        defaultCacheStore.removeExpiredIdentities();

        // Retrieve expired identities that are as old or older
        // than 99 - TTL (should be none).
        assertNull("T11", defaultCacheStore.retrieveOldestExpiredIdentity());

        // Retrieve expired identities that are as old or older
        // than 100 - TTL (should be identity1).
        assertEquals("T12", defaultCacheStore.retrieveOldestExpiredIdentity(),
                identity1);

        // Remove entries that are as old or older
        // than 100 - TTL (Should be identity1). Note we will call cacheTime
        // two times to look up to first non-expires entry.
        defaultCacheStore.removeExpiredIdentities();

        // Retrieve expired identities that are as old or older
        // than 100 - TTL (should be none as we deleted identity1).
        assertNull("T13", defaultCacheStore.retrieveOldestExpiredIdentity());

        // Retrieve expired identities that are as old or older
        // than 110 - TTL (should be identity2).
        assertEquals("T14", defaultCacheStore.retrieveOldestExpiredIdentity(),
                identity2);

        // Retrieve expired identities that are as old or older
        // than 200 - TTL (should be still identity2).
        assertEquals("T15", defaultCacheStore.retrieveOldestExpiredIdentity(),
                identity2);

        // Remove entries that are as old or older
        // than 210 - TTL (Should be identity1). Note we will call cacheTime
        // one time to look up to first non-expires entry.
        defaultCacheStore.removeExpiredIdentities();

        // Retrieve expired identities that are as old or older
        // than 220 - TTL (should be none).
        assertEquals("T16", defaultCacheStore.retrieveOldestExpiredIdentity(),
                null);
       
        // Final test for expected number of getTimeInMillis() calls.
        assertEquals("T17", Integer.MAX_VALUE, cacheTime.getTimeInMillis());
    }
View Full Code Here

Examples of org.directmemory.CacheStore

  public static CacheStore cache = null;
  public static Split wholeTestSplit = null;
 
  @BeforeClass
  public static void setup() {
    cache = new CacheStore(100, 10 * 1024 * 1024, 1);
    cache.serializer = new ProtoStuffSerializer();
//    cache.supervisor = new AsyncBatchSupervisor(750);
    cache.supervisor = new TimedSupervisor(1500);
  }
View Full Code Here

Examples of org.infinispan.loaders.CacheStore

   }

   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

Examples of org.infinispan.loaders.CacheStore

               sendEntry(ice, segmentId);
            }
         }

         // send cache store entries if needed
         CacheStore cacheStore = getCacheStore();
         if (cacheStore != null) {
            try {
               //todo [anistor] need to extend CacheStore interface to be able to specify a filter when loading keys (ie. keys should belong to desired segments)
               Set<Object> storedKeys = cacheStore.loadAllKeys(new ReadOnlyDataContainerBackedKeySet(dataContainer));
               for (Object key : storedKeys) {
                  int segmentId = readCh.getSegment(key);
                  if (segments.contains(segmentId)) {
                     try {
                        InternalCacheEntry ice = cacheStore.load(key);
                        if (ice != null) { // check entry still exists
                           sendEntry(ice, segmentId);
                        }
                     } catch (CacheLoaderException e) {
                        log.failedLoadingValueFromCacheStore(key, e);
View Full Code Here

Examples of org.infinispan.loaders.CacheStore

         } else if (!newSegments.contains(keySegment)) {
            keysToRemove.add(key);
         }
      }

      CacheStore cacheStore = getCacheStore();
      if (cacheStore != null) {
         //todo [anistor] extend CacheStore interface to be able to specify a filter when loading keys (ie. keys should belong to desired segments)
         try {
            Set<Object> storedKeys = cacheStore.loadAllKeys(new ReadOnlyDataContainerBackedKeySet(dataContainer));
            for (Object key : storedKeys) {
               int keySegment = getSegment(key);
               if (segmentsToL1.contains(keySegment)) {
                  keysToL1.add(key);
               } else if (!newSegments.contains(keySegment)) {
View Full Code Here

Examples of org.infinispan.loaders.CacheStore

      for(int i = 0; i < 4; i++){
         cache.put(cacheManagers.get(0).getAddress().toString()+"-"+i, "42");
      }

      // lets check if all elements arrived
      CacheStore cs1 = cache.getAdvancedCache().getComponentRegistry().getComponent(CacheLoaderManager.class).getCacheStore();
      Set<Object> keys = cs1.loadAllKeys(null);

      Assert.assertEquals(keys.size(), 4);

      // now start 2nd node
      addClusterEnabledCacheManager(getCB());
      waitForClusterToForm("P006");

      cache = cacheManagers.get(1).getCache("P006");

      // add next 4 elements
      for(int i = 0; i < 4; i++){
         cache.put(cacheManagers.get(1).getAddress().toString()+"-"+i, "42");
      }

      Set mergedKeys = new HashSet();
      // add keys from all cache stores
      CacheStore cs2 = cache.getAdvancedCache().getComponentRegistry().getComponent(CacheLoaderManager.class).getCacheStore();
      log.debugf("Load from cache store via cache 1");
      mergedKeys.addAll(cs1.loadAllKeys(null));
      log.debugf("Load from cache store via cache 2");
      mergedKeys.addAll(cs2.loadAllKeys(null));

      Assert.assertEquals(mergedKeys.size(), 8);

   }
View Full Code Here

Examples of org.infinispan.loaders.CacheStore

         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

Examples of org.infinispan.loaders.CacheStore

         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

Examples of org.infinispan.loaders.CacheStore

            for (InternalCacheEntry ice : dataContainer) {
               rebalance(ice.getKey(), ice, numOwners, chOld, chNew, null, states, keysToRemove);
            }

            // Only fetch the data from the cache store if the cache store is not shared
            CacheStore cacheStore = distributionManager.getCacheStoreForRehashing();
            if (cacheStore != null) {
               for (Object key : cacheStore.loadAllKeys(new ReadOnlyDataContainerBackedKeySet(dataContainer))) {
                  rebalance(key, null, numOwners, chOld, chNew, cacheStore, states, keysToRemove);
               }
            } else {
               if (trace) log.trace("No cache store or cache store is shared, not rebalancing stored keys");
            }
View Full Code Here

Examples of org.infinispan.loaders.CacheStore

            for (InternalCacheEntry ice : dataContainer) {
               rebalance(ice.getKey(), ice, numOwners, chOld, chNew, null, states, keysToRemove);
            }

            // Only fetch the data from the cache store if the cache store is not shared
            CacheStore cacheStore = distributionManager.getCacheStoreForRehashing();
            if (cacheStore != null) {
               for (Object key : cacheStore.loadAllKeys(new ReadOnlyDataContainerBackedKeySet(dataContainer))) {
                  rebalance(key, null, numOwners, chOld, chNew, cacheStore, states, keysToRemove);
               }
            } else {
               if (trace) log.trace("No cache store or cache store is shared, not rebalancing stored keys");
            }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.