Package org.jboss.cache

Examples of org.jboss.cache.CacheSPI


         try
         {
            if (c!= null) utf.removeCache(c);
            if (c != null) // && ( (c.getCacheStatus() == CacheStatus.STARTED) || c.getCacheStatus() == CacheStatus.FAILED) )
            {
               CacheSPI spi = (CacheSPI) c;

               Channel channel = null;
               if (spi.getRPCManager() != null)
               {
                  channel = spi.getRPCManager().getChannel();
               }
               if (spi.getTransactionManager() != null)
               {
                  try
                  {
                     spi.getTransactionManager().rollback();
                  }
                  catch (Throwable t)
                  {
                     // don't care
                  }
               }

               CacheLoaderManager clm = spi.getCacheLoaderManager();
               CacheLoader cl = clm == null ? null : clm.getCacheLoader();
               if (cl != null)
               {
                  try
                  {
                     cl.remove(Fqn.ROOT);
                  }
                  catch (Throwable t)
                  {
                     // don't care
                  }
               }

               try
               {
                  spi.stop();
               } catch (Throwable t) {
                  System.err.println(Thread.currentThread().getName() + " !!!!!!!!!!!!!!!!!!!!! WARNING - Cache instance refused to stop.");
                  t.printStackTrace();
               }
               try {
                  spi.destroy();
               } catch (Throwable t) {
                  System.err.println(Thread.currentThread().getName() + " !!!!!!!!!!!!!!!!!!!!! WARNING - Cache instance refused to destroy.");
                  t.printStackTrace();
               }
               if (channel != null)
View Full Code Here


         try
         {
            if (c!= null) utf.removeCache(c);
            if (c != null) // && ( (c.getCacheStatus() == CacheStatus.STARTED) || c.getCacheStatus() == CacheStatus.FAILED) )
            {
               CacheSPI spi = (CacheSPI) c;

               Channel channel = null;
               if (spi.getRPCManager() != null)
               {
                  channel = spi.getRPCManager().getChannel();
               }
               if (spi.getTransactionManager() != null)
               {
                  try
                  {
                     spi.getTransactionManager().rollback();
                  }
                  catch (Throwable t)
                  {
                     // don't care
                  }
               }

               if (clearCacheLoader)
               {
                  CacheLoaderManager clm = spi.getCacheLoaderManager();
                  CacheLoader cl = clm == null ? null : clm.getCacheLoader();
                  if (cl != null)
                  {
                     try
                     {
                        cl.remove(Fqn.ROOT);
                     }
                     catch (Throwable t)
                     {
                        // don't care
                     }
                  }
               }

               try
               {
                  spi.stop();
               } catch (Throwable t) {
                  System.err.println(Thread.currentThread().getName() + " !!!!!!!!!!!!!!!!!!!!! WARNING - Cache instance refused to stop.");
                  t.printStackTrace();
               }
               try {
                  spi.destroy();
               } catch (Throwable t) {
                  System.err.println(Thread.currentThread().getName() + " !!!!!!!!!!!!!!!!!!!!! WARNING - Cache instance refused to destroy.");
                  t.printStackTrace();
               }
               if (channel != null)
View Full Code Here

   {
      for (Cache c : caches)
      {
         if (c != null && c.getCacheStatus() == CacheStatus.STARTED)
         {
            CacheSPI ci = (CacheSPI) c;
            if (ci.getTransactionManager() != null)
            {
               try
               {
                  ci.getTransactionManager().rollback();
               }
               catch (Exception e)
               {
                  // don't care
               }
View Full Code Here

    * @param cacheStatus status to wait for
    * @param timeout     timeout to wait for
    */
   public static void blockUntilCacheStatusAchieved(Cache cache, CacheStatus cacheStatus, long timeout)
   {
      CacheSPI spi = (CacheSPI) cache;
      long killTime = System.currentTimeMillis() + timeout;
      while (System.currentTimeMillis() < killTime)
      {
         if (spi.getCacheStatus() == cacheStatus) return;
         sleepThread(50);
      }
      throw new RuntimeException("Timed out waiting for condition");
   }
View Full Code Here

   {
      System.out.println("**** START: Cache Contents ****");
      int count = 1;
      for (Object o : caches)
      {
         CacheSPI c = (CacheSPI) o;
         if (c == null)
         {
            System.out.println("  ** Cache " + count + " is null!");
         }
         else
         {
            System.out.println("  ** Cache " + count + " is " + c.getLocalAddress());
            System.out.println("    " + CachePrinter.printCacheDetails(c));
         }
         count++;
      }
      System.out.println("**** END: Cache Contents ****");
 
View Full Code Here

      cache = null;
   }

   private void assertNoStaleLocks()
   {
      CacheSPI spi = (CacheSPI) cache;
      assert spi.getNumberOfLocksHeld() == 0 : "Should have no stale locks!";
   }
View Full Code Here

      cache1.put(A_B, "name", JOE);
      cache1.put(A_B, "age", TWENTY);
      cache1.put(A_C, "name", BOB);
      cache1.put(A_C, "age", FORTY);

      CacheSPI cache2 = null;
      try
      {
         cache2 = createCache(false, false, true, false, false, true);
         cache2.start();

         //Vladimir  October 5th 2007
         //failure of integration of persistent state is not considered to be fatal
         //to revisit with Manik
         //fail("Should have caused an exception");
      }
      catch (Exception e)
      {
      }

      //when persistent transfer fails as in this case state recipient cacheloader should be wiped clean
      assertFalse("/a/b is not in cache loader ", cache2.getCacheLoaderManager().getCacheLoader().exists(A_B));
   }
View Full Code Here

      return o instanceof MarshalledValue ? ((MarshalledValue) o).get() : o;
   }

   public void testStalePersistentState() throws Exception
   {
      CacheSPI c1 = createCache(true, false, true, true);
      c1.put(A, "K", "V");

      assert c1.get(A, "K").equals("V");
      CacheLoader l1 = c1.getCacheLoaderManager().getCacheLoader();
      assert l1 != null;

      assert l1.exists(A);
      assert l1.get(A).get("K").equals("V");

      // test persistence
      c1.stop();

      assert l1.exists(A);
      assert l1.get(A).get("K").equals("V");

      Cache c2 = createCache(true, false, true, true);

      c2.put(B, "K", "V");

      assert c1.getConfiguration().isFetchInMemoryState();
      assert c1.getConfiguration().getCacheLoaderConfig().isFetchPersistentState();
      c1.start();

      assert c1.get(B, "K").equals("V");
      assert c1.get(A, "K") == null;
   }
View Full Code Here

   public void testInjectConfigFilePath() throws Exception
   {
      createTcpCacheServer();
      Configuration conf = UnitTestConfigurationFactory.createConfiguration(Configuration.CacheMode.LOCAL, true);
      CacheSPI cacheSPI = (CacheSPI) new UnitTestCacheFactory<Object, Object>().createCache(conf, getClass());
      cache_server.setCache(cacheSPI);
      startTcpCacheServer();
      createCacheAndLoader();
      cacheCheck();
      usabilityCheck();
View Full Code Here

   public void testInjectCache() throws Exception
   {
      createTcpCacheServer();
      Configuration conf = UnitTestConfigurationFactory.createConfiguration(Configuration.CacheMode.LOCAL, true);
      CacheSPI cacheSPI = (CacheSPI) new UnitTestCacheFactory<Object, Object>().createCache(conf, getClass());
      cache_server.setCache(cacheSPI);
      startTcpCacheServer();
      createCacheAndLoader();
      cacheCheck();
      usabilityCheck();
View Full Code Here

TOP

Related Classes of org.jboss.cache.CacheSPI

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.