Examples of CacheSPI


Examples of org.jboss.cache.CacheSPI

      // disable state transfer!!
      cache.getConfiguration().setFetchInMemoryState(false);

      cache.start();

      CacheSPI spi = (CacheSPI) cache;

      DummyInMemoryCacheLoader loader = (DummyInMemoryCacheLoader) spi.getCacheLoaderManager().getCacheLoader();
      loaderTL.set(loader);

      return cache;
   }
View Full Code Here

Examples of org.jboss.cache.CacheSPI

   public void testExistenceOfTombstones()
   {
      Cache<String, String> observer = observerTL.get();
      Cache<String, String> modifier = modifierTL.get();

      CacheSPI modifierImpl = (CacheSPI) modifier;
      CacheSPI observerImpl = (CacheSPI) observer;

      modifier.put(parent, K, V);
      modifier.removeNode(parent);

      if (isOptimistic() && invalidation)
      {
         // if we are using optimistic invalidation then we should see tombstones.  NOT otherwise.
         NodeSPI modifierTombstone = modifierImpl.peek(parent, true, true);
         NodeSPI observerTombstone = observerImpl.peek(parent, true, true);

         assert modifierTombstone != null : "Modifier tombstone should not be null";
         assert observerTombstone != null : "Observer tombstone should not be null";

         assert !modifierTombstone.isValid() : "Should not be valid";
         assert !observerTombstone.isValid() : "Should not be valid";

         assert ((DefaultDataVersion) modifierTombstone.getVersion()).getRawVersion() == 2 : "Tombstone should be versioned";
         assert ((DefaultDataVersion) observerTombstone.getVersion()).getRawVersion() == 2 : "Tombstone should be versioned";

      }
      else
      {
         // if we are using pess locking there should be NO tombstones, regardless of replication/invalidation!
         assert modifierImpl.peek(parent, true, true) == null : "Tombstone should not exist";
         assert observerImpl.peek(parent, true, true) == null : "Tombstone should not exist";
      }
   }
View Full Code Here

Examples of org.jboss.cache.CacheSPI

   public void testExistenceOfTombstonesWithChildren()
   {
      Cache<String, String> observer = observerTL.get();
      Cache<String, String> modifier = modifierTL.get();

      CacheSPI modifierImpl = (CacheSPI) modifier;
      CacheSPI observerImpl = (CacheSPI) observer;

      modifier.put(child, K, V);
      modifier.removeNode(parent);

      if (isOptimistic() && invalidation)
      {
         // if we are using optimistic invalidation then we should see tombstones.  NOT otherwise.
         NodeSPI modifierParentTombstone = modifierImpl.peek(parent, true, true);
         NodeSPI observerParentTombstone = observerImpl.peek(parent, true, true);
         NodeSPI modifierChildTombstone = modifierImpl.peek(child, true, true);
         NodeSPI observerChildTombstone = observerImpl.peek(child, true, true);

         assert modifierParentTombstone != null : "Modifier parent tombstone should not be null";
         assert observerParentTombstone != null : "Observer parent tombstone should not be null";
         assert modifierChildTombstone != null : "Modifier child tombstone should not be null";
         assert observerChildTombstone != null : "Observer child tombstone should not be null";

         assert !modifierParentTombstone.isValid() : "Should not be valid";
         assert !observerParentTombstone.isValid() : "Should not be valid";
         assert !modifierChildTombstone.isValid() : "Should not be valid";
         assert !observerChildTombstone.isValid() : "Should not be valid";

         assert ((DefaultDataVersion) modifierParentTombstone.getVersion()).getRawVersion() == 1 : "Tombstone should be versioned";
         assert ((DefaultDataVersion) observerParentTombstone.getVersion()).getRawVersion() == 1 : "Tombstone should be versioned";

         // note that versions on children cannot be incremented/updated since the remove operation was
         // performed on the parent.
         assert ((DefaultDataVersion) modifierChildTombstone.getVersion()).getRawVersion() == 1 : "Tombstone should be versioned";
         assert ((DefaultDataVersion) observerChildTombstone.getVersion()).getRawVersion() == 1 : "Tombstone should be versioned";

      }
      else
      {
         // if we are using pess locking there should be NO tombstones, regardless of replication/invalidation!
         assert modifierImpl.peek(parent, true, true) == null : "Tombstone should not exist";
         assert observerImpl.peek(parent, true, true) == null : "Tombstone should not exist";
         assert modifierImpl.peek(child, true, true) == null : "Tombstone should not exist";
         assert observerImpl.peek(child, true, true) == null : "Tombstone should not exist";
      }
   }
