geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From upthewatersp...@apache.org
Subject incubator-geode git commit: GEODE-1814: Create the gateway receivers after regions
Date Tue, 23 Aug 2016 22:03:21 GMT
Repository: incubator-geode
Updated Branches:
  refs/heads/develop 91cca477f -> 37269735e


GEODE-1814: Create the gateway receivers after regions

Create the gateway receivers last, to ensure that they don't try to
process any events until the regions are actually created.


Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/37269735
Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/37269735
Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/37269735

Branch: refs/heads/develop
Commit: 37269735eec44f51ee53075718afe2fa85edc22e
Parents: 91cca47
Author: Dan Smith <upthewaterspout@apache.org>
Authored: Tue Aug 23 11:18:49 2016 -0700
Committer: Dan Smith <upthewaterspout@apache.org>
Committed: Tue Aug 23 11:22:18 2016 -0700

----------------------------------------------------------------------
 .../internal/cache/xmlcache/CacheCreation.java  | 49 ++++++++++----------
 .../cache/xmlcache/CacheCreationJUnitTest.java  | 23 +++++++++
 2 files changed, 48 insertions(+), 24 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/37269735/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/xmlcache/CacheCreation.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/xmlcache/CacheCreation.java
b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/xmlcache/CacheCreation.java
index 3bc743f..14a0064 100755
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/xmlcache/CacheCreation.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/xmlcache/CacheCreation.java
@@ -485,30 +485,6 @@ public class CacheCreation implements InternalCache {
       }
     }
     
-    for (GatewayReceiver receiverCreation : this.getGatewayReceivers()) {
-      GatewayReceiverFactory factory = cache.createGatewayReceiverFactory();
-      factory.setBindAddress(receiverCreation.getBindAddress());
-      factory.setMaximumTimeBetweenPings(receiverCreation
-          .getMaximumTimeBetweenPings());
-      factory.setStartPort(receiverCreation.getStartPort());
-      factory.setEndPort(receiverCreation.getEndPort());
-      factory.setSocketBufferSize(receiverCreation.getSocketBufferSize());
-      factory.setManualStart(receiverCreation.isManualStart());
-      for (GatewayTransportFilter filter : receiverCreation
-          .getGatewayTransportFilters()) {
-        factory.addGatewayTransportFilter(filter);
-      }
-      factory.setHostnameForSenders(receiverCreation.getHost()); 
-      GatewayReceiver receiver = factory.create();
-       if (receiver.isManualStart()) {
-        cache
-            .getLoggerI18n()
-            .info(
-                LocalizedStrings.CacheCreation_0_IS_NOT_BEING_STARTED_SINCE_IT_IS_CONFIGURED_FOR_MANUAL_START,
-                receiver);
-      }
-    }
-
     cache.initializePdxRegistry();
 
     
@@ -540,6 +516,31 @@ public class CacheCreation implements InternalCache {
     String serverBindAdd = CacheServerLauncher.getServerBindAddress();
     Boolean disableDefaultServer = CacheServerLauncher.disableDefaultServer.get();
     startCacheServers(this.getCacheServers(), cache, serverPort, serverBindAdd, disableDefaultServer);
+
+    for (GatewayReceiver receiverCreation : this.getGatewayReceivers()) {
+      GatewayReceiverFactory factory = cache.createGatewayReceiverFactory();
+      factory.setBindAddress(receiverCreation.getBindAddress());
+      factory.setMaximumTimeBetweenPings(receiverCreation
+          .getMaximumTimeBetweenPings());
+      factory.setStartPort(receiverCreation.getStartPort());
+      factory.setEndPort(receiverCreation.getEndPort());
+      factory.setSocketBufferSize(receiverCreation.getSocketBufferSize());
+      factory.setManualStart(receiverCreation.isManualStart());
+      for (GatewayTransportFilter filter : receiverCreation
+          .getGatewayTransportFilters()) {
+        factory.addGatewayTransportFilter(filter);
+      }
+      factory.setHostnameForSenders(receiverCreation.getHost());
+      GatewayReceiver receiver = factory.create();
+      if (receiver.isManualStart()) {
+        cache
+            .getLoggerI18n()
+            .info(
+                LocalizedStrings.CacheCreation_0_IS_NOT_BEING_STARTED_SINCE_IT_IS_CONFIGURED_FOR_MANUAL_START,
+                receiver);
+      }
+    }
+
     cache.setBackupFiles(this.backups);
     cache.addDeclarableProperties(this.declarablePropertiesMap);
     runInitializer();

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/37269735/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/xmlcache/CacheCreationJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/xmlcache/CacheCreationJUnitTest.java
b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/xmlcache/CacheCreationJUnitTest.java
index d2b43b0..e99a04b 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/xmlcache/CacheCreationJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/xmlcache/CacheCreationJUnitTest.java
@@ -23,9 +23,13 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
+import com.gemstone.gemfire.cache.GemFireCache;
+import com.gemstone.gemfire.cache.wan.GatewayReceiver;
+import com.gemstone.gemfire.cache.wan.GatewayReceiverFactory;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
+import org.mockito.InOrder;
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
 
@@ -201,4 +205,23 @@ public class CacheCreationJUnitTest {
 
     cacheCreation.startCacheServers(cacheCreation.getCacheServers(), cache, configuredServerPort,
configuredServerBindAddress, disableDefaultCacheServer);
   }
+
+  @Test
+  public void shouldCreateGatewaySenderAfterRegions() {
+    CacheCreation cacheCreation = new CacheCreation();
+    GatewayReceiver receiver = mock(GatewayReceiver.class);
+    cacheCreation.addGatewayReceiver(receiver);
+    cacheCreation.addRootRegion(new RegionCreation(cacheCreation, "region"));
+    GemFireCacheImpl cache = mock(GemFireCacheImpl.class);
+    GatewayReceiverFactory receiverFactory = mock(GatewayReceiverFactory.class);
+    when(cache.createGatewayReceiverFactory()).thenReturn(receiverFactory);
+    when(receiverFactory.create()).thenReturn(receiver);
+
+    InOrder inOrder = inOrder(cache, receiverFactory);
+    cacheCreation.create(cache);
+
+    inOrder.verify(cache).basicCreateRegion(eq("region"),any());
+    inOrder.verify(cache).createGatewayReceiverFactory();
+    inOrder.verify(receiverFactory).create();
+  }
 }


Mime
View raw message