geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bschucha...@apache.org
Subject incubator-geode git commit: GEODE-77 fixing LocatorDUnitTest issues
Date Thu, 17 Sep 2015 23:02:49 GMT
Repository: incubator-geode
Updated Branches:
  refs/heads/feature/GEODE-77 9cd82c7b9 -> 377a495b8


GEODE-77 fixing LocatorDUnitTest issues

Members trying to rejoin with the same inetaddr:port were causing
issues.
This also moves us to JGroups 3.6.6.Final


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

Branch: refs/heads/feature/GEODE-77
Commit: 377a495b8ea6ac7b41998ce2d46fbd84a13afb5f
Parents: 9cd82c7
Author: Bruce Schuchardt <bschuchardt@pivotal.io>
Authored: Thu Sep 17 16:01:54 2015 -0700
Committer: Bruce Schuchardt <bschuchardt@pivotal.io>
Committed: Thu Sep 17 16:01:54 2015 -0700

----------------------------------------------------------------------
 gemfire-core/build.gradle                       |   2 +-
 .../membership/InternalDistributedMember.java   |  28 +--
 .../internal/membership/gms/GMSMember.java      |   1 +
 .../internal/membership/gms/ServiceConfig.java  |  16 +-
 .../internal/membership/gms/Services.java       |  81 ++++++--
 .../membership/gms/fd/GMSHealthMonitor.java     |   6 +-
 .../membership/gms/interfaces/Manager.java      |  10 +-
 .../gms/locator/FindCoordinatorResponse.java    |   8 +-
 .../membership/gms/locator/GMSLocator.java      |  20 +-
 .../membership/gms/membership/GMSJoinLeave.java | 208 +++++++++++++------
 .../gms/messenger/JGroupsMessenger.java         |  13 +-
 .../gms/mgr/GMSMembershipManager.java           |  46 ++--
 .../internal/cli/i18n/CliStrings.java           |   4 +-
 .../gemfire/distributed/LocatorDUnitTest.java   |  24 ++-
 .../gms/locator/GMSLocatorJUnitTest.java        | 169 ---------------
 .../locator/GMSLocatorRecoveryJUnitTest.java    | 169 +++++++++++++++
 .../cache/ConnectDisconnectDUnitTest.java       |  25 +--
 .../test/java/dunit/DistributedTestCase.java    |   1 +
 18 files changed, 476 insertions(+), 355 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/377a495b/gemfire-core/build.gradle
----------------------------------------------------------------------
diff --git a/gemfire-core/build.gradle b/gemfire-core/build.gradle
index 98b8193..7237782 100755
--- a/gemfire-core/build.gradle
+++ b/gemfire-core/build.gradle
@@ -12,7 +12,7 @@ configurations {
 
 dependencies {
   provided files("${System.getProperty('java.home')}/../lib/tools.jar")
-  compile 'org.jgroups:jgroups:3.6.4'
+  compile 'org.jgroups:jgroups:3.6.6.Final'
   compile 'antlr:antlr:2.7.7'
   compile 'com.fasterxml.jackson.core:jackson-annotations:2.2.0'
   compile 'com.fasterxml.jackson.core:jackson-core:2.2.0'

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/377a495b/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/InternalDistributedMember.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/InternalDistributedMember.java b/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/InternalDistributedMember.java
index c18d237..ad9e4b4 100755
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/InternalDistributedMember.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/InternalDistributedMember.java
@@ -566,8 +566,11 @@ public final class InternalDistributedMember
    *              if the specified object's type prevents it from being compared
    *              to this Object.
    */
-  public int compareTo(DistributedMember o)
-  {
+  public int compareTo(DistributedMember o) {
+    return compareTo(o, true);
+  }
+  
+  public int compareTo(DistributedMember o, boolean checkNetMembersIfEqual) {
     if (this == o) {
       return 0;
     }
@@ -635,11 +638,13 @@ public final class InternalDistributedMember
 
     if (this.uniqueTag == null && other.uniqueTag == null) {
       // not loners, so look at P2P view ID
-      if (this.vmViewId < other.vmViewId) {
-        return -1;
-      } else if (this.vmViewId > other.vmViewId) {
-        return 1;
-      } // else they're the same, so continue
+      if (this.vmViewId >= 0 && other.vmViewId >= 0) {
+        if (this.vmViewId < other.vmViewId) {
+          return -1;
+        } else if (this.vmViewId > other.vmViewId) {
+          return 1;
+        } // else they're the same, so continue
+      }
     } else if (this.uniqueTag == null) {
       return -1;
     }
@@ -653,7 +658,8 @@ public final class InternalDistributedMember
       }
     }
     
-    if (this.netMbr != null && other.netMbr != null) {
+    if (checkNetMembersIfEqual
+        && this.netMbr != null && other.netMbr != null) {
       return this.netMbr.compareTo(other.netMbr);
     } else {
       return 0;
@@ -754,10 +760,8 @@ public final class InternalDistributedMember
         sb.append(vmStr);
         sb.append(")");
       }
-      if (netMbr.splitBrainEnabled()) {
-        if (netMbr.preferredForCoordinator()) {
-          sb.append("<ec>");
-        }
+      if (netMbr.preferredForCoordinator()) {
+        sb.append("<ec>");
       }
       if (this.vmViewId >= 0) {
         sb.append("<v" + this.vmViewId + ">");

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/377a495b/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/GMSMember.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/GMSMember.java b/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/GMSMember.java
index efd2067..038bdce 100755
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/GMSMember.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/GMSMember.java
@@ -444,6 +444,7 @@ public class GMSMember implements NetMember, DataSerializableFixedID {
 
   @Override
   public void writeAdditionalData(DataOutput out) throws IOException {
+    // note: member weight and other GMS-only info is not included here
     out.writeLong(uuidMSBs);
     out.writeLong(uuidLSBs);
   }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/377a495b/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/ServiceConfig.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/ServiceConfig.java b/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/ServiceConfig.java
index c66e262..d7f722a 100755
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/ServiceConfig.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/ServiceConfig.java
@@ -8,7 +8,6 @@ import com.gemstone.gemfire.internal.admin.remote.RemoteTransportConfig;
 public class ServiceConfig {
   /** various settings from Geode configuration */
   private int joinTimeout;
-  private long fdTimeout;
   private int[] membershipPortRange;
   private int udpRecvBufferSize;
   private int udpSendBufferSize;
@@ -35,11 +34,6 @@ public class ServiceConfig {
   }
 
 
-  public long getFdTimeout() {
-    return fdTimeout;
-  }
-
-
   public int[] getMembershipPortRange() {
     return membershipPortRange;
   }
@@ -60,12 +54,12 @@ public class ServiceConfig {
   }
 
 
-  public Integer getLossThreshold() {
+  public int getLossThreshold() {
     return lossThreshold;
   }
 
 
-  public Integer getMemberWeight() {
+  public int getMemberWeight() {
     return memberWeight;
   }
 
@@ -92,11 +86,7 @@ public class ServiceConfig {
     this.dconfig = theConfig;
     this.transport = transport;
     
-    // see whether the FD protocol or FD_SOCK protocol should be used
-    fdTimeout = Long.getLong("gemfire.FD_TIMEOUT", 0).longValue(); // in 4.1.2 to force use of FD
-    
     int defaultJoinTimeout = 17000;
-    int defaultNumPings = 1; // number of get_mbrs loops per findInitialMembers
     if (theConfig.getLocators().length() > 0 && !Locator.hasLocators()) {
       defaultJoinTimeout = 60000;
     }
@@ -116,7 +106,7 @@ public class ServiceConfig {
     udpRecvBufferSize = DistributionConfig.DEFAULT_UDP_RECV_BUFFER_SIZE_REDUCED;
     udpSendBufferSize = theConfig.getUdpSendBufferSize();
 
-    memberTimeout = (fdTimeout > 0) ? fdTimeout : theConfig.getMemberTimeout();
+    memberTimeout = theConfig.getMemberTimeout();
 
     // The default view-ack timeout in 7.0 is 12347 ms but is adjusted based on the member-timeout.
     // We don't want a longer timeout than 12437 because new members will likely time out trying to 

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/377a495b/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/Services.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/Services.java b/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/Services.java
index cdbe2aa..9382d9c 100755
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/Services.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/Services.java
@@ -120,15 +120,16 @@ public class Services {
   protected void start() {
     boolean started = false;
     try {
-      logger.info("Membership: starting Authenticator");
+      logger.info("Starting membership services");
+      logger.debug("starting Authenticator");
       this.auth.start();
-      logger.info("Membership: starting Messenger");
+      logger.debug("starting Messenger");
       this.messenger.start();
-      logger.info("Membership: starting JoinLeave");
+      logger.debug("starting JoinLeave");
       this.joinLeave.start();
-      logger.info("Membership: starting HealthMonitor");
+      logger.debug("starting HealthMonitor");
       this.healthMon.start();
-      logger.info("Membership: starting Manager");
+      logger.debug("starting Manager");
       this.manager.start();
       started = true;
     } catch (RuntimeException e) {
@@ -148,7 +149,7 @@ public class Services {
     this.joinLeave.started();
     this.healthMon.started();
     this.manager.started();
-    logger.info("Membership: all services have been started");
+    logger.info("Attempting to join the distributed system");
     try {
       this.manager.joinDistributedSystem();
     } catch (Throwable e) {
@@ -158,34 +159,68 @@ public class Services {
   }
   
   public void emergencyClose() {
-    logger.info("Membership: stopping services");
     if (stopping) {
       return;
     }
     stopping = true;
-    this.timer.cancel();
-    this.joinLeave.emergencyClose();
-    this.healthMon.emergencyClose();
-    this.auth.emergencyClose();
-    this.messenger.emergencyClose();
-    this.manager.emergencyClose();
-    this.cancelCriterion.cancel("Membership services are shut down");
+    logger.info("Stopping membership services");
+    timer.cancel();
+    try {
+      joinLeave.emergencyClose();
+    } finally {
+      try {
+        healthMon.emergencyClose();
+      } finally {
+        try {
+          auth.emergencyClose();
+        } finally {
+          try {
+            messenger.emergencyClose();
+          } finally {
+            try {
+              manager.emergencyClose();
+            } finally {
+              cancelCriterion.cancel("Membership services are shut down");
+              stopped = true;
+            }
+          }
+        }
+      }
+    }
   }
   
   public void stop() {
-    logger.info("Membership: stopping services");
     if (stopping) {
       return;
     }
+    logger.info("Stopping membership services");
     stopping = true;
-    this.timer.cancel();
-    this.joinLeave.stop();
-    this.healthMon.stop();
-    this.auth.stop();
-    this.messenger.stop();
-    this.manager.stop();
-    this.cancelCriterion.cancel("Membership services are shut down");
-    stopped = true;
+    try {
+      timer.cancel();
+    } finally {
+      try {
+        joinLeave.stop();
+      } finally {
+        try {
+          healthMon.stop();
+        } finally {
+          try {
+            auth.stop();
+          } finally {
+            try {
+              messenger.stop();
+            } finally {
+              try {
+                manager.stop();
+              } finally {
+                cancelCriterion.cancel("Membership services are shut down");
+                stopped = true;
+              }
+            }
+          }
+        }
+      }
+    }
   }
 
   public static void setLogWriter(InternalLogWriter writer) {

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/377a495b/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/fd/GMSHealthMonitor.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/fd/GMSHealthMonitor.java b/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/fd/GMSHealthMonitor.java
index 22a6633..ae867d1 100755
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/fd/GMSHealthMonitor.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/fd/GMSHealthMonitor.java
@@ -717,7 +717,7 @@ public class GMSHealthMonitor implements HealthMonitor, MessageHandler {
     @Override
     public void run() {
       List<T> requests = null;
-      logger.info("Suspect thread is starting");
+      logger.debug("Suspect thread is starting");
       long okayToSendSuspectRequest = System.currentTimeMillis() + timeout;
       try {
         for (;;) {
@@ -727,7 +727,7 @@ public class GMSHealthMonitor implements HealthMonitor, MessageHandler {
             }
             if (listToTrack.isEmpty()) {
               try {
-                logger.debug("Result collector is waiting");
+                logger.trace("Result collector is waiting");
                 listToTrack.wait();
               } catch (InterruptedException e) {
                 return;
@@ -762,7 +762,7 @@ public class GMSHealthMonitor implements HealthMonitor, MessageHandler {
         }
       } finally {
         shutdown = true;
-        logger.info("Suspect thread is stopped");
+        logger.debug("Suspect thread is stopped");
       }
     }
   }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/377a495b/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/interfaces/Manager.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/interfaces/Manager.java b/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/interfaces/Manager.java
index f2f7dc1..4539909 100755
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/interfaces/Manager.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/interfaces/Manager.java
@@ -99,11 +99,11 @@ public interface Manager extends Service, MessageHandler {
    */
   boolean shutdownInProgress();
 
-  /**
-   * similar to forceDisconnect but is used solely by Messenger
-   * to tell Manager that communications have been lost
-   */
-  void membershipFailure(String message, Exception cause);
+//  /**
+//   * similar to forceDisconnect but is used solely by Messenger
+//   * to tell Manager that communications have been lost
+//   */
+//  void membershipFailure(String message, Exception cause);
 
   /**
    * used by HealthMonitor to tell Manager that a member is under

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/377a495b/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/locator/FindCoordinatorResponse.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/locator/FindCoordinatorResponse.java b/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/locator/FindCoordinatorResponse.java
index 61d2333..e475796 100755
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/locator/FindCoordinatorResponse.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/locator/FindCoordinatorResponse.java
@@ -22,6 +22,8 @@ public class FindCoordinatorResponse  implements DataSerializableFixedID {
       boolean fromView, int viewId,
       boolean networkPartitionDectionEnabled, boolean usePreferredCoordinators) {
     this.coordinator = coordinator;
+    this.fromView = fromView;
+    this.viewId = viewId;
     this.networkPartitionDetectionEnabled = networkPartitionDectionEnabled;
     this.usePreferredCoordinators = usePreferredCoordinators;
   }
@@ -52,7 +54,9 @@ public class FindCoordinatorResponse  implements DataSerializableFixedID {
   
   @Override
   public String toString() {
-    return "FindCoordinatorResponse(coordinator="+coordinator+")";
+    return "FindCoordinatorResponse(coordinator="+coordinator+", fromView="+fromView+", viewId="+viewId
+        +", network partition detection enabled="+this.networkPartitionDetectionEnabled
+        +", locators preferred as coordinators="+this.usePreferredCoordinators+")";
   }
 
 
@@ -79,7 +83,7 @@ public class FindCoordinatorResponse  implements DataSerializableFixedID {
   @Override
   public void fromData(DataInput in) throws IOException, ClassNotFoundException {
     coordinator = DataSerializer.readObject(in);
-    int viewId = in.readInt();
+    viewId = in.readInt();
     fromView = in.readBoolean();
     networkPartitionDetectionEnabled = in.readBoolean();
     usePreferredCoordinators = in.readBoolean();

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/377a495b/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/locator/GMSLocator.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/locator/GMSLocator.java b/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/locator/GMSLocator.java
index e0f0a4a..e0ee678 100755
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/locator/GMSLocator.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/locator/GMSLocator.java
@@ -57,7 +57,11 @@ public class GMSLocator implements Locator, NetLocator {
   
   private Set<InternalDistributedMember> registrants = new HashSet<InternalDistributedMember>();
 
-  private NetView view;
+  /**
+   * The current membership view, or one recovered from disk.
+   * This is a copy-on-write variable.
+   */
+  private transient NetView view;
 
   private File viewFile;
 
@@ -103,6 +107,8 @@ public class GMSLocator implements Locator, NetLocator {
   
   @Override
   public void init(TcpServer server) throws InternalGemFireException {
+    logger.info("GemFire peer location service starting.  Other locators: {}  Locators preferred as coordinators: {}  Network partition detection enabled: {}  View persistence file: {}",
+        locatorString, usePreferredCoordinators, networkPartitionDetectionEnabled, viewFile);
     recover();
   }
   
@@ -153,6 +159,17 @@ public class GMSLocator implements Locator, NetLocator {
         int viewId = -1;
         
         if (view != null) {
+          // if the ID of the requester matches an entry in the membership view then remove
+          // that entry
+          InternalDistributedMember rid = findRequest.getMemberID();
+          for (InternalDistributedMember id: view.getMembers()) {
+            if (rid.compareTo(id, false) == 0) {
+              NetView newView = new NetView(view, view.getViewId());
+              newView.remove(id);
+              this.view = newView;
+              break;
+            }
+          }
           viewId = view.getViewId();
           if (viewId > findRequest.getLastViewId()) {
             // ignore the requests rejectedCoordinators if the view has changed
@@ -226,7 +243,6 @@ public class GMSLocator implements Locator, NetLocator {
     catch (Exception e) {
       logger.warn("Peer locator encountered an error writing current membership to disk.  Disabling persistence.  Care should be taken when bouncing this locator as it will not be able to recover knowledge of the running distributed system", e);
       this.viewFile = null;
-      // TODO - force TcpServer to shut down if this happens instead of continuing to run
     }
   }
 

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/377a495b/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/membership/GMSJoinLeave.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/membership/GMSJoinLeave.java b/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/membership/GMSJoinLeave.java
index f64538c..f88e1c0 100755
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/membership/GMSJoinLeave.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/membership/GMSJoinLeave.java
@@ -34,6 +34,7 @@ import com.gemstone.gemfire.GemFireConfigException;
 import com.gemstone.gemfire.SystemConnectException;
 import com.gemstone.gemfire.distributed.DistributedMember;
 import com.gemstone.gemfire.distributed.DistributedSystemDisconnectedException;
+import com.gemstone.gemfire.distributed.Locator;
 import com.gemstone.gemfire.distributed.internal.DistributionConfig;
 import com.gemstone.gemfire.distributed.internal.DistributionManager;
 import com.gemstone.gemfire.distributed.internal.DistributionMessage;
@@ -67,20 +68,14 @@ public class GMSJoinLeave implements JoinLeave, MessageHandler {
   
   public static String BYPASS_DISCOVERY = "gemfire.bypass-discovery";
 
-  /** number of times to try joining before giving up */
-  private static final int JOIN_ATTEMPTS = Integer.getInteger("gemfire.join-attempts", 4);
-  
   /** amount of time to sleep before trying to join after a failed attempt */
   private static final int JOIN_RETRY_SLEEP = Integer.getInteger("gemfire.join-retry-sleep", 1000);
   
-  /** amount of time to wait for a view to be acked by all members before performing suspect processing on non-responders */
-  private static final int VIEW_INSTALLATION_TIMEOUT = Integer.getInteger("gemfire.view-ack-timeout", 12500);
-
   /** stall time to wait for concurrent join/leave/remove requests to be received */
-  public static final long MEMBER_REQUEST_COLLECTION_INTERVAL = Long.getLong("gemfire.member-request-collection-interval", 2000);
+  public static final long MEMBER_REQUEST_COLLECTION_INTERVAL = Long.getLong("gemfire.member-request-collection-interval", 500);
 
   /** time to wait for a leave request to be transmitted by jgroups */
-  private static final long LEAVE_MESSAGE_SLEEP_TIME = Long.getLong("gemfire.leave-message-sleep-time", 4000);
+  private static final long LEAVE_MESSAGE_SLEEP_TIME = Long.getLong("gemfire.leave-message-sleep-time", 1000);
   
   /** membership logger */
   private static final Logger logger = Services.getLogger();
@@ -95,7 +90,7 @@ public class GMSJoinLeave implements JoinLeave, MessageHandler {
   private Services services;
   
   /** have I connected to the distributed system? */
-  private boolean isJoined;
+  private volatile boolean isJoined;
 
   /** a lock governing GMS state */
   private ReadWriteLock stateLock = new ReentrantReadWriteLock();
@@ -157,36 +152,65 @@ public class GMSJoinLeave implements JoinLeave, MessageHandler {
    * @return true if successful, false if not
    */
   public boolean join() {
-    Set<InternalDistributedMember> alreadyTried = new HashSet<>();
-    int[] lastViewIdHolder = new int[] {-1};
     
     if (Boolean.getBoolean(BYPASS_DISCOVERY)) {
       becomeCoordinator();
       return true;
     }
-
-    for (int tries=0; tries<JOIN_ATTEMPTS; tries++) {
-      InternalDistributedMember coord = findCoordinator(alreadyTried, lastViewIdHolder);
-      logger.debug("found possible coordinator {}", coord);
-      if (coord != null) {
-        if (coord.equals(this.localAddress)) {
-          if (tries > (JOIN_ATTEMPTS/2)) {
+    
+    SearchState state = new SearchState();
+    
+    long timeout = services.getConfig().getJoinTimeout();
+    long retrySleep =  JOIN_RETRY_SLEEP;
+    long startTime = System.currentTimeMillis();
+    long giveupTime = startTime + timeout;
+
+    for (int tries=0; !this.isJoined; tries++) {
+
+      boolean found = findCoordinator(state);
+      if (found) {
+        logger.debug("found possible coordinator {}", state.possibleCoordinator);
+        if (state.possibleCoordinator.equals(this.localAddress)) {
+          if (tries > 2 || System.currentTimeMillis() < giveupTime ) {
             becomeCoordinator();
             return true;
           }
         } else {
-          if (attemptToJoin(coord)) {
+          if (attemptToJoin(state)) {
             return true;
           }
-          alreadyTried.add(coord);
+          if (System.currentTimeMillis() < giveupTime) {
+            break;
+          }
+          if (!state.possibleCoordinator.equals(localAddress)) {
+            state.alreadyTried.add(state.possibleCoordinator);
+          }
+        }
+      } else {
+        if (System.currentTimeMillis() < giveupTime) {
+          break;
         }
+        state.alreadyTried.clear();
       }
       try {
-        Thread.sleep(JOIN_RETRY_SLEEP);
+        Thread.sleep(retrySleep);
       } catch (InterruptedException e) {
+        logger.debug("retry sleep interrupted - giving up on joining the distributed system");
         return false;
       }
     } // for
+    
+    if (!this.isJoined) {
+      logger.debug("giving up attempting to join the distributed system after " + (System.currentTimeMillis() - startTime) + "ms");
+    }
+    
+    // to preserve old behavior we need to throw a SystemConnectException if
+    // unable to contact any of the locators
+    if (!this.isJoined && state.hasContactedALocator) {
+      throw new SystemConnectException("Unable to join the distributed system in "
+         + (System.currentTimeMillis()-startTime) + "ms");
+    }
+    
     return this.isJoined;
   }
 
@@ -196,8 +220,9 @@ public class GMSJoinLeave implements JoinLeave, MessageHandler {
    * @param coord
    * @return true if the attempt succeeded, false if it timed out
    */
-  private boolean attemptToJoin(InternalDistributedMember coord) {
+  private boolean attemptToJoin(SearchState state) {
     // send a join request to the coordinator and wait for a response
+    InternalDistributedMember coord = state.possibleCoordinator;
     logger.info("Attempting to join the distributed system through coordinator " + coord + " using address " + this.localAddress);
     JoinRequestMessage req = new JoinRequestMessage(coord, this.localAddress, 
         services.getAuthenticator().getCredentials(coord));
@@ -208,8 +233,14 @@ public class GMSJoinLeave implements JoinLeave, MessageHandler {
     synchronized(joinResponse) {
       if (joinResponse[0] == null) {
         try {
-          joinResponse.wait(services.getConfig().getJoinTimeout()/JOIN_ATTEMPTS);
+          // Note that if we give up waiting but a response is on
+          // the way we will get the new view and join that way.
+          // See installView()
+          long timeout = Math.max(services.getConfig().getMemberTimeout(),
+                                     services.getConfig().getJoinTimeout()/5);
+          joinResponse.wait(timeout);
         } catch (InterruptedException e) {
+          logger.debug("join attempt was interrupted");
           Thread.currentThread().interrupt();
           return false;
         }
@@ -227,27 +258,26 @@ public class GMSJoinLeave implements JoinLeave, MessageHandler {
         }
         throw new AuthenticationFailedException(failReason);
       }
-      if (response.getBecomeCoordinator()) {
-        logger.info("I am being told to become the membership coordinator by {}", coord);
-        this.currentView = response.getCurrentView();
-        becomeCoordinator(response.getCurrentView().getCoordinator());
-        return true;
-      }
       if (response.getCurrentView() != null) {
         this.birthViewId = response.getMemberID().getVmViewId();
         this.localAddress.setVmViewId(this.birthViewId);
         GMSMember me = (GMSMember)this.localAddress.getNetMember();
-        GMSMember o = (GMSMember)response.getMemberID().getNetMember();
         me.setBirthViewId(birthViewId);
-        me.setSplitBrainEnabled(o.isSplitBrainEnabled());
-        me.setPreferredForCoordinator(o.preferredForCoordinator());
-        services.getConfig().getDistributionConfig().setEnableNetworkPartitionDetection(o.isSplitBrainEnabled());
-        services.getConfig().setNetworkPartitionDetectionEnabled(o.isSplitBrainEnabled());
         installView(response.getCurrentView());
+
+        if (response.getBecomeCoordinator()) {
+          logger.info("I am being told to become the membership coordinator by {}", coord);
+          this.currentView = response.getCurrentView();
+          becomeCoordinator(response.getCurrentView().getCoordinator());
+        }
+
         return true;
+
       } else {
         logger.info("received join response with no membership view: {}", response);
       }
+    } else {
+      logger.debug("received no join response");
     }
     return false;
   }
@@ -264,12 +294,6 @@ public class GMSJoinLeave implements JoinLeave, MessageHandler {
 
     logger.info("received join request from {}", incomingRequest.getMemberID());
 
-    if (!this.localAddress.getNetMember().preferredForCoordinator() &&
-        incomingRequest.getMemberID().getNetMember().preferredForCoordinator()) {
-      // tell the new guy to become the coordinator
-      
-    }
-    
     if (incomingRequest.getMemberID().getVersionObject().compareTo(Version.CURRENT) < 0) {
       logger.warn("detected an attempt to start a peer using an older version of the product {}",
           incomingRequest.getMemberID());
@@ -292,6 +316,13 @@ public class GMSJoinLeave implements JoinLeave, MessageHandler {
       services.getMessenger().send(m);
       return;
     }
+    
+    if (!this.localAddress.getNetMember().preferredForCoordinator() &&
+        incomingRequest.getMemberID().getNetMember().preferredForCoordinator()) {
+      JoinResponseMessage m = new JoinResponseMessage(incomingRequest.getMemberID(), currentView, true);
+      services.getMessenger().send(m);
+      return;
+    }
     recordViewRequest(incomingRequest);
   }
   
@@ -603,14 +634,14 @@ public class GMSJoinLeave implements JoinLeave, MessageHandler {
    * All locators are contacted.  If they don't agree then we choose the oldest
    * coordinator and return it.
    */
-  private InternalDistributedMember findCoordinator(Set<InternalDistributedMember> alreadyTried,
-      int[] lastViewIdHolder) {
+  private boolean findCoordinator(SearchState state) {
     assert this.localAddress != null;
     
-    FindCoordinatorRequest request = new FindCoordinatorRequest(this.localAddress, alreadyTried, lastViewIdHolder[0]);
+    FindCoordinatorRequest request = new FindCoordinatorRequest(this.localAddress, state.alreadyTried, state.viewId);
     Set<InternalDistributedMember> coordinators = new HashSet<InternalDistributedMember>();
     long giveUpTime = System.currentTimeMillis() + (services.getConfig().getLocatorWaitTime() * 1000L);
     boolean anyResponses = false;
+    boolean flagsSet = false;
     
     logger.debug("sending {} to {}", request, locators);
     
@@ -624,19 +655,35 @@ public class GMSJoinLeave implements JoinLeave, MessageHandler {
           if (response != null && response.getCoordinator() != null) {
             anyResponses = false;
             int viewId = response.getViewId();
-            if (viewId > lastViewIdHolder[0]) {
+            if (viewId > state.viewId) {
               // if the view has changed it is possible that a member
               // that we already tried to join with will become coordinator
-              alreadyTried.clear();
-              lastViewIdHolder[0] = viewId;
+              state.alreadyTried.clear();
+              state.viewId = viewId;
             }
             coordinators.add(response.getCoordinator());
-            if (response.isFromView()) {
+            if (!flagsSet) {
+              flagsSet = true;
+              
+              boolean enabled = response.isNetworkPartitionDetectionEnabled();
+              if (!enabled && services.getConfig().isNetworkPartitionDetectionEnabled()) {
+                throw new GemFireConfigException("locator at "+addr
+                    +" does not have network-partition-detection enabled but my configuration has it enabled");
+              }
+
               GMSMember mbr = (GMSMember)this.localAddress.getNetMember();
-              services.getConfig().setNetworkPartitionDetectionEnabled(response.isNetworkPartitionDetectionEnabled());
-              if (response.isUsePreferredCoordinators()
-                  && localAddress.getVmKind() != DistributionManager.LOCATOR_DM_TYPE) {
-                mbr.setPreferredForCoordinator(false);
+              mbr.setSplitBrainEnabled(enabled);
+              services.getConfig().setNetworkPartitionDetectionEnabled(enabled);
+              services.getConfig().getDistributionConfig().setEnableNetworkPartitionDetection(enabled);
+
+              if (response.isUsePreferredCoordinators()) {
+                logger.debug("The locator indicates that all locators should be preferred as coordinators");
+                if (services.getLocator() != null
+                    || Locator.hasLocator()
+                    || !services.getConfig().getDistributionConfig().getStartLocator().isEmpty()
+                    || localAddress.getVmKind() == DistributionManager.LOCATOR_DM_TYPE) {
+                  ((GMSMember)localAddress.getNetMember()).setPreferredForCoordinator(true);
+                }
               }
             }
           }
@@ -644,28 +691,31 @@ public class GMSJoinLeave implements JoinLeave, MessageHandler {
         }
       }
       if (coordinators.isEmpty()) {
-        return null;
+        return false;
       }
       if (!anyResponses) {
         try { Thread.sleep(2000); } catch (InterruptedException e) {
           Thread.currentThread().interrupt();
-          return null;
+          return false;
         }
       }
     } while (!anyResponses && System.currentTimeMillis() < giveUpTime);
     
+    
     Iterator<InternalDistributedMember> it = coordinators.iterator();
     if (coordinators.size() == 1) {
-      return it.next();
-    }
-    InternalDistributedMember oldest = it.next();
-    while (it.hasNext()) {
-      InternalDistributedMember candidate = it.next();
-      if (oldest.compareTo(candidate) > 0) {
-        oldest = candidate;
+      state.possibleCoordinator = it.next();
+    } else {
+      InternalDistributedMember oldest = it.next();
+      while (it.hasNext()) {
+        InternalDistributedMember candidate = it.next();
+        if (oldest.compareTo(candidate) > 0) {
+          oldest = candidate;
+        }
       }
+      state.possibleCoordinator = oldest;
     }
-    return oldest;
+    return true;
   }
   
   
@@ -700,6 +750,19 @@ public class GMSJoinLeave implements JoinLeave, MessageHandler {
         return;
       }
       
+      if (currentView == null && !this.isJoined) {
+        for (InternalDistributedMember mbr: newView.getMembers()) {
+          if (this.localAddress.equals(mbr)) {
+            this.birthViewId = mbr.getVmViewId();
+            this.localAddress.setVmViewId(this.birthViewId);
+            GMSMember me = (GMSMember)this.localAddress.getNetMember();
+            me.setBirthViewId(birthViewId);
+            isJoined = true;
+            break;
+          }
+        }
+      }
+      
       if (isNetworkPartition(newView)) {
         if (quorumRequired) {
           Set<InternalDistributedMember> crashes = newView.getActualCrashedMembers(currentView);
@@ -872,21 +935,21 @@ public class GMSJoinLeave implements JoinLeave, MessageHandler {
 
   @Override
   public void leave() {
+    boolean waitForProcessing = false;
     synchronized(viewInstallationLock) {
       NetView view = currentView;
       isStopping = true;
+      stopCoordinatorServices();
       if (view != null) {
         if (view.size() > 1) {
           if (this.isCoordinator) {
             logger.debug("JoinLeave stopping coordination services");
-            stopCoordinatorServices();
             NetView newView = new NetView(view, view.getViewId()+1);
             newView.remove(localAddress);
             InstallViewMessage m = new InstallViewMessage(newView, services.getAuthenticator().getCredentials(this.localAddress));
             m.setRecipients(newView.getMembers());
             services.getMessenger().send(m);
-            try { Thread.sleep(LEAVE_MESSAGE_SLEEP_TIME); }
-            catch (InterruptedException e) { Thread.currentThread().interrupt(); }
+            waitForProcessing = true;
           }
           else {
             List<InternalDistributedMember> coords = view.getPreferredCoordinators(Collections.<InternalDistributedMember>emptySet(), localAddress, 5);
@@ -894,11 +957,19 @@ public class GMSJoinLeave implements JoinLeave, MessageHandler {
             logger.debug("JoinLeave sending a leave request to {}", coords);
             LeaveRequestMessage m = new LeaveRequestMessage(coords, this.localAddress, "this member is shutting down");
             services.getMessenger().send(m);
+            waitForProcessing = true;
           }
         } // view.size
       }// view != null
     }
-      
+    if (waitForProcessing) {
+      try {
+        Thread.sleep(LEAVE_MESSAGE_SLEEP_TIME);
+      }
+      catch (InterruptedException e) {
+        Thread.currentThread().interrupt();
+      }
+    }
   }
 
 
@@ -1394,5 +1465,12 @@ public class GMSJoinLeave implements JoinLeave, MessageHandler {
       }
     }
   }
+  
+  private static class SearchState {
+    Set<InternalDistributedMember> alreadyTried = new HashSet<>();
+    InternalDistributedMember possibleCoordinator;
+    int viewId = -1;
+    private boolean hasContactedALocator;
+  }
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/377a495b/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/JGroupsMessenger.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/JGroupsMessenger.java b/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/JGroupsMessenger.java
index 7bd3048..1bf0213 100755
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/JGroupsMessenger.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/JGroupsMessenger.java
@@ -372,6 +372,7 @@ public class JGroupsMessenger implements Messenger {
     // add the JGroups logical address to the GMSMember
     UUID uuid = this.jgAddress;
     ((GMSMember)localAddress.getNetMember()).setUUID(uuid);
+    ((GMSMember)localAddress.getNetMember()).setMemberWeight((byte)(services.getConfig().getMemberWeight() & 0xff));
   }
   
   @Override
@@ -439,7 +440,7 @@ public class JGroupsMessenger implements Messenger {
         problem = e;
       }
       catch (Exception e) {
-        logger.info("caught unexpected exception", e);
+        logger.debug("caught unexpected exception", e);
         Throwable cause = e.getCause();
         if (cause instanceof ForcedDisconnectException) {
           problem = (Exception) cause;
@@ -463,7 +464,7 @@ public class JGroupsMessenger implements Messenger {
           }
         }
         final String channelClosed = LocalizedStrings.GroupMembershipService_CHANNEL_CLOSED.toLocalizedString();
-        services.getManager().membershipFailure(channelClosed, problem);
+//        services.getManager().membershipFailure(channelClosed, problem);
         throw new DistributedSystemDisconnectedException(channelClosed, problem);
       }
     } // useMcast
@@ -539,8 +540,9 @@ public class JGroupsMessenger implements Messenger {
                 ne.initCause(services.getManager().getShutdownCause());
               }
             }
-            services.getManager().membershipFailure("Channel closed", problem);
-            throw new DistributedSystemDisconnectedException("Channel closed", problem);
+          final String channelClosed = LocalizedStrings.GroupMembershipService_CHANNEL_CLOSED.toLocalizedString();
+//          services.getManager().membershipFailure(channelClosed, problem);
+          throw new DistributedSystemDisconnectedException(channelClosed, problem);
           }
         } // send individually
     } // !useMcast
@@ -808,6 +810,9 @@ public class JGroupsMessenger implements Messenger {
       }
       
       try {
+        if (logger.isTraceEnabled()) {
+          logger.trace("JGroupsMessenger dispatching {}", msg);
+        }
         filterIncomingMessage(msg);
         MessageHandler h = getMessageHandler(msg);
         logger.trace("Handler for this message is {}", h);

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/377a495b/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/mgr/GMSMembershipManager.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/mgr/GMSMembershipManager.java b/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/mgr/GMSMembershipManager.java
index c8358d9..d58bef1 100755
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/mgr/GMSMembershipManager.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/mgr/GMSMembershipManager.java
@@ -2711,29 +2711,29 @@ public class GMSMembershipManager implements MembershipManager, Manager
     this.shutdownCause = t;
   }
 
-  @Override
-  public void membershipFailure(String reason, Exception e) {
-    try {
-      if (this.membershipTestHooks != null) {
-        List l = this.membershipTestHooks;
-        for (Iterator it=l.iterator(); it.hasNext(); ) {
-          MembershipTestHook dml = (MembershipTestHook)it.next();
-          dml.beforeMembershipFailure(reason, e);
-        }
-      }
-      listener.membershipFailure(reason, e);
-      if (this.membershipTestHooks != null) {
-        List l = this.membershipTestHooks;
-        for (Iterator it=l.iterator(); it.hasNext(); ) {
-          MembershipTestHook dml = (MembershipTestHook)it.next();
-          dml.afterMembershipFailure(reason, e);
-        }
-      }
-    }
-    catch (RuntimeException re) {
-      logger.warn(LocalizedMessage.create(LocalizedStrings.GroupMembershipService_EXCEPTION_CAUGHT_WHILE_SHUTTING_DOWN), re);
-    }
-  }
+//  @Override
+//  public void membershipFailure(String reason, Exception e) {
+//    try {
+//      if (this.membershipTestHooks != null) {
+//        List l = this.membershipTestHooks;
+//        for (Iterator it=l.iterator(); it.hasNext(); ) {
+//          MembershipTestHook dml = (MembershipTestHook)it.next();
+//          dml.beforeMembershipFailure(reason, e);
+//        }
+//      }
+//      listener.membershipFailure(reason, e);
+//      if (this.membershipTestHooks != null) {
+//        List l = this.membershipTestHooks;
+//        for (Iterator it=l.iterator(); it.hasNext(); ) {
+//          MembershipTestHook dml = (MembershipTestHook)it.next();
+//          dml.afterMembershipFailure(reason, e);
+//        }
+//      }
+//    }
+//    catch (RuntimeException re) {
+//      logger.warn(LocalizedMessage.create(LocalizedStrings.GroupMembershipService_EXCEPTION_CAUGHT_WHILE_SHUTTING_DOWN), re);
+//    }
+//  }
   
   public void registerTestHook(MembershipTestHook mth) {
     // lock for additions to avoid races during startup

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/377a495b/gemfire-core/src/main/java/com/gemstone/gemfire/management/internal/cli/i18n/CliStrings.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/management/internal/cli/i18n/CliStrings.java b/gemfire-core/src/main/java/com/gemstone/gemfire/management/internal/cli/i18n/CliStrings.java
index 9ed9164..6034f96 100644
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/management/internal/cli/i18n/CliStrings.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/management/internal/cli/i18n/CliStrings.java
@@ -1489,8 +1489,8 @@ public class CliStrings {
   public static final String SHOW_DEADLOCK__HELP = "Display any deadlocks in the GemFire distributed system.";
   public static final String SHOW_DEADLOCK__DEPENDENCIES__FILE = "file";
   public static final String SHOW_DEADLOCK__DEPENDENCIES__FILE__HELP = "Name of the file to which dependencies between members will be written.";
-  public static final String SHOW_DEADLOCK__NO__DEADLOCK = "No dead lock detected.";
-  public static final String SHOW_DEADLOCK__DEADLOCK__DETECTED = "Dead lock detected.";
+  public static final String SHOW_DEADLOCK__NO__DEADLOCK = "No deadlock was detected.";
+  public static final String SHOW_DEADLOCK__DEADLOCK__DETECTED = "Deadlock detected.";
   public static final String SHOW_DEADLOCK__DEEPEST_FOUND = "No deadlock was detected.  Here is the deepest call chain that could be found";
   public static final String SHOW_DEADLOCK__DEPENDENCIES__REVIEW = "Please view the dependencies between the members in file : {0}";
   public static final String SHOW_DEADLOCK__ERROR = "Error";

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/377a495b/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/LocatorDUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/LocatorDUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/LocatorDUnitTest.java
index 845e6a6..afd87d4 100644
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/LocatorDUnitTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/LocatorDUnitTest.java
@@ -86,6 +86,9 @@ public class LocatorDUnitTest extends DistributedTestCase {
   
   @Override
   public void tearDown2() {
+    if (Locator.hasLocator()) {
+      Locator.getLocator().stop();
+    }
     // delete locator state files so they don't accidentally
     // get used by other tests
     if (port1 > 0) {
@@ -121,7 +124,8 @@ public class LocatorDUnitTest extends DistributedTestCase {
     final Properties properties = new Properties();
     properties.put("mcast-port", "0");
     properties.put("start-locator", locators);
-    properties.put("log-level", getDUnitLogLevel());
+    properties.put("log-level", "finer");
+//    properties.put("log-level", getDUnitLogLevel());
     properties.put("security-peer-auth-init","com.gemstone.gemfire.distributed.AuthInitializer.create");
     properties.put("security-peer-authenticator","com.gemstone.gemfire.distributed.MyAuthenticator.create");
     properties.put(DistributionConfig.ENABLE_CLUSTER_CONFIGURATION_NAME, "false");
@@ -132,6 +136,8 @@ public class LocatorDUnitTest extends DistributedTestCase {
         DistributionManager.NORMAL_DM_TYPE, system.getDistributedMember().getVmKind());
     
     properties.remove("start-locator");
+    properties.put("log-level", "finer");
+//  properties.put("log-level", getDUnitLogLevel());
     properties.put("locators", locators);
     SerializableRunnable startSystem = new SerializableRunnable("start system") {
       public void run() {
@@ -190,7 +196,10 @@ public class LocatorDUnitTest extends DistributedTestCase {
       });
   
       properties.put("start-locator", locators);
+//    properties.put("log-level", getDUnitLogLevel());
+      properties.put("log-level", "finer");
       system = (InternalDistributedSystem)DistributedSystem.connect(properties);
+      System.out.println("done connecting distributed system");
       
       assertEquals("should be the coordinator", system.getDistributedMember(), MembershipManagerHelper.getCoordinator(system));
       NetView view = MembershipManagerHelper.getMembershipManager(system).getView();
@@ -1575,8 +1584,7 @@ public class LocatorDUnitTest extends DistributedTestCase {
       properties2.put("locators", locators);
       properties2.put(DistributionConfig.ENABLE_NETWORK_PARTITION_DETECTION_NAME, "false");
       properties2.put(DistributionConfig.ENABLE_CLUSTER_CONFIGURATION_NAME, "false");
-
-      properties.put("disable-auto-reconnect", "true");
+      properties2.put("disable-auto-reconnect", "true");
       
       vm1.invoke(new SerializableRunnable("try to connect") {
         public void run() {
@@ -1604,12 +1612,14 @@ public class LocatorDUnitTest extends DistributedTestCase {
       vm1.invoke(new SerializableRunnable("try to connect") {
         public void run() {
           DistributedSystem s = null;
-          s = DistributedSystem.connect(properties);
-          boolean enabled = ((InternalDistributedSystem)s).getConfig().getEnableNetworkPartitionDetection();
-          s.disconnect();
-          if (enabled) {
+          try {
+            s = DistributedSystem.connect(properties);
+            s.disconnect();
             fail("should not have been able to connect with different enable-network-partition-detection settings");
           }
+          catch (GemFireConfigException e) {
+            // passed
+          }
         }
       });
       

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/377a495b/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/locator/GMSLocatorJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/locator/GMSLocatorJUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/locator/GMSLocatorJUnitTest.java
deleted file mode 100644
index f33dbe0..0000000
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/locator/GMSLocatorJUnitTest.java
+++ /dev/null
@@ -1,169 +0,0 @@
-package com.gemstone.gemfire.distributed.internal.membership.gms.locator;
-
-import com.gemstone.gemfire.DataSerializer;
-import com.gemstone.gemfire.InternalGemFireException;
-import com.gemstone.gemfire.distributed.Locator;
-import com.gemstone.gemfire.distributed.internal.DMStats;
-import com.gemstone.gemfire.distributed.internal.DistributionConfig;
-import com.gemstone.gemfire.distributed.internal.DistributionConfigImpl;
-import com.gemstone.gemfire.distributed.internal.DistributionManager;
-import com.gemstone.gemfire.distributed.internal.InternalLocator;
-import com.gemstone.gemfire.distributed.internal.LocatorStats;
-import com.gemstone.gemfire.distributed.internal.membership.DistributedMembershipListener;
-import com.gemstone.gemfire.distributed.internal.membership.MemberFactory;
-import com.gemstone.gemfire.distributed.internal.membership.MembershipManager;
-import com.gemstone.gemfire.distributed.internal.membership.NetView;
-import com.gemstone.gemfire.internal.AvailablePortHelper;
-import com.gemstone.gemfire.internal.OSProcess;
-import com.gemstone.gemfire.internal.SocketCreator;
-import com.gemstone.gemfire.internal.Version;
-import com.gemstone.gemfire.internal.admin.remote.RemoteTransportConfig;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-
-import com.gemstone.gemfire.test.junit.categories.UnitTest;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.ObjectOutputStream;
-import java.net.InetAddress;
-import java.util.Properties;
-
-import static org.junit.Assert.*;
-import static org.mockito.Mockito.mock;
-
-@Category(UnitTest.class)
-public class GMSLocatorJUnitTest {
-
-  File tempStateFile = null;
-  GMSLocator locator = null;
-
-  @Before
-  public void setUp() throws Exception {
-    tempStateFile = new File("GMSLocatorJUnitTest_locator.dat");
-    if (tempStateFile.exists()) {
-      tempStateFile.delete();
-    }
-    locator = new GMSLocator(null, tempStateFile, null, false, false, new LocatorStats());
-    // System.out.println("temp state file: " + tempStateFile);
-  }
-
-  @After
-  public void tearDown() throws Exception {
-    if (tempStateFile.exists()) {
-      tempStateFile.delete();
-    }
-  }
-
-  private void populateStateFile(File file, int fileStamp, int ordinal, Object object) throws Exception {
-    try (ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(file))) {
-      oos.writeInt(fileStamp);
-      oos.writeInt(ordinal);
-      DataSerializer.writeObject(object, oos);
-      oos.flush();
-    }
-  }
-
-  @Test
-  public void testRecoverFromFileWithNonExistFile() throws Exception {
-    tempStateFile.delete();
-    assertFalse(tempStateFile.exists());
-    assertFalse(locator.recoverFromFile(tempStateFile));
-  }
-
-  @Test
-  public void testRecoverFromFileWithNormalFile() throws Exception {
-    NetView view = new NetView();
-    populateStateFile(tempStateFile, GMSLocator.LOCATOR_FILE_STAMP, Version.CURRENT_ORDINAL, view);
-    assertTrue(locator.recoverFromFile(tempStateFile));
-  }
-
-  @Test
-  public void testRecoverFromFileWithWrongFileStamp() throws Exception {
-    // add 1 to file stamp to make it invalid
-    populateStateFile(tempStateFile, GMSLocator.LOCATOR_FILE_STAMP + 1, Version.CURRENT_ORDINAL, 1);
-    assertFalse(locator.recoverFromFile(tempStateFile));
-  }
-
-  @Test
-  public void testRecoverFromFileWithWrongOrdinal() throws Exception {
-    // add 1 to ordinal to make it wrong
-    populateStateFile(tempStateFile, GMSLocator.LOCATOR_FILE_STAMP, Version.CURRENT_ORDINAL + 1, 1);
-    try {
-      locator.recoverFromFile(tempStateFile);
-      fail("expected an InternalGemFireException to be thrown");
-    } catch (InternalGemFireException e) {
-      // success
-    }
-  }
-
-  @Test
-  public void testRecoverFromFileWithInvalidViewObject() throws Exception {
-    populateStateFile(tempStateFile, GMSLocator.LOCATOR_FILE_STAMP, Version.CURRENT_ORDINAL, 1);
-    try {
-      locator.recoverFromFile(tempStateFile);
-      fail("should catch InternalGemFileException");
-    } catch (InternalGemFireException e) {
-      assertTrue(e.getMessage().startsWith("Unable to recover previous membership view from"));
-    }
-  }
-
-  @Test
-  public void testRecoverFromOther() throws Exception {
-    
-    MembershipManager m1=null, m2=null;
-    Locator l = null;
-    
-    try {
-      
-      // boot up a locator
-      int port = AvailablePortHelper.getRandomAvailableTCPPort();
-      InetAddress localHost = SocketCreator.getLocalHost();
-      
-      // this locator will hook itself up with the first MembershipManager
-      // to be created
-//      l = Locator.startLocator(port, new File(""), localHost);
-      l = InternalLocator.startLocator(port, new File(""), null,
-          null, null, localHost, false, new Properties(), true, false, null,
-          false);
-      
-      // create configuration objects
-      Properties nonDefault = new Properties();
-      nonDefault.put(DistributionConfig.DISABLE_TCP_NAME, "true");
-      nonDefault.put(DistributionConfig.MCAST_PORT_NAME, "0");
-      nonDefault.put(DistributionConfig.LOG_FILE_NAME, "");
-      nonDefault.put(DistributionConfig.LOG_LEVEL_NAME, "fine");
-      nonDefault.put(DistributionConfig.LOCATORS_NAME, localHost.getHostName()+'['+port+']');
-      DistributionConfigImpl config = new DistributionConfigImpl(nonDefault);
-      RemoteTransportConfig transport = new RemoteTransportConfig(config,
-          DistributionManager.NORMAL_DM_TYPE);
-
-      // start the first membership manager
-      DistributedMembershipListener listener1 = mock(DistributedMembershipListener.class);
-      DMStats stats1 = mock(DMStats.class);
-      m1 = MemberFactory.newMembershipManager(listener1, config, transport, stats1);
-      
-      // hook up the locator to the membership manager
-      ((InternalLocator)l).getLocatorHandler().setMembershipManager(m1);
-      
-      GMSLocator l2 = new GMSLocator(SocketCreator.getLocalHost(), new File("l2.dat"),
-          m1.getLocalMember().getHost()+"["+port+"]", true, true, new LocatorStats());
-      l2.init(null);
-      
-      assertTrue("expected view to contain "
-          + m1.getLocalMember() + ": " + l2.getMembers(),
-          l2.getMembers().contains(m1.getLocalMember()));
-    } finally {
-      if (m1 != null) {
-        m1.shutdown();
-      }
-      if (l != null) {
-        l.stop();
-      }
-    }
-  }
-}
-

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/377a495b/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/locator/GMSLocatorRecoveryJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/locator/GMSLocatorRecoveryJUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/locator/GMSLocatorRecoveryJUnitTest.java
new file mode 100644
index 0000000..7fd4a03
--- /dev/null
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/locator/GMSLocatorRecoveryJUnitTest.java
@@ -0,0 +1,169 @@
+package com.gemstone.gemfire.distributed.internal.membership.gms.locator;
+
+import com.gemstone.gemfire.DataSerializer;
+import com.gemstone.gemfire.InternalGemFireException;
+import com.gemstone.gemfire.distributed.Locator;
+import com.gemstone.gemfire.distributed.internal.DMStats;
+import com.gemstone.gemfire.distributed.internal.DistributionConfig;
+import com.gemstone.gemfire.distributed.internal.DistributionConfigImpl;
+import com.gemstone.gemfire.distributed.internal.DistributionManager;
+import com.gemstone.gemfire.distributed.internal.InternalLocator;
+import com.gemstone.gemfire.distributed.internal.LocatorStats;
+import com.gemstone.gemfire.distributed.internal.membership.DistributedMembershipListener;
+import com.gemstone.gemfire.distributed.internal.membership.MemberFactory;
+import com.gemstone.gemfire.distributed.internal.membership.MembershipManager;
+import com.gemstone.gemfire.distributed.internal.membership.NetView;
+import com.gemstone.gemfire.internal.AvailablePortHelper;
+import com.gemstone.gemfire.internal.OSProcess;
+import com.gemstone.gemfire.internal.SocketCreator;
+import com.gemstone.gemfire.internal.Version;
+import com.gemstone.gemfire.internal.admin.remote.RemoteTransportConfig;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import com.gemstone.gemfire.test.junit.categories.UnitTest;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.ObjectOutputStream;
+import java.net.InetAddress;
+import java.util.Properties;
+
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.mock;
+
+@Category(UnitTest.class)
+public class GMSLocatorRecoveryJUnitTest {
+
+  File tempStateFile = null;
+  GMSLocator locator = null;
+
+  @Before
+  public void setUp() throws Exception {
+    tempStateFile = new File("GMSLocatorJUnitTest_locator.dat");
+    if (tempStateFile.exists()) {
+      tempStateFile.delete();
+    }
+    locator = new GMSLocator(null, tempStateFile, null, false, false, new LocatorStats());
+    // System.out.println("temp state file: " + tempStateFile);
+  }
+
+  @After
+  public void tearDown() throws Exception {
+    if (tempStateFile.exists()) {
+      tempStateFile.delete();
+    }
+  }
+
+  private void populateStateFile(File file, int fileStamp, int ordinal, Object object) throws Exception {
+    try (ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(file))) {
+      oos.writeInt(fileStamp);
+      oos.writeInt(ordinal);
+      DataSerializer.writeObject(object, oos);
+      oos.flush();
+    }
+  }
+
+  @Test
+  public void testRecoverFromFileWithNonExistFile() throws Exception {
+    tempStateFile.delete();
+    assertFalse(tempStateFile.exists());
+    assertFalse(locator.recoverFromFile(tempStateFile));
+  }
+
+  @Test
+  public void testRecoverFromFileWithNormalFile() throws Exception {
+    NetView view = new NetView();
+    populateStateFile(tempStateFile, GMSLocator.LOCATOR_FILE_STAMP, Version.CURRENT_ORDINAL, view);
+    assertTrue(locator.recoverFromFile(tempStateFile));
+  }
+
+  @Test
+  public void testRecoverFromFileWithWrongFileStamp() throws Exception {
+    // add 1 to file stamp to make it invalid
+    populateStateFile(tempStateFile, GMSLocator.LOCATOR_FILE_STAMP + 1, Version.CURRENT_ORDINAL, 1);
+    assertFalse(locator.recoverFromFile(tempStateFile));
+  }
+
+  @Test
+  public void testRecoverFromFileWithWrongOrdinal() throws Exception {
+    // add 1 to ordinal to make it wrong
+    populateStateFile(tempStateFile, GMSLocator.LOCATOR_FILE_STAMP, Version.CURRENT_ORDINAL + 1, 1);
+    try {
+      locator.recoverFromFile(tempStateFile);
+      fail("expected an InternalGemFireException to be thrown");
+    } catch (InternalGemFireException e) {
+      // success
+    }
+  }
+
+  @Test
+  public void testRecoverFromFileWithInvalidViewObject() throws Exception {
+    populateStateFile(tempStateFile, GMSLocator.LOCATOR_FILE_STAMP, Version.CURRENT_ORDINAL, 1);
+    try {
+      locator.recoverFromFile(tempStateFile);
+      fail("should catch InternalGemFileException");
+    } catch (InternalGemFireException e) {
+      assertTrue(e.getMessage().startsWith("Unable to recover previous membership view from"));
+    }
+  }
+
+  @Test
+  public void testRecoverFromOther() throws Exception {
+    
+    MembershipManager m1=null, m2=null;
+    Locator l = null;
+    
+    try {
+      
+      // boot up a locator
+      int port = AvailablePortHelper.getRandomAvailableTCPPort();
+      InetAddress localHost = SocketCreator.getLocalHost();
+      
+      // this locator will hook itself up with the first MembershipManager
+      // to be created
+//      l = Locator.startLocator(port, new File(""), localHost);
+      l = InternalLocator.startLocator(port, new File(""), null,
+          null, null, localHost, false, new Properties(), true, false, null,
+          false);
+      
+      // create configuration objects
+      Properties nonDefault = new Properties();
+      nonDefault.put(DistributionConfig.DISABLE_TCP_NAME, "true");
+      nonDefault.put(DistributionConfig.MCAST_PORT_NAME, "0");
+      nonDefault.put(DistributionConfig.LOG_FILE_NAME, "");
+      nonDefault.put(DistributionConfig.LOG_LEVEL_NAME, "fine");
+      nonDefault.put(DistributionConfig.LOCATORS_NAME, localHost.getHostName()+'['+port+']');
+      DistributionConfigImpl config = new DistributionConfigImpl(nonDefault);
+      RemoteTransportConfig transport = new RemoteTransportConfig(config,
+          DistributionManager.NORMAL_DM_TYPE);
+
+      // start the first membership manager
+      DistributedMembershipListener listener1 = mock(DistributedMembershipListener.class);
+      DMStats stats1 = mock(DMStats.class);
+      m1 = MemberFactory.newMembershipManager(listener1, config, transport, stats1);
+      
+      // hook up the locator to the membership manager
+      ((InternalLocator)l).getLocatorHandler().setMembershipManager(m1);
+      
+      GMSLocator l2 = new GMSLocator(SocketCreator.getLocalHost(), new File("l2.dat"),
+          m1.getLocalMember().getHost()+"["+port+"]", true, true, new LocatorStats());
+      l2.init(null);
+      
+      assertTrue("expected view to contain "
+          + m1.getLocalMember() + ": " + l2.getMembers(),
+          l2.getMembers().contains(m1.getLocalMember()));
+    } finally {
+      if (m1 != null) {
+        m1.shutdown();
+      }
+      if (l != null) {
+        l.stop();
+      }
+    }
+  }
+}
+

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/377a495b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/ConnectDisconnectDUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/ConnectDisconnectDUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/ConnectDisconnectDUnitTest.java
index 675fcbe..44ee0a1 100644
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/ConnectDisconnectDUnitTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/ConnectDisconnectDUnitTest.java
@@ -31,29 +31,6 @@ public class ConnectDisconnectDUnitTest extends CacheTestCase {
   
   
   
-//  @Override
-//  public void setUp() throws Exception {
-//    super.setUp();
-//    invokeInEveryVM(new SerializableRunnable() {
-//      
-//      @Override
-//      public void run() {
-//        JGroupMembershipManager.setDebugJGroups(true);
-//        System.setProperty("p2p.simulateDiscard", "true");
-//        System.setProperty("p2p.simulateDiscard.received", "0.10");
-//        System.setProperty("p2p.simulateDiscard.sent", "0.10");
-//        System.setProperty("gemfire.membership-port-range", "17000-17200");
-//      }
-//    });
-//  }
-  
-  
-//  @Override
-//  public void tearDown2() throws Exception {
-//    ex.remove();
-//  }
-
-
   // see bugs #50785 and #46438 
   public void testManyConnectsAndDisconnects() throws Throwable {
 //    invokeInEveryVM(new SerializableRunnable() {
@@ -68,7 +45,7 @@ public class ConnectDisconnectDUnitTest extends CacheTestCase {
 //     int[] ports = AvailablePortHelper.getRandomAvailableTCPPorts(4);
 //     setLocatorPorts(ports);
 
-    for(int i = 0; i < 50; i++) {
+    for(int i = 0; i < 20; i++) {
       getLogWriter().info("Test run: " + i);
       runOnce();
       tearDown();

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/377a495b/gemfire-core/src/test/java/dunit/DistributedTestCase.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/dunit/DistributedTestCase.java b/gemfire-core/src/test/java/dunit/DistributedTestCase.java
index 058980f..2e6346d 100755
--- a/gemfire-core/src/test/java/dunit/DistributedTestCase.java
+++ b/gemfire-core/src/test/java/dunit/DistributedTestCase.java
@@ -39,6 +39,7 @@ import com.gemstone.gemfire.cache30.GlobalLockingDUnitTest;
 import com.gemstone.gemfire.cache30.MultiVMRegionTestCase;
 import com.gemstone.gemfire.cache30.RegionTestCase;
 import com.gemstone.gemfire.distributed.DistributedSystem;
+import com.gemstone.gemfire.distributed.Locator;
 import com.gemstone.gemfire.distributed.internal.DistributionConfig;
 import com.gemstone.gemfire.distributed.internal.DistributionConfigImpl;
 import com.gemstone.gemfire.distributed.internal.DistributionMessageObserver;


Mime
View raw message