[infinispan-commits] Infinispan SVN: r2385 - in trunk/core/src: main/java/org/infinispan/remoting and 1 other directories.

infinispan-commits at lists.jboss.org infinispan-commits at lists.jboss.org
Wed Sep 15 12:19:59 EDT 2010


Author: manik.surtani at jboss.com
Date: 2010-09-15 12:19:59 -0400 (Wed, 15 Sep 2010)
New Revision: 2385

Modified:
   trunk/core/src/main/java/org/infinispan/factories/ComponentRegistry.java
   trunk/core/src/main/java/org/infinispan/remoting/InboundInvocationHandlerImpl.java
   trunk/core/src/test/java/org/infinispan/statetransfer/StateTransferFunctionalTest.java
Log:
Fixed test regressions

Modified: trunk/core/src/main/java/org/infinispan/factories/ComponentRegistry.java
===================================================================
--- trunk/core/src/main/java/org/infinispan/factories/ComponentRegistry.java	2010-09-15 16:16:58 UTC (rev 2384)
+++ trunk/core/src/main/java/org/infinispan/factories/ComponentRegistry.java	2010-09-15 16:19:59 UTC (rev 2385)
@@ -52,6 +52,10 @@
          if (globalComponents == null) throw new NullPointerException("GlobalComponentRegistry cannot be null!");
          this.globalComponents = globalComponents;
 
+         // set this up *before* starting the components since some components - specifically state transfer - needs to be
+         // able to locate this registry via the InboundInvocationHandler
+         this.globalComponents.registerNamedComponentRegistry(this, cacheName);
+
          registerDefaultClassLoader(null);
          registerComponent(this, ComponentRegistry.class);
          registerComponent(configuration, Configuration.class);
@@ -136,10 +140,6 @@
       }
       boolean needToNotify = state != ComponentStatus.RUNNING && state != ComponentStatus.INITIALIZING;
 
-      // set this up *before* starting the components since some components - specifically state transfer - needs to be
-      // able to locate this registry via the InboundInvocationHandler
-      globalComponents.registerNamedComponentRegistry(this, cacheName);
-
       if (needToNotify) {
          for (ModuleLifecycle l : moduleLifecycles) {
             l.cacheStarting(this, cacheName);

Modified: trunk/core/src/main/java/org/infinispan/remoting/InboundInvocationHandlerImpl.java
===================================================================
--- trunk/core/src/main/java/org/infinispan/remoting/InboundInvocationHandlerImpl.java	2010-09-15 16:16:58 UTC (rev 2384)
+++ trunk/core/src/main/java/org/infinispan/remoting/InboundInvocationHandlerImpl.java	2010-09-15 16:19:59 UTC (rev 2385)
@@ -8,6 +8,7 @@
 import org.infinispan.factories.annotations.Inject;
 import org.infinispan.factories.scopes.Scope;
 import org.infinispan.factories.scopes.Scopes;
+import org.infinispan.manager.EmbeddedCacheManager;
 import org.infinispan.manager.NamedCacheNotFoundException;
 import org.infinispan.marshall.StreamingMarshaller;
 import org.infinispan.remoting.responses.ExceptionResponse;
@@ -34,25 +35,41 @@
    GlobalComponentRegistry gcr;
    private static final Log log = LogFactory.getLog(InboundInvocationHandlerImpl.class);
    private StreamingMarshaller marshaller;
+   private EmbeddedCacheManager embeddedCacheManager;
 
    @Inject
-   public void inject(GlobalComponentRegistry gcr, StreamingMarshaller marshaller) {
+   public void inject(GlobalComponentRegistry gcr, StreamingMarshaller marshaller, EmbeddedCacheManager embeddedCacheManager) {
       this.gcr = gcr;
       this.marshaller = marshaller;
+      this.embeddedCacheManager = embeddedCacheManager;
    }
 
+   private boolean isDefined(String cacheName) {
+      log.error("Defined caches: {0}", embeddedCacheManager.getCacheNames());
+      return embeddedCacheManager.getCacheNames().contains(cacheName);
+   }
+
    public Response handle(CacheRpcCommand cmd) throws Throwable {
       String cacheName = cmd.getCacheName();
       ComponentRegistry cr = gcr.getNamedComponentRegistry(cacheName);
-//      long giveupTime = System.currentTimeMillis() + 30000; // arbitraty (?) wait time for caches to start
-//      while (cr == null && System.currentTimeMillis() < giveupTime) {
-//         Thread.sleep(100);
-//         cr = gcr.getNamedComponentRegistry(cacheName);
-//      }
 
       if (cr == null) {
-         if (log.isInfoEnabled()) log.info("Cache named {0} does not exist on this cache manager!", cacheName);
-         return new ExceptionResponse(new NamedCacheNotFoundException(cacheName));
+         // lets see if the cache is *defined* and perhaps just not started.
+         if (isDefined(cacheName)) {
+            log.info("Will trya nd wait for the cache to start");
+            long giveupTime = System.currentTimeMillis() + 30000; // arbitraty (?) wait time for caches to start
+            while (cr == null && System.currentTimeMillis() < giveupTime) {
+               Thread.sleep(100);
+               cr = gcr.getNamedComponentRegistry(cacheName);
+            }
+         } else {
+            log.info("Cache {0} is not defined.  No point in waiting.", cacheName);
+         }
+
+         if (cr == null) {
+            if (log.isInfoEnabled()) log.info("Cache named {0} does not exist on this cache manager!", cacheName);
+            return new ExceptionResponse(new NamedCacheNotFoundException(cacheName));
+         }
       }
 
       Configuration localConfig = cr.getComponent(Configuration.class);

Modified: trunk/core/src/test/java/org/infinispan/statetransfer/StateTransferFunctionalTest.java
===================================================================
--- trunk/core/src/test/java/org/infinispan/statetransfer/StateTransferFunctionalTest.java	2010-09-15 16:16:58 UTC (rev 2384)
+++ trunk/core/src/test/java/org/infinispan/statetransfer/StateTransferFunctionalTest.java	2010-09-15 16:19:59 UTC (rev 2385)
@@ -21,8 +21,6 @@
 @Test(groups = "functional", testName = "statetransfer.StateTransferFunctionalTest", enabled = true)
 public class StateTransferFunctionalTest extends MultipleCacheManagersTest {
 
-   protected static final String ADDRESS_CLASSNAME = Address.class.getName();
-   protected static final String PERSON_CLASSNAME = Person.class.getName();
    public static final String A_B_NAME = "a_b_name";
    public static final String A_C_NAME = "a_c_name";
    public static final String A_D_NAME = "a_d_age";



More information about the infinispan-commits mailing list