geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From u..@apache.org
Subject [01/27] geode git commit: Revert "GEODE-2804 Update InetSocketAddress, when there is IOException."
Date Fri, 09 Jun 2017 20:13:35 GMT
Repository: geode
Updated Branches:
  refs/heads/feature/GEODE-3023 7997b2047 -> 7b05e6062


Revert "GEODE-2804 Update InetSocketAddress, when there is IOException."

This reverts commit e216fde1e4b1613bde22112cfb1544be022c3aac.

We are reverting previous fix. As that fix caused some more issues.
Currently we cache InetAddress in Geode. Solution was to cache hostname
but in certain cases that's not enough.


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

Branch: refs/heads/feature/GEODE-3023
Commit: f2f1311a8858c5bf5244c654a06d0430a1538e1d
Parents: 86b4757
Author: Hitesh Khamesra <hkhamesra@pivotal.io>
Authored: Thu Jun 8 09:48:46 2017 -0700
Committer: Udo Kohlmeyer <ukohlmeyer@pivotal.io>
Committed: Fri Jun 9 13:12:03 2017 -0700

----------------------------------------------------------------------
 .../internal/AutoConnectionSourceImpl.java      | 72 ++------------------
 .../membership/gms/membership/GMSJoinLeave.java |  3 +-
 .../internal/tcpserver/TcpClient.java           | 27 +-------
 .../internal/JmxManagerLocatorRequest.java      |  5 +-
 .../cli/commands/LauncherLifecycleCommands.java |  1 +
 .../ClusterConfigurationStatusRetriever.java    | 13 ++--
 .../AutoConnectionSourceImplJUnitTest.java      | 64 -----------------
 7 files changed, 19 insertions(+), 166 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/f2f1311a/geode-core/src/main/java/org/apache/geode/cache/client/internal/AutoConnectionSourceImpl.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/cache/client/internal/AutoConnectionSourceImpl.java
b/geode-core/src/main/java/org/apache/geode/cache/client/internal/AutoConnectionSourceImpl.java
index 070451c..53d401a 100644
--- a/geode-core/src/main/java/org/apache/geode/cache/client/internal/AutoConnectionSourceImpl.java
+++ b/geode-core/src/main/java/org/apache/geode/cache/client/internal/AutoConnectionSourceImpl.java
@@ -204,10 +204,12 @@ public class AutoConnectionSourceImpl implements ConnectionSource {
 
   private ServerLocationResponse queryOneLocator(InetSocketAddress locator,
       ServerLocationRequest request) {
+    InetAddress addr = locator.getAddress();
+    int port = locator.getPort();
     Object returnObj = null;
     try {
       pool.getStats().incLocatorRequests();
-      returnObj = tcpClient.requestToServer(locator, request, connectionTimeout, true);
+      returnObj = tcpClient.requestToServer(addr, port, request, connectionTimeout);
       ServerLocationResponse response = (ServerLocationResponse) returnObj;
       pool.getStats().incLocatorResponses();
       if (response != null) {
@@ -216,7 +218,6 @@ public class AutoConnectionSourceImpl implements ConnectionSource {
       return response;
     } catch (IOException ioe) {
       reportDeadLocator(locator, ioe);
-      updateLocatorInLocatorList(locator);
       return null;
     } catch (ClassNotFoundException e) {
       logger.warn(
@@ -233,45 +234,6 @@ public class AutoConnectionSourceImpl implements ConnectionSource {
     }
   }
 
-  /**
-   * If connecting to the locator fails with an IOException, this may be because the locator's
IP
-   * has changed. Add the locator back to the list of locators using host address rather
than IP.
-   * This will cause another DNS lookup, hopefully finding the locator.
-   * 
-   * @param locator
-   */
-  protected void updateLocatorInLocatorList(InetSocketAddress locator) {
-    if (locator.getHostName() != null) {
-      LocatorList locatorList = locators.get();
-      List<InetSocketAddress> newLocatorsList = new ArrayList<>();
-
-      for (InetSocketAddress tloc : locatorList.getLocators()) {
-        if (tloc.equals(locator)) {
-          /**
-           * This call doesn't throw UnknownHostException;
-           */
-          InetSocketAddress changeLoc =
-              new InetSocketAddress(locator.getHostName(), locator.getPort());
-          newLocatorsList.add(changeLoc);
-          logger.info("updateLocatorInLocatorList changing locator list: loc form: " + locator
-              + " ,loc to: " + changeLoc);
-        } else {
-          newLocatorsList.add(tloc);
-        }
-      }
-
-      logger.info("updateLocatorInLocatorList locator list from:" + locatorList.getLocators()
-          + " to: " + newLocatorsList);
-
-      LocatorList newLocatorList = new LocatorList(newLocatorsList);
-      locators.set(newLocatorList);
-    }
-  }
-
-  protected List<InetSocketAddress> getCurrentLocators() {
-    return locators.get().locators;
-  }
-
   protected ServerLocationResponse queryLocators(ServerLocationRequest request) {
     Iterator controllerItr = locators.get().iterator();
     ServerLocationResponse response = null;
@@ -314,7 +276,7 @@ public class AutoConnectionSourceImpl implements ConnectionSource {
       badLocators.remove(address);
     }
 
-    addbadLocators(newLocators, badLocators);
+    newLocators.addAll(badLocators);
 
     if (logger.isInfoEnabled()) {
       LocatorList oldLocators = (LocatorList) locators.get();
@@ -338,37 +300,11 @@ public class AutoConnectionSourceImpl implements ConnectionSource {
       }
     }
     LocatorList newLocatorList = new LocatorList(newLocators);
-
     locators.set(newLocatorList);
     onlineLocators.set(new LocatorList(newOnlineLocators));
     pool.getStats().setLocatorCount(newLocators.size());
   }
 
-  /**
-   * This method will add bad locator only when locator with hostname and port is not already
in
-   * list.
-   */
-  protected void addbadLocators(List<InetSocketAddress> newLocators,
-      Set<InetSocketAddress> badLocators) {
-    for (InetSocketAddress badLoc : badLocators) {
-      boolean addIt = true;
-      for (InetSocketAddress goodloc : newLocators) {
-        boolean isSameHost = badLoc.getHostName().equals(goodloc.getHostName());
-        if (isSameHost) {
-          boolean isSamePort = badLoc.getPort() == goodloc.getPort();
-          if (isSamePort) {
-            // ip has been changed so don't add this in current list
-            addIt = false;
-            break;
-          }
-        }
-      }
-      if (addIt) {
-        newLocators.add(badLoc);
-      }
-    }
-  }
-
   public void start(InternalPool pool) {
     this.pool = pool;
     pool.getStats().setInitialContacts(((LocatorList) locators.get()).size());

http://git-wip-us.apache.org/repos/asf/geode/blob/f2f1311a/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/gms/membership/GMSJoinLeave.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/gms/membership/GMSJoinLeave.java
b/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/gms/membership/GMSJoinLeave.java
index 84d42cf..8abcc45 100644
--- a/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/gms/membership/GMSJoinLeave.java
+++ b/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/gms/membership/GMSJoinLeave.java
@@ -1153,7 +1153,8 @@ public class GMSJoinLeave implements JoinLeave, MessageHandler {
         FindCoordinatorRequest request, int connectTimeout)
         throws ClassNotFoundException, IOException {
       TcpClient client = new TcpClient();
-      return client.requestToServer(addr.getAddress(), addr.getPort(), request, connectTimeout);
+      return client.requestToServer(addr.getAddress(), addr.getPort(), request, connectTimeout,
+          true);
     }
   }
 

http://git-wip-us.apache.org/repos/asf/geode/blob/f2f1311a/geode-core/src/main/java/org/apache/geode/distributed/internal/tcpserver/TcpClient.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/distributed/internal/tcpserver/TcpClient.java
b/geode-core/src/main/java/org/apache/geode/distributed/internal/tcpserver/TcpClient.java
index e9476b5..6b54170 100644
--- a/geode-core/src/main/java/org/apache/geode/distributed/internal/tcpserver/TcpClient.java
+++ b/geode-core/src/main/java/org/apache/geode/distributed/internal/tcpserver/TcpClient.java
@@ -134,7 +134,6 @@ public class TcpClient {
    */
   public Object requestToServer(InetAddress addr, int port, Object request, int timeout)
       throws IOException, ClassNotFoundException {
-
     return requestToServer(addr, port, request, timeout, true);
   }
 
@@ -147,7 +146,7 @@ public class TcpClient {
    * @param timeout Timeout for sending the message and receiving a reply
    * @param replyExpected Whether to wait for a reply
    *
-   * @return the reply
+   * @return The reply, or null if no reply is expected
    *
    * @throws IOException
    * @throws ClassNotFoundException
@@ -158,30 +157,8 @@ public class TcpClient {
     if (addr == null) {
       ipAddr = new InetSocketAddress(port);
     } else {
-      ipAddr = new InetSocketAddress(addr.getHostName(), port); // fix for bug 30810
+      ipAddr = new InetSocketAddress(addr, port); // fix for bug 30810
     }
-    return requestToServer(ipAddr, request, timeout, replyExpected);
-  }
-
-  /**
-   * Send a request to a Locator
-   * 
-   * @param ipAddr The locator's inet socket address
-   * @param request The request message
-   * @param timeout Timeout for sending the message and receiving a reply
-   * @param replyExpected Whether to wait for a reply
-   *
-   * @return The reply, or null if no reply is expected
-   *
-   * @throws IOException
-   * @throws ClassNotFoundException
-   */
-  public Object requestToServer(InetSocketAddress ipAddr, Object request, int timeout,
-      boolean replyExpected) throws IOException, ClassNotFoundException {
-    /*
-     * InetSocketAddress ipAddr; if (addr == null) { ipAddr = new InetSocketAddress(port);
} else {
-     * ipAddr = new InetSocketAddress(addr, port); // fix for bug 30810 }
-     */
 
     long giveupTime = System.currentTimeMillis() + timeout;
 

http://git-wip-us.apache.org/repos/asf/geode/blob/f2f1311a/geode-core/src/main/java/org/apache/geode/management/internal/JmxManagerLocatorRequest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/JmxManagerLocatorRequest.java
b/geode-core/src/main/java/org/apache/geode/management/internal/JmxManagerLocatorRequest.java
index eb71d38..0efba01 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/JmxManagerLocatorRequest.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/JmxManagerLocatorRequest.java
@@ -18,7 +18,6 @@ import java.io.DataInput;
 import java.io.DataOutput;
 import java.io.IOException;
 import java.net.InetAddress;
-import java.net.InetSocketAddress;
 import java.util.Map;
 import java.util.Properties;
 
@@ -72,7 +71,6 @@ public class JmxManagerLocatorRequest implements DataSerializableFixedID
{
       Map<String, String> sslConfigProps) throws IOException {
     Properties distributionConfigProps = new Properties();
     InetAddress networkAddress = InetAddress.getByName(locatorHost);
-    InetSocketAddress inetSockAddr = new InetSocketAddress(networkAddress, locatorPort);
 
     try {
       if (sslConfigProps != null) {
@@ -80,7 +78,8 @@ public class JmxManagerLocatorRequest implements DataSerializableFixedID
{
       }
 
       TcpClient client = new TcpClient(new DistributionConfigImpl(distributionConfigProps));
-      Object responseFromServer = client.requestToServer(inetSockAddr, SINGLETON, msTimeout,
true);
+      Object responseFromServer =
+          client.requestToServer(networkAddress, locatorPort, SINGLETON, msTimeout);
 
       return (JmxManagerLocatorResponse) responseFromServer;
     } catch (ClassNotFoundException unexpected) {

http://git-wip-us.apache.org/repos/asf/geode/blob/f2f1311a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/LauncherLifecycleCommands.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/LauncherLifecycleCommands.java
b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/LauncherLifecycleCommands.java
index 4c668b6..89a236b 100755
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/LauncherLifecycleCommands.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/LauncherLifecycleCommands.java
@@ -625,6 +625,7 @@ public class LauncherLifecycleCommands implements GfshCommand {
     return configurationProperties;
   }
 
+
   // TODO re-evaluate whether a MalformedObjectNameException should be thrown here; just
because we
   // were not able to find
   // the "current" Locators in order to conveniently add the new member to the GemFire cluster
does

http://git-wip-us.apache.org/repos/asf/geode/blob/f2f1311a/geode-core/src/main/java/org/apache/geode/management/internal/configuration/utils/ClusterConfigurationStatusRetriever.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/configuration/utils/ClusterConfigurationStatusRetriever.java
b/geode-core/src/main/java/org/apache/geode/management/internal/configuration/utils/ClusterConfigurationStatusRetriever.java
index 9f35edd..3080809 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/configuration/utils/ClusterConfigurationStatusRetriever.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/configuration/utils/ClusterConfigurationStatusRetriever.java
@@ -35,19 +35,22 @@ public class ClusterConfigurationStatusRetriever {
 
     try {
       final InetAddress networkAddress = InetAddress.getByName(locatorHostName);
-      InetSocketAddress inetSockAddr = new InetSocketAddress(networkAddress, locatorPort);
 
       TcpClient client = new TcpClient();
-      SharedConfigurationStatusResponse statusResponse = (SharedConfigurationStatusResponse)
client
-          .requestToServer(inetSockAddr, new SharedConfigurationStatusRequest(), 10000, true);
+      SharedConfigurationStatusResponse statusResponse =
+          (SharedConfigurationStatusResponse) client.requestToServer(networkAddress, locatorPort,
+              new SharedConfigurationStatusRequest(), 10000, true);
+
+
 
       for (int i = 0; i < NUM_ATTEMPTS_FOR_SHARED_CONFIGURATION_STATUS; i++) {
         if (statusResponse.getStatus().equals(
             org.apache.geode.management.internal.configuration.domain.SharedConfigurationStatus.STARTED)
             || statusResponse.getStatus().equals(
                 org.apache.geode.management.internal.configuration.domain.SharedConfigurationStatus.NOT_STARTED))
{
-          statusResponse = (SharedConfigurationStatusResponse) client.requestToServer(inetSockAddr,
-              new SharedConfigurationStatusRequest(), 10000, true);
+          statusResponse =
+              (SharedConfigurationStatusResponse) client.requestToServer(networkAddress,
+                  locatorPort, new SharedConfigurationStatusRequest(), 10000, true);
           try {
             Thread.sleep(5000);
           } catch (InterruptedException e) {

http://git-wip-us.apache.org/repos/asf/geode/blob/f2f1311a/geode-core/src/test/java/org/apache/geode/cache/client/internal/AutoConnectionSourceImplJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/cache/client/internal/AutoConnectionSourceImplJUnitTest.java
b/geode-core/src/test/java/org/apache/geode/cache/client/internal/AutoConnectionSourceImplJUnitTest.java
index 9ceb461..da3cbdb 100644
--- a/geode-core/src/test/java/org/apache/geode/cache/client/internal/AutoConnectionSourceImplJUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/cache/client/internal/AutoConnectionSourceImplJUnitTest.java
@@ -45,20 +45,15 @@ import org.junit.Test;
 import org.junit.contrib.java.lang.system.RestoreSystemProperties;
 import org.junit.experimental.categories.Category;
 
-import junit.framework.Assert;
-
 import java.io.IOException;
 import java.net.ConnectException;
 import java.net.InetAddress;
 import java.net.InetSocketAddress;
 import java.net.UnknownHostException;
 import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.Properties;
-import java.util.Set;
 import java.util.concurrent.Executors;
 import java.util.concurrent.ScheduledExecutorService;
 import java.util.concurrent.TimeUnit;
@@ -146,65 +141,6 @@ public class AutoConnectionSourceImplJUnitTest {
     }
   }
 
-  /**
-   * This test validates the AutoConnectionSourceImpl.updateLocatorInLocatorList method.
That method
-   * takes InetSocketAddres of locator which unable to connect to locator. And update that
-   * InetSocketAddres with hostaddress of locator in locatorlist.
-   * 
-   * In this test we validate this using identityHashCode.
-   */
-  @Test
-  public void testLocatorIpChange() {
-    int port = 11011;
-    List<InetSocketAddress> locators = new ArrayList();
-    InetSocketAddress floc1 = new InetSocketAddress("fakeLocalHost1", port);
-    InetSocketAddress floc2 = new InetSocketAddress("fakeLocalHost2", port);
-    locators.add(floc1);
-    locators.add(floc2);
-    AutoConnectionSourceImpl src = new AutoConnectionSourceImpl(locators, "", 60 * 1000);
-
-    // This method will create a new InetSocketAddress of floc1
-    src.updateLocatorInLocatorList(floc1);
-
-    List<InetSocketAddress> cLocList = src.getCurrentLocators();
-
-    Assert.assertEquals(2, cLocList.size());
-
-    Iterator<InetSocketAddress> itr = cLocList.iterator();
-
-    while (itr.hasNext()) {
-      InetSocketAddress t = itr.next();
-      Assert.assertFalse("Should have replaced floc1 intsance", t == floc1);
-    }
-  }
-
-  /**
-   * This test validates the AutoConnectionSourceImpl.addbadLocators method. That method
adds
-   * badLocator from badLocator list to new Locator list. And it make sure that new locator
list
-   * doesn't have similar entry. For that it checks hostname and port only.
-   */
-  @Test
-  public void testAddBadLocator() {
-    int port = 11011;
-    List<InetSocketAddress> locators = new ArrayList();
-    InetSocketAddress floc1 = new InetSocketAddress("fakeLocalHost1", port);
-    InetSocketAddress floc2 = new InetSocketAddress("fakeLocalHost2", port);
-    locators.add(floc1);
-    locators.add(floc2);
-    AutoConnectionSourceImpl src = new AutoConnectionSourceImpl(locators, "", 60 * 1000);
-
-
-    Set<InetSocketAddress> badLocators = new HashSet<>();
-    InetSocketAddress b1 = new InetSocketAddress("fakeLocalHost1", port);
-    InetSocketAddress b2 = new InetSocketAddress("fakeLocalHost3", port);
-    badLocators.add(b1);
-    badLocators.add(b2);
-
-    src.addbadLocators(locators, badLocators);
-
-    Assert.assertEquals(3, locators.size());
-  }
-
   @Test
   public void testNoRespondingLocators() {
     try {


Mime
View raw message