Package org.jboss.cache.loader

Examples of org.jboss.cache.loader.CacheLoader


      if (clm == null)
      {
         LOG.error("The CacheLoaderManager cannot be found");
         return;
      }
      CacheLoader currentCL = clm.getCacheLoader();
      if (currentCL == null)
      {
         LOG.error("The CacheLoader cannot be found");
         return;
      }
View Full Code Here


      if (clm == null)
      {
         LOG.error("The CacheLoaderManager cannot be found");
         return null;
      }
      CacheLoader currentCL = clm.getCacheLoader();
      if (currentCL == null)
      {
         LOG.error("The CacheLoader cannot be found");
         return null;
      }
View Full Code Here

      if (clm == null)
      {
         LOG.error("The CacheLoaderManager cannot be found");
         return;
      }
      CacheLoader currentCL = clm.getCacheLoader();
      if (currentCL == null)
      {
         LOG.error("The CacheLoader cannot be found");
         return;
      }
View Full Code Here

   protected void integratePersistentState(ObjectInputStream in, Fqn targetFqn) throws Exception
   {
      if (trace) log.trace("Reading persistent state from stream");
      CacheLoaderManager loaderManager = cache.getCacheLoaderManager();
      CacheLoader loader = loaderManager == null ? null : loaderManager.getCacheLoader();
      if (loader == null)
      {
         if (log.isTraceEnabled())
         {
            log.trace("cache loader is null, will not attempt to integrate persistent state");
         }
      }
      else
      {

         if (log.isTraceEnabled())
         {
            log.trace("integrating persistent state using " + loader.getClass().getName());
         }

         boolean persistentSet = false;
         try
         {
            if (targetFqn.isRoot())
            {
               loader.storeEntireState(in);
            }
            else
            {
               loader.storeState(targetFqn, in);
            }
            persistentSet = true;
         }
         catch (ClassCastException cce)
         {
            log.error("Failed integrating persistent state. One of cacheloaders is not"
                  + " adhering to state stream format. See JBCACHE-738.");
            throw cce;
         }
         finally
         {
            if (!persistentSet)
            {
               log.warn("persistent state integration failed, removing all nodes from loader");
               loader.remove(targetFqn);
            }
            else
            {
               if (log.isTraceEnabled())
               {
View Full Code Here

      if (clm == null)
      {
         LOG.error("The CacheLoaderManager cannot be found");
         return;
      }
      CacheLoader currentCL = clm.getCacheLoader();
      if (currentCL == null)
      {
         LOG.error("The CacheLoader cannot be found");
         return;
      }
View Full Code Here

      assertNull(loader.get(fqn));
   }

   public void testCacheLoadOnTree() throws Exception
   {
      CacheLoader loader = null;
      try
      {
         CacheSPI<Object, Object> cache = createCacheWithLoader();
         loader = cache.getCacheLoaderManager().getCacheLoader();

         TransactionManager mgr = cache.getTransactionManager();
         Transaction tx;

         // make sure the fqn is not in cache
         assertNull(cache.getNode(fqn));

         // put something in the loader and make sure all tx's can see it
         loader.put(fqn, key, value);

         // start the 1st tx
         mgr.begin();
         tx = mgr.getTransaction();
         assertEquals(value, cache.get(fqn, key));
         mgr.suspend();

         // start a new tx
         mgr.begin();
         assertEquals(value, cache.get(fqn, key));
         mgr.commit();

         mgr.resume(tx);
         assertEquals(value, cache.get(fqn, key));
         mgr.commit();
      }
      finally
      {
         // cleanup
         if (loader != null) loader.remove(fqn);
      }
   }
View Full Code Here

   public void testCacheStoring() throws Exception
   {
      Transaction tx;
      CacheSPI<Object, Object> cache = createCacheWithLoader();
      CacheLoader loader = cache.getCacheLoaderManager().getCacheLoader();

      // test the cache ...
      TransactionManager mgr = cache.getTransactionManager();
      assertNull(mgr.getTransaction());
      mgr.begin();
      cache.put(fqn, key, value);
      mgr.commit();

      assertEquals(value, cache.get(fqn, key));

      //now lets see if the state has been persisted in the cache loader
      assertEquals(value, loader.get(fqn).get(key));


      mgr.begin();
      cache.removeNode(fqn);
      mgr.commit();

      assertNull(cache.get(fqn, key));
      //now lets see if the state has been persisted in the cache loader
      assertNull(loader.get(fqn));

      mgr.begin();
      cache.put(fqn, key, value);
      tx = mgr.getTransaction();
      mgr.suspend();

      // lets see what we've got halfway within a tx
      assertNull(cache.get(fqn, key));
      assertNull(loader.get(fqn));

      mgr.resume(tx);
      mgr.commit();

      // and after committing...
      assertEquals(value, cache.get(fqn, key));
      assertEquals(value, loader.get(fqn).get(key));

      // clean up loader
      loader.remove(fqn);
   }
View Full Code Here


   public void testCacheStoringImplicitTx() throws Exception
   {
      CacheSPI<Object, Object> cache = createCacheWithLoader();
      CacheLoader loader = cache.getCacheLoaderManager().getCacheLoader();

      // test the cache ...
      TransactionManager mgr = cache.getTransactionManager();
      assertNull(mgr.getTransaction());
      cache.put(fqn, key, value);

      assertEquals(value, cache.get(fqn, key));

      //now lets see if the state has been persisted in the cache loader
      assertEquals(value, loader.get(fqn).get(key));


      cache.removeNode(fqn);

      assertNull(cache.get(fqn, key));
      //now lets see if the state has been persisted in the cache loader
      assertNull(loader.get(fqn));

      cache.put(fqn, key, value);

      assertEquals(value, cache.get(fqn, key));
      assertEquals(value, loader.get(fqn).get(key));

      // clean up loader
      loader.remove(fqn);
   }
View Full Code Here

   }

   public void testCacheStoringImplicitTxOptionOverride() throws Exception
   {
      CacheSPI<Object, Object> cache = createCacheWithLoader();
      CacheLoader loader = cache.getCacheLoaderManager().getCacheLoader();
      Option option = new Option();
      option.setCacheModeLocal(true);
      cache.getInvocationContext().setOptionOverrides(option);
      cache.put(fqn, key, value);
      assertEquals(value, cache.get(fqn, key));
      //now lets see if the state has been persisted in the cache loader
      assertNotNull(loader.get(fqn));
      assertNotNull(value, loader.get(fqn).get(key));
      cache.removeNode(fqn);
   }
View Full Code Here


   public void testCacheLoading() throws Exception
   {
      CacheSPI<Object, Object> cache = createCacheWithLoader();
      CacheLoader loader = cache.getCacheLoaderManager().getCacheLoader();

      assertNull(cache.get(fqn, key));

      // put something in the loader
      loader.put(fqn, key, value);
      assertEquals(value, loader.get(fqn).get(key));

      // test that this can now be accessed by the cache
      assertEquals(value, cache.get(fqn, key));

      // clean up loader
      loader.remove(fqn);

      // what's in the cache now?  Should not ne null...
      assertNotNull(cache.get(fqn, key));
   }
View Full Code Here

TOP

Related Classes of org.jboss.cache.loader.CacheLoader

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.