geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ladyva...@apache.org
Subject [geode] 01/01: GEODE-3612: Add support for hostname-for-senders in gfsh create gateway-receiver command
Date Thu, 28 Sep 2017 20:48:15 GMT
This is an automated email from the ASF dual-hosted git repository.

ladyvader pushed a commit to branch feature/GEODE-3612
in repository https://gitbox.apache.org/repos/asf/geode.git

commit 2d426ff389fb402a557212727a5682a6fc315445
Author: Lynn Hughes-Godfrey <lhughesgodfrey@pivotal.io>
AuthorDate: Thu Sep 21 16:45:06 2017 -0700

    GEODE-3612: Add support for hostname-for-senders in gfsh create gateway-receiver command
---
 .../geode/internal/i18n/LocalizedStrings.java      |   2 +-
 .../cli/commands/CreateGatewayReceiverCommand.java |  11 +-
 .../functions/GatewayReceiverCreateFunction.java   |   5 +
 .../cli/functions/GatewayReceiverFunctionArgs.java |  10 +-
 .../management/internal/cli/i18n/CliStrings.java   |   4 +-
 .../geode/codeAnalysis/sanctionedSerializables.txt |   5 +-
 .../CreateGatewayReceiverCommandDUnitTest.java     | 112 ++++++++++++++++-----
 .../cache/wan/wancommand/WANCommandTestBase.java   |  32 +++++-
 8 files changed, 145 insertions(+), 36 deletions(-)

diff --git a/geode-core/src/main/java/org/apache/geode/internal/i18n/LocalizedStrings.java
b/geode-core/src/main/java/org/apache/geode/internal/i18n/LocalizedStrings.java
index 3a32db8..4d40ea2 100755
--- a/geode-core/src/main/java/org/apache/geode/internal/i18n/LocalizedStrings.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/i18n/LocalizedStrings.java
@@ -7213,7 +7213,7 @@ public class LocalizedStrings {
       new StringId(5305,
           "Exception occurred while handling call to {0}.afterAcknowledgement for event {1}:");
   public static final StringId GatewayReceiverImpl_USING_LOCAL_HOST =
-      new StringId(5399, "No bind-address or hostname-for-sender is specified, Using local
host ");
+      new StringId(5399, "No bind-address or hostname-for-senders specified, Using local
host ");
   public static final StringId GatewayReceiverImpl_COULD_NOT_GET_HOST_NAME =
       new StringId(5400, "Could not get host name");
   public static final StringId CqService_ERROR_SENDING_CQ_CONNECTION_STATUS =
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/CreateGatewayReceiverCommand.java
b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/CreateGatewayReceiverCommand.java
index a07aee1..33b3ff5 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/CreateGatewayReceiverCommand.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/CreateGatewayReceiverCommand.java
@@ -73,15 +73,18 @@ public class CreateGatewayReceiverCommand implements GfshCommand {
           help = CliStrings.CREATE_GATEWAYRECEIVER__SOCKETBUFFERSIZE__HELP) Integer socketBufferSize,
 
       @CliOption(key = CliStrings.CREATE_GATEWAYRECEIVER__GATEWAYTRANSPORTFILTER,
-          help = CliStrings.CREATE_GATEWAYRECEIVER__GATEWAYTRANSPORTFILTER__HELP) String[]
gatewayTransportFilters) {
+          help = CliStrings.CREATE_GATEWAYRECEIVER__GATEWAYTRANSPORTFILTER__HELP) String[]
gatewayTransportFilters,
+
+      @CliOption(key = CliStrings.CREATE_GATEWAYRECEIVER__HOSTNAMEFORSENDERS,
+          help = CliStrings.CREATE_GATEWAYRECEIVER__HOSTNAMEFORSENDERS__HELP) String hostnameForSenders)
{
 
     Result result;
 
     AtomicReference<XmlEntity> xmlEntity = new AtomicReference<>();
     try {
-      GatewayReceiverFunctionArgs gatewayReceiverFunctionArgs =
-          new GatewayReceiverFunctionArgs(manualStart, startPort, endPort, bindAddress,
-              socketBufferSize, maximumTimeBetweenPings, gatewayTransportFilters);
+      GatewayReceiverFunctionArgs gatewayReceiverFunctionArgs = new GatewayReceiverFunctionArgs(
+          manualStart, startPort, endPort, bindAddress, socketBufferSize, maximumTimeBetweenPings,
+          gatewayTransportFilters, hostnameForSenders);
 
       Set<DistributedMember> membersToCreateGatewayReceiverOn =
           CliUtil.findMembers(onGroups, onMember);
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/GatewayReceiverCreateFunction.java
b/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/GatewayReceiverCreateFunction.java
index a7dc7ea..c3da49a 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/GatewayReceiverCreateFunction.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/GatewayReceiverCreateFunction.java
@@ -157,6 +157,11 @@ public class GatewayReceiverCreateFunction extends FunctionAdapter implements
In
                 CliStrings.CREATE_GATEWAYRECEIVER__GATEWAYTRANSPORTFILTER));
       }
     }
+
+    String hostnameForSenders = gatewayReceiverCreateArgs.getHostnameForSenders();
+    if (hostnameForSenders != null) {
+      gatewayReceiverFactory.setHostnameForSenders(hostnameForSenders);
+    }
     return gatewayReceiverFactory.create();
   }
 
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/GatewayReceiverFunctionArgs.java
b/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/GatewayReceiverFunctionArgs.java
index 2084af9..72bcb83 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/GatewayReceiverFunctionArgs.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/GatewayReceiverFunctionArgs.java
@@ -36,9 +36,11 @@ public class GatewayReceiverFunctionArgs implements Serializable {
 
   private final String[] gatewayTransportFilters;
 
+  private final String hostnameForSenders;
+
   public GatewayReceiverFunctionArgs(Boolean manualStart, Integer startPort, Integer endPort,
       String bindAddress, Integer socketBufferSize, Integer maximumTimeBetweenPings,
-      String[] gatewayTransportFilters) {
+      String[] gatewayTransportFilters, String hostnameForSenders) {
     this.manualStart = manualStart;
     this.startPort = startPort;
     this.endPort = endPort;
@@ -46,6 +48,7 @@ public class GatewayReceiverFunctionArgs implements Serializable {
     this.socketBufferSize = socketBufferSize;
     this.maximumTimeBetweenPings = maximumTimeBetweenPings;
     this.gatewayTransportFilters = gatewayTransportFilters;
+    this.hostnameForSenders = hostnameForSenders;
   }
 
   public Boolean isManualStart() {
@@ -75,4 +78,9 @@ public class GatewayReceiverFunctionArgs implements Serializable {
   public String[] getGatewayTransportFilters() {
     return this.gatewayTransportFilters;
   }
+
+  public String getHostnameForSenders() {
+    return hostnameForSenders;
+  }
+
 }
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/i18n/CliStrings.java
b/geode-core/src/main/java/org/apache/geode/management/internal/cli/i18n/CliStrings.java
index 2492490..aa93e49 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/i18n/CliStrings.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/i18n/CliStrings.java
@@ -2122,7 +2122,9 @@ public class CliStrings {
   public static final String CREATE_GATEWAYRECEIVER__MANUALSTART = "manual-start";
   public static final String CREATE_GATEWAYRECEIVER__MANUALSTART__HELP =
       "Whether manual start is to be enabled or the receiver will start automatically after
creation.";
-
+  public static final String CREATE_GATEWAYRECEIVER__HOSTNAMEFORSENDERS = "hostname-for-senders";
+  public static final String CREATE_GATEWAYRECEIVER__HOSTNAMEFORSENDERS__HELP =
+      "The host name that server locators will tell GatewaySenders this GatewayReceiver is
listening on.";
 
   /* start gateway-receiver */
   public static final String START_GATEWAYRECEIVER = "start gateway-receiver";
diff --git a/geode-core/src/test/resources/org/apache/geode/codeAnalysis/sanctionedSerializables.txt
b/geode-core/src/test/resources/org/apache/geode/codeAnalysis/sanctionedSerializables.txt
index a588268..2df5d83 100755
--- a/geode-core/src/test/resources/org/apache/geode/codeAnalysis/sanctionedSerializables.txt
+++ b/geode-core/src/test/resources/org/apache/geode/codeAnalysis/sanctionedSerializables.txt
@@ -554,7 +554,7 @@ org/apache/geode/management/internal/cli/functions/FetchRegionAttributesFunction
 org/apache/geode/management/internal/cli/functions/FetchSharedConfigurationStatusFunction,true,1
 org/apache/geode/management/internal/cli/functions/GarbageCollectionFunction,true,1
 org/apache/geode/management/internal/cli/functions/GatewayReceiverCreateFunction,true,8746830191680509335
-org/apache/geode/management/internal/cli/functions/GatewayReceiverFunctionArgs,true,-5158224572470173267,bindAddress:java/lang/String,endPort:java/lang/Integer,gatewayTransportFilters:java/lang/String[],manualStart:java/lang/Boolean,maximumTimeBetweenPings:java/lang/Integer,socketBufferSize:java/lang/Integer,startPort:java/lang/Integer
+org/apache/geode/management/internal/cli/functions/GatewayReceiverFunctionArgs,true,-5158224572470173267,bindAddress:java/lang/String,endPort:java/lang/Integer,gatewayTransportFilters:java/lang/String[],hostnameForSenders:java/lang/String,manualStart:java/lang/Boolean,maximumTimeBetweenPings:java/lang/Integer,socketBufferSize:java/lang/Integer,startPort:java/lang/Integer
 org/apache/geode/management/internal/cli/functions/GatewaySenderCreateFunction,true,8746830191680509335
 org/apache/geode/management/internal/cli/functions/GatewaySenderDestroyFunction,true,1
 org/apache/geode/management/internal/cli/functions/GatewaySenderDestroyFunctionArgs,true,3848480256348119530,id:java/lang/String
@@ -612,10 +612,7 @@ org/apache/geode/management/internal/configuration/domain/SharedConfigurationSta
 org/apache/geode/management/internal/configuration/functions/GetRegionNamesFunction,false
 org/apache/geode/management/internal/configuration/functions/RecreateCacheFunction,false
 org/apache/geode/management/internal/configuration/functions/UploadJarFunction,true,1
-org/apache/geode/management/internal/web/domain/Link,false,href:java/net/URI,method:org/apache/geode/management/internal/web/http/HttpMethod,relation:java/lang/String
 org/apache/geode/management/internal/web/domain/QueryParameterSource,true,34131123582155,objectName:javax/management/ObjectName,queryExpression:javax/management/QueryExp
-org/apache/geode/management/internal/web/http/HttpHeader,false,name:java/lang/String
-org/apache/geode/management/internal/web/http/HttpMethod,false
 org/apache/geode/management/internal/web/shell/MBeanAccessException,true,813768898269516238
 org/apache/geode/management/internal/web/shell/RestApiCallForCommandNotFoundException,true,6686566370779394304
 org/apache/geode/memcached/GemFireMemcachedServer$Protocol,false
diff --git a/geode-wan/src/test/java/org/apache/geode/internal/cache/wan/wancommand/CreateGatewayReceiverCommandDUnitTest.java
b/geode-wan/src/test/java/org/apache/geode/internal/cache/wan/wancommand/CreateGatewayReceiverCommandDUnitTest.java
index af27a60..63a5043 100644
--- a/geode-wan/src/test/java/org/apache/geode/internal/cache/wan/wancommand/CreateGatewayReceiverCommandDUnitTest.java
+++ b/geode-wan/src/test/java/org/apache/geode/internal/cache/wan/wancommand/CreateGatewayReceiverCommandDUnitTest.java
@@ -19,9 +19,14 @@ import static org.apache.geode.test.dunit.Assert.assertTrue;
 import static org.apache.geode.test.dunit.Assert.fail;
 import static org.apache.geode.test.dunit.LogWriterUtils.getLogWriter;
 
+import java.net.InetAddress;
+import java.net.UnknownHostException;
 import java.util.ArrayList;
 import java.util.List;
 
+import org.apache.geode.internal.i18n.LocalizedStrings;
+import org.apache.geode.internal.logging.log4j.LocalizedMessage;
+import org.apache.geode.internal.net.SocketCreator;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
 
@@ -48,7 +53,7 @@ public class CreateGatewayReceiverCommandDUnitTest extends WANCommandTestBase
{
    * GatewayReceiver with all default attributes
    */
   @Test
-  public void testCreateGatewayReceiverWithDefault() {
+  public void testCreateGatewayReceiverWithDefault() throws Exception {
     VM puneLocator = Host.getLocator();
     int dsIdPort = puneLocator.invoke(this::getLocatorPort);
     propsSetUp(dsIdPort);
@@ -76,18 +81,21 @@ public class CreateGatewayReceiverCommandDUnitTest extends WANCommandTestBase
{
       fail("testCreateGatewayReceiver failed as did not get CommandResult");
     }
 
+    String hostname;
+    hostname = SocketCreator.getLocalHost().getHostName();
+
     vm3.invoke(() -> verifyReceiverCreationWithAttributes(!GatewayReceiver.DEFAULT_MANUAL_START,
         GatewayReceiver.DEFAULT_START_PORT, GatewayReceiver.DEFAULT_END_PORT,
         GatewayReceiver.DEFAULT_BIND_ADDRESS, GatewayReceiver.DEFAULT_MAXIMUM_TIME_BETWEEN_PINGS,
-        GatewayReceiver.DEFAULT_SOCKET_BUFFER_SIZE, null));
+        GatewayReceiver.DEFAULT_SOCKET_BUFFER_SIZE, null, hostname));
     vm4.invoke(() -> verifyReceiverCreationWithAttributes(!GatewayReceiver.DEFAULT_MANUAL_START,
         GatewayReceiver.DEFAULT_START_PORT, GatewayReceiver.DEFAULT_END_PORT,
         GatewayReceiver.DEFAULT_BIND_ADDRESS, GatewayReceiver.DEFAULT_MAXIMUM_TIME_BETWEEN_PINGS,
-        GatewayReceiver.DEFAULT_SOCKET_BUFFER_SIZE, null));
+        GatewayReceiver.DEFAULT_SOCKET_BUFFER_SIZE, null, hostname));
     vm5.invoke(() -> verifyReceiverCreationWithAttributes(!GatewayReceiver.DEFAULT_MANUAL_START,
         GatewayReceiver.DEFAULT_START_PORT, GatewayReceiver.DEFAULT_END_PORT,
         GatewayReceiver.DEFAULT_BIND_ADDRESS, GatewayReceiver.DEFAULT_MAXIMUM_TIME_BETWEEN_PINGS,
-        GatewayReceiver.DEFAULT_SOCKET_BUFFER_SIZE, null));
+        GatewayReceiver.DEFAULT_SOCKET_BUFFER_SIZE, null, hostname));
   }
 
   /**
@@ -128,14 +136,70 @@ public class CreateGatewayReceiverCommandDUnitTest extends WANCommandTestBase
{
       fail("testCreateGatewayReceiver failed as did not get CommandResult");
     }
     vm3.invoke(() -> verifyReceiverCreationWithAttributes(false, 10000, 11000, "localhost",
100000,
-        512000, null));
+        512000, null, "localhost"));
     vm4.invoke(() -> verifyReceiverCreationWithAttributes(false, 10000, 11000, "localhost",
100000,
-        512000, null));
+        512000, null, "localhost"));
     vm5.invoke(() -> verifyReceiverCreationWithAttributes(false, 10000, 11000, "localhost",
100000,
-        512000, null));
+        512000, null, "localhost"));
   }
 
   /**
+   * GatewayReceiver with hostnameForSenders
+   */
+  @Test
+  public void testCreateGatewayReceiverWithHostnameForSenders() throws UnknownHostException
{
+    VM puneLocator = Host.getLocator();
+    int dsIdPort = puneLocator.invoke(this::getLocatorPort);
+    propsSetUp(dsIdPort);
+    vm2.invoke(() -> createFirstRemoteLocator(2, dsIdPort));
+
+    vm3.invoke(() -> createCache(dsIdPort));
+    vm4.invoke(() -> createCache(dsIdPort));
+    vm5.invoke(() -> createCache(dsIdPort));
+
+    String hostnameForSenders = InetAddress.getLocalHost().getHostName();
+    String command =
+        CliStrings.CREATE_GATEWAYRECEIVER + " --" + CliStrings.CREATE_GATEWAYRECEIVER__MANUALSTART
+            + "=false" + " --" + CliStrings.CREATE_GATEWAYRECEIVER__HOSTNAMEFORSENDERS +
"="
+            + hostnameForSenders + " --" + CliStrings.CREATE_GATEWAYRECEIVER__STARTPORT +
"=10000"
+            + " --" + CliStrings.CREATE_GATEWAYRECEIVER__ENDPORT + "=11000" + " --"
+            + CliStrings.CREATE_GATEWAYRECEIVER__MAXTIMEBETWEENPINGS + "=100000" + " --"
+            + CliStrings.CREATE_GATEWAYRECEIVER__SOCKETBUFFERSIZE + "=512000";
+    CommandResult cmdResult = executeCommand(command);
+    if (cmdResult != null) {
+      String strCmdResult = commandResultToString(cmdResult);
+      getLogWriter().info("testCreateGatewayReceiver stringResult : " + strCmdResult + ">>>>");
+      assertEquals(Result.Status.OK, cmdResult.getStatus());
+
+      TabularResultData resultData = (TabularResultData) cmdResult.getResultData();
+      List<String> status = resultData.retrieveAllValues("Status");
+      assertEquals(4, status.size());// expected size 4 includes the manager node
+      // verify there is no error in the status
+      for (String stat : status) {
+        assertTrue("GatewayReceiver creation failed with: " + stat, !stat.contains("ERROR:"));
+      }
+    } else {
+      fail("testCreateGatewayReceiver failed as did not get CommandResult");
+    }
+
+    vm3.invoke(() -> verifyGatewayReceiverProfile(hostnameForSenders));
+    vm4.invoke(() -> verifyGatewayReceiverProfile(hostnameForSenders));
+    vm5.invoke(() -> verifyGatewayReceiverProfile(hostnameForSenders));
+
+    vm3.invoke(() -> verifyGatewayReceiverServerLocations(dsIdPort, hostnameForSenders));
+    vm4.invoke(() -> verifyGatewayReceiverServerLocations(dsIdPort, hostnameForSenders));
+    vm5.invoke(() -> verifyGatewayReceiverServerLocations(dsIdPort, hostnameForSenders));
+
+    vm3.invoke(() -> verifyReceiverCreationWithAttributes(true, 10000, 11000, "", 100000,
512000,
+        null, hostnameForSenders));
+    vm4.invoke(() -> verifyReceiverCreationWithAttributes(true, 10000, 11000, "", 100000,
512000,
+        null, hostnameForSenders));
+    vm5.invoke(() -> verifyReceiverCreationWithAttributes(true, 10000, 11000, "", 100000,
512000,
+        null, hostnameForSenders));
+  }
+
+
+  /**
    * GatewayReceiver with given attributes and a single GatewayTransportFilter.
    */
   @Test
@@ -178,11 +242,11 @@ public class CreateGatewayReceiverCommandDUnitTest extends WANCommandTestBase
{
     transportFilters.add("org.apache.geode.cache30.MyGatewayTransportFilter1");
 
     vm3.invoke(() -> verifyReceiverCreationWithAttributes(true, 10000, 11000, "localhost",
100000,
-        512000, transportFilters));
+        512000, transportFilters, "localhost"));
     vm4.invoke(() -> verifyReceiverCreationWithAttributes(true, 10000, 11000, "localhost",
100000,
-        512000, transportFilters));
+        512000, transportFilters, "localhost"));
     vm5.invoke(() -> verifyReceiverCreationWithAttributes(true, 10000, 11000, "localhost",
100000,
-        512000, transportFilters));
+        512000, transportFilters, "localhost"));
   }
 
   /**
@@ -228,11 +292,11 @@ public class CreateGatewayReceiverCommandDUnitTest extends WANCommandTestBase
{
     transportFilters.add("org.apache.geode.cache30.MyGatewayTransportFilter2");
 
     vm3.invoke(() -> verifyReceiverCreationWithAttributes(!GatewayReceiver.DEFAULT_MANUAL_START,
-        10000, 11000, "localhost", 100000, 512000, transportFilters));
+        10000, 11000, "localhost", 100000, 512000, transportFilters, "localhost"));
     vm4.invoke(() -> verifyReceiverCreationWithAttributes(!GatewayReceiver.DEFAULT_MANUAL_START,
-        10000, 11000, "localhost", 100000, 512000, transportFilters));
+        10000, 11000, "localhost", 100000, 512000, transportFilters, "localhost"));
     vm5.invoke(() -> verifyReceiverCreationWithAttributes(!GatewayReceiver.DEFAULT_MANUAL_START,
-        10000, 11000, "localhost", 100000, 512000, transportFilters));
+        10000, 11000, "localhost", 100000, 512000, transportFilters, "localhost"));
   }
 
   /**
@@ -315,7 +379,7 @@ public class CreateGatewayReceiverCommandDUnitTest extends WANCommandTestBase
{
       fail("testCreateGatewayReceiver failed as did not get CommandResult");
     }
     vm3.invoke(() -> verifyReceiverCreationWithAttributes(false, 10000, 11000, "localhost",
100000,
-        512000, null));
+        512000, null, "localhost"));
   }
 
   /**
@@ -361,9 +425,9 @@ public class CreateGatewayReceiverCommandDUnitTest extends WANCommandTestBase
{
       fail("testCreateGatewayReceiver failed as did not get CommandResult");
     }
     vm3.invoke(() -> verifyReceiverCreationWithAttributes(false, 10000, 11000, "localhost",
100000,
-        512000, null));
+        512000, null, "localhost"));
     vm4.invoke(() -> verifyReceiverCreationWithAttributes(false, 10000, 11000, "localhost",
100000,
-        512000, null));
+        512000, null, "localhost"));
   }
 
   /**
@@ -406,11 +470,11 @@ public class CreateGatewayReceiverCommandDUnitTest extends WANCommandTestBase
{
     }
 
     vm3.invoke(() -> verifyReceiverCreationWithAttributes(false, 10000, 11000, "localhost",
100000,
-        512000, null));
+        512000, null, "localhost"));
     vm4.invoke(() -> verifyReceiverCreationWithAttributes(false, 10000, 11000, "localhost",
100000,
-        512000, null));
+        512000, null, "localhost"));
     vm5.invoke(() -> verifyReceiverCreationWithAttributes(false, 10000, 11000, "localhost",
100000,
-        512000, null));
+        512000, null, "localhost"));
   }
 
   /**
@@ -453,9 +517,9 @@ public class CreateGatewayReceiverCommandDUnitTest extends WANCommandTestBase
{
       fail("testCreateGatewayReceiver failed as did not get CommandResult");
     }
     vm3.invoke(() -> verifyReceiverCreationWithAttributes(false, 10000, 11000, "localhost",
100000,
-        512000, null));
+        512000, null, "localhost"));
     vm4.invoke(() -> verifyReceiverCreationWithAttributes(false, 10000, 11000, "localhost",
100000,
-        512000, null));
+        512000, null, "localhost"));
   }
 
   /**
@@ -497,10 +561,10 @@ public class CreateGatewayReceiverCommandDUnitTest extends WANCommandTestBase
{
       fail("testCreateGatewayReceiver failed as did not get CommandResult");
     }
     vm3.invoke(() -> verifyReceiverCreationWithAttributes(false, 10000, 11000, "localhost",
100000,
-        512000, null));
+        512000, null, "localhost"));
     vm4.invoke(() -> verifyReceiverCreationWithAttributes(false, 10000, 11000, "localhost",
100000,
-        512000, null));
+        512000, null, "localhost"));
     vm5.invoke(() -> verifyReceiverCreationWithAttributes(false, 10000, 11000, "localhost",
100000,
-        512000, null));
+        512000, null, "localhost"));
   }
 }
diff --git a/geode-wan/src/test/java/org/apache/geode/internal/cache/wan/wancommand/WANCommandTestBase.java
b/geode-wan/src/test/java/org/apache/geode/internal/cache/wan/wancommand/WANCommandTestBase.java
index 1e67093..eb5da71 100644
--- a/geode-wan/src/test/java/org/apache/geode/internal/cache/wan/wancommand/WANCommandTestBase.java
+++ b/geode-wan/src/test/java/org/apache/geode/internal/cache/wan/wancommand/WANCommandTestBase.java
@@ -37,6 +37,10 @@ import org.apache.geode.cache.Cache;
 import org.apache.geode.cache.CacheFactory;
 import org.apache.geode.cache.DiskStore;
 import org.apache.geode.cache.DiskStoreFactory;
+import org.apache.geode.cache.client.PoolFactory;
+import org.apache.geode.cache.client.PoolManager;
+import org.apache.geode.cache.client.internal.ConnectionSource;
+import org.apache.geode.cache.client.internal.PoolImpl;
 import org.apache.geode.cache.wan.GatewayEventFilter;
 import org.apache.geode.cache.wan.GatewayReceiver;
 import org.apache.geode.cache.wan.GatewayReceiverFactory;
@@ -47,8 +51,11 @@ import org.apache.geode.cache.wan.GatewayTransportFilter;
 import org.apache.geode.distributed.DistributedMember;
 import org.apache.geode.distributed.Locator;
 import org.apache.geode.distributed.internal.InternalDistributedSystem;
+import org.apache.geode.distributed.internal.ServerLocation;
 import org.apache.geode.internal.AvailablePort;
 import org.apache.geode.internal.AvailablePortHelper;
+import org.apache.geode.internal.cache.CacheServerAdvisor;
+import org.apache.geode.internal.cache.CacheServerImpl;
 import org.apache.geode.internal.cache.GemFireCacheImpl;
 import org.apache.geode.internal.cache.LocalRegion;
 import org.apache.geode.internal.cache.wan.AbstractGatewaySender;
@@ -409,9 +416,31 @@ public abstract class WANCommandTestBase extends CliCommandTestBase {
     }
   }
 
+  protected void verifyGatewayReceiverServerLocations(int locatorPort, String hostname) {
+    PoolFactory pf = PoolManager.createFactory();
+    pf.setServerGroup(GatewayReceiver.RECEIVER_GROUP);
+    pf.addLocator("localhost", locatorPort);
+    PoolImpl pool = (PoolImpl) pf.create("gateway-receiver-pool");
+    ConnectionSource connectionSource = pool.getConnectionSource();
+    List<ServerLocation> serverLocations = connectionSource.getAllServers();
+    for (ServerLocation serverLocation : serverLocations) {
+      assertEquals(hostname, serverLocation.getHostName());
+    }
+  }
+
+  protected void verifyGatewayReceiverProfile(String hostname) {
+    Set<GatewayReceiver> receivers = ((Cache) this.cache).getGatewayReceivers();
+    for (GatewayReceiver receiver : receivers) {
+      CacheServerImpl server = (CacheServerImpl) receiver.getServer();
+      CacheServerAdvisor.CacheServerProfile profile =
+          (CacheServerAdvisor.CacheServerProfile) server.getProfile();
+      assertEquals(hostname, profile.getHost());
+    }
+  }
+
   public void verifyReceiverCreationWithAttributes(boolean isRunning, int startPort, int
endPort,
       String bindAddress, int maxTimeBetweenPings, int socketBufferSize,
-      List<String> expectedGatewayTransportFilters) {
+      List<String> expectedGatewayTransportFilters, String hostnameForSenders) {
 
     Set<GatewayReceiver> receivers = cache.getGatewayReceivers();
     assertEquals("Number of receivers is incorrect", 1, receivers.size());
@@ -423,6 +452,7 @@ public abstract class WANCommandTestBase extends CliCommandTestBase {
       assertEquals("maximumTimeBetweenPings", maxTimeBetweenPings,
           receiver.getMaximumTimeBetweenPings());
       assertEquals("socketBufferSize", socketBufferSize, receiver.getSocketBufferSize());
+      assertEquals("hostnameForSenders", hostnameForSenders, receiver.getHost());
 
       // verify GatewayTransportFilters
       if (expectedGatewayTransportFilters != null) {

-- 
To stop receiving notification emails like this one, please contact
"commits@geode.apache.org" <commits@geode.apache.org>.

Mime
View raw message