View Full Code Here

Examples of org.jboss.cache.CacheSPI

      return isCacheViewComplete(c, memberCount, true);
   }

   public static boolean isCacheViewComplete(Cache c, int memberCount, boolean barfIfTooManyMembers)
   {
      CacheSPI cache = (CacheSPI) c;
      List members = cache.getMembers();
      if (members == null || memberCount > members.size())
      {
         return false;
      }
      else if (memberCount < members.size())
      {
         if (barfIfTooManyMembers)
         {
            // This is an exceptional condition
            StringBuilder sb = new StringBuilder("Cache at address ");
            sb.append(cache.getLocalAddress());
            sb.append(" had ");
            sb.append(members.size());
            sb.append(" members; expecting ");
            sb.append(memberCount);
            sb.append(". Members were (");
View Full Code Here

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

Examples of org.jboss.cache.CacheSPI

   {
      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

Examples of org.jboss.cache.CacheSPI

    * @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

Examples of org.jboss.cache.CacheSPI

   {
      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

Examples of org.jboss.cache.CacheSPI

   public void testTombstoneVersioningFailure() throws Exception
   {
      Cache<String, String> observer = observerTL.get();
      Cache<String, String> modifier = modifierTL.get();

      CacheSPI modifierImpl = (CacheSPI) modifier;
      CacheSPI observerImpl = (CacheSPI) observer;

      modifier.put(parent, K, V);

      DummyInMemoryCacheLoader loader = loaderTL.get();
     
      // test that this exists in the (shared) loader
      assert loader.get(parent) != null;
      assert loader.get(parent).size() > 0;

      modifier.removeNode(parent);

      // assert that tombstones exist on both instances
      assert modifierImpl.peek(parent, true, true) != null;
      assert observerImpl.peek(parent, true, true) != null;
      assert modifierImpl.peek(parent, false, false) == null;
      assert observerImpl.peek(parent, false, false) == null;

      // make sure this does not exist in the loader; since it HAS been removed
      assert loader.get(parent) == null;

      NodeSPI observerNode = (NodeSPI) observer.getRoot().getChild(parent);
      assert observerNode == null : "Should be removed";

      // now try a put on a with a newer data version; should work
      modifier.getInvocationContext().getOptionOverrides().setDataVersion(new DefaultDataVersion(1));
      try
      {
         modifier.put(parent, K, V);
         assert false : "Should have barfed!";
      }
      catch (RuntimeException expected)
      {

      }

      NodeSPI modifierNode = (NodeSPI) modifier.getRoot().getChild(parent);
      assert modifierNode == null : "Should be null";

      observerNode = (NodeSPI) observer.getRoot().getChild(parent);
      assert observerNode == null : "Should be null";

      NodeSPI modifierTombstone = modifierImpl.peek(parent, true, true);
      NodeSPI observerTombstone = observerImpl.peek(parent, true, true);

      assert modifierTombstone != null : "Tombstone should still exist";
      assert observerTombstone != null : "Tombstone should still exist";

      assert !modifierTombstone.isValid() : "Should not be valid";
View Full Code Here

Examples of org.jboss.cache.CacheSPI

      caches.add(createCache());
   }

   public void testBuddyBackupActivation() throws Exception
   {
      CacheSPI cache1 = caches.get(0);
      CacheSPI cache2 = caches.get(1);
      Fqn A = Fqn.fromString("/a");
      TestingUtil.blockUntilViewsReceived(VIEW_BLOCK_TIMEOUT, cache1, cache2);

      // create the regions on the two cachePool first
      Region c1 = cache1.getRegionManager().getRegion(A, Region.Type.MARSHALLING, true);
      Region c2 = cache2.getRegionManager().getRegion(A, Region.Type.MARSHALLING, true);

      assertFalse(c1.isActive());
      assertFalse(c2.isActive());

      c1.activate();
      cache1.put(A_B, "name", JOE);

      waitForBuddy(cache2, cache1, true);
      waitForBuddy(cache1, cache2, true);

//      TestingUtil.sleepThread(getSleepTimeout());

      c2.activate();

      Fqn fqn = fqnTransformer.getBackupFqn(cache1.getLocalAddress(), A_B);

      assertEquals("State transferred with activation", JOE, cache2.get(fqn, "name"));
   }
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.