geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From u..@apache.org
Subject [2/2] incubator-geode git commit: GEODE-420: Locator ssl config.
Date Fri, 05 Aug 2016 23:06:25 GMT
GEODE-420: Locator ssl config.


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

Branch: refs/heads/feature/GEODE-420
Commit: b557ccfefb5f775df82386f8a4a51d2b02ae570c
Parents: 7ecc663
Author: Udo Kohlmeyer <ukohlmeyer@pivotal.io>
Authored: Fri Aug 5 16:06:15 2016 -0700
Committer: Udo Kohlmeyer <ukohlmeyer@pivotal.io>
Committed: Fri Aug 5 16:06:15 2016 -0700

----------------------------------------------------------------------
 .../distributed/ConfigurationProperties.java    |   11 +
 .../distributed/SSLEnabledComponents.java       |    5 +
 .../internal/AbstractDistributionConfig.java    |    5 +-
 .../internal/DistributionConfig.java            |   23 +
 .../internal/DistributionConfigImpl.java        |   15 +
 .../distributed/internal/InternalLocator.java   |  962 ++++++++---------
 .../internal/tcpserver/TcpClient.java           |   59 +-
 .../internal/tcpserver/TcpServer.java           |   12 +-
 .../gemfire/internal/i18n/LocalizedStrings.java |    3 +
 .../internal/net/SSLConfigurationFactory.java   |    6 +
 .../internal/net/SSLEnabledComponent.java       |    1 +
 .../gemfire/internal/net/SocketCreator.java     |   10 +
 .../internal/net/SocketCreatorFactory.java      |   14 +-
 .../gemfire/distributed/LocatorDUnitTest.java   | 1012 ++++++++++++------
 .../net/SocketCreatorFactoryJUnitTest.java      |   17 +
 .../gemfire/management/JMXMBeanDUnitTest.java   |    1 +
 .../gemstone/gemfire/internal/net/multiKey.jks  |  Bin 10062 -> 12102 bytes
 .../gemfire/internal/net/multiKeyTrust.jks      |  Bin 3614 -> 4366 bytes
 18 files changed, 1321 insertions(+), 835 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/b557ccfe/geode-core/src/main/java/com/gemstone/gemfire/distributed/ConfigurationProperties.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/distributed/ConfigurationProperties.java b/geode-core/src/main/java/com/gemstone/gemfire/distributed/ConfigurationProperties.java
index d356d20..ddec998 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/distributed/ConfigurationProperties.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/distributed/ConfigurationProperties.java
@@ -934,6 +934,17 @@ public interface ConfigurationProperties {
    */
   String LOAD_CLUSTER_CONFIGURATION_FROM_DIR = "load-cluster-configuration-from-dir";
   /**
+   * The static String definition of the <i>"locator-ssl-alias"</i> property
+   * <a name="locator-ssl-alias"/a></p>
+   * <U>Description</U>: This property is to be used if a specific key is to be used for the SSL communications for the locator.
+   * These Communications would be either locator-client or locator-server
+   * </p>
+   * <U><i>Optional</i></U>
+   * <U>Default</U>: "" </p>
+   * <U>Since</U>: Geode 1.0
+   */
+  String LOCATOR_SSL_ALIAS = "locator-ssl-alias";
+  /**
    * The static String definition of the <i>"locator-wait-time"</i> property
    * <a name="locator-wait-time"/a><p>
    * <U>Description</U>: The number of seconds to wait for a locator to start

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/b557ccfe/geode-core/src/main/java/com/gemstone/gemfire/distributed/SSLEnabledComponents.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/distributed/SSLEnabledComponents.java b/geode-core/src/main/java/com/gemstone/gemfire/distributed/SSLEnabledComponents.java
index a403662..51cc99a 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/distributed/SSLEnabledComponents.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/distributed/SSLEnabledComponents.java
@@ -54,4 +54,9 @@ public interface SSLEnabledComponents {
    * <U>Since</U>: Geode 1.0
    */
   String GATEWAY = "gateway";
+  /**
+   * This determines that the locator component will use the SSL for its communications between server and locator and client and locator.
+   * <U>Since</U>: Geode 1.0
+   */
+  String LOCATOR = "locator";
 }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/b557ccfe/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/AbstractDistributionConfig.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/AbstractDistributionConfig.java b/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/AbstractDistributionConfig.java
index 56de76d..458b1ad 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/AbstractDistributionConfig.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/AbstractDistributionConfig.java
@@ -485,6 +485,7 @@ public abstract class AbstractDistributionConfig extends AbstractConfig implemen
           case SSLEnabledComponents.GATEWAY:
           case SSLEnabledComponents.JMX:
           case SSLEnabledComponents.HTTP_SERVICE:
+          case SSLEnabledComponents.LOCATOR:
             continue;
           default:
             throw new IllegalArgumentException(LocalizedStrings.AbstractDistributionConfig_SSL_ENABLED_COMPONENTS_0_INVALID_TRY_1.toLocalizedString(new Object[] {
@@ -494,7 +495,8 @@ public abstract class AbstractDistributionConfig extends AbstractConfig implemen
               SSLEnabledComponents.SERVER,
               SSLEnabledComponents.GATEWAY,
               SSLEnabledComponents.JMX,
-              SSLEnabledComponents.HTTP_SERVICE
+              SSLEnabledComponents.HTTP_SERVICE,
+              SSLEnabledComponents.LOCATOR
             }, ",")
             }));
         }
@@ -891,6 +893,7 @@ public abstract class AbstractDistributionConfig extends AbstractConfig implemen
     m.put(JMX_MANAGER_ACCESS_FILE, "The name of the file the jmx manager will use to define the access level of authenticated clients. Default is \"\" which causes the jmx manager to allow all clients all access. This property is ignored if jmx-manager-port is \"0\".");
     m.put(JMX_MANAGER_HTTP_PORT, "By default when a jmx-manager is started it will also start an http server on this port. This server is used by the GemFire Pulse application. Setting this property to zero disables the http server. It defaults to 8080. Ignored if jmx-manager is false.");
     m.put(JMX_MANAGER_UPDATE_RATE, "The rate in milliseconds at which this member will send updates to each jmx manager. Default is " + DEFAULT_JMX_MANAGER_UPDATE_RATE + ". Values must be in the range " + MIN_JMX_MANAGER_UPDATE_RATE + ".." + MAX_JMX_MANAGER_UPDATE_RATE + ".");
+    m.put(LOCATOR_SSL_ALIAS, LocalizedStrings.AbstractDistributionConfig_LOCATOR_SSL_ALIAS_0.toLocalizedString(Boolean.valueOf(DEFAULT_CLUSTER_SSL_ALIAS)));
     m.put(MEMCACHED_PORT, "The port GemFireMemcachedServer will listen on. Default is 0. Set to zero to disable GemFireMemcachedServer.");
     m.put(MEMCACHED_PROTOCOL, "The protocol that GemFireMemcachedServer understands. Default is ASCII. Values may be ASCII or BINARY");
     m.put(MEMCACHED_BIND_ADDRESS, "The address the GemFireMemcachedServer will listen on for remote connections. Default is \"\" which causes the GemFireMemcachedServer to listen on the host's default address. This property is ignored if memcached-port is \"0\".");

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/b557ccfe/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/DistributionConfig.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/DistributionConfig.java b/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/DistributionConfig.java
index d8eee84..3eac56a 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/DistributionConfig.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/DistributionConfig.java
@@ -4177,6 +4177,29 @@ public interface DistributionConfig extends Config, LogConfig {
   String CLUSTER_SSL_ALIAS_NAME = CLUSTER_SSL_ALIAS;
 
   /**
+   * Returns the value of the {@link ConfigurationProperties#LOCATOR_SSL_ALIAS}
+   * property.
+   * @since Geode 1.0
+   */
+  @ConfigAttributeGetter(name = LOCATOR_SSL_ALIAS)
+  String getLocatorSSLAlias();
+
+  /**
+   * Sets the value of the {@link ConfigurationProperties#LOCATOR_SSL_ALIAS}
+   * property.
+   * @since Geode 1.0
+   */
+  @ConfigAttributeSetter(name = LOCATOR_SSL_ALIAS)
+  void setLocatorSSLAlias(String alias);
+
+  /**
+   * The name of the {@link ConfigurationProperties#LOCATOR_SSL_ALIAS} property
+   * @since Geode 1.0
+   */
+  @ConfigAttribute(type = String.class)
+  String LOCATOR_SSL_ALIAS_NAME = LOCATOR_SSL_ALIAS;
+
+  /**
    * Returns the value of the {@link ConfigurationProperties#GATEWAY_SSL_ALIAS}
    * property.
    * @since Geode 1.0

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/b557ccfe/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/DistributionConfigImpl.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/DistributionConfigImpl.java b/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/DistributionConfigImpl.java
index 4ae6db6..7720dbf 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/DistributionConfigImpl.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/DistributionConfigImpl.java
@@ -498,8 +498,11 @@ public class DistributionConfigImpl extends AbstractDistributionConfig implement
 
   private String httpServiceSSLAlias = clusterSSLAlias;
 
+  //TODO UDO Clean this up. Move this to an SSLEnabledComponent[]
   private String[] sslEnabledComponents = DEFAULT_SSL_ENABLED_COMPONENTS;
 
+  private String locatorSSLAlias = clusterSSLAlias;
+
   private Map<String, ConfigSource> sourceMap = Collections.synchronizedMap(new HashMap<String, ConfigSource>());
 
   protected String userCommandPackages = DEFAULT_USER_COMMAND_PACKAGES;
@@ -698,6 +701,8 @@ public class DistributionConfigImpl extends AbstractDistributionConfig implement
     this.jmxManagerSSLAlias = other.getJMXManagerSSLAlias();
     this.serverSSLAlias = other.getServerSSLAlias();
     this.sslEnabledComponents = ((DistributionConfigImpl) other).sslEnabledComponents;
+
+    this.locatorSSLAlias = other.getLocatorSSLAlias();
   }
 
   /**
@@ -2357,6 +2362,16 @@ public class DistributionConfigImpl extends AbstractDistributionConfig implement
   }
 
   @Override
+  public String getLocatorSSLAlias() {
+    return locatorSSLAlias;
+  }
+
+  @Override
+  public void setLocatorSSLAlias(final String locatorSSLAlias) {
+    this.locatorSSLAlias = locatorSSLAlias;
+  }
+
+  @Override
   public String getGatewaySSLAlias() {
     return gatewaySSLAlias;
   }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/b557ccfe/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 58f2602..d96d0ce 100755
--- 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
@@ -16,11 +16,37 @@
  */
 package com.gemstone.gemfire.distributed.internal;
 
+import static com.gemstone.gemfire.distributed.ConfigurationProperties.*;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.ConnectException;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Properties;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+import org.apache.logging.log4j.Logger;
+
 import com.gemstone.gemfire.CancelException;
 import com.gemstone.gemfire.cache.Cache;
 import com.gemstone.gemfire.cache.CacheFactory;
 import com.gemstone.gemfire.cache.GemFireCache;
-import com.gemstone.gemfire.cache.client.internal.locator.*;
+import com.gemstone.gemfire.cache.client.internal.locator.ClientConnectionRequest;
+import com.gemstone.gemfire.cache.client.internal.locator.ClientReplacementRequest;
+import com.gemstone.gemfire.cache.client.internal.locator.GetAllServersRequest;
+import com.gemstone.gemfire.cache.client.internal.locator.LocatorListRequest;
+import com.gemstone.gemfire.cache.client.internal.locator.LocatorStatusRequest;
+import com.gemstone.gemfire.cache.client.internal.locator.QueueConnectionRequest;
+import com.gemstone.gemfire.cache.client.internal.locator.ServerLocationRequest;
 import com.gemstone.gemfire.cache.client.internal.locator.wan.LocatorMembershipListener;
 import com.gemstone.gemfire.distributed.DistributedSystem;
 import com.gemstone.gemfire.distributed.Locator;
@@ -31,10 +57,10 @@ import com.gemstone.gemfire.distributed.internal.membership.MemberFactory;
 import com.gemstone.gemfire.distributed.internal.membership.QuorumChecker;
 import com.gemstone.gemfire.distributed.internal.membership.gms.NetLocator;
 import com.gemstone.gemfire.distributed.internal.membership.gms.locator.PeerLocatorRequest;
+import com.gemstone.gemfire.distributed.internal.tcpserver.LocatorCancelException;
 import com.gemstone.gemfire.distributed.internal.tcpserver.TcpClient;
 import com.gemstone.gemfire.distributed.internal.tcpserver.TcpHandler;
 import com.gemstone.gemfire.distributed.internal.tcpserver.TcpServer;
-import com.gemstone.gemfire.internal.net.*;
 import com.gemstone.gemfire.internal.admin.remote.DistributionLocatorId;
 import com.gemstone.gemfire.internal.cache.GemFireCacheImpl;
 import com.gemstone.gemfire.internal.cache.wan.WANServiceProvider;
@@ -47,6 +73,8 @@ import com.gemstone.gemfire.internal.logging.log4j.LocalizedMessage;
 import com.gemstone.gemfire.internal.logging.log4j.LogMarker;
 import com.gemstone.gemfire.internal.logging.log4j.LogWriterAppenders;
 import com.gemstone.gemfire.internal.logging.log4j.LogWriterLogger;
+import com.gemstone.gemfire.internal.net.SocketCreator;
+import com.gemstone.gemfire.internal.net.SocketCreatorFactory;
 import com.gemstone.gemfire.management.internal.JmxManagerLocator;
 import com.gemstone.gemfire.management.internal.JmxManagerLocatorRequest;
 import com.gemstone.gemfire.management.internal.JmxManagerLocatorResponse;
@@ -57,132 +85,138 @@ import com.gemstone.gemfire.management.internal.configuration.handlers.SharedCon
 import com.gemstone.gemfire.management.internal.configuration.messages.ConfigurationRequest;
 import com.gemstone.gemfire.management.internal.configuration.messages.SharedConfigurationStatusRequest;
 import com.gemstone.gemfire.management.internal.configuration.messages.SharedConfigurationStatusResponse;
-import org.apache.logging.log4j.Logger;
-
-import java.io.File;
-import java.io.IOException;
-import java.net.ConnectException;
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-import java.util.*;
-import java.util.concurrent.Callable;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Future;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicBoolean;
-
-import static com.gemstone.gemfire.distributed.ConfigurationProperties.*;
 
 /**
  * Provides the implementation of a distribution <code>Locator</code>
  * as well as internal-only functionality.
- * 
- * This class has APIs that perform essentially three layers of 
+ * <p>
+ * This class has APIs that perform essentially three layers of
  * services. At the bottom layer is the JGroups location service. On
  * top of that you can start a distributed system. And then on top
  * of that you can start server location services.
- * 
+ * <p>
  * Server Location Service
  * DistributedSystem
  * Peer Location Service
- * 
+ * <p>
  * The startLocator() methods provide a way to start all three
- * services in one call. Otherwise, the services can be started 
+ * services in one call. Otherwise, the services can be started
  * independently
  * <code>
  * locator = createLocator()
  * locator.startPeerLocation();
  * locator.startDistributeSystem();
- *
  * @since GemFire 4.0
  */
 public class InternalLocator extends Locator implements ConnectListener {
 
   private static final Logger logger = LogService.getLogger();
-  
-  /** How long (in milliseconds) a member that we haven't heard from
-   * in a while should live before we call it dead? */
+
+  /**
+   * How long (in milliseconds) a member that we haven't heard from
+   * in a while should live before we call it dead?
+   */
   private static final long EXPIRY_MS = 60000; // one minute
-  
+
   private static final int SHARED_CONFIG_STATUS_TIMEOUT = 10000; //10 seconds
-  
-  /** system property name for forcing an locator distribution manager type */
+
+  /**
+   * system property name for forcing an locator distribution manager type
+   */
   public static final String FORCE_LOCATOR_DM_TYPE = "Locator.forceLocatorDMType";
-  
-  /** system property name for inhibiting DM banner */
+
+  /**
+   * system property name for inhibiting DM banner
+   */
   public static final String INHIBIT_DM_BANNER = "Locator.inhibitDMBanner";
-  
-  /** system property name for forcing locators to be preferred as coordinators */
+
+  /**
+   * system property name for forcing locators to be preferred as coordinators
+   */
   public static final String LOCATORS_PREFERRED_AS_COORDINATORS = DistributionConfig.GEMFIRE_PREFIX + "disable-floating-coordinator";
 
   /////////////////////  Instance Fields  //////////////////////
 
-  /** The tcp server responding to locator requests */
+  /**
+   * The tcp server responding to locator requests
+   */
   private final TcpServer server;
 
   /**
    * @since GemFire 5.7
    */
   private final PrimaryHandler handler;
-  
-  /** The distributed system owned by this locator, if any.
+
+  /**
+   * The distributed system owned by this locator, if any.
    * Note that if a ds already exists because the locator is
    * being colocated in a normal member this field will be null.
    */
   private InternalDistributedSystem myDs;
-  /** The cache owned by this locator, if any.
+  /**
+   * The cache owned by this locator, if any.
    * Note that if a cache already exists because the locator is
    * being colocated in a normal member this field will be null.
    */
   private Cache myCache;
-  
-  /** locator state file */
+
+  /**
+   * locator state file
+   */
   private File stateFile;
-  
-  /** product use logging */
+
+  /**
+   * product use logging
+   */
   private ProductUseLog productUseLog;
-  
+
   private boolean peerLocator;
-  
+
   private ServerLocator serverLocator;
-  
+
   protected volatile LocatorStats stats;
 
   //TODO - these to properties are a waste of memory once
   //the system is started.
   private Properties env;
-  
-  /** the TcpHandler used for peer location */
+
+  /**
+   * the TcpHandler used for peer location
+   */
   private NetLocator locatorImpl;
-  
+
   private DistributionConfigImpl config;
-  
+
   private LocatorMembershipListener locatorListener;
 
   private WanLocatorDiscoverer locatorDiscoverer;
-  
-  /** whether the locator was stopped during forced-disconnect processing but a reconnect will occur */
+
+  /**
+   * whether the locator was stopped during forced-disconnect processing but a reconnect will occur
+   */
   private volatile boolean stoppedForReconnect;
-  
-  /** whether the locator was stopped during forced-disconnect processing */
+
+  /**
+   * whether the locator was stopped during forced-disconnect processing
+   */
   private volatile boolean forcedDisconnect;
-  
+
   private final AtomicBoolean shutdownHandled = new AtomicBoolean(false);
-  
+
   private SharedConfiguration sharedConfig;
-  
-  private volatile boolean isSharedConfigurationStarted = false; 
-  
+
+  private volatile boolean isSharedConfigurationStarted = false;
+
   private volatile Thread restartThread;
 
   public boolean isSharedConfigurationEnabled() {
     return this.config.getEnableClusterConfiguration();
   }
-  
+
   public boolean loadFromSharedConfigDir() {
     return this.config.getLoadClusterConfigFromDir();
   }
-  
+
   public boolean isSharedConfigurationRunning() {
     if (this.sharedConfig != null) {
       return this.sharedConfig.getStatus() == SharedConfigurationStatus.RUNNING;
@@ -190,10 +224,12 @@ public class InternalLocator extends Locator implements ConnectListener {
       return false;
     }
   }
-  
+
   //////////////////////  Static Methods  /////////////////////
-  
-  /** the locator hosted by this JVM. As of 7.0 it is a singleton. */
+
+  /**
+   * the locator hosted by this JVM. As of 7.0 it is a singleton.
+   */
   private static InternalLocator locator; // must synchronize on locatorLock
   private static final Object locatorLock = new Object();
 
@@ -203,13 +239,17 @@ public class InternalLocator extends Locator implements ConnectListener {
       return locator;
     }
   }
+
   public static boolean hasLocator() {
     synchronized (locatorLock) {
       return locator != null;
     }
   }
+
   private static boolean removeLocator(InternalLocator l) {
-    if (l == null) return false;
+    if (l == null) {
+      return false;
+    }
     synchronized (locatorLock) {
       if (hasLocator()) {
         if (l.equals(locator)) {
@@ -220,7 +260,7 @@ public class InternalLocator extends Locator implements ConnectListener {
       return false;
     }
   }
-  
+
   public LocatorMembershipListener getlocatorMembershipListener() {
     return this.locatorListener;
   }
@@ -229,32 +269,25 @@ public class InternalLocator extends Locator implements ConnectListener {
    * Create a locator that listens on a given port. This locator will not have
    * peer or server location services available until they are started by
    * calling startServerLocation or startPeerLocation on the locator object.
-   * 
-   * @param port
-   *                the tcp/ip port to listen on
-   * @param logFile
-   *                the file that log messages should be written to
-   * @param stateFile
-   *                the file that state should be read from / written to for recovery               
-   * @param logger
-   *                a log writer that should be used (logFile parameter is
-   *                ignored)
-   * @param securityLogger
-   *                the logger to be used for security related log messages
-   * @param distributedSystemProperties
-   *                optional properties to configure the distributed system
-   *                (e.g., mcast addr/port, other locators)
+   * @param port the tcp/ip port to listen on
+   * @param logFile the file that log messages should be written to
+   * @param stateFile the file that state should be read from / written to for recovery
+   * @param logger a log writer that should be used (logFile parameter is
+   * ignored)
+   * @param securityLogger the logger to be used for security related log messages
+   * @param distributedSystemProperties optional properties to configure the distributed system
+   * (e.g., mcast addr/port, other locators)
    * @param startDistributedSystem if true then this locator will also start its own ds
    */
-  public static InternalLocator createLocator(
-      int port,
-      File logFile,
-      File stateFile,
-      InternalLogWriter logger,
-      InternalLogWriter securityLogger,
-      InetAddress bindAddress,
-      String hostnameForClients,
-      java.util.Properties distributedSystemProperties, boolean startDistributedSystem) throws IOException {
+  public static InternalLocator createLocator(int port,
+                                              File logFile,
+                                              File stateFile,
+                                              InternalLogWriter logger,
+                                              InternalLogWriter securityLogger,
+                                              InetAddress bindAddress,
+                                              String hostnameForClients,
+                                              java.util.Properties distributedSystemProperties,
+                                              boolean startDistributedSystem) throws IOException {
     synchronized (locatorLock) {
       if (hasLocator()) {
         throw new IllegalStateException("A locator can not be created because one already exists in this JVM.");
@@ -264,159 +297,138 @@ public class InternalLocator extends Locator implements ConnectListener {
       return l;
     }
   }
-  
+
   private static void setLocator(InternalLocator l) {
-    synchronized(locatorLock) {
-      if (locator != null  &&  locator != l) {
+    synchronized (locatorLock) {
+      if (locator != null && locator != l) {
         throw new IllegalStateException("A locator can not be created because one already exists in this JVM.");
       }
       locator = l;
     }
   }
 
-  
+
   /**
    * Creates a distribution locator that runs in this VM on the given
    * port and bind address and creates a distributed system.
-   * 
-   * @param port
-   *    the tcp/ip port to listen on
-   * @param logFile
-   *    the file that log messages should be written to
-   * @param logger
-   *    a log writer that should be used (logFile parameter is ignored)
-   * @param securityLogger
-   *    the logger to be used for security related log messages
-   * @param dsProperties
-   *    optional properties to configure the distributed system (e.g., mcast addr/port, other locators)
-   * @param peerLocator
-   *    enable peer location services
-   * @param enableServerLocator
-   *    enable server location services
-   * @param hostnameForClients
-   *    the name to give to clients for connecting to this locator
-   * @param loadSharedConfigFromDir 
-   *    load the shared configuration from the shared configuration directory
-   * @throws IOException 
+   * @param port the tcp/ip port to listen on
+   * @param logFile the file that log messages should be written to
+   * @param logger a log writer that should be used (logFile parameter is ignored)
+   * @param securityLogger the logger to be used for security related log messages
+   * @param dsProperties optional properties to configure the distributed system (e.g., mcast addr/port, other locators)
+   * @param peerLocator enable peer location services
+   * @param enableServerLocator enable server location services
+   * @param hostnameForClients the name to give to clients for connecting to this locator
+   * @param loadSharedConfigFromDir load the shared configuration from the shared configuration directory
+   *
+   * @throws IOException
    * @since GemFire 7.0
    */
-  public static InternalLocator startLocator(
-      int port,
-      File logFile,
-      File stateFile,
-      InternalLogWriter logger,
-      InternalLogWriter securityLogger,
-      InetAddress bindAddress,
-      java.util.Properties dsProperties,
-      boolean peerLocator, 
-      boolean enableServerLocator,
-      String hostnameForClients, 
-      boolean loadSharedConfigFromDir
-      )
-      throws IOException {
+  public static InternalLocator startLocator(int port,
+                                             File logFile,
+                                             File stateFile,
+                                             InternalLogWriter logger,
+                                             InternalLogWriter securityLogger,
+                                             InetAddress bindAddress,
+                                             java.util.Properties dsProperties,
+                                             boolean peerLocator,
+                                             boolean enableServerLocator,
+                                             String hostnameForClients,
+                                             boolean loadSharedConfigFromDir) throws IOException {
     return startLocator(port, logFile, stateFile, logger, securityLogger, bindAddress, true, dsProperties, peerLocator, enableServerLocator, hostnameForClients, loadSharedConfigFromDir);
   }
-  
-  
+
+
   /**
    * Creates a distribution locator that runs in this VM on the given
    * port and bind address.
-   * 
+   * <p>
    * This is for internal use only as it does not create a distributed
    * system unless told to do so.
-   * 
-   * @param port
-   *    the tcp/ip port to listen on
-   * @param logFile
-   *    the file that log messages should be written to
-   * @param logger
-   *    a log writer that should be used (logFile parameter is ignored)
-   * @param securityLogger
-   *    the logger to be used for security related log messages
-   * @param startDistributedSystem
-   *    if true, a distributed system is started
-   * @param dsProperties
-   *    optional properties to configure the distributed system (e.g., mcast addr/port, other locators)
-   * @param peerLocator
-   *    enable peer location services
-   * @param enableServerLocator
-   *    enable server location services
-   * @param hostnameForClients
-   *    the name to give to clients for connecting to this locator
+   * @param port the tcp/ip port to listen on
+   * @param logFile the file that log messages should be written to
+   * @param logger a log writer that should be used (logFile parameter is ignored)
+   * @param securityLogger the logger to be used for security related log messages
+   * @param startDistributedSystem if true, a distributed system is started
+   * @param dsProperties optional properties to configure the distributed system (e.g., mcast addr/port, other locators)
+   * @param peerLocator enable peer location services
+   * @param enableServerLocator enable server location services
+   * @param hostnameForClients the name to give to clients for connecting to this locator
    * @param loadSharedConfigFromDir TODO:CONFIG
-   * @throws IOException 
+   *
+   * @throws IOException
    */
-  public static InternalLocator startLocator(
-    int port,
-    File logFile,
-    File stateFile,
-    InternalLogWriter logger,
-    InternalLogWriter securityLogger,
-    InetAddress bindAddress,
-    boolean startDistributedSystem,
-    java.util.Properties dsProperties,
-    boolean peerLocator, 
-    boolean enableServerLocator, 
-    String hostnameForClients, 
-    boolean loadSharedConfigFromDir
-    )
-    throws IOException
-  {
-
-    if(!peerLocator && !enableServerLocator) {
+  public static InternalLocator startLocator(int port,
+                                             File logFile,
+                                             File stateFile,
+                                             InternalLogWriter logger,
+                                             InternalLogWriter securityLogger,
+                                             InetAddress bindAddress,
+                                             boolean startDistributedSystem,
+                                             java.util.Properties dsProperties,
+                                             boolean peerLocator,
+                                             boolean enableServerLocator,
+                                             String hostnameForClients,
+                                             boolean loadSharedConfigFromDir) throws IOException {
+
+    if (!peerLocator && !enableServerLocator) {
       throw new IllegalArgumentException(LocalizedStrings.InternalLocator_EITHER_PEER_LOCATOR_OR_SERVER_LOCATOR_MUST_BE_ENABLED.toLocalizedString());
     }
-    
+
     System.setProperty(FORCE_LOCATOR_DM_TYPE, "true");
     InternalLocator slocator = null;
-    
+
     boolean startedLocator = false;
     try {
-      
-    slocator = createLocator(port, logFile, stateFile, logger, securityLogger, bindAddress, hostnameForClients, dsProperties, startDistributedSystem);
-    
-    // TODO:GEODE-1243: this.server is now a TcpServer and it should store or return its non-zero port in a variable to use here
 
-    if (enableServerLocator) {
-      slocator.handler.willHaveServerLocator = true;
-    }
-    
-    if(peerLocator)  {
-      slocator.startPeerLocation(startDistributedSystem);
-    }
-    
-    if (startDistributedSystem) {
-      try {
-        slocator.startDistributedSystem(); // TODO:GEODE-1243: throws Exception if TcpServer still has zero for its locator port
-      } catch (RuntimeException e) {
-        slocator.stop();
-        throw e;
-      }
-      // fix bug #46324
-      final InternalDistributedSystem ids = (InternalDistributedSystem)slocator.myDs;
-      if (ids != null) {
-        ids.getDistributionManager().addHostedLocators(ids.getDistributedMember(), getLocatorStrings(), slocator.isSharedConfigurationEnabled());
+      slocator = createLocator(port, logFile, stateFile, logger, securityLogger, bindAddress, hostnameForClients, dsProperties, startDistributedSystem);
+
+      // TODO:GEODE-1243: this.server is now a TcpServer and it should store or return its non-zero port in a variable to use here
+
+      if (enableServerLocator) {
+        slocator.handler.willHaveServerLocator = true;
       }
-    }
-    // during the period when the product is using only paper licenses we always
-    // start server location services in order to be able to log information
-    // about the use of cache servers
-//    if(enableServerLocator) {
-//      slocator.startServerLocation(InternalDistributedSystem.getConnectedInstance());
-//  }
-    InternalDistributedSystem sys = InternalDistributedSystem.getConnectedInstance();
-    if (sys != null) {
       try {
-        slocator.startServerLocation(sys);
-      } catch (RuntimeException e) {
+        if (peerLocator) {
+          slocator.startPeerLocation(startDistributedSystem);
+        }
+        if (startDistributedSystem) {
+          try {
+            slocator.startDistributedSystem(); // TODO:GEODE-1243: throws Exception if TcpServer still has zero for its locator port
+          } catch (RuntimeException e) {
+            slocator.stop();
+            throw e;
+          }
+          // fix bug #46324
+          final InternalDistributedSystem ids = (InternalDistributedSystem) slocator.myDs;
+          if (ids != null) {
+            ids.getDistributionManager().addHostedLocators(ids.getDistributedMember(), getLocatorStrings(), slocator.isSharedConfigurationEnabled());
+          }
+        }
+      } catch (LocatorCancelException e) {
         slocator.stop();
-        throw e;
       }
-    }
-    
-    slocator.endStartLocator(null);
-    startedLocator = true;
-    return slocator;
+
+
+      // during the period when the product is using only paper licenses we always
+      // start server location services in order to be able to log information
+      // about the use of cache servers
+      //    if(enableServerLocator) {
+      //      slocator.startServerLocation(InternalDistributedSystem.getConnectedInstance());
+      //  }
+      InternalDistributedSystem sys = InternalDistributedSystem.getConnectedInstance();
+      if (sys != null) {
+        try {
+          slocator.startServerLocation(sys);
+        } catch (RuntimeException e) {
+          slocator.stop();
+          throw e;
+        }
+      }
+
+      slocator.endStartLocator(null);
+      startedLocator = true;
+      return slocator;
 
     } finally {
       System.getProperties().remove(FORCE_LOCATOR_DM_TYPE);
@@ -426,17 +438,18 @@ public class InternalLocator extends Locator implements ConnectListener {
       }
     }
   }
-  
+
   /***
    * Determines if this VM is a locator which must ignore a shutdown.
    * @return true if this VM is a locator which should ignore a shutdown , false if it is a normal member.
    */
   public static boolean isDedicatedLocator() {
     InternalLocator internalLocator = getLocator();
-    if (internalLocator == null)
+    if (internalLocator == null) {
       return false;
-    
-    InternalDistributedSystem ids = (InternalDistributedSystem)internalLocator.myDs;
+    }
+
+    InternalDistributedSystem ids = (InternalDistributedSystem) internalLocator.myDs;
     if (ids == null) {
       return false;
     }
@@ -444,66 +457,59 @@ public class InternalLocator extends Locator implements ConnectListener {
     if (dm.isLoner()) {
       return false;
     }
-    DistributionManager distMgr = (DistributionManager)ids.getDistributionManager();
+    DistributionManager distMgr = (DistributionManager) ids.getDistributionManager();
     return distMgr.getDMType() == DistributionManager.LOCATOR_DM_TYPE;
   }
 
   ///////////////////////  Constructors  //////////////////////
-  
+
   /**
    * Creates a new <code>Locator</code> with the given port, log file, logger,
    * and bind address.
-   * 
-   * @param port
-   *                the tcp/ip port to listen on
-   * @param logF
-   *                the file that log messages should be written to
-   * @param stateF
-   *    the file that state should be read from / written to for recovery
-   * @param logWriter
-   *                a log writer that should be used (logFile parameter is
-   *                ignored)
-   * @param securityLogWriter
-   *                the log writer to be used for security related log messages
-   * @param hostnameForClients
-   *    the name to give to clients for connecting to this locator
-   * @param distributedSystemProperties
-   *                optional properties to configure the distributed system
-   *                (e.g., mcast addr/port, other locators)
+   * @param port the tcp/ip port to listen on
+   * @param logF the file that log messages should be written to
+   * @param stateF the file that state should be read from / written to for recovery
+   * @param logWriter a log writer that should be used (logFile parameter is
+   * ignored)
+   * @param securityLogWriter the log writer to be used for security related log messages
+   * @param hostnameForClients the name to give to clients for connecting to this locator
+   * @param distributedSystemProperties optional properties to configure the distributed system
+   * (e.g., mcast addr/port, other locators)
    * @param cfg the config if being called from a distributed system; otherwise null.
    * @param startDistributedSystem if true locator will start its own distributed system
    */
-  private InternalLocator(
-    int port,
-    File logF,
-    File stateF,
-    InternalLogWriter logWriter, // LOG: 3 non-null sources: GemFireDistributionLocator, InternalDistributedSystem, LocatorLauncher
-    InternalLogWriter securityLogWriter, // LOG: 1 non-null source: GemFireDistributionLocator(same instance as logWriter), InternalDistributedSystem
-    InetAddress bindAddress,
-    String hostnameForClients,
-    java.util.Properties distributedSystemProperties, DistributionConfigImpl cfg, boolean startDistributedSystem) {
+  private InternalLocator(int port,
+                          File logF,
+                          File stateF,
+                          InternalLogWriter logWriter,
+                          // LOG: 3 non-null sources: GemFireDistributionLocator, InternalDistributedSystem, LocatorLauncher
+                          InternalLogWriter securityLogWriter,
+                          // LOG: 1 non-null source: GemFireDistributionLocator(same instance as logWriter), InternalDistributedSystem
+                          InetAddress bindAddress,
+                          String hostnameForClients,
+                          java.util.Properties distributedSystemProperties,
+                          DistributionConfigImpl cfg,
+                          boolean startDistributedSystem) {
     this.logFile = logF;
     this.bindAddress = bindAddress;
     this.hostnameForClients = hostnameForClients;
     if (stateF == null) {
       this.stateFile = new File("locator" + port + "view.dat");
-    }
-    else {
+    } else {
       this.stateFile = stateF;
     }
-    File productUseFile = new File("locator"+port+"views.log");
+    File productUseFile = new File("locator" + port + "views.log");
     this.productUseLog = new ProductUseLog(productUseFile);
     this.config = cfg;
-    
+
     env = new Properties();
 
     // set bind-address explicitly only if not wildcard and let any explicit
     // value in distributedSystemProperties take precedence (#46870)
     if (bindAddress != null && !bindAddress.isAnyLocalAddress()) {
-      env.setProperty(BIND_ADDRESS,
-          bindAddress.getHostAddress());
+      env.setProperty(BIND_ADDRESS, bindAddress.getHostAddress());
     }
-    
+
     if (distributedSystemProperties != null) {
       env.putAll(distributedSystemProperties);
     }
@@ -516,8 +522,10 @@ public class InternalLocator extends Locator implements ConnectListener {
       this.env.clear();
       this.env.putAll(this.config.getProps());
     }
-    
-    final boolean hasLogFileButConfigDoesNot = this.logFile != null && this.config.getLogFile().toString().equals(DistributionConfig.DEFAULT_LOG_FILE.toString());
+
+    final boolean hasLogFileButConfigDoesNot = this.logFile != null && this.config.getLogFile()
+                                                                                  .toString()
+                                                                                  .equals(DistributionConfig.DEFAULT_LOG_FILE.toString());
     if (logWriter == null && hasLogFileButConfigDoesNot) {
       this.config.unsafeSetLogFile(this.logFile); // LOG: this is(was) a hack for when logFile and config don't match -- if config specifies a different log-file things will break!
     }
@@ -527,20 +535,20 @@ public class InternalLocator extends Locator implements ConnectListener {
     final boolean hasSecurityLogFile = this.config.getSecurityLogFile() != null && !this.config.getSecurityLogFile().equals(new File(""));
     LogService.configureLoggers(hasLogFile, hasSecurityLogFile);
     if (hasLogFile || hasSecurityLogFile) {
-      
+
       if (hasLogFile) {
         // if log-file then create logWriterAppender
         LogWriterAppenders.getOrCreateAppender(LogWriterAppenders.Identifier.MAIN, true, false, this.config, !startDistributedSystem);
       }
-      
+
       if (hasSecurityLogFile) {
         // if security-log-file then create securityLogWriterAppender
         LogWriterAppenders.getOrCreateAppender(LogWriterAppenders.Identifier.SECURITY, true, false, this.config, false);
-        
+
       } else {
         // do not create a LogWriterAppender for security -- let it go through to logWriterAppender
       }
-    }    
+    }
 
     // LOG: create LogWriters for GemFireTracer (or use whatever was passed in)
     if (logWriter == null) {
@@ -549,31 +557,32 @@ public class InternalLocator extends Locator implements ConnectListener {
         logger.debug("LogWriter for locator is created.");
       }
     }
-    
+
     if (securityLogWriter == null) {
       securityLogWriter = LogWriterFactory.createLogWriterLogger(false, true, this.config, false);
       ((LogWriterLogger) logWriter).setLogWriterLevel(this.config.getSecurityLogLevel());
       securityLogWriter.fine("SecurityLogWriter for locator is created.");
     }
-    
+
     this.locatorListener = WANServiceProvider.createLocatorMembershipListener();
-    if(locatorListener != null) {
+    if (locatorListener != null) {
       // We defer setting the port until the handler is init'd - that way we'll have an actual port in the
       // case where we're starting with port = 0.
       this.locatorListener.setConfig(this.getConfig());
     }
     this.handler = new PrimaryHandler(this, locatorListener);
-  
+
     ThreadGroup group = LoggingThreadGroup.createThreadGroup("Distribution locators", logger);
     stats = new LocatorStats();
-    server = new TcpServer(port, this.bindAddress, null, this.config,
-        this.handler, new DelayedPoolStatHelper(), group, this.toString());
+
+    SocketCreatorFactory.setDistributionConfig(this.config);
+    server = new TcpServer(port, this.bindAddress, null, this.config, this.handler, new DelayedPoolStatHelper(), group, this.toString());
   }
 
   //Reset the file names with the correct port number if startLocatorAndDS was called with port number 0
-  public void resetInternalLocatorFileNamesWithCorrectPortNumber(int port){
+  public void resetInternalLocatorFileNamesWithCorrectPortNumber(int port) {
     this.stateFile = new File("locator" + port + "view.dat");
-    File productUseFile = new File("locator"+port+"views.log");
+    File productUseFile = new File("locator" + port + "views.log");
     this.productUseLog = new ProductUseLog(productUseFile);
   }
 
@@ -582,53 +591,51 @@ public class InternalLocator extends Locator implements ConnectListener {
     logger.info(LocalizedMessage.create(LocalizedStrings.InternalLocator_STARTING_0, this));
     server.start();
   }
-  
+
   public SharedConfiguration getSharedConfiguration() {
     return this.sharedConfig;
   }
-  
+
   public DistributionConfigImpl getConfig() {
     return config;
   }
-  
+
   /**
    * Start peer location in this locator. If you plan on starting a distributed
    * system later, this method should be called first so that the distributed
    * system can use this locator.
-   * 
    * @param withDS true if a distributed system has been or will be started
+   *
    * @throws IOException
    * @since GemFire 5.7
    */
   public void startPeerLocation(boolean withDS) throws IOException {
-    if(isPeerLocator()) {
+    if (isPeerLocator()) {
       throw new IllegalStateException(LocalizedStrings.InternalLocator_PEER_LOCATION_IS_ALREADY_RUNNING_FOR_0.toLocalizedString(this));
     }
     logger.info(LocalizedMessage.create(LocalizedStrings.InternalLocator_STARTING_PEER_LOCATION_FOR_0, this));
-    
+
     String locatorsProp = this.config.getLocators();
-    
+
     // check for settings that would require only locators to hold the
     // coordinator - e.g., security and network-partition detection
     boolean locatorsAreCoordinators = false;
     boolean networkPartitionDetectionEnabled = this.config.getEnableNetworkPartitionDetection();
     if (networkPartitionDetectionEnabled) {
       locatorsAreCoordinators = true;
-    }
-    else {
+    } else {
       // check if security is enabled
       String prop = this.config.getSecurityPeerAuthInit();
-      locatorsAreCoordinators =  (prop != null && prop.length() > 0);
+      locatorsAreCoordinators = (prop != null && prop.length() > 0);
       if (!locatorsAreCoordinators) {
         locatorsAreCoordinators = Boolean.getBoolean(LOCATORS_PREFERRED_AS_COORDINATORS);
       }
     }
 
-    this.locatorImpl = MemberFactory.newLocatorHandler(this.bindAddress, this.stateFile,
-        locatorsProp, locatorsAreCoordinators, networkPartitionDetectionEnabled, stats);
+    this.locatorImpl = MemberFactory.newLocatorHandler(this.bindAddress, this.stateFile, locatorsProp, locatorsAreCoordinators, networkPartitionDetectionEnabled, stats);
     this.handler.addHandler(PeerLocatorRequest.class, this.locatorImpl);
     peerLocator = true;
-    if(!server.isAlive()) {
+    if (!server.isAlive()) {
       startTcpServer();
     }
   }
@@ -639,11 +646,11 @@ public class InternalLocator extends Locator implements ConnectListener {
   public NetLocator getLocatorHandler() {
     return this.locatorImpl;
   }
-  
-  class SharedConfigurationRunnable implements Runnable{
-    
+
+  class SharedConfigurationRunnable implements Runnable {
+
     private final InternalLocator locator = InternalLocator.this;
-    
+
     @Override
     public void run() {
       try {
@@ -667,165 +674,154 @@ public class InternalLocator extends Locator implements ConnectListener {
       }
     }
   }
+
   /**
    * Start a distributed system whose life cycle is managed by this locator. When
    * the locator is stopped, this distributed system will be disconnected. If a
    * distributed system already exists, this method will have no affect.
-   * 
    * @throws UnknownHostException
    * @since GemFire 5.7
    */
   public void startDistributedSystem() throws UnknownHostException {
     InternalDistributedSystem existing = InternalDistributedSystem.getConnectedInstance();
-    
+
     //TODO : For now set this property to create a PDX registry that does nothing
     // Investigate keeping the typeRegistry in the locators
     if (existing != null) {
       // LOG: changed from config to info
       logger.info(LocalizedMessage.create(LocalizedStrings.InternalLocator_USING_EXISTING_DISTRIBUTED_SYSTEM__0, existing));
       startCache(existing);
-    }
-    else {
+    } else {
       String thisLocator;
       {
         StringBuilder sb = new StringBuilder(100);
         if (bindAddress != null) {
           sb.append(bindAddress.getHostAddress());
-        }
-        else {
+        } else {
           sb.append(SocketCreator.getLocalHost().getHostAddress());
         }
         sb.append('[').append(getPort()).append(']');
         thisLocator = sb.toString();
       }
-      
-
-      if(peerLocator) {
-          // append this locator to the locators list from the config properties
-          //this.logger.config("ensuring that this locator is in the locators list");
-          boolean setLocatorsProp = false;
-          String locatorsProp = this.config.getLocators();
-          if (locatorsProp != null && locatorsProp.trim().length() > 0) {
-            if (!locatorsProp.contains(thisLocator)) {
-              locatorsProp = locatorsProp + "," + thisLocator;
-              setLocatorsProp = true;
-            }
-          }
-          else {
-            locatorsProp = thisLocator;
+
+
+      if (peerLocator) {
+        // append this locator to the locators list from the config properties
+        //this.logger.config("ensuring that this locator is in the locators list");
+        boolean setLocatorsProp = false;
+        String locatorsProp = this.config.getLocators();
+        if (locatorsProp != null && locatorsProp.trim().length() > 0) {
+          if (!locatorsProp.contains(thisLocator)) {
+            locatorsProp = locatorsProp + "," + thisLocator;
             setLocatorsProp = true;
           }
-          if (setLocatorsProp) {
-            Properties updateEnv = new Properties();
-            updateEnv.setProperty(LOCATORS, locatorsProp);
-            this.config.setApiProps(updateEnv);
-            // fix for bug 41248
-            String propName = DistributionConfig.GEMFIRE_PREFIX +
-                LOCATORS;
-            if (System.getProperty(propName) != null) {
-              System.setProperty(propName, locatorsProp);
-            }
+        } else {
+          locatorsProp = thisLocator;
+          setLocatorsProp = true;
+        }
+        if (setLocatorsProp) {
+          Properties updateEnv = new Properties();
+          updateEnv.setProperty(LOCATORS, locatorsProp);
+          this.config.setApiProps(updateEnv);
+          // fix for bug 41248
+          String propName = DistributionConfig.GEMFIRE_PREFIX + LOCATORS;
+          if (System.getProperty(propName) != null) {
+            System.setProperty(propName, locatorsProp);
           }
-
-          // No longer default mcast-port to zero. See 46277.
         }
 
-        
-        Properties connectEnv = new Properties();
-        // LogWriterAppender is now shared via that class
-        // using a DistributionConfig earlier in this method
-        connectEnv.put(DistributionConfig.DS_CONFIG_NAME, this.config);
+        // No longer default mcast-port to zero. See 46277.
+      }
+
 
-        logger.info(LocalizedMessage.create(LocalizedStrings.InternalLocator_STARTING_DISTRIBUTED_SYSTEM));
-        // LOG:CONFIG: changed from config to info
-        logger.info(LogMarker.CONFIG, LocalizedMessage.create(LocalizedStrings.InternalDistributedSystem_STARTUP_CONFIGURATIONN_0, this.config.toLoggerString()));
+      Properties connectEnv = new Properties();
+      // LogWriterAppender is now shared via that class
+      // using a DistributionConfig earlier in this method
+      connectEnv.put(DistributionConfig.DS_CONFIG_NAME, this.config);
 
-        myDs = (InternalDistributedSystem)DistributedSystem.connect(connectEnv);
-        
-        if (peerLocator) {
-          this.locatorImpl.setMembershipManager(myDs.getDM().getMembershipManager());
+      logger.info(LocalizedMessage.create(LocalizedStrings.InternalLocator_STARTING_DISTRIBUTED_SYSTEM));
+      // LOG:CONFIG: changed from config to info
+      logger.info(LogMarker.CONFIG, LocalizedMessage.create(LocalizedStrings.InternalDistributedSystem_STARTUP_CONFIGURATIONN_0, this.config.toLoggerString()));
+
+      myDs = (InternalDistributedSystem) DistributedSystem.connect(connectEnv);
+
+      if (peerLocator) {
+        this.locatorImpl.setMembershipManager(myDs.getDM().getMembershipManager());
+      }
+
+      myDs.addDisconnectListener(new DisconnectListener() {
+        @Override
+        public void onDisconnect(InternalDistributedSystem sys) {
+          stop(false, false, false);
         }
-        
-        myDs.addDisconnectListener(new DisconnectListener() {
-          @Override
-          public void onDisconnect(InternalDistributedSystem sys) {
-            stop(false, false, false);
-          }
-        });
-        
-        startCache(myDs);
-        
-        logger.info(LocalizedMessage.create(LocalizedStrings.InternalLocator_LOCATOR_STARTED_ON__0, thisLocator));
-          
-        ((InternalDistributedSystem)myDs).setDependentLocator(this);
+      });
+
+      startCache(myDs);
+
+      logger.info(LocalizedMessage.create(LocalizedStrings.InternalLocator_LOCATOR_STARTED_ON__0, thisLocator));
+
+      ((InternalDistributedSystem) myDs).setDependentLocator(this);
     }
   }
-  
-  
+
+
   private void startCache(DistributedSystem ds) {
-  
+
     GemFireCacheImpl gfc = GemFireCacheImpl.getInstance();
     if (gfc == null) {
       logger.info("Creating cache for locator.");
       this.myCache = new CacheFactory(ds.getProperties()).create();
-      gfc = (GemFireCacheImpl)this.myCache;
+      gfc = (GemFireCacheImpl) this.myCache;
     } else {
       logger.info("Using existing cache for locator.");
-      ((InternalDistributedSystem) ds).handleResourceEvent(
-          ResourceEvent.LOCATOR_START, this);
+      ((InternalDistributedSystem) ds).handleResourceEvent(ResourceEvent.LOCATOR_START, this);
     }
     startJmxManagerLocationService(gfc);
-    
+
     startSharedConfigurationService(gfc);
   }
-  
+
   /**
    * End the initialization of the locator. This method should
    * be called once the location services and distributed
    * system are started.
-   * 
-   * @param distributedSystem
-   *                The distributed system to use for the statistics.
-   *                
-   * @since GemFire 5.7
-   * 
+   * @param distributedSystem The distributed system to use for the statistics.
+   *
    * @throws UnknownHostException
+   * @since GemFire 5.7
    */
   public void endStartLocator(InternalDistributedSystem distributedSystem) throws UnknownHostException {
     env = null;
     if (distributedSystem == null) {
       distributedSystem = InternalDistributedSystem.getConnectedInstance();
     }
-    if(distributedSystem != null) {
+    if (distributedSystem != null) {
       onConnect(distributedSystem);
     } else {
       InternalDistributedSystem.addConnectListener(this);
     }
-    
+
     this.locatorDiscoverer = WANServiceProvider.createLocatorDiscoverer();
-    if(this.locatorDiscoverer != null) {
+    if (this.locatorDiscoverer != null) {
       this.locatorDiscoverer.discover(getPort(), config, locatorListener);
     }
   }
-  
+
   /**
    * Start server location services in this locator. Server location
    * can only be started once there is a running distributed system.
-   * 
-   * @param distributedSystem
-   *                The distributed system which the server location services
-   *                should use. If null, the method will try to find an already
-   *                connected distributed system.
+   * @param distributedSystem The distributed system which the server location services
+   * should use. If null, the method will try to find an already
+   * connected distributed system.
+   *
    * @since GemFire 5.7
    */
-  public void startServerLocation(InternalDistributedSystem distributedSystem)
-    throws IOException
-  {
-    if(isServerLocator()) {
+  public void startServerLocation(InternalDistributedSystem distributedSystem) throws IOException {
+    if (isServerLocator()) {
       throw new IllegalStateException(LocalizedStrings.InternalLocator_SERVER_LOCATION_IS_ALREADY_RUNNING_FOR_0.toLocalizedString(this));
     }
     logger.info(LocalizedMessage.create(LocalizedStrings.InternalLocator_STARTING_SERVER_LOCATION_FOR_0, this));
-    
+
     if (distributedSystem == null) {
       distributedSystem = InternalDistributedSystem.getConnectedInstance();
       if (distributedSystem == null) {
@@ -834,15 +830,8 @@ public class InternalLocator extends Locator implements ConnectListener {
     }
 
     this.productUseLog.monitorUse(distributedSystem);
-    
-    ServerLocator sl = new ServerLocator(getPort(),
-                                         this.bindAddress,
-                                         this.hostnameForClients,
-                                         this.logFile,
-                                         this.productUseLog,
-                                         getConfig().getName(),
-                                         distributedSystem,
-                                         stats);
+
+    ServerLocator sl = new ServerLocator(getPort(), this.bindAddress, this.hostnameForClients, this.logFile, this.productUseLog, getConfig().getName(), distributedSystem, stats);
     this.handler.addHandler(LocatorListRequest.class, sl);
     this.handler.addHandler(ClientConnectionRequest.class, sl);
     this.handler.addHandler(QueueConnectionRequest.class, sl);
@@ -850,19 +839,20 @@ public class InternalLocator extends Locator implements ConnectListener {
     this.handler.addHandler(GetAllServersRequest.class, sl);
     this.handler.addHandler(LocatorStatusRequest.class, sl);
     this.serverLocator = sl;
-    if(!server.isAlive()) {
+    if (!server.isAlive()) {
       startTcpServer();
     }
   }
-  
+
   /**
    * Stop this locator.
    */
   @Override
   public void stop() {
     stop(false, false, true);
+//    SocketCreatorFactory.close();
   }
-  
+
   /**
    * Was this locator stopped during forced-disconnect processing but should
    * reconnect?
@@ -870,7 +860,7 @@ public class InternalLocator extends Locator implements ConnectListener {
   public boolean getStoppedForReconnect() {
     return this.stoppedForReconnect;
   }
-  
+
   /**
    * Stop this locator
    * @param stopForReconnect - stopping for distributed system reconnect
@@ -878,10 +868,10 @@ public class InternalLocator extends Locator implements ConnectListener {
    */
   public void stop(boolean forcedDisconnect, boolean stopForReconnect, boolean waitForDisconnect) {
     final boolean isDebugEnabled = logger.isDebugEnabled();
-    
+
     this.stoppedForReconnect = stopForReconnect;
     this.forcedDisconnect = forcedDisconnect;
-    
+
     if (this.server.isShuttingDown()) {
       // fix for bug 46156
       // If we are already shutting down don't do all of this again.
@@ -893,7 +883,9 @@ public class InternalLocator extends Locator implements ConnectListener {
           logger.debug("sleeping to wait for the locator server to shut down...");
         }
         while (this.server.isAlive() && System.currentTimeMillis() < endOfWait) {
-          try { Thread.sleep(500); } catch (InterruptedException e) {
+          try {
+            Thread.sleep(500);
+          } catch (InterruptedException e) {
             Thread.currentThread().interrupt();
             return;
           }
@@ -918,25 +910,24 @@ public class InternalLocator extends Locator implements ConnectListener {
       logger.info(LocalizedMessage.create(LocalizedStrings.InternalLocator_STOPPING__0, this));
       try {
         new TcpClient().stop(this.bindAddress, getPort());
-      } catch ( ConnectException ignore ) {
+      } catch (ConnectException ignore) {
         // must not be running
       }
       boolean interrupted = Thread.interrupted();
       try {
         this.server.join(TcpServer.SHUTDOWN_WAIT_TIME * 1000 + 10000);
-  
+
       } catch (InterruptedException ex) {
         interrupted = true;
         logger.warn(LocalizedMessage.create(LocalizedStrings.InternalLocator_INTERRUPTED_WHILE_STOPPING__0, this), ex);
-        
+
         // Continue running -- doing our best to stop everything...
-      }
-      finally {
+      } finally {
         if (interrupted) {
           Thread.currentThread().interrupt();
         }
       }
-  
+
       if (this.server.isAlive()) {
         logger.fatal(LocalizedMessage.create(LocalizedStrings.InternalLocator_COULD_NOT_STOP__0__IN_60_SECONDS, this));
       }
@@ -947,27 +938,29 @@ public class InternalLocator extends Locator implements ConnectListener {
     handleShutdown();
 
     logger.info(LocalizedMessage.create(LocalizedStrings.InternalLocator_0__IS_STOPPED, this));
-    
+
     if (stoppedForReconnect) {
       if (this.myDs != null) {
         launchRestartThread();
       }
     }
   }
-  
-  
-  /** answers whether this locator is currently stopped */
+
+
+  /**
+   * answers whether this locator is currently stopped
+   */
   public boolean isStopped() {
-    return this.server == null  ||  !this.server.isAlive();
+    return this.server == null || !this.server.isAlive();
   }
-  
+
   private void handleShutdown() {
     if (!this.shutdownHandled.compareAndSet(false, true)) {
       return; // already shutdown
     }
     productUseLog.close();
     if (myDs != null) {
-      ((InternalDistributedSystem)myDs).setDependentLocator(null);
+      ((InternalDistributedSystem) myDs).setDependentLocator(null);
     }
     if (this.myCache != null && !this.stoppedForReconnect && !this.forcedDisconnect) {
       logger.info("Closing locator's cache");
@@ -977,15 +970,15 @@ public class InternalLocator extends Locator implements ConnectListener {
         logger.info("Could not close locator's cache because: {}", ex);
       }
     }
-    
-    if(stats != null) {
+
+    if (stats != null) {
       stats.close();
     }
-    
-    if(this.locatorListener != null){
+
+    if (this.locatorListener != null) {
       this.locatorListener.clearLocatorInfo();
     }
-    
+
     this.isSharedConfigurationStarted = false;
     if (myDs != null && !this.forcedDisconnect) {
       if (myDs.isConnected()) {
@@ -997,7 +990,6 @@ public class InternalLocator extends Locator implements ConnectListener {
 
   /**
    * Waits for a locator to be told to stop.
-   * 
    * @throws InterruptedException thrown if the thread is interrupted
    */
   public void waitToStop() throws InterruptedException {
@@ -1028,8 +1020,10 @@ public class InternalLocator extends Locator implements ConnectListener {
       }
     } while (restarted);
   }
-  
-  /** launch a thread that will restart location services */
+
+  /**
+   * launch a thread that will restart location services
+   */
   private void launchRestartThread() {
     // create a thread group having a last-chance exception-handler
     ThreadGroup group = LoggingThreadGroup.createThreadGroup("Locator restart thread group");
@@ -1044,7 +1038,7 @@ public class InternalLocator extends Locator implements ConnectListener {
         } catch (IOException e) {
           logger.info("attempt to restart location services terminated", e);
         } finally {
-          if (! restarted) {
+          if (!restarted) {
             stoppedForReconnect = false;
           }
         }
@@ -1054,6 +1048,7 @@ public class InternalLocator extends Locator implements ConnectListener {
     this.restartThread.setDaemon(true);
     this.restartThread.start();
   }
+
   /**
    * reconnects the locator to a restarting DistributedSystem.  If quorum checks
    * are enabled this will start peer location services before a distributed
@@ -1069,10 +1064,9 @@ public class InternalLocator extends Locator implements ConnectListener {
       logger.info("attempting to restart locator");
       boolean tcpServerStarted = false;
       InternalDistributedSystem ds = this.myDs;
-      long waitTime = ds.getConfig().getMaxWaitTimeForReconnect()/2;
+      long waitTime = ds.getConfig().getMaxWaitTimeForReconnect() / 2;
       QuorumChecker checker = null;
-      while (ds.getReconnectedSystem() == null &&
-          !ds.isReconnectCancelled()) {
+      while (ds.getReconnectedSystem() == null && !ds.isReconnectCancelled()) {
         if (checker == null) {
           checker = this.myDs.getQuorumChecker();
           if (checker != null) {
@@ -1080,12 +1074,12 @@ public class InternalLocator extends Locator implements ConnectListener {
           }
         }
         if (checker != null && !tcpServerStarted) {
-          boolean start = checker.checkForQuorum(3*this.myDs.getConfig().getMemberTimeout());
+          boolean start = checker.checkForQuorum(3 * this.myDs.getConfig().getMemberTimeout());
           if (start) {
             // start up peer location.  server location is started after the DS finishes
             // reconnecting
             logger.info("starting peer location");
-            if(this.locatorListener != null){
+            if (this.locatorListener != null) {
               this.locatorListener.clearLocatorInfo();
             }
             this.stoppedForReconnect = false;
@@ -1098,12 +1092,12 @@ public class InternalLocator extends Locator implements ConnectListener {
         }
         ds.waitUntilReconnected(waitTime, TimeUnit.MILLISECONDS);
       }
-      InternalDistributedSystem newSystem = (InternalDistributedSystem)ds.getReconnectedSystem();
-//      LogWriter log = new ManagerLogWriter(LogWriterImpl.FINE_LEVEL, System.out);
+      InternalDistributedSystem newSystem = (InternalDistributedSystem) ds.getReconnectedSystem();
+      //      LogWriter log = new ManagerLogWriter(LogWriterImpl.FINE_LEVEL, System.out);
       if (newSystem != null) {
-//        log.fine("reconnecting locator: starting location services");
+        //        log.fine("reconnecting locator: starting location services");
         if (!tcpServerStarted) {
-          if(this.locatorListener != null){
+          if (this.locatorListener != null) {
             this.locatorListener.clearLocatorInfo();
           }
           this.stoppedForReconnect = false;
@@ -1113,11 +1107,11 @@ public class InternalLocator extends Locator implements ConnectListener {
         restarted = true;
       }
     }
-    logger.info("restart thread exiting.  Service was "+(restarted? "" : "not ") + "restarted");
+    logger.info("restart thread exiting.  Service was " + (restarted ? "" : "not ") + "restarted");
     return restarted;
   }
-  
-  
+
+
   private void restartWithoutDS() throws IOException {
     synchronized (locatorLock) {
       if (locator != this && hasLocator()) {
@@ -1136,7 +1130,7 @@ public class InternalLocator extends Locator implements ConnectListener {
       }
     }
   }
-  
+
   private void restartWithDS(InternalDistributedSystem newSystem, GemFireCacheImpl newCache) throws IOException {
     synchronized (locatorLock) {
       if (locator != this && hasLocator()) {
@@ -1144,7 +1138,7 @@ public class InternalLocator extends Locator implements ConnectListener {
       }
       this.myDs = newSystem;
       this.myCache = newCache;
-      ((InternalDistributedSystem)myDs).setDependentLocator(this);
+      ((InternalDistributedSystem) myDs).setDependentLocator(this);
       logger.info("Locator restart: initializing TcpServer");
       if (isSharedConfigurationEnabled()) {
         this.sharedConfig = new SharedConfiguration(newCache);
@@ -1165,23 +1159,23 @@ public class InternalLocator extends Locator implements ConnectListener {
       }
       logger.info("Locator restart: initializing JMX manager");
       startJmxManagerLocationService(newCache);
-      endStartLocator((InternalDistributedSystem)myDs);
+      endStartLocator((InternalDistributedSystem) myDs);
       logger.info("Locator restart completed");
     }
   }
-  
-  
+
+
   // implementation of abstract method in Locator
   @Override
   public DistributedSystem getDistributedSystem() {
     return myDs;
   }
-  
+
   @Override
   public boolean isPeerLocator() {
     return peerLocator;
   }
-  
+
   @Override
   public boolean isServerLocator() {
     return this.serverLocator != null;
@@ -1198,7 +1192,6 @@ public class InternalLocator extends Locator implements ConnectListener {
   /**
    * Return the port on which the locator is actually listening. If called before the locator has actually
    * started, this method will return null.
-   *
    * @return the port the locator is listening on or null if it has not yet been started
    */
   public Integer getPort() {
@@ -1207,19 +1200,21 @@ public class InternalLocator extends Locator implements ConnectListener {
     }
     return null;
   }
-  
+
   /******
-   * 
+   *
    *
    */
   class FetchSharedConfigStatus implements Callable<SharedConfigurationStatusResponse> {
+
     static final int SLEEPTIME = 1000;
     static final byte MAX_RETRIES = 5;
+
     public SharedConfigurationStatusResponse call() throws Exception {
       SharedConfigurationStatusResponse response;
-      
+
       final InternalLocator locator = InternalLocator.this;
-      for (int i=0; i<MAX_RETRIES; i++) {
+      for (int i = 0; i < MAX_RETRIES; i++) {
         if (locator.sharedConfig != null) {
           SharedConfigurationStatus status = locator.sharedConfig.getStatus();
           if (status != SharedConfigurationStatus.STARTED || status != SharedConfigurationStatus.NOT_STARTED) {
@@ -1237,10 +1232,10 @@ public class InternalLocator extends Locator implements ConnectListener {
       return response;
     }
   }
-  
-  
+
+
   public SharedConfigurationStatusResponse getSharedConfigurationStatus() {
-    ExecutorService es = ((GemFireCacheImpl)myCache).getDistributionManager().getWaitingThreadPool();
+    ExecutorService es = ((GemFireCacheImpl) myCache).getDistributionManager().getWaitingThreadPool();
     Future<SharedConfigurationStatusResponse> statusFuture = es.submit(new FetchSharedConfigStatus());
     SharedConfigurationStatusResponse response = null;
 
@@ -1248,14 +1243,15 @@ public class InternalLocator extends Locator implements ConnectListener {
       response = statusFuture.get(5, TimeUnit.SECONDS);
     } catch (Exception e) {
       logger.info("Exception occured while fetching the status {}", CliUtil.stackTraceAsString(e));
-      response =  new SharedConfigurationStatusResponse();
+      response = new SharedConfigurationStatusResponse();
       response.setStatus(SharedConfigurationStatus.UNDETERMINED);
-    } 
+    }
     return response;
   }
-  
-  
+
+
   private static class PrimaryHandler implements TcpHandler {
+
     private volatile HashMap<Class, TcpHandler> handlerMapping = new HashMap<Class, TcpHandler>();
     private volatile HashSet<TcpHandler> allHandlers = new HashSet<TcpHandler>();
     private TcpServer tcpServer;
@@ -1264,9 +1260,8 @@ public class InternalLocator extends Locator implements ConnectListener {
     private Object locatorJoinObject = new Object();
     private InternalLocator internalLocator;
     boolean willHaveServerLocator;  // flag to avoid warning about missing handlers during startup
-    
-    public PrimaryHandler(InternalLocator locator,
-        LocatorMembershipListener listener) {
+
+    public PrimaryHandler(InternalLocator locator, LocatorMembershipListener listener) {
       this.locatorListener = listener;
       internalLocator = locator;
       //this.locatorJoinMessages = new ArrayList<LocatorJoinMessage>();
@@ -1280,7 +1275,7 @@ public class InternalLocator extends Locator implements ConnectListener {
         this.locatorListener.setPort(internalLocator.getPort());
       }
       this.tcpServer = tcpServer;
-      for(Iterator itr = allHandlers.iterator(); itr.hasNext();) {
+      for (Iterator itr = allHandlers.iterator(); itr.hasNext(); ) {
         TcpHandler handler = (TcpHandler) itr.next();
         handler.init(tcpServer);
       }
@@ -1288,7 +1283,7 @@ public class InternalLocator extends Locator implements ConnectListener {
 
     public void restarting(DistributedSystem ds, GemFireCache cache, SharedConfiguration sharedConfig) {
       if (ds != null) {
-        for (TcpHandler handler: this.allHandlers) {
+        for (TcpHandler handler : this.allHandlers) {
           handler.restarting(ds, cache, sharedConfig);
         }
       }
@@ -1297,29 +1292,24 @@ public class InternalLocator extends Locator implements ConnectListener {
     public Object processRequest(Object request) throws IOException {
       TcpHandler handler = null;
       if (request instanceof PeerLocatorRequest) {
-        handler = (TcpHandler)handlerMapping.get(PeerLocatorRequest.class);
-      }
-      else {
-        handler = (TcpHandler)handlerMapping.get(request.getClass());
+        handler = (TcpHandler) handlerMapping.get(PeerLocatorRequest.class);
+      } else {
+        handler = (TcpHandler) handlerMapping.get(request.getClass());
       }
-      
+
       if (handler != null) {
         Object result;
         result = handler.processRequest(request);
         return result;
-      }
-      else {  
+      } else {
         Object response;
-        if(locatorListener != null){
+        if (locatorListener != null) {
           response = locatorListener.handleRequest(request);
-        }
-        else {
+        } else {
           if (!(willHaveServerLocator && (request instanceof ServerLocationRequest))) {
-            logger
-                .warn(LocalizedMessage
-                    .create(
-                        LocalizedStrings.InternalLocator_EXPECTED_ONE_OF_THESE_0_BUT_RECEIVED_1,
-                        new Object[] { handlerMapping.keySet(), request }));
+            logger.warn(LocalizedMessage.create(LocalizedStrings.InternalLocator_EXPECTED_ONE_OF_THESE_0_BUT_RECEIVED_1, new Object[] {
+              handlerMapping.keySet(), request
+            }));
           }
           return null;
         }
@@ -1332,52 +1322,52 @@ public class InternalLocator extends Locator implements ConnectListener {
       // NYI
       return result;
     }
-    
+
     public void shutDown() {
       try {
-      for(Iterator itr = allHandlers.iterator(); itr.hasNext(); ) {
-        TcpHandler handler = (TcpHandler) itr.next();
-        handler.shutDown();
-      }
+        for (Iterator itr = allHandlers.iterator(); itr.hasNext(); ) {
+          TcpHandler handler = (TcpHandler) itr.next();
+          handler.shutDown();
+        }
       } finally {
         this.internalLocator.handleShutdown();
       }
     }
-    
+
     public synchronized boolean isHandled(Class clazz) {
       return this.handlerMapping.containsKey(clazz);
     }
-    
+
     public synchronized void addHandler(Class clazz, TcpHandler handler) {
       HashMap tmpHandlerMapping = new HashMap(handlerMapping);
       HashSet tmpAllHandlers = new HashSet(allHandlers);
       tmpHandlerMapping.put(clazz, handler);
-      if(tmpAllHandlers.add(handler) && tcpServer != null ) {
+      if (tmpAllHandlers.add(handler) && tcpServer != null) {
         handler.init(tcpServer);
       }
       handlerMapping = tmpHandlerMapping;
       allHandlers = tmpAllHandlers;
     }
-    
-    public void endRequest(Object request,long startTime) {
+
+    public void endRequest(Object request, long startTime) {
       TcpHandler handler = (TcpHandler) handlerMapping.get(request.getClass());
-      if(handler != null) {
+      if (handler != null) {
         handler.endRequest(request, startTime);
       }
     }
-    
-    public void endResponse(Object request,long startTime) {
+
+    public void endResponse(Object request, long startTime) {
       TcpHandler handler = (TcpHandler) handlerMapping.get(request.getClass());
-      if(handler != null) {
+      if (handler != null) {
         handler.endResponse(request, startTime);
       }
     }
   }
-  
+
   public void onConnect(InternalDistributedSystem sys) {
     try {
-      stats.hookupStats(sys,  SocketCreator.getLocalHost().getCanonicalHostName() + "-" + server.getBindAddress().toString());
-    } catch(UnknownHostException uhe) {
+      stats.hookupStats(sys, SocketCreator.getLocalHost().getCanonicalHostName() + "-" + server.getBindAddress().toString());
+    } catch (UnknownHostException uhe) {
       uhe.printStackTrace();
     }
   }
@@ -1385,14 +1375,12 @@ public class InternalLocator extends Locator implements ConnectListener {
   /**
    * Returns collection of locator strings representing every locator instance
    * hosted by this member.
-   * 
    * @see #getLocators()
    */
   public static Collection<String> getLocatorStrings() {
     Collection<String> locatorStrings = null;
     try {
-      Collection<DistributionLocatorId> locatorIds = 
-          DistributionLocatorId.asDistributionLocatorIds(getLocators());
+      Collection<DistributionLocatorId> locatorIds = DistributionLocatorId.asDistributionLocatorIds(getLocators());
       locatorStrings = DistributionLocatorId.asStrings(locatorIds);
     } catch (UnknownHostException e) {
       locatorStrings = null;
@@ -1403,33 +1391,33 @@ public class InternalLocator extends Locator implements ConnectListener {
       return locatorStrings;
     }
   }
-  
+
   /**
    * A helper object so that the TcpServer can record
    * its stats to the proper place. Stats are only recorded
    * if a distributed system is started.
-   * 
    */
   protected class DelayedPoolStatHelper implements PoolStatHelper {
-    
+
     public void startJob() {
       stats.incRequestInProgress(1);
-      
+
     }
+
     public void endJob() {
       stats.incRequestInProgress(-1);
     }
   }
-  
-  public void startSharedConfigurationService(GemFireCacheImpl gfc){
-    
-    
+
+  public void startSharedConfigurationService(GemFireCacheImpl gfc) {
+
+
     if (this.config.getEnableClusterConfiguration() && !this.isSharedConfigurationStarted) {
       if (!isDedicatedLocator()) {
         logger.info("Cluster configuration service is only supported in dedicated locators");
         return;
-      } 
-      
+      }
+
       this.isSharedConfigurationStarted = true;
       installSharedConfigStatus();
       ExecutorService es = gfc.getDistributionManager().getThreadPool();
@@ -1438,7 +1426,7 @@ public class InternalLocator extends Locator implements ConnectListener {
       logger.info("Cluster configuration service is disabled");
     }
   }
-  
+
   public void startJmxManagerLocationService(GemFireCacheImpl gfc) {
     if (gfc.getJmxManagerAdvisor() != null) {
       if (!this.handler.isHandled(JmxManagerLocatorRequest.class)) {
@@ -1446,7 +1434,7 @@ public class InternalLocator extends Locator implements ConnectListener {
       }
     }
   }
-  
+
   /***
    * Creates and installs the handler {@link ConfigurationRequestHandler}
    */
@@ -1456,7 +1444,7 @@ public class InternalLocator extends Locator implements ConnectListener {
       logger.info("ConfigRequestHandler installed");
     }
   }
-  
+
   public void installSharedConfigStatus() {
     if (!this.handler.isHandled(SharedConfigurationStatusRequest.class)) {
       this.handler.addHandler(SharedConfigurationStatusRequest.class, new SharedConfigurationStatusRequestHandler());

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/b557ccfe/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/tcpserver/TcpClient.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/tcpserver/TcpClient.java b/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/tcpserver/TcpClient.java
index d4db321..968adc2 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/tcpserver/TcpClient.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/tcpserver/TcpClient.java
@@ -20,20 +20,26 @@ import java.io.DataInputStream;
 import java.io.DataOutputStream;
 import java.io.EOFException;
 import java.io.IOException;
-import java.net.*;
+import java.io.InputStream;
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
+import java.net.Socket;
 import java.util.HashMap;
 import java.util.Map;
 
+import javax.net.ssl.SSLHandshakeException;
+
 import org.apache.logging.log4j.Logger;
 
 import com.gemstone.gemfire.DataSerializer;
 import com.gemstone.gemfire.cache.UnsupportedVersionException;
-import com.gemstone.gemfire.cache.client.internal.locator.*;
 import com.gemstone.gemfire.internal.Version;
 import com.gemstone.gemfire.internal.VersionedDataInputStream;
 import com.gemstone.gemfire.internal.VersionedDataOutputStream;
 import com.gemstone.gemfire.internal.logging.LogService;
-import com.gemstone.gemfire.internal.net.*;
+import com.gemstone.gemfire.internal.net.SSLEnabledComponent;
+import com.gemstone.gemfire.internal.net.SocketCreator;
+import com.gemstone.gemfire.internal.net.SocketCreatorFactory;
 
 /**
  * <p>Client for the TcpServer component of the Locator.
@@ -43,19 +49,19 @@ import com.gemstone.gemfire.internal.net.*;
 public class TcpClient {
 
   private static final Logger logger = LogService.getLogger();
-  
+
   private static final int DEFAULT_REQUEST_TIMEOUT = 60 * 2 * 1000;
 
   private static Map<InetSocketAddress, Short> serverVersions = new HashMap<InetSocketAddress, Short>();
-  
+
   private final SocketCreator socketCreator;
-  
+
   /**
    * Constructs a new TcpClient using the default (Locator) SocketCreator.
    * SocketCreatorFactory should be initialized before invoking this method.
    */
   public TcpClient() {
-    this(SocketCreatorFactory.getClusterSSLSocketCreator());
+    this(SocketCreatorFactory.getSSLSocketCreatorForComponent(SSLEnabledComponent.LOCATOR));
   }
 
   /**
@@ -105,12 +111,13 @@ public class TcpClient {
 
   /**
    * Send a request to a Locator and expect a reply
-   * 
    * @param addr The locator's address
    * @param port The locator's tcp/ip port
    * @param request The request message
    * @param timeout Timeout for sending the message and receiving a reply
+   *
    * @return the reply
+   *
    * @throws IOException
    * @throws ClassNotFoundException
    */
@@ -125,12 +132,13 @@ public class TcpClient {
    * @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(InetAddress addr, int port, Object request, int timeout, boolean replyExpected)
-    throws IOException, ClassNotFoundException {
+  public Object requestToServer(InetAddress addr, int port, Object request, int timeout, boolean replyExpected) throws IOException, ClassNotFoundException {
     InetSocketAddress ipAddr;
     if (addr == null) {
       ipAddr = new InetSocketAddress(port);
@@ -161,7 +169,7 @@ public class TcpClient {
 
     logger.debug("TcpClient sending {} to {}", request, ipAddr);
 
-    Socket sock = SocketCreatorFactory.getClusterSSLSocketCreator().connect(ipAddr.getAddress(), ipAddr.getPort(), (int) newTimeout, null, false);
+    Socket sock = socketCreator.connect(ipAddr.getAddress(), ipAddr.getPort(), (int) newTimeout, null, false);
     sock.setSoTimeout((int) newTimeout);
     DataOutputStream out = null;
     try {
@@ -203,7 +211,9 @@ public class TcpClient {
           // with the socket and is closing it.  Aborting the connection by
           // setting SO_LINGER to zero will clean up the TIME_WAIT socket on
           // the locator's machine.
-          sock.setSoLinger(true, 0);
+          if (!sock.isClosed() && !socketCreator.useSSL()) {
+            sock.setSoLinger(true, 0);
+          }
         }
         sock.close();
       } catch (Exception e) {
@@ -230,8 +240,13 @@ public class TcpClient {
 
     gossipVersion = TcpServer.getOldGossipVersion();
 
-    Socket sock = SocketCreatorFactory.getClusterSSLSocketCreator().connect(ipAddr.getAddress(), ipAddr.getPort(), timeout, null, false);
-    sock.setSoTimeout(timeout);
+    Socket sock = null;
+    try {
+      sock = socketCreator.connect(ipAddr.getAddress(), ipAddr.getPort(), timeout, null, false);
+      sock.setSoTimeout(timeout);
+    } catch (SSLHandshakeException e) {
+      throw new LocatorCancelException("Unrecognisable response received");
+    }
 
     try {
       DataOutputStream out = new DataOutputStream(sock.getOutputStream());
@@ -243,10 +258,16 @@ public class TcpClient {
       DataSerializer.writeObject(verRequest, out);
       out.flush();
 
-      DataInputStream in = new DataInputStream(sock.getInputStream());
+      InputStream inputStream = sock.getInputStream();
+      DataInputStream in = new DataInputStream(inputStream);
       in = new VersionedDataInputStream(in, Version.GFE_57);
       try {
-        VersionResponse response = DataSerializer.readObject(in);
+        Object readObject = DataSerializer.readObject(in);
+        if (!(readObject instanceof VersionResponse)) {
+          throw new LocatorCancelException("Unrecognisable response received");
+          //          throw new IOException("Unexpected response received from locator");
+        }
+        VersionResponse response = (VersionResponse) readObject;
         if (response != null) {
           serverVersion = Short.valueOf(response.getVersionOrdinal());
           synchronized (serverVersions) {
@@ -259,8 +280,8 @@ public class TcpClient {
       }
     } finally {
       try {
-        sock.setSoLinger(true, 0); // initiate an abort on close to shut down the server's socket
-        sock.close();
+          sock.setSoLinger(true, 0); // initiate an abort on close to shut down the server's socket
+          sock.close();
       } catch (Exception e) {
         logger.error("Error closing socket ", e);
       }
@@ -281,7 +302,7 @@ public class TcpClient {
    * knowledge of their communication protocols.
    */
   public static void clearStaticData() {
-    synchronized(serverVersions) {
+    synchronized (serverVersions) {
       serverVersions.clear();
     }
   }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/b557ccfe/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/tcpserver/TcpServer.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/tcpserver/TcpServer.java b/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/tcpserver/TcpServer.java
index cf048bf..6743634 100755
--- a/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/tcpserver/TcpServer.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/tcpserver/TcpServer.java
@@ -27,6 +27,13 @@ import java.net.ServerSocket;
 import java.net.Socket;
 import java.net.SocketAddress;
 import java.net.URL;
+import java.nio.ByteBuffer;
+import java.nio.CharBuffer;
+import java.nio.DoubleBuffer;
+import java.nio.FloatBuffer;
+import java.nio.IntBuffer;
+import java.nio.LongBuffer;
+import java.nio.ShortBuffer;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.Iterator;
@@ -58,8 +65,10 @@ import com.gemstone.gemfire.internal.VersionedDataInputStream;
 import com.gemstone.gemfire.internal.VersionedDataOutputStream;
 import com.gemstone.gemfire.internal.cache.GemFireCacheImpl;
 import com.gemstone.gemfire.internal.logging.LogService;
+import com.gemstone.gemfire.internal.net.SSLEnabledComponent;
 import com.gemstone.gemfire.internal.net.SocketCreator;
 import com.gemstone.gemfire.internal.net.SocketCreatorFactory;
+import com.gemstone.gemfire.internal.tcp.ByteBufferInputStream.ByteBufferByteSource;
 
 /**
  * TCP server which listens on a port and delegates requests to a request
@@ -166,7 +175,8 @@ public class TcpServer {
     }
 
     //TODO Udo: How would I handle this case where the cfg is empty???
-    this.socketCreator = SocketCreatorFactory.getClusterSSLSocketCreator();
+
+    this.socketCreator = SocketCreatorFactory.getSSLSocketCreatorForComponent(SSLEnabledComponent.LOCATOR);
   }
 
   private static PooledExecutorWithDMStats createExecutor(PoolStatHelper poolHelper, final ThreadGroup threadGroup) {



Mime
View raw message