Examples of CacheStoreInterceptor


Examples of org.infinispan.interceptors.CacheStoreInterceptor

      cache.put("k1", "v1");
     
      // ensure that the implicit transaction created for the "put" is cleaned up from the
      // CacheStoreInterceptor "preparingTxs" and "txStores" maps
      for (int i = 0; i < getCacheManagers().size(); i++) {
         CacheStoreInterceptor cacheStoreInterceptor = getCacheStoreInterceptor(i);
         assertTxFieldsEmpty(cacheStoreInterceptor, i);
      }
   }
View Full Code Here

Examples of org.infinispan.interceptors.CacheStoreInterceptor

   public void disableCacheStore(String loaderType) {
      if (isEnabled()) {
         boolean disableInterceptors = false;
         ComponentRegistry cr = cache.getComponentRegistry();
         CacheLoaderInterceptor cli = cr.getComponent(CacheLoaderInterceptor.class);
         CacheStoreInterceptor csi = cr.getComponent(CacheStoreInterceptor.class);

         if (loader instanceof ChainingCacheStore) {
            ChainingCacheStore ccs = (ChainingCacheStore) loader;
            ccs.removeCacheLoader(loaderType);
            if (ccs.getStores().isEmpty()) disableInterceptors = true;
         } else {
            if (loader.getClass().getName().equals(loaderType)) {
               try {
                  log.debugf("Stopping and removing cache loader %s", loaderType);
                  loader.stop();
               } catch (Exception e) {
                  log.infof("Problems shutting down cache loader %s", loaderType, e);
               }
               disableInterceptors = true;
            }
         }

         if (disableInterceptors) {
            cli.disableInterceptor();
            csi.disableInterceptor();
            cache.removeInterceptor(cli.getClass());
            cache.removeInterceptor(csi.getClass());
            clmConfig = null;
         }
      }
   }
View Full Code Here

Examples of org.infinispan.interceptors.CacheStoreInterceptor

   public void disableCacheStore(String loaderType) {
      if (isEnabled()) {
         boolean disableInterceptors = false;
         ComponentRegistry cr = cache.getComponentRegistry();
         CacheLoaderInterceptor cli = cr.getComponent(CacheLoaderInterceptor.class);
         CacheStoreInterceptor csi = cr.getComponent(CacheStoreInterceptor.class);

         if (loader instanceof ChainingCacheStore) {
            ChainingCacheStore ccs = (ChainingCacheStore) loader;
            ccs.removeCacheLoader(loaderType);
            if (ccs.getStores().isEmpty()) disableInterceptors = true;
         } else {
            if (loader.getClass().getName().equals(loaderType)) {
               try {
                  log.debugf("Stopping and removing cache loader %s", loaderType);
                  loader.stop();
               } catch (Exception e) {
                  log.infof("Problems shutting down cache loader %s", loaderType, e);
               }
               disableInterceptors = true;
            }
         }

         if (disableInterceptors) {
            cli.disableInterceptor();
            csi.disableInterceptor();
            cache.removeInterceptor(cli.getClass());
            cache.removeInterceptor(csi.getClass());
            clmConfig = null;
         }
      }
   }
View Full Code Here

Examples of org.infinispan.interceptors.CacheStoreInterceptor

   public void disableCacheStore(String loaderType) {
      if (isEnabled()) {
         boolean disableInterceptors = false;
         ComponentRegistry cr = cache.getComponentRegistry();
         CacheLoaderInterceptor cli = cr.getComponent(CacheLoaderInterceptor.class);
         CacheStoreInterceptor csi = cr.getComponent(CacheStoreInterceptor.class);

         if (loader instanceof ChainingCacheStore) {
            ChainingCacheStore ccs = (ChainingCacheStore) loader;
            ccs.removeCacheLoader(loaderType);
            if (ccs.getStores().isEmpty()) disableInterceptors = true;
         } else {
            if (loader.getClass().getName().equals(loaderType)) {
               try {
                  log.debugf("Stopping and removing cache loader %s", loaderType);
                  loader.stop();
               } catch (Exception e) {
                  log.infof("Problems shutting down cache loader %s", loaderType, e);
               }
               disableInterceptors = true;
            }
         }

         if (disableInterceptors) {
            cli.disableInterceptor();
            csi.disableInterceptor();
            cache.removeInterceptor(cli.getClass());
            cache.removeInterceptor(csi.getClass());
            clmConfig = null;
         }
      }
   }
View Full Code Here

Examples of org.infinispan.interceptors.CacheStoreInterceptor

   public void disableCacheStore(String loaderType) {
      if (isEnabled()) {
         boolean disableInterceptors = false;
         ComponentRegistry cr = cache.getComponentRegistry();
         CacheLoaderInterceptor cli = cr.getComponent(CacheLoaderInterceptor.class);
         CacheStoreInterceptor csi = cr.getComponent(CacheStoreInterceptor.class);

         if (loader instanceof ChainingCacheStore) {
            ChainingCacheStore ccs = (ChainingCacheStore) loader;
            ccs.removeCacheLoader(loaderType);
            if (ccs.getStores().isEmpty()) disableInterceptors = true;
         } else {
            String loaderClassName = undelegateCacheLoader(loader).getClass().getName();
            if (loaderClassName.equals(loaderType)) {
               try {
                  log.debugf("Stopping and removing cache loader %s", loaderType);
                  loader.stop();
               } catch (Exception e) {
                  log.infof("Problems shutting down cache loader %s", loaderType, e);
               }
               disableInterceptors = true;
            }
         }

         if (disableInterceptors) {
            cli.disableInterceptor();
            csi.disableInterceptor();
            cache.removeInterceptor(cli.getClass());
            cache.removeInterceptor(csi.getClass());
            clmConfig = null;
         }
      }
   }
View Full Code Here

Examples of org.infinispan.interceptors.CacheStoreInterceptor

      cache.put("k1", "v1");
     
      // ensure that the implicit transaction created for the "put" is cleaned up from the
      // CacheStoreInterceptor "preparingTxs" and "txStores" maps
      for (int i = 0; i < getCacheManagers().size(); i++) {
         CacheStoreInterceptor cacheStoreInterceptor = getCacheStoreInterceptor(i);
         assertTxFieldsEmpty(cacheStoreInterceptor, i);
      }
   }
View Full Code Here

Examples of org.jboss.cache.interceptors.CacheStoreInterceptor

   }

   protected CacheStoreInterceptor findCacheStoreInterceptor(CacheSPI cache)
   {
      Iterator ints = cache.getInterceptorChain().iterator();
      CacheStoreInterceptor csi = null;
      while (ints.hasNext())
      {
         CommandInterceptor i = (CommandInterceptor) ints.next();
         if (i instanceof CacheStoreInterceptor)
         {
View Full Code Here

Examples of org.jboss.cache.interceptors.CacheStoreInterceptor

      // Note: because these tests are normally executed without a server, the interceptor
      // MBeans are usually not available for use in the tests.  Consequently it's necessary
      // to obtain references to the interceptors and work with them directly.
      CacheLoaderInterceptor loader = TestingUtil.findInterceptor(cache, CacheLoaderInterceptor.class);
      assertNotNull("CacheLoaderInterceptor not found.", loader);
      CacheStoreInterceptor store = TestingUtil.findInterceptor(cache, CacheStoreInterceptor.class);
      assertNotNull("CacheStoreInterceptor not found.", store);

      // verify cache loader statistics for entries loaded into cache
      int miss = 5;
      int load = 0;
      int stores = 5;
      assertEquals("CacheLoaderLoads count error: ", load, loader.getCacheLoaderLoads());
      assertEquals("CacheLoaderMisses count error: ", miss, loader.getCacheLoaderMisses());
      assertEquals("CacheLoaderStores count error: ", stores, store.getCacheLoaderStores());

      // now try retrieving a valid attribute and an invalid attribute
      assertNotNull("Retrieval error: expected to retrieve " + CAPITAL + " for " + AUSTRIA, cache.get(AUSTRIA, CAPITAL));
      assertNull("Retrieval error: did not expect to retrieve " + AREA + " for " + AUSTRIA, cache.get(AUSTRIA, AREA));

      // verify statistics after retrieving entries - misses should still be same since nodes were already loaded
      assertEquals("CacheLoaderLoads count error: ", load, loader.getCacheLoaderLoads());
      assertEquals("CacheLoaderMisses count error: ", miss, loader.getCacheLoaderMisses());
      assertEquals("CacheLoaderStores count error: ", stores, store.getCacheLoaderStores());

      // now try retrieving an attribute for an invalid node
      assertNull("Retrieval error: did not expect to retrieve " + CAPITAL + " for " + POLAND, cache.get(POLAND, CAPITAL));

      // verify statistics for after retrieving entries - misses should now be +1 after attempt to load Poland
      miss++;
      assertEquals("CacheLoaderLoads count error: ", load, loader.getCacheLoaderLoads());
      assertEquals("CacheLoaderMisses count error: ", miss, loader.getCacheLoaderMisses());
      assertEquals("CacheLoaderStores count error: ", stores, store.getCacheLoaderStores());

      // now evict Austria and confirm that it's no longer in cache
      cache.evict(AUSTRIA, false);
      assertNull("Retrieval error: did not expect to find node " + AUSTRIA + " in cache", cache.peek(AUSTRIA, false));

      // now try retrieving its attributes again - first retrieval should trigger a cache load
      assertNotNull("Retrieval error: expected to retrieve " + CAPITAL + " for " + AUSTRIA, cache.get(AUSTRIA, CAPITAL));
      assertNotNull("Retrieval error: expected to retrieve " + CURRENCY + " for " + AUSTRIA, cache.get(AUSTRIA, CURRENCY));

      // verify statistics after retrieving evicted entry - loads should now be +1
      load++;
      assertEquals("CacheLoaderLoads count error: ", load, loader.getCacheLoaderLoads());
      assertEquals("CacheLoaderMisses count error: ", miss, loader.getCacheLoaderMisses());
      assertEquals("CacheLoaderStores count error: ", stores, store.getCacheLoaderStores());

      // now remove Austria and confirm that it's not in cache or loader
      cache.removeNode(AUSTRIA);
      assertNull("Retrieval error: did not expect to find node " + AUSTRIA + " in cache", cache.peek(AUSTRIA, false));
      assertFalse("Retrieval error: did not expect to find node " + AUSTRIA + " in loader", cl.exists(AUSTRIA));

      // verify statistics after removing entry - should be unchanged
      assertEquals("CacheLoaderLoads count error: ", load, loader.getCacheLoaderLoads());
      assertEquals("CacheLoaderMisses count error: ", miss, loader.getCacheLoaderMisses());
      assertEquals("CacheLoaderStores count error: ", stores, store.getCacheLoaderStores());

      // now try retrieving attributes again - each attempt should fail and cause a miss since node is now removed
      assertNull("Retrieval error: did not expect to retrieve " + CAPITAL + " for " + AUSTRIA, cache.get(AUSTRIA, CAPITAL));
      assertNull("Retrieval error: did not expect to retrieve " + CURRENCY + " for " + AUSTRIA, cache.get(AUSTRIA, CURRENCY));

      // verify statistics after trying to retrieve removed node's attributes - should be two more misses
      miss += 2;
      assertEquals("CacheLoaderLoads count error: ", load, loader.getCacheLoaderLoads());
      assertEquals("CacheLoaderMisses count error: ", miss, loader.getCacheLoaderMisses());
      assertEquals("CacheLoaderStores count error: ", stores, store.getCacheLoaderStores());

      // add a new node - this should cause a store
      stores++;
      miss++;
      cache.put(POLAND, new HashMap<String, Object>());
      assertEquals("CacheLoaderLoads count error: ", load, loader.getCacheLoaderLoads());
      assertEquals("CacheLoaderMisses count error: ", miss, loader.getCacheLoaderMisses());
      assertEquals("CacheLoaderStores count error: ", stores, store.getCacheLoaderStores());

      // add two attributes - this should cause two stores
      stores += 2;
      cache.put(POLAND, CAPITAL, "Warsaw");
      cache.put(POLAND, CURRENCY, "Zloty");
      assertEquals("CacheLoaderLoads count error: ", load, loader.getCacheLoaderLoads());
      assertEquals("CacheLoaderMisses count error: ", miss, loader.getCacheLoaderMisses());
      assertEquals("CacheLoaderStores count error: ", stores, store.getCacheLoaderStores());

      // evict Poland and then try to retrieve an invalid attribute - this will cause a load as the node is restored
      load++;
      cache.evict(POLAND, false);
      assertNull("Retrieval error: did not expect to retrieve " + AREA + " for " + POLAND, cache.get(POLAND, AREA));
      assertEquals("CacheLoaderLoads count error: ", load, loader.getCacheLoaderLoads());
      assertEquals("CacheLoaderMisses count error: ", miss, loader.getCacheLoaderMisses());
      assertEquals("CacheLoaderStores count error: ", stores, store.getCacheLoaderStores());

      // reset statistics
      loader.resetStatistics();
      store.resetStatistics();

      // check the statistics again
      assertEquals("CacheLoaderLoads count error after reset: ", 0, loader.getCacheLoaderLoads());
      assertEquals("CacheLoaderMisses count error after reset: ", 0, loader.getCacheLoaderMisses());
      assertEquals("CacheLoaderStores count error after reset: ", 0, store.getCacheLoaderStores());
   }
View Full Code Here

Examples of org.jboss.cache.interceptors.CacheStoreInterceptor

      // Note: because these tests are normally executed without a server, the interceptor
      // MBeans are usually not available for use in the tests.  Consequently it's necessary
      // to obtain references to the interceptors and work with them directly.
      CacheLoaderInterceptor loader = TestingUtil.findInterceptor(cache, CacheLoaderInterceptor.class);
      assertNotNull("CacheLoaderInterceptor not found.", loader);
      CacheStoreInterceptor store = TestingUtil.findInterceptor(cache, CacheStoreInterceptor.class);
      assertNotNull("CacheStoreInterceptor not found.", store);

      // verify cache loader statistics for entries loaded into cache
      int miss = 5;
      int load = 0;
      int stores = 5;
      assertEquals("CacheLoaderLoads count error: ", load, loader.getCacheLoaderLoads());
      assertEquals("CacheLoaderMisses count error: ", miss, loader.getCacheLoaderMisses());
      assertEquals("CacheLoaderStores count error: ", stores, store.getCacheLoaderStores());

      // now try retrieving a valid attribute and an invalid attribute
      assertNotNull("Retrieval error: expected to retrieve " + CAPITAL + " for " + AUSTRIA, cache.get(AUSTRIA, CAPITAL));
      assertNull("Retrieval error: did not expect to retrieve " + AREA + " for " + AUSTRIA, cache.get(AUSTRIA, AREA));

      // verify statistics after retrieving entries - misses should still be same since nodes were already loaded
      assertEquals("CacheLoaderLoads count error: ", load, loader.getCacheLoaderLoads());
      assertEquals("CacheLoaderMisses count error: ", miss, loader.getCacheLoaderMisses());
      assertEquals("CacheLoaderStores count error: ", stores, store.getCacheLoaderStores());

      // now try retrieving an attribute for an invalid node
      assertNull("Retrieval error: did not expect to retrieve " + CAPITAL + " for " + POLAND, cache.get(POLAND, CAPITAL));

      // verify statistics for after retrieving entries - misses should now be +1 after attempt to load Poland
      miss++;
      assertEquals("CacheLoaderLoads count error: ", load, loader.getCacheLoaderLoads());
      assertEquals("CacheLoaderMisses count error: ", miss, loader.getCacheLoaderMisses());
      assertEquals("CacheLoaderStores count error: ", stores, store.getCacheLoaderStores());

      // now evict Austria and confirm that it's no longer in cache
      cache.evict(AUSTRIA, false);
      assertNull("Retrieval error: did not expect to find node " + AUSTRIA + " in cache", cache.peek(AUSTRIA, false));

      // now try retrieving its attributes again - first retrieval should trigger a cache load
      assertNotNull("Retrieval error: expected to retrieve " + CAPITAL + " for " + AUSTRIA, cache.get(AUSTRIA, CAPITAL));
      assertNotNull("Retrieval error: expected to retrieve " + CURRENCY + " for " + AUSTRIA, cache.get(AUSTRIA, CURRENCY));

      // verify statistics after retrieving evicted entry - loads should now be +1
      load++;
      assertEquals("CacheLoaderLoads count error: ", load, loader.getCacheLoaderLoads());
      assertEquals("CacheLoaderMisses count error: ", miss, loader.getCacheLoaderMisses());
      assertEquals("CacheLoaderStores count error: ", stores, store.getCacheLoaderStores());

      // now remove Austria and confirm that it's not in cache or loader
      cache.removeNode(AUSTRIA);
      assertNull("Retrieval error: did not expect to find node " + AUSTRIA + " in cache", cache.peek(AUSTRIA, false));
      assertFalse("Retrieval error: did not expect to find node " + AUSTRIA + " in loader", cl.exists(AUSTRIA));

      // verify statistics after removing entry - should be unchanged
      assertEquals("CacheLoaderLoads count error: ", load, loader.getCacheLoaderLoads());
      assertEquals("CacheLoaderMisses count error: ", miss, loader.getCacheLoaderMisses());
      assertEquals("CacheLoaderStores count error: ", stores, store.getCacheLoaderStores());

      // now try retrieving attributes again - each attempt should fail and cause a miss since node is now removed
      assertNull("Retrieval error: did not expect to retrieve " + CAPITAL + " for " + AUSTRIA, cache.get(AUSTRIA, CAPITAL));
      assertNull("Retrieval error: did not expect to retrieve " + CURRENCY + " for " + AUSTRIA, cache.get(AUSTRIA, CURRENCY));

      // verify statistics after trying to retrieve removed node's attributes - should be two more misses
      miss += 2;
      assertEquals("CacheLoaderLoads count error: ", load, loader.getCacheLoaderLoads());
      assertEquals("CacheLoaderMisses count error: ", miss, loader.getCacheLoaderMisses());
      assertEquals("CacheLoaderStores count error: ", stores, store.getCacheLoaderStores());

      // add a new node - this should cause a store
      stores++;
      miss++;
      cache.put(POLAND, new HashMap<String, Object>());
      assertEquals("CacheLoaderLoads count error: ", load, loader.getCacheLoaderLoads());
      assertEquals("CacheLoaderMisses count error: ", miss, loader.getCacheLoaderMisses());
      assertEquals("CacheLoaderStores count error: ", stores, store.getCacheLoaderStores());

      // add two attributes - this should cause two stores
      stores += 2;
      cache.put(POLAND, CAPITAL, "Warsaw");
      cache.put(POLAND, CURRENCY, "Zloty");
      assertEquals("CacheLoaderLoads count error: ", load, loader.getCacheLoaderLoads());
      assertEquals("CacheLoaderMisses count error: ", miss, loader.getCacheLoaderMisses());
      assertEquals("CacheLoaderStores count error: ", stores, store.getCacheLoaderStores());

      // evict Poland and then try to retrieve an invalid attribute - this will cause a load as the node is restored
      load++;
      cache.evict(POLAND, false);
      assertNull("Retrieval error: did not expect to retrieve " + AREA + " for " + POLAND, cache.get(POLAND, AREA));
      assertEquals("CacheLoaderLoads count error: ", load, loader.getCacheLoaderLoads());
      assertEquals("CacheLoaderMisses count error: ", miss, loader.getCacheLoaderMisses());
      assertEquals("CacheLoaderStores count error: ", stores, store.getCacheLoaderStores());

      // reset statistics
      loader.resetStatistics();
      store.resetStatistics();

      // check the statistics again
      assertEquals("CacheLoaderLoads count error after reset: ", 0, loader.getCacheLoaderLoads());
      assertEquals("CacheLoaderMisses count error after reset: ", 0, loader.getCacheLoaderMisses());
      assertEquals("CacheLoaderStores count error after reset: ", 0, store.getCacheLoaderStores());
   }
View Full Code Here

Examples of org.jboss.cache.interceptors.CacheStoreInterceptor

   }

   protected CacheStoreInterceptor findCacheStoreInterceptor(CacheSPI cache)
   {
      Iterator ints = cache.getInterceptorChain().iterator();
      CacheStoreInterceptor csi = null;
      while (ints.hasNext())
      {
         CommandInterceptor i = (CommandInterceptor) ints.next();
         if (i instanceof CacheStoreInterceptor)
         {
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.