geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From upthewatersp...@apache.org
Subject [2/2] incubator-geode git commit: GEODE-1810: WAN locator exchange doesn't include hostname-for-clients if it is set
Date Tue, 23 Aug 2016 16:38:36 GMT
GEODE-1810: WAN locator exchange doesn't include hostname-for-clients if it is set

While exchanging locators, DistributionLocatorID will be constructed
using hostNameforClients. It looks like this was happening if an
embedded locator was started using the start-locator distributed system
property, but not for any other case.

Adding a test that we actually send the hostname for clients to remote
locators.


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

Branch: refs/heads/develop
Commit: 48589a0fa0d841bf53e200dcdc967c82cd95e05b
Parents: d5018b2
Author: Dan Smith <upthewaterspout@apache.org>
Authored: Mon Aug 22 15:43:26 2016 -0700
Committer: Dan Smith <upthewaterspout@apache.org>
Committed: Tue Aug 23 09:28:38 2016 -0700

----------------------------------------------------------------------
 .../distributed/internal/InternalLocator.java   |   2 +-
 .../internal/WanLocatorDiscoverer.java          |   2 +-
 .../admin/remote/DistributionLocatorId.java     |  12 +-
 .../gemfire/internal/i18n/LocalizedStrings.java |   2 +-
 .../internal/locator/wan/LocatorDiscovery.java  |   4 +-
 .../locator/wan/WanLocatorDiscovererImpl.java   |  36 +++--
 .../gemfire/internal/cache/wan/WANTestBase.java |  50 ++++---
 .../wan/misc/WanAutoDiscoveryDUnitTest.java     | 134 ++++++++++++-------
 8 files changed, 153 insertions(+), 89 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/48589a0f/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/InternalLocator.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/InternalLocator.java
b/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/InternalLocator.java
index 46d9610..3c9fa97 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/InternalLocator.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/InternalLocator.java
@@ -833,7 +833,7 @@ public class InternalLocator extends Locator implements ConnectListener
{
     
     this.locatorDiscoverer = WANServiceProvider.createLocatorDiscoverer();
     if(this.locatorDiscoverer != null) {
-      this.locatorDiscoverer.discover(getPort(), config, locatorListener);
+      this.locatorDiscoverer.discover(getPort(), config, locatorListener, hostnameForClients);
     }
   }
   

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/48589a0f/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/WanLocatorDiscoverer.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/WanLocatorDiscoverer.java
b/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/WanLocatorDiscoverer.java
index 450d3a1..05e04e0 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/WanLocatorDiscoverer.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/WanLocatorDiscoverer.java
@@ -27,7 +27,7 @@ public interface WanLocatorDiscoverer {
    * For WAN 70 Exchange the locator information within the distributed system
    */
   void discover(int port, DistributionConfigImpl config,
-      LocatorMembershipListener locatorListener);
+                LocatorMembershipListener locatorListener, final String hostnameForClients);
 
   void stop();
 

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/48589a0f/geode-core/src/main/java/com/gemstone/gemfire/internal/admin/remote/DistributionLocatorId.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/admin/remote/DistributionLocatorId.java
b/geode-core/src/main/java/com/gemstone/gemfire/internal/admin/remote/DistributionLocatorId.java
index 1459d89..60d740a 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/admin/remote/DistributionLocatorId.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/admin/remote/DistributionLocatorId.java
@@ -67,6 +67,10 @@ public class DistributionLocatorId implements java.io.Serializable {
    * set to the local host.
    */
   public DistributionLocatorId(int port, String bindAddress) {
+    this(port, bindAddress, null);
+  }
+  
+  public DistributionLocatorId(int port, String bindAddress, String hostnameForClients) {
     try {
       this.host = SocketCreator.getLocalHost();
     } catch (UnknownHostException ex) {
@@ -75,6 +79,7 @@ public class DistributionLocatorId implements java.io.Serializable {
     this.port = port;
     this.bindAddress = validateBindAddress(bindAddress);
     this.sslConfig = validateSSLConfig(null);
+    this.hostnameForClients = hostnameForClients;
   }
   
   public DistributionLocatorId(InetAddress host, 
@@ -283,8 +288,11 @@ public class DistributionLocatorId implements java.io.Serializable {
 	public String toString() {
           StringBuffer sb = new StringBuffer();
   
-          // if bindAddress then use that instead of host...
-          if (this.bindAddress != null && this.bindAddress.length() > 0) {
+          // If hostnameForClients is set, use that
+          if (this.hostnameForClients != null && this.hostnameForClients.length()
> 0) {
+            sb.append(this.hostnameForClients);
+          } else if (this.bindAddress != null && this.bindAddress.length() > 0)
{
+            // if bindAddress then use that instead of host...
             sb.append(this.bindAddress);
           }
           else {

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/48589a0f/geode-core/src/main/java/com/gemstone/gemfire/internal/i18n/LocalizedStrings.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/i18n/LocalizedStrings.java
b/geode-core/src/main/java/com/gemstone/gemfire/internal/i18n/LocalizedStrings.java
index 5f9213d..95bf700 100755
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/i18n/LocalizedStrings.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/i18n/LocalizedStrings.java
@@ -3431,7 +3431,7 @@ public class LocalizedStrings {
   public static final StringId GatewaySenderImpl_GATEWAY_0_CANNOT_BE_CREATED_WITH_REMOTE_SITE_ID_LESS_THAN_ZERO
= new StringId(5200, "GatewaySender {0} cannot be created with remote DS Id less than 0. ");
   public static final StringId CacheXmlParser_A_0_MUST_BE_DEFINED_IN_THE_CONTEXT_OF_GATEWAYSENDER_OR_GATEWAYRECEIVER
= new StringId(5201, "A  {0}  must be defined in the context of gateway-sender or gateway-receiver.");
   public static final StringId Sender_COULD_NOT_START_GATEWAYSENDER_0_BECAUSE_OF_EXCEPTION_1
= new StringId(5202, "Could not start a gateway sender {0} because of exception {1}");
-  public static final StringId LOCATOR_DISCOVERY_TASK_EXCHANGED_LOCATOR_INFORMATION_0_WITH_1
= new StringId(5203, "Locator discovery task exchanged locator information {0} with {1}.");
+  public static final StringId LOCATOR_DISCOVERY_TASK_EXCHANGED_LOCATOR_INFORMATION_0_WITH_1
= new StringId(5203, "Locator discovery task exchanged locator information {0} with {1}: {2}.");
 
   public static final StringId DistributionManager_RECEIVED_NO_STARTUP_RESPONSES_BUT_OTHER_MEMBERS_EXIST_MULTICAST_IS_NOT_RESPONSIVE
= new StringId(5205, "Did not receive a startup response but other members exist.  Multicast
does not seem to be working.");
 

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/48589a0f/geode-wan/src/main/java/com/gemstone/gemfire/cache/client/internal/locator/wan/LocatorDiscovery.java
----------------------------------------------------------------------
diff --git a/geode-wan/src/main/java/com/gemstone/gemfire/cache/client/internal/locator/wan/LocatorDiscovery.java
b/geode-wan/src/main/java/com/gemstone/gemfire/cache/client/internal/locator/wan/LocatorDiscovery.java
index 0fd206e..7e2b8ae 100644
--- a/geode-wan/src/main/java/com/gemstone/gemfire/cache/client/internal/locator/wan/LocatorDiscovery.java
+++ b/geode-wan/src/main/java/com/gemstone/gemfire/cache/client/internal/locator/wan/LocatorDiscovery.java
@@ -136,7 +136,7 @@ public class LocatorDiscovery{
           LocatorHelper.addExchangedLocators(response.getLocators(),
               this.locatorListener);
           logger.info(LocalizedMessage.create(LocalizedStrings.LOCATOR_DISCOVERY_TASK_EXCHANGED_LOCATOR_INFORMATION_0_WITH_1,
-              new Object[] { request.getLocator(), locatorId }));
+              new Object[] { request.getLocator(), locatorId, response.getLocators() }));
           break;
         }
       }
@@ -182,7 +182,7 @@ public class LocatorDiscovery{
         if (response != null) {
           LocatorHelper.addExchangedLocators(response.getLocators(), this.locatorListener);
           logger.info(LocalizedMessage.create(LocalizedStrings.LOCATOR_DISCOVERY_TASK_EXCHANGED_LOCATOR_INFORMATION_0_WITH_1,
-              new Object[] { request.getLocator(), locatorId }));
+              new Object[] { request.getLocator(), locatorId, response.getLocators() }));
           RemoteLocatorPingRequest pingRequest = new RemoteLocatorPingRequest(
               "");
           while (true) {

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/48589a0f/geode-wan/src/main/java/com/gemstone/gemfire/cache/client/internal/locator/wan/WanLocatorDiscovererImpl.java
----------------------------------------------------------------------
diff --git a/geode-wan/src/main/java/com/gemstone/gemfire/cache/client/internal/locator/wan/WanLocatorDiscovererImpl.java
b/geode-wan/src/main/java/com/gemstone/gemfire/cache/client/internal/locator/wan/WanLocatorDiscovererImpl.java
index b6a0070..1d44e65 100644
--- a/geode-wan/src/main/java/com/gemstone/gemfire/cache/client/internal/locator/wan/WanLocatorDiscovererImpl.java
+++ b/geode-wan/src/main/java/com/gemstone/gemfire/cache/client/internal/locator/wan/WanLocatorDiscovererImpl.java
@@ -42,7 +42,10 @@ public class WanLocatorDiscovererImpl implements WanLocatorDiscoverer{
   }
   
   @Override
-  public void discover(int port, DistributionConfigImpl config, LocatorMembershipListener
locatorListener) {
+  public void discover(int port,
+                       DistributionConfigImpl config,
+                       LocatorMembershipListener locatorListener,
+                       final String hostnameForClients) {
     final LoggingThreadGroup loggingThreadGroup = LoggingThreadGroup
         .createThreadGroup("WAN Locator Discovery Logger Group", logger);
 
@@ -56,8 +59,8 @@ public class WanLocatorDiscovererImpl implements WanLocatorDiscoverer{
     };
 
     this._executor = Executors.newCachedThreadPool(threadFactory);
-    exchangeLocalLocators(port, config, locatorListener);
-    exchangeRemoteLocators(port, config, locatorListener);
+    exchangeLocalLocators(port, config, locatorListener, hostnameForClients);
+    exchangeRemoteLocators(port, config, locatorListener, hostnameForClients);
     this._executor.shutdown();
   }
 
@@ -73,21 +76,25 @@ public class WanLocatorDiscovererImpl implements WanLocatorDiscoverer{
 
   /**
    * For WAN 70 Exchange the locator information within the distributed system
-   * 
+   *
    * @param config
+   * @param hostnameForClients
    */
-  private void exchangeLocalLocators(int port, DistributionConfigImpl config, LocatorMembershipListener
locatorListener) {
+  private void exchangeLocalLocators(int port,
+                                     DistributionConfigImpl config,
+                                     LocatorMembershipListener locatorListener,
+                                     final String hostnameForClients) {
     String localLocator = config.getStartLocator();
     DistributionLocatorId locatorId = null;
     if (localLocator.equals(DistributionConfig.DEFAULT_START_LOCATOR)) {
-      locatorId = new DistributionLocatorId(port, config.getBindAddress());
+      locatorId = new DistributionLocatorId(port, config.getBindAddress(), hostnameForClients);
     }
     else {
       locatorId = new DistributionLocatorId(localLocator);
     }
     LocatorHelper.addLocator(config.getDistributedSystemId(), locatorId, locatorListener,
null);
 
-    RemoteLocatorJoinRequest request = buildRemoteDSJoinRequest(port, config);
+    RemoteLocatorJoinRequest request = buildRemoteDSJoinRequest(port, config, hostnameForClients);
     StringTokenizer locatorsOnThisVM = new StringTokenizer(
         config.getLocators(), ",");
     while (locatorsOnThisVM.hasMoreTokens()) {
@@ -104,11 +111,15 @@ public class WanLocatorDiscovererImpl implements WanLocatorDiscoverer{
   /**
    * For WAN 70 Exchange the locator information across the distributed systems
    * (sites)
-   * 
+   *
    * @param config
+   * @param hostnameForClients
    */
-  private void exchangeRemoteLocators(int port, DistributionConfigImpl config, LocatorMembershipListener
locatorListener) {
-    RemoteLocatorJoinRequest request = buildRemoteDSJoinRequest(port, config);
+  private void exchangeRemoteLocators(int port,
+                                      DistributionConfigImpl config,
+                                      LocatorMembershipListener locatorListener,
+                                      final String hostnameForClients) {
+    RemoteLocatorJoinRequest request = buildRemoteDSJoinRequest(port, config, hostnameForClients);
     String remoteDistributedSystems = config.getRemoteLocators();
     if (remoteDistributedSystems.length() > 0) {
       StringTokenizer remoteLocators = new StringTokenizer(
@@ -125,11 +136,12 @@ public class WanLocatorDiscovererImpl implements WanLocatorDiscoverer{
   }
   
   private RemoteLocatorJoinRequest buildRemoteDSJoinRequest(int port,
-      DistributionConfigImpl config) {
+                                                            DistributionConfigImpl config,
+                                                            final String hostnameForClients)
{
     String localLocator = config.getStartLocator();
     DistributionLocatorId locatorId = null;
     if (localLocator.equals(DistributionConfig.DEFAULT_START_LOCATOR)) {
-      locatorId = new DistributionLocatorId(port, config.getBindAddress());
+      locatorId = new DistributionLocatorId(port, config.getBindAddress(), hostnameForClients);
     }
     else {
       locatorId = new DistributionLocatorId(localLocator);

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/48589a0f/geode-wan/src/test/java/com/gemstone/gemfire/internal/cache/wan/WANTestBase.java
----------------------------------------------------------------------
diff --git a/geode-wan/src/test/java/com/gemstone/gemfire/internal/cache/wan/WANTestBase.java
b/geode-wan/src/test/java/com/gemstone/gemfire/internal/cache/wan/WANTestBase.java
index fd2c0b5..fac9a76 100644
--- a/geode-wan/src/test/java/com/gemstone/gemfire/internal/cache/wan/WANTestBase.java
+++ b/geode-wan/src/test/java/com/gemstone/gemfire/internal/cache/wan/WANTestBase.java
@@ -22,7 +22,9 @@ import static org.junit.Assert.*;
 import java.io.File;
 import java.io.IOException;
 import java.io.Serializable;
+import java.net.InetAddress;
 import java.net.InetSocketAddress;
+import java.net.UnknownHostException;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
@@ -44,6 +46,7 @@ import java.util.concurrent.Future;
 import java.util.concurrent.ThreadFactory;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicInteger;
+import java.util.stream.Collectors;
 
 import com.jayway.awaitility.Awaitility;
 import org.junit.experimental.categories.Category;
@@ -354,6 +357,22 @@ public class WANTestBase extends JUnit4DistributedTestCase {
     return port;
   }
 
+  public static Integer createSecondRemoteLocatorWithAPI(int dsId, int localPort,
+                                                  int remoteLocPort, String hostnameForClients)
+    throws IOException
+  {
+    stopOldLocator();
+    WANTestBase test = new WANTestBase();
+    int port = AvailablePortHelper.getRandomAvailablePortForDUnitSite();
+    Properties props = test.getDistributedSystemProperties();
+    props.setProperty(MCAST_PORT, "0");
+    props.setProperty(DISTRIBUTED_SYSTEM_ID, ""+dsId);
+    props.setProperty(LOCATORS, "localhost[" + localPort + "]");
+    props.setProperty(REMOTE_LOCATORS, "localhost[" + remoteLocPort + "]");
+    Locator locator = Locator.startLocatorAndDS(0, null, InetAddress.getByName("localhost"),
props, true, true, hostnameForClients);
+    return locator.getPort();
+  }
+
   public static Integer createSecondRemotePeerLocator(int dsId, int localPort,
       int remoteLocPort) {
     stopOldLocator();
@@ -2976,27 +2995,22 @@ public class WANTestBase extends JUnit4DistributedTestCase {
   }
 
   public static void checkAllSiteMetaData(
-      Map<Integer, ArrayList<Integer>> dsVsPorts) {
-    Awaitility.await().atMost(10,TimeUnit.SECONDS).until(() -> assertNotNull(getSystemStatic()));
+      Map<Integer, Set<InetSocketAddress>> dsIdToLocatorAddresses) {
     List<Locator> locatorsConfigured = Locator.getLocators();
     Locator locator = locatorsConfigured.get(0);
-    Map<Integer,Set<DistributionLocatorId>> allSiteMetaData = ((InternalLocator)locator).getlocatorMembershipListener().getAllLocatorsInfo();
-    System.out.println("allSiteMetaData : " + allSiteMetaData);
-    System.out.println("dsVsPorts : " + dsVsPorts);
-    System.out.println("Server allSiteMetaData : " + ((InternalLocator)locator).getlocatorMembershipListener().getAllServerLocatorsInfo());
-    for (Map.Entry<Integer, ArrayList<Integer>> entry : dsVsPorts.entrySet())
{
-      Set<DistributionLocatorId> locators = allSiteMetaData.get(entry.getKey());
-      assertNotNull(locators);
-      for (Integer port : entry.getValue()) {
-        boolean portAvailable = false;
-        for(DistributionLocatorId locId : locators){
-          if(locId.getPort() == port){
-            portAvailable = true;
-          }
-        }
-        assertTrue(portAvailable);
+    Awaitility.waitAtMost(60, TimeUnit.SECONDS).until( () -> {
+      Map<Integer, Set<DistributionLocatorId>> allSiteMetaData = ((InternalLocator)
locator)
+        .getlocatorMembershipListener().getAllLocatorsInfo();
+      for (Map.Entry<Integer, Set<InetSocketAddress>> entry : dsIdToLocatorAddresses.entrySet())
{
+        Set<DistributionLocatorId> foundLocatorIds = allSiteMetaData.get(entry.getKey());
+        Set<InetSocketAddress> expectedLocators = entry.getValue();
+        final Set<InetSocketAddress> foundLocators = foundLocatorIds.stream()
+          .map(distributionLocatorId -> new InetSocketAddress(distributionLocatorId.getHostnameForClients(),
+            distributionLocatorId.getPort()))
+          .collect(Collectors.toSet());
+        assertEquals(expectedLocators, foundLocators);
       }
-    }
+    });
   }
 
   public static Long checkAllSiteMetaDataFor3Sites(final Map<Integer, Set<String>>
dsVsPort) {

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/48589a0f/geode-wan/src/test/java/com/gemstone/gemfire/internal/cache/wan/misc/WanAutoDiscoveryDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-wan/src/test/java/com/gemstone/gemfire/internal/cache/wan/misc/WanAutoDiscoveryDUnitTest.java
b/geode-wan/src/test/java/com/gemstone/gemfire/internal/cache/wan/misc/WanAutoDiscoveryDUnitTest.java
index fc16571..4148789 100644
--- a/geode-wan/src/test/java/com/gemstone/gemfire/internal/cache/wan/misc/WanAutoDiscoveryDUnitTest.java
+++ b/geode-wan/src/test/java/com/gemstone/gemfire/internal/cache/wan/misc/WanAutoDiscoveryDUnitTest.java
@@ -108,31 +108,62 @@ public class WanAutoDiscoveryDUnitTest extends WANTestBase {
    */
   @Test
   public void test_NY_Recognises_ALL_LN_Locators() throws Exception {
-    ArrayList<Integer> locatorPorts = new ArrayList<Integer>();
-    Map<Integer, ArrayList<Integer>> dsVsPort = new HashMap<Integer, ArrayList<Integer>>();
+    Set<InetSocketAddress> locatorPorts = new HashSet<>();
+    Map<Integer, Set<InetSocketAddress>> dsVsPort = new HashMap<>();
     dsVsPort.put(1, locatorPorts);
 
     Integer lnLocPort1 = (Integer)vm0.invoke(() -> WANTestBase.createFirstLocatorWithDSId(1));
-    locatorPorts.add(lnLocPort1);
+    locatorPorts.add(new InetSocketAddress("localhost", lnLocPort1));
 
     Integer lnLocPort2 = (Integer)vm1.invoke(() -> WANTestBase.createSecondLocator( 1,
lnLocPort1 ));
-    locatorPorts.add(lnLocPort2);
+    locatorPorts.add(new InetSocketAddress("localhost", lnLocPort2));
     
-    locatorPorts = new ArrayList<Integer>();
+    locatorPorts = new HashSet<>();
     dsVsPort.put(2, locatorPorts);
     Integer nyLocPort1 = (Integer)vm2.invoke(() -> WANTestBase.createFirstRemoteLocator(
2, lnLocPort1 ));
-    locatorPorts.add(nyLocPort1);
+    locatorPorts.add(new InetSocketAddress("localhost", nyLocPort1));
     
     Integer nyLocPort2 = (Integer)vm3.invoke(() -> WANTestBase.createSecondRemoteLocator(
             2, nyLocPort1, lnLocPort1));
-    locatorPorts.add(nyLocPort2);
+    locatorPorts.add(new InetSocketAddress("localhost", nyLocPort2));
     
     vm0.invoke(() -> WANTestBase.checkAllSiteMetaData( dsVsPort ));
     vm1.invoke(() -> WANTestBase.checkAllSiteMetaData( dsVsPort ));
     vm2.invoke(() -> WANTestBase.checkAllSiteMetaData( dsVsPort ));
     vm3.invoke(() -> WANTestBase.checkAllSiteMetaData( dsVsPort ));
   }
- 
+
+  /**
+   * Test to validate that multiple locators added two sets receive eachothers
+   * hostname for client setting even when the locator is started through the API.
+   */
+  @Test
+  public void locatorsReceiveHostnameForClientsFromRemoteSite() throws Exception {
+    Set<InetSocketAddress> locatorPorts = new HashSet<>();
+    Map<Integer, Set<InetSocketAddress>> dsVsPort = new HashMap<>();
+    dsVsPort.put(1, locatorPorts);
+
+    Integer lnLocPort1 = (Integer)vm0.invoke(() -> WANTestBase.createFirstLocatorWithDSId(1));
+    locatorPorts.add(new InetSocketAddress("localhost", lnLocPort1));
+
+    Integer lnLocPort2 = (Integer)vm1.invoke(() -> WANTestBase.createSecondLocator( 1,
lnLocPort1 ));
+    locatorPorts.add(new InetSocketAddress("localhost", lnLocPort2));
+
+    locatorPorts = new HashSet<>();
+    dsVsPort.put(2, locatorPorts);
+    Integer nyLocPort1 = (Integer)vm2.invoke(() -> WANTestBase.createFirstRemoteLocator(
2, lnLocPort1 ));
+    locatorPorts.add(new InetSocketAddress("localhost", nyLocPort1));
+
+    Integer nyLocPort2 = (Integer)vm3.invoke(() -> WANTestBase.createSecondRemoteLocatorWithAPI(
+      2, nyLocPort1, lnLocPort1, "localhost"));
+    locatorPorts.add(new InetSocketAddress("localhost", nyLocPort2));
+
+    vm0.invoke(() -> WANTestBase.checkAllSiteMetaData( dsVsPort ));
+    vm1.invoke(() -> WANTestBase.checkAllSiteMetaData( dsVsPort ));
+    vm2.invoke(() -> WANTestBase.checkAllSiteMetaData( dsVsPort ));
+    vm3.invoke(() -> WANTestBase.checkAllSiteMetaData( dsVsPort ));
+  }
+
   /**
    * Test to validate that TK site's locator is recognized by LN and NY. Test to
    * validate that HK site's locator is recognized by LN , NY, TK.
@@ -140,28 +171,28 @@ public class WanAutoDiscoveryDUnitTest extends WANTestBase {
   @Test
   public void test_NY_Recognises_TK_AND_HK_Through_LN_Locator() {
 
-    Map<Integer, ArrayList<Integer>> dsVsPort = new HashMap<Integer, ArrayList<Integer>>();
+    Map<Integer, Set<InetSocketAddress>> dsVsPort = new HashMap<>();
 
-    ArrayList<Integer> locatorPorts = new ArrayList<Integer>();
+    Set<InetSocketAddress> locatorPorts = new HashSet<>();
     dsVsPort.put(1, locatorPorts);
     
     Integer lnLocPort1 = (Integer)vm0.invoke(() -> WANTestBase.createFirstLocatorWithDSId(
1 ));
-    locatorPorts.add(lnLocPort1);
+    locatorPorts.add(new InetSocketAddress("localhost", lnLocPort1));
 
-    locatorPorts = new ArrayList<Integer>();
+    locatorPorts = new HashSet<>();
     dsVsPort.put(2, locatorPorts);
     Integer nyLocPort1 = (Integer)vm1.invoke(() -> WANTestBase.createFirstRemoteLocator(
2, lnLocPort1 ));
-    locatorPorts.add(nyLocPort1);
+    locatorPorts.add(new InetSocketAddress("localhost", nyLocPort1));
 
-    locatorPorts = new ArrayList<Integer>();
+    locatorPorts = new HashSet<>();
     dsVsPort.put(3, locatorPorts);
     Integer tkLocPort = (Integer)vm2.invoke(() -> WANTestBase.createFirstRemoteLocator(
3, lnLocPort1 ));
-    locatorPorts.add(tkLocPort);
+    locatorPorts.add(new InetSocketAddress("localhost", tkLocPort));
 
-    locatorPorts = new ArrayList<Integer>();
+    locatorPorts = new HashSet<>();
     dsVsPort.put(4, locatorPorts);
     Integer hkLocPort = (Integer)vm3.invoke(() -> WANTestBase.createFirstRemoteLocator(
4, lnLocPort1 ));
-    locatorPorts.add(hkLocPort);
+    locatorPorts.add(new InetSocketAddress("localhost", hkLocPort));
 
     vm0.invoke(() -> WANTestBase.checkAllSiteMetaData( dsVsPort ));
     vm1.invoke(() -> WANTestBase.checkAllSiteMetaData( dsVsPort ));
@@ -172,23 +203,23 @@ public class WanAutoDiscoveryDUnitTest extends WANTestBase {
   @Test
   public void test_TK_Recognises_LN_AND_NY() {
 
-    Map<Integer, ArrayList<Integer>> dsVsPort = new HashMap<Integer, ArrayList<Integer>>();
+    Map<Integer, Set<InetSocketAddress>> dsVsPort = new HashMap<>();
 
-    ArrayList<Integer> locatorPorts = new ArrayList<Integer>();
+    Set<InetSocketAddress> locatorPorts = new HashSet<>();
     dsVsPort.put(1, locatorPorts);
     
     Integer lnLocPort1 = (Integer)vm0.invoke(() -> WANTestBase.createFirstLocatorWithDSId(
1 ));
-    locatorPorts.add(lnLocPort1);
+    locatorPorts.add(new InetSocketAddress("localhost", lnLocPort1));
 
-    locatorPorts = new ArrayList<Integer>();
+    locatorPorts = new HashSet<>();
     dsVsPort.put(2, locatorPorts);
     Integer nyLocPort1 = (Integer)vm1.invoke(() -> WANTestBase.createFirstRemoteLocator(
2, lnLocPort1 ));
-    locatorPorts.add(nyLocPort1);
+    locatorPorts.add(new InetSocketAddress("localhost", nyLocPort1));
 
-    locatorPorts = new ArrayList<Integer>();
+    locatorPorts = new HashSet<>();
     dsVsPort.put(3, locatorPorts);
     Integer tkLocPort = (Integer)vm2.invoke(() -> WANTestBase.createFirstRemoteLocator(
3, nyLocPort1 ));
-    locatorPorts.add(tkLocPort);
+    locatorPorts.add(new InetSocketAddress("localhost", tkLocPort));
 
 
     vm0.invoke(() -> WANTestBase.checkAllSiteMetaData( dsVsPort ));
@@ -198,26 +229,26 @@ public class WanAutoDiscoveryDUnitTest extends WANTestBase {
   
   @Test
   public void test_NY_Recognises_TK_AND_HK_Simultaneously() {
-    Map<Integer, ArrayList<Integer>> dsVsPort = new HashMap<Integer, ArrayList<Integer>>();
+    Map<Integer, Set<InetSocketAddress>> dsVsPort = new HashMap<>();
 
-    ArrayList<Integer> locatorPortsln = new ArrayList<Integer>();
+    Set<InetSocketAddress> locatorPortsln = new HashSet<>();
     dsVsPort.put(1, locatorPortsln);
     Integer lnLocPort1 = (Integer)vm0.invoke(() -> WANTestBase.createFirstLocatorWithDSId(
1 ));
-    locatorPortsln.add(lnLocPort1);
+    locatorPortsln.add(new InetSocketAddress("localhost", lnLocPort1));
 
-    ArrayList<Integer> locatorPortsny = new ArrayList<Integer>();
+    Set<InetSocketAddress> locatorPortsny = new HashSet<>();
     dsVsPort.put(2, locatorPortsny);
     Integer nyLocPort1 = (Integer)vm1.invoke(() -> WANTestBase.createFirstRemoteLocator(
2, lnLocPort1 ));
-    locatorPortsny.add(nyLocPort1);
+    locatorPortsny.add(new InetSocketAddress("localhost", nyLocPort1));
 
     int AsyncInvocationArrSize = 4;
     AsyncInvocation[] async = new AsyncInvocation[AsyncInvocationArrSize];
 
-    ArrayList<Integer> locatorPortstk = new ArrayList<Integer>();
+    Set<InetSocketAddress> locatorPortstk = new HashSet<>();
     dsVsPort.put(3, locatorPortstk);
     async[0] = vm2.invokeAsync(() -> WANTestBase.createFirstRemoteLocator( 3, lnLocPort1
));
 
-    ArrayList<Integer> locatorPortshk = new ArrayList<Integer>();
+    Set<InetSocketAddress> locatorPortshk = new HashSet<>();
     dsVsPort.put(4, locatorPortshk);
     async[1] = vm3.invokeAsync(() -> WANTestBase.createFirstRemoteLocator(4, nyLocPort1));
 
@@ -238,10 +269,10 @@ public class WanAutoDiscoveryDUnitTest extends WANTestBase {
       fail();
     }
     
-    locatorPortstk.add((Integer)async[0].getReturnValue());
-    locatorPortshk.add((Integer)async[1].getReturnValue());
-    locatorPortsln.add((Integer)async[2].getReturnValue());
-    locatorPortsny.add((Integer)async[3].getReturnValue());
+    locatorPortstk.add(new InetSocketAddress("localhost", (Integer)async[0].getReturnValue()));
+    locatorPortshk.add(new InetSocketAddress("localhost", (Integer)async[1].getReturnValue()));
+    locatorPortsln.add(new InetSocketAddress("localhost", (Integer)async[2].getReturnValue()));
+    locatorPortsny.add(new InetSocketAddress("localhost", (Integer)async[3].getReturnValue()));
     
     vm0.invoke(() -> WANTestBase.checkAllSiteMetaData( dsVsPort ));
     vm1.invoke(() -> WANTestBase.checkAllSiteMetaData( dsVsPort ));
@@ -290,8 +321,7 @@ public class WanAutoDiscoveryDUnitTest extends WANTestBase {
     vm2.invoke(() -> WANTestBase.checkLocatorsinSender("ln", locatorToWaitFor2 ));
 
   }
-  
-  
+
   @Test
   public void test_RingTopology() {
 
@@ -434,15 +464,15 @@ public class WanAutoDiscoveryDUnitTest extends WANTestBase {
   
   @Test
   public void test_LN_Peer_Locators_Exchange_Information() {
-    ArrayList<Integer> locatorPorts = new ArrayList<Integer>();
-    Map<Integer, ArrayList<Integer>> dsVsPort = new HashMap<Integer, ArrayList<Integer>>();
+    Set<InetSocketAddress> locatorPorts = new HashSet<>();
+    Map<Integer, Set<InetSocketAddress>> dsVsPort = new HashMap<>();
     dsVsPort.put(1, locatorPorts);
 
     Integer lnLocPort1 = (Integer)vm0.invoke(() -> WANTestBase.createFirstPeerLocator(1));
-    locatorPorts.add(lnLocPort1);
+    locatorPorts.add(new InetSocketAddress("localhost", lnLocPort1));
 
     Integer lnLocPort2 = (Integer)vm1.invoke(() -> WANTestBase.createSecondPeerLocator(
1, lnLocPort1 ));
-    locatorPorts.add(lnLocPort2);
+    locatorPorts.add(new InetSocketAddress("localhost", lnLocPort2));
     
     vm0.invoke(() -> WANTestBase.checkAllSiteMetaData( dsVsPort ));
     vm1.invoke(() -> WANTestBase.checkAllSiteMetaData( dsVsPort ));
@@ -450,31 +480,31 @@ public class WanAutoDiscoveryDUnitTest extends WANTestBase {
   
   @Test
   public void test_LN_NY_TK_5_PeerLocators_1_ServerLocator() {
-    Map<Integer, ArrayList<Integer>> dsVsPort = new HashMap<Integer, ArrayList<Integer>>();
+    Map<Integer, Set<InetSocketAddress>> dsVsPort = new HashMap<>();
     
     
-    ArrayList<Integer> locatorPorts = new ArrayList<Integer>();
+    Set<InetSocketAddress> locatorPorts = new HashSet<>();
     dsVsPort.put(1, locatorPorts);
     Integer lnLocPort1 = (Integer)vm0.invoke(() -> WANTestBase.createFirstPeerLocator(1));
-    locatorPorts.add(lnLocPort1);
+    locatorPorts.add(new InetSocketAddress("localhost", lnLocPort1));
     Integer lnLocPort2 = (Integer)vm1.invoke(() -> WANTestBase.createSecondPeerLocator(
1, lnLocPort1 ));
-    locatorPorts.add(lnLocPort2);
+    locatorPorts.add(new InetSocketAddress("localhost", lnLocPort2));
     
-    locatorPorts = new ArrayList<Integer>();
+    locatorPorts = new HashSet<>();
     dsVsPort.put(2, locatorPorts);
     Integer nyLocPort1 = (Integer)vm2.invoke(() -> WANTestBase.createFirstRemotePeerLocator(2,
lnLocPort1));
-    locatorPorts.add(nyLocPort1);
+    locatorPorts.add(new InetSocketAddress("localhost", nyLocPort1));
     Integer nyLocPort2 = (Integer)vm3.invoke(() -> WANTestBase.createSecondRemotePeerLocator(
2, nyLocPort1, lnLocPort2));
-    locatorPorts.add(nyLocPort2);
+    locatorPorts.add(new InetSocketAddress("localhost", nyLocPort2));
     
-    locatorPorts = new ArrayList<Integer>();
+    locatorPorts = new HashSet<>();
     dsVsPort.put(3, locatorPorts);
     Integer tkLocPort1 = (Integer)vm4.invoke(() -> WANTestBase.createFirstRemotePeerLocator(3,
nyLocPort1));
-    locatorPorts.add(tkLocPort1);
+    locatorPorts.add(new InetSocketAddress("localhost", tkLocPort1));
     Integer tkLocPort2 = (Integer)vm5.invoke(() -> WANTestBase.createSecondRemotePeerLocator(
3, tkLocPort1, nyLocPort1));
-    locatorPorts.add(tkLocPort2);
+    locatorPorts.add(new InetSocketAddress("localhost", tkLocPort2));
     Integer tkLocPort3 = (Integer)vm6.invoke(() -> WANTestBase.createSecondRemoteLocator(
3, tkLocPort1, nyLocPort2));
-    locatorPorts.add(tkLocPort3);
+    locatorPorts.add(new InetSocketAddress("localhost", tkLocPort3));
     
    // pause(5000);
     


Mime
View raw message