geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kl...@apache.org
Subject [14/50] [abbrv] incubator-geode git commit: GEODE-1237 remove the check for network-partition-detection uniformity
Date Thu, 28 Apr 2016 23:09:53 GMT
GEODE-1237 remove the check for network-partition-detection uniformity

Each member now determines whether to force shutdown due to loss of quorum.
They also decide whether locators are preferred as membership coordinators.
This primarily meant removing the method GMSJoinLeave
.inheritSettingsFromLocator() but the ID settings needed to be made in
other places (JGroupsMessenger.establishLocalAddress() and
GMSJoinLeave.started()).

I also noticed that some of the code was still using "splitBrain" and
"SB" instead of networkPartitionDetection and "NPD" and fixed that.

One test had to be removed from LocatorDUnitTest and a couple of others
needed to be adjusted to have all of the members set network-partition
-detection-enabled=true.  Precheckin is running and I'll fix any other
tests that have this problem.


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

Branch: refs/heads/feature/GEODE-1255
Commit: 872f955c491b6ec3e3881be2d7f0c1d192478aee
Parents: 3c5a2e8
Author: Bruce Schuchardt <bschuchardt@pivotal.io>
Authored: Mon Apr 25 11:49:15 2016 -0700
Committer: Bruce Schuchardt <bschuchardt@pivotal.io>
Committed: Mon Apr 25 11:49:15 2016 -0700

----------------------------------------------------------------------
 .../distributed/internal/InternalLocator.java   |   6 +-
 .../membership/InternalDistributedMember.java   |  68 ++++++------
 .../internal/membership/NetMember.java          |   4 +-
 .../internal/membership/gms/GMSMember.java      |  36 +++---
 .../internal/membership/gms/ServiceConfig.java  |  18 +++
 .../membership/gms/locator/GMSLocator.java      |   2 +-
 .../membership/gms/membership/GMSJoinLeave.java |  56 +++-------
 .../gms/messenger/JGroupsMessenger.java         |   7 +-
 .../internal/i18n/ParentLocalizedStrings.java   |   2 +-
 .../gemfire/distributed/LocatorDUnitTest.java   | 110 +++----------------
 .../gms/membership/GMSJoinLeaveTestHelper.java  |   2 +-
 11 files changed, 110 insertions(+), 201 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/872f955c/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
old mode 100644
new mode 100755
index a5d269b..7effa3d
--- 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
@@ -663,11 +663,7 @@ public class InternalLocator extends Locator implements ConnectListener
{
         locatorsAreCoordinators = Boolean.getBoolean(LOCATORS_PREFERRED_AS_COORDINATORS);
       }
     }
-    if (locatorsAreCoordinators) {
-      // LOG: changed from config to info
-      logger.info(LocalizedMessage.create(LocalizedStrings.InternalLocator_FORCING_GROUP_COORDINATION_INTO_LOCATORS));
-    }
-    
+
     this.locatorImpl = MemberFactory.newLocatorHandler(this.bindAddress, this.stateFile,
         locatorsProp, locatorsAreCoordinators, networkPartitionDetectionEnabled, stats);
     this.handler.addHandler(PeerLocatorRequest.class, this.locatorImpl);

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/872f955c/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/InternalDistributedMember.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/InternalDistributedMember.java
b/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/InternalDistributedMember.java
index 81058f8..f7572af 100755
--- a/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/InternalDistributedMember.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/InternalDistributedMember.java
@@ -121,17 +121,17 @@ public class InternalDistributedMember
    */
   private String uniqueTag = null;
 
-  /** serialization bit mask */
-  private static final int SB_ENABLED_MASK = 0x1;
+  /** serialization bit flag */
+  private static final int NPD_ENABLED_BIT = 0x1;
 
-  /** serialization bit mask */
-  private static final int COORD_ENABLED_MASK = 0x2;
+  /** serialization bit flag */
+  private static final int COORD_ENABLED_BIT = 0x2;
 
-  /** partial ID bit mask */
-  private static final int PARTIAL_ID_MASK = 0x4;
+  /** partial ID bit flag */
+  private static final int PARTIAL_ID_BIT = 0x4;
 
-  /** product version bit mask */
-  private static final int VERSION_MASK = 0x8;
+  /** product version bit flag */
+  private static final int VERSION_BIT = 0x8;
 
   /**
    * Representing the host name of this member.
@@ -832,7 +832,7 @@ public class InternalDistributedMember
   }
 
   private void readVersion(int flags, DataInput in) throws IOException {
-    if ((flags & VERSION_MASK) != 0) {
+    if ((flags & VERSION_BIT) != 0) {
       this.version = Version.readOrdinal(in);
       this.versionObj = Version.fromOrdinalNoThrow(this.version, false);
     } else {
@@ -863,12 +863,12 @@ public class InternalDistributedMember
     DataSerializer.writeString(this.hostName, out);
     
     int flags = 0;
-    if (netMbr.splitBrainEnabled()) flags |= SB_ENABLED_MASK;
-    if (netMbr.preferredForCoordinator()) flags |= COORD_ENABLED_MASK;
-    if (this.isPartial) flags |= PARTIAL_ID_MASK;
+    if (netMbr.isNetworkPartitionDetectionEnabled()) flags |= NPD_ENABLED_BIT;
+    if (netMbr.preferredForCoordinator()) flags |= COORD_ENABLED_BIT;
+    if (this.isPartial) flags |= PARTIAL_ID_BIT;
     // always write product version but enable reading from older versions
     // that do not have it
-    flags |= VERSION_MASK;
+    flags |= VERSION_BIT;
     out.writeByte((byte)(flags & 0xff));
 
     out.writeInt(dcPort);
@@ -901,9 +901,9 @@ public class InternalDistributedMember
      this.hostName = DataSerializer.readString(in);
 
      int flags = in.readUnsignedByte();
-     boolean sbEnabled = (flags & SB_ENABLED_MASK) != 0;
-     boolean elCoord = (flags & COORD_ENABLED_MASK) != 0;
-     this.isPartial = (flags & PARTIAL_ID_MASK) != 0;
+     boolean sbEnabled = (flags & NPD_ENABLED_BIT) != 0;
+     boolean elCoord = (flags & COORD_ENABLED_BIT) != 0;
+     this.isPartial = (flags & PARTIAL_ID_BIT) != 0;
      
      this.dcPort = in.readInt();
      this.vmPid = in.readInt();
@@ -955,12 +955,12 @@ public class InternalDistributedMember
     DataSerializer.writeString(this.hostName, out);
 
     int flags = 0;
-    if (netMbr.splitBrainEnabled()) flags |= SB_ENABLED_MASK;
-    if (netMbr.preferredForCoordinator()) flags |= COORD_ENABLED_MASK;
-    if (this.isPartial) flags |= PARTIAL_ID_MASK;
+    if (netMbr.isNetworkPartitionDetectionEnabled()) flags |= NPD_ENABLED_BIT;
+    if (netMbr.preferredForCoordinator()) flags |= COORD_ENABLED_BIT;
+    if (this.isPartial) flags |= PARTIAL_ID_BIT;
     // always write product version but enable reading from older versions
     // that do not have it
-    flags |= VERSION_MASK;
+    flags |= VERSION_BIT;
     out.writeByte((byte)(flags & 0xff));
     
     out.writeInt(dcPort);
@@ -997,9 +997,9 @@ public class InternalDistributedMember
     DataSerializer.writeString(this.hostName, out);
 
     int flags = 0;
-    if (netMbr.splitBrainEnabled()) flags |= SB_ENABLED_MASK;
-    if (netMbr.preferredForCoordinator()) flags |= COORD_ENABLED_MASK;
-    if (this.isPartial) flags |= PARTIAL_ID_MASK;
+    if (netMbr.isNetworkPartitionDetectionEnabled()) flags |= NPD_ENABLED_BIT;
+    if (netMbr.preferredForCoordinator()) flags |= COORD_ENABLED_BIT;
+    if (this.isPartial) flags |= PARTIAL_ID_BIT;
     out.writeByte((byte)(flags & 0xff));
     
     out.writeInt(dcPort);
@@ -1041,9 +1041,9 @@ public class InternalDistributedMember
     this.hostName = SocketCreator.resolve_dns? SocketCreator.getCanonicalHostName(inetAddr,
hostName) : inetAddr.getHostAddress();
 
     int flags = in.readUnsignedByte();
-    boolean sbEnabled = (flags & SB_ENABLED_MASK) != 0;
-    boolean elCoord = (flags & COORD_ENABLED_MASK) != 0;
-    this.isPartial = (flags & PARTIAL_ID_MASK) != 0;
+    boolean sbEnabled = (flags & NPD_ENABLED_BIT) != 0;
+    boolean elCoord = (flags & COORD_ENABLED_BIT) != 0;
+    this.isPartial = (flags & PARTIAL_ID_BIT) != 0;
 
     this.dcPort = in.readInt();
     this.vmPid = in.readInt();
@@ -1084,9 +1084,9 @@ public class InternalDistributedMember
     this.hostName = SocketCreator.resolve_dns? SocketCreator.getCanonicalHostName(inetAddr,
hostName) : inetAddr.getHostAddress();
 
     int flags = in.readUnsignedByte();
-    boolean sbEnabled = (flags & SB_ENABLED_MASK) != 0;
-    boolean elCoord = (flags & COORD_ENABLED_MASK) != 0;
-    this.isPartial = (flags & PARTIAL_ID_MASK) != 0;
+    boolean sbEnabled = (flags & NPD_ENABLED_BIT) != 0;
+    boolean elCoord = (flags & COORD_ENABLED_BIT) != 0;
+    this.isPartial = (flags & PARTIAL_ID_BIT) != 0;
 
     this.dcPort = in.readInt();
     this.vmPid = in.readInt();
@@ -1134,8 +1134,8 @@ public class InternalDistributedMember
      this.hostName = SocketCreator.resolve_dns? SocketCreator.getHostName(inetAddr) : inetAddr.getHostAddress();
 
      int flags = in.readUnsignedByte();
-     boolean sbEnabled = (flags & SB_ENABLED_MASK) != 0;
-     boolean elCoord = (flags & COORD_ENABLED_MASK) != 0;
+     boolean sbEnabled = (flags & NPD_ENABLED_BIT) != 0;
+     boolean elCoord = (flags & COORD_ENABLED_BIT) != 0;
 
      this.vmKind = in.readUnsignedByte();
      
@@ -1170,9 +1170,9 @@ public class InternalDistributedMember
      out.writeInt(getPort());
 
      int flags = 0;
-     if (netMbr.splitBrainEnabled()) flags |= SB_ENABLED_MASK;
-     if (netMbr.preferredForCoordinator()) flags |= COORD_ENABLED_MASK;
-     flags |= PARTIAL_ID_MASK;
+     if (netMbr.isNetworkPartitionDetectionEnabled()) flags |= NPD_ENABLED_BIT;
+     if (netMbr.preferredForCoordinator()) flags |= COORD_ENABLED_BIT;
+     flags |= PARTIAL_ID_BIT;
      out.writeByte((byte)(flags & 0xff));
      
 //     out.writeInt(dcPort);

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/872f955c/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/NetMember.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/NetMember.java
b/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/NetMember.java
index 43f3cf1..bdaf579 100755
--- a/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/NetMember.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/NetMember.java
@@ -50,9 +50,9 @@ public interface NetMember extends Comparable<NetMember>
    * return a flag stating whether the member has network partition detection enabled
    * @since 5.6
    */
-  public boolean splitBrainEnabled();
+  public boolean isNetworkPartitionDetectionEnabled();
   
-  public void setSplitBrainEnabled(boolean enabled);
+  public void setNetworkPartitionDetectionEnabled(boolean enabled);
   
   /**
    * return a flag stating whether the member can be the membership coordinator

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/872f955c/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/GMSMember.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/GMSMember.java
b/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/GMSMember.java
index 84ace6c..6089eb8 100755
--- a/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/GMSMember.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/GMSMember.java
@@ -50,7 +50,7 @@ public class GMSMember implements NetMember, DataSerializableFixedID {
   
   private int udpPort=0;
   private boolean preferredForCoordinator;
-  private boolean splitBrainEnabled;
+  private boolean networkPartitionDetectionEnabled;
   private byte memberWeight;
   private InetAddress inetAddr;
   private int processId;
@@ -112,19 +112,19 @@ public class GMSMember implements NetMember, DataSerializableFixedID
{
    * 
    * @param i the hostname, must be for the current host
    * @param p the membership listening port
-   * @param splitBrainEnabled whether the member has network partition detection enabled
+   * @param networkPartitionDetectionEnabled whether the member has network partition detection
enabled
    * @param preferredForCoordinator whether the member can be group coordinator
    * @param version the member's version ordinal
    * @param msbs - most significant bytes of UUID
    * @param lsbs - least significant bytes of UUID
    */
-  public GMSMember(MemberAttributes attr, InetAddress i, int p, boolean splitBrainEnabled,
boolean preferredForCoordinator,
-      short version,
-      long msbs, long lsbs) {
+  public GMSMember(MemberAttributes attr, InetAddress i, int p, boolean networkPartitionDetectionEnabled,
boolean preferredForCoordinator,
+                   short version,
+                   long msbs, long lsbs) {
     setAttributes(attr);
     this.inetAddr = i;
     this.udpPort=p;
-    this.splitBrainEnabled = splitBrainEnabled;
+    this.networkPartitionDetectionEnabled = networkPartitionDetectionEnabled;
     this.preferredForCoordinator = preferredForCoordinator;
     this.versionOrdinal = version;
     this.uuidMSBs = msbs;
@@ -139,10 +139,6 @@ public class GMSMember implements NetMember, DataSerializableFixedID
{
     return false;  //ipAddr.isMulticastAddress();
   }
   
-  public boolean splitBrainEnabled() {
-    return this.splitBrainEnabled;
-  }
-  
   public boolean preferredForCoordinator() {
     return this.preferredForCoordinator;
   }
@@ -284,8 +280,8 @@ public class GMSMember implements NetMember, DataSerializableFixedID {
     return udpPort;
   }
 
-  public boolean isSplitBrainEnabled() {
-    return splitBrainEnabled;
+  public boolean isNetworkPartitionDetectionEnabled() {
+    return networkPartitionDetectionEnabled;
   }
 
   public byte getMemberWeight() {
@@ -328,8 +324,8 @@ public class GMSMember implements NetMember, DataSerializableFixedID {
     this.udpPort = udpPort;
   }
 
-  public void setSplitBrainEnabled(boolean splitBrainEnabled) {
-    this.splitBrainEnabled = splitBrainEnabled;
+  public void setNetworkPartitionDetectionEnabled(boolean networkPartitionDetectionEnabled)
{
+    this.networkPartitionDetectionEnabled = networkPartitionDetectionEnabled;
   }
 
   public void setMemberWeight(byte memberWeight) {
@@ -395,16 +391,16 @@ public class GMSMember implements NetMember, DataSerializableFixedID
{
     return GMSMEMBER;
   }
 
-  static final int SB_ENABLED = 0x01;
-  static final int PREFERRED_FOR_COORD = 0x02;
+  static final int NPD_ENABLED_BIT = 0x01;
+  static final int PREFERRED_FOR_COORD_BIT = 0x02;
   
   @Override
   public void toData(DataOutput out) throws IOException {
     Version.writeOrdinal(out, this.versionOrdinal, true);
     
     int flags = 0;
-    if (splitBrainEnabled) flags |= SB_ENABLED;
-    if (preferredForCoordinator) flags |= PREFERRED_FOR_COORD;
+    if (networkPartitionDetectionEnabled) flags |= NPD_ENABLED_BIT;
+    if (preferredForCoordinator) flags |= PREFERRED_FOR_COORD_BIT;
     out.writeShort(flags);
 
     DataSerializer.writeInetAddress(inetAddr, out);
@@ -425,8 +421,8 @@ public class GMSMember implements NetMember, DataSerializableFixedID {
     this.versionOrdinal = Version.readOrdinal(in);
     
     int flags = in.readShort();
-    this.splitBrainEnabled = (flags & SB_ENABLED) != 0;
-    this.preferredForCoordinator = (flags & PREFERRED_FOR_COORD) != 0;
+    this.networkPartitionDetectionEnabled = (flags & NPD_ENABLED_BIT) != 0;
+    this.preferredForCoordinator = (flags & PREFERRED_FOR_COORD_BIT) != 0;
     
     this.inetAddr = DataSerializer.readInetAddress(in);
     this.udpPort = in.readInt();

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/872f955c/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/ServiceConfig.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/ServiceConfig.java
b/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/ServiceConfig.java
index 9f0bbf7..3a48c3f 100755
--- a/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/ServiceConfig.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/ServiceConfig.java
@@ -20,6 +20,7 @@ import java.net.InetAddress;
 
 import com.gemstone.gemfire.distributed.Locator;
 import com.gemstone.gemfire.distributed.internal.DistributionConfig;
+import com.gemstone.gemfire.distributed.internal.InternalLocator;
 import com.gemstone.gemfire.distributed.internal.membership.gms.membership.GMSJoinLeave;
 import com.gemstone.gemfire.internal.SocketCreator;
 import com.gemstone.gemfire.internal.admin.remote.RemoteTransportConfig;
@@ -118,6 +119,23 @@ public class ServiceConfig {
 
     }
   }
+
+  public boolean areLocatorsPreferredAsCoordinators() {
+    boolean locatorsAreCoordinators = false;
+
+    if (networkPartitionDetectionEnabled) {
+      locatorsAreCoordinators = true;
+    }
+    else {
+      // check if security is enabled
+      String prop = dconfig.getSecurityPeerAuthInit();
+      locatorsAreCoordinators =  (prop != null && prop.length() > 0);
+      if (!locatorsAreCoordinators) {
+        locatorsAreCoordinators = Boolean.getBoolean(InternalLocator.LOCATORS_PREFERRED_AS_COORDINATORS);
+      }
+    }
+    return locatorsAreCoordinators;
+  }
   
   public DistributionConfig getDistributionConfig() {
     return this.dconfig;

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/872f955c/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/locator/GMSLocator.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/locator/GMSLocator.java
b/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/locator/GMSLocator.java
index c8b6aaa..aab9002 100755
--- a/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/locator/GMSLocator.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/locator/GMSLocator.java
@@ -218,7 +218,7 @@ public class GMSLocator implements Locator, NetLocator {
             for (InternalDistributedMember mbr: registrants) {
               if (mbr != coord  &&  (coord==null  ||  mbr.compareTo(coord) < 0))
{
                 if (!rejections.contains(mbr)
-                    && (mbr.getNetMember().preferredForCoordinator() || !mbr.getNetMember().splitBrainEnabled()))
{
+                    && (mbr.getNetMember().preferredForCoordinator() || !mbr.getNetMember().isNetworkPartitionDetectionEnabled()))
{
                   coord = mbr;
                 }
               }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/872f955c/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/membership/GMSJoinLeave.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/membership/GMSJoinLeave.java
b/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/membership/GMSJoinLeave.java
index 05350e5..9f5648b 100755
--- a/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/membership/GMSJoinLeave.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/membership/GMSJoinLeave.java
@@ -800,7 +800,9 @@ public class GMSJoinLeave implements JoinLeave, MessageHandler {
     }
 
     if (recips.isEmpty()) {
-      logger.info("no recipients for new view aside from myself");
+      if (!preparing) {
+        logger.info("no recipients for new view aside from myself");
+      }
       return true;
     }
 
@@ -958,7 +960,6 @@ public class GMSJoinLeave implements JoinLeave, MessageHandler {
 
     int connectTimeout = (int) services.getConfig().getMemberTimeout() * 2;
     boolean anyResponses = false;
-    boolean flagsSet = false;
 
     logger.debug("sending {} to {}", request, locators);
 
@@ -995,10 +996,6 @@ public class GMSJoinLeave implements JoinLeave, MessageHandler {
               }
               
               possibleCoordinators.add(response.getCoordinator());
-              if (!flagsSet) {
-                flagsSet = true;
-                inheritSettingsFromLocator(addr, response);
-              }
             }
           }
         } catch (IOException | ClassNotFoundException problem) {
@@ -1124,36 +1121,6 @@ public class GMSJoinLeave implements JoinLeave, MessageHandler {
   }
 
   /**
-   * Some settings are gleaned from locator responses and set into the local
-   * configuration
-   */
-  private void inheritSettingsFromLocator(InetSocketAddress addr, FindCoordinatorResponse
response) {
-    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();
-    mbr.setSplitBrainEnabled(enabled);
-    services.getConfig().setNetworkPartitionDetectionEnabled(enabled);
-    services.getConfig().getDistributionConfig().setEnableNetworkPartitionDetection(enabled);
-
-    if (response.isUsePreferredCoordinators()) {
-      this.quorumRequired = enabled;
-      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);
-      }
-    } else {
-      ((GMSMember) localAddress.getNetMember()).setPreferredForCoordinator(true);
-    }
-  }
-
-  /**
    * receives a JoinResponse holding a membership view or rejection message
    *
    * @param rsp
@@ -1238,7 +1205,6 @@ public class GMSJoinLeave implements JoinLeave, MessageHandler {
             this.localAddress.setVmViewId(this.birthViewId);
             GMSMember me = (GMSMember) this.localAddress.getNetMember();
             me.setBirthViewId(birthViewId);
-            me.setSplitBrainEnabled(mbr.getNetMember().splitBrainEnabled());
             break;
           }
         }
@@ -1422,6 +1388,21 @@ public class GMSJoinLeave implements JoinLeave, MessageHandler {
   @Override
   public void started() {
     this.localAddress = services.getMessenger().getMemberID();
+    GMSMember mbr = (GMSMember)this.localAddress.getNetMember();
+
+    if (services.getConfig().areLocatorsPreferredAsCoordinators()) {
+      boolean preferred = false;
+      if (services.getLocator() != null
+              || Locator.hasLocator()
+              || !services.getConfig().getDistributionConfig().getStartLocator().isEmpty()
+              || localAddress.getVmKind() == DistributionManager.LOCATOR_DM_TYPE) {
+        logger.info("This member is hosting a locator will be preferred as a membership coordinator");
+        preferred = true;
+      }
+      mbr.setPreferredForCoordinator(preferred);
+    } else {
+      mbr.setPreferredForCoordinator(true);
+    }
   }
 
   @Override
@@ -2144,7 +2125,6 @@ public class GMSJoinLeave implements JoinLeave, MessageHandler {
 
       for (InternalDistributedMember mbr : joinReqs) {
         mbr.setVmViewId(newView.getViewId());
-        mbr.getNetMember().setSplitBrainEnabled(services.getConfig().isNetworkPartitionDetectionEnabled());
       }
 
       if (isShutdown()) {

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/872f955c/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/JGroupsMessenger.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/JGroupsMessenger.java
b/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/JGroupsMessenger.java
index a9abea3..4a54e84 100755
--- a/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/JGroupsMessenger.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/JGroupsMessenger.java
@@ -477,8 +477,11 @@ 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));
+    GMSMember gmsMember = (GMSMember)localAddress.getNetMember();
+    gmsMember.setUUID(uuid);
+    gmsMember.setMemberWeight((byte)(services.getConfig().getMemberWeight() & 0xff));
+    gmsMember.setNetworkPartitionDetectionEnabled(services.getConfig().getDistributionConfig().getEnableNetworkPartitionDetection());
+
   }
   
   @Override

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/872f955c/geode-core/src/main/java/com/gemstone/gemfire/internal/i18n/ParentLocalizedStrings.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/i18n/ParentLocalizedStrings.java
b/geode-core/src/main/java/com/gemstone/gemfire/internal/i18n/ParentLocalizedStrings.java
index 8285a65..c34c91a 100755
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/i18n/ParentLocalizedStrings.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/i18n/ParentLocalizedStrings.java
@@ -704,7 +704,7 @@ class ParentLocalizedStrings {
   public static final StringId InternalInstantiator_COULD_NOT_LOAD_INSTANTIATOR_CLASS_0 =
new StringId(1697, "Could not load instantiator class: {0}");
   public static final StringId InternalLocator_0__IS_STOPPED = new StringId(1698, "{0}  is
stopped");
   public static final StringId InternalLocator_COULD_NOT_STOP__0__IN_60_SECONDS = new StringId(1699,
"Could not stop  {0}  in 60 seconds");
-  public static final StringId InternalLocator_FORCING_GROUP_COORDINATION_INTO_LOCATORS =
new StringId(1700, "Forcing group coordination into Locators.");
+  // ok to reuse 1700
   public static final StringId InternalLocator_INTERRUPTED_WHILE_STOPPING__0 = new StringId(1701,
"Interrupted while stopping  {0}");
   public static final StringId InternalLocator_LOCATOR_STARTED_ON__0 = new StringId(1702,
"Locator started on  {0}");
   public static final StringId StartupMessage_REJECTED_NEW_SYSTEM_NODE_0_BECAUSE_MCAST_PORT_1_DOES_NOT_MATCH_THE_DISTRIBUTED_SYSTEM_2_IT_IS_ATTEMPTING_TO_JOIN
= new StringId(1703, "Rejected new system node {0} because its mcast-port {1} does not match
the mcast-port {2} of the distributed system it is attempting to join. To fix this make sure
the \"mcast-port\" gemfire property is set the same on all members of the same distributed
system.");

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/872f955c/geode-core/src/test/java/com/gemstone/gemfire/distributed/LocatorDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/distributed/LocatorDUnitTest.java
b/geode-core/src/test/java/com/gemstone/gemfire/distributed/LocatorDUnitTest.java
old mode 100644
new mode 100755
index 702a859..a62a317
--- a/geode-core/src/test/java/com/gemstone/gemfire/distributed/LocatorDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/distributed/LocatorDUnitTest.java
@@ -1186,8 +1186,8 @@ public class LocatorDUnitTest extends DistributedTestCase {
     try {
 
       final Properties props = new Properties();
-      props.setProperty("mcast-port", "0");
-      props.setProperty("locators", locators);
+      props.setProperty(DistributionConfig.LOCATORS_NAME, locators);
+      props.setProperty(DistributionConfig.ENABLE_NETWORK_PARTITION_DETECTION_NAME, "true");
       props.put(DistributionConfig.ENABLE_CLUSTER_CONFIGURATION_NAME, "false");
 
       SerializableRunnable connect =
@@ -1438,10 +1438,9 @@ public class LocatorDUnitTest extends DistributedTestCase {
         host0 + "[" + port3 + "]";
 
     final Properties dsProps = new Properties();
-    dsProps.setProperty("locators", locators);
-    dsProps.setProperty("mcast-port", "0");
-    dsProps.setProperty("log-level", LogWriterUtils.getDUnitLogLevel());
-    dsProps.setProperty("enable-network-partition-detection", "true");
+    dsProps.setProperty(DistributionConfig.LOCATORS_NAME, locators);
+    dsProps.setProperty(DistributionConfig.LOG_LEVEL_NAME, LogWriterUtils.getDUnitLogLevel());
+    dsProps.setProperty(DistributionConfig.ENABLE_NETWORK_PARTITION_DETECTION_NAME, "true");
     dsProps.setProperty(DistributionConfig.ENABLE_CLUSTER_CONFIGURATION_NAME, "false");
 
     startLocatorSync(vm0, new Object[] { port1, dsProps });
@@ -1453,22 +1452,13 @@ public class LocatorDUnitTest extends DistributedTestCase {
         SerializableRunnable connect =
             new SerializableRunnable("Connect to " + locators) {
               public void run() {
-                Properties props = new Properties();
-                props.setProperty("mcast-port", "0");
-                props.setProperty("locators", locators);
-                props.setProperty("log-level", LogWriterUtils.getDUnitLogLevel());
-                props.setProperty("enable-network-partition-detection", "true");
-                DistributedSystem.connect(props);
+                DistributedSystem.connect(dsProps);
               }
             };
         vm3.invoke(connect);
         vm4.invoke(connect);
 
-        Properties props = new Properties();
-        props.setProperty("mcast-port", "0");
-        props.setProperty("locators", locators);
-
-        system = (InternalDistributedSystem) DistributedSystem.connect(props);
+        system = (InternalDistributedSystem) DistributedSystem.connect(dsProps);
 
         WaitCriterion waitCriterion = new WaitCriterion() {
           public boolean done() {
@@ -1497,7 +1487,7 @@ public class LocatorDUnitTest extends DistributedTestCase {
         waitCriterion = new WaitCriterion() {
           public boolean done() {
             try {
-              return system.getDM().getAllHostedLocators().size() == 0;
+              return system.getDM().getMembershipManager().getView().size() <= 3;
             } catch (Exception e) {
               e.printStackTrace();
               com.gemstone.gemfire.test.dunit.Assert.fail("unexpected exception", e);
@@ -1515,11 +1505,11 @@ public class LocatorDUnitTest extends DistributedTestCase {
             host0 + "[" + port3 + "]";
         dsProps.setProperty("locators", newLocators);
 
-        assertTrue(vm3.invoke("Checking ViewCreator thread on Lead Server", () -> GMSJoinLeaveTestHelper.isViewCreator()));
-        //Given the start up order of servers, this server is the elder server
-        assertTrue(vm3.invoke("Checking ViewCreator thread on Lead Server", () -> GMSJoinLeaveTestHelper.isViewCreator()));
-        
         final InternalDistributedMember currentCoordinator = GMSJoinLeaveTestHelper.getCurrentCoordinator();
+        DistributedMember vm3ID = vm3.invoke(() -> GMSJoinLeaveTestHelper.getInternalDistributedSystem().getDM().getDistributionManagerId());
+        assertTrue("View is " + system.getDM().getMembershipManager().getView() +
+                " and vm3's ID is " + vm3ID,
+                vm3.invoke(() -> GMSJoinLeaveTestHelper.isViewCreator()));
 
         startLocatorAsync(vm1, new Object[] { port2, dsProps });
         startLocatorAsync(vm2, new Object[] { port3, dsProps });
@@ -1544,7 +1534,7 @@ public class LocatorDUnitTest extends DistributedTestCase {
             return null;
           }
         };
-        Wait.waitForCriterion(waitCriterion, 15 * 1000, 200, true);
+        Wait.waitForCriterion(waitCriterion, 30 * 1000, 1000, true);
 
         int netviewId = vm1.invoke("Checking ViewCreator", () -> GMSJoinLeaveTestHelper.getViewId());
         assertEquals(netviewId, (int) vm2.invoke("checking ViewID", () -> GMSJoinLeaveTestHelper.getViewId()));
@@ -1739,80 +1729,6 @@ public class LocatorDUnitTest extends DistributedTestCase {
   }
 
   /**
-   * Tests that a VM cannot connect if the locator has a different
-   * enable-network-partition-detection setting
-   */
-  public void testLocatorForcesDetection() throws Exception {
-    disconnectAllFromDS();
-    Host host = Host.getHost(0);
-    VM vm1 = host.getVM(1);
-    Locator locator = null;
-
-    try {
-      port1 = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
-      DistributedTestUtils.deleteLocatorStateFile(port1);
-      final String locators = NetworkUtils.getServerHostName(host) + "[" + port1 + "]";
-      final Properties properties = new Properties();
-      properties.put("mcast-port", "0");
-      properties.put("locators", locators);
-      properties.put(DistributionConfig.ENABLE_NETWORK_PARTITION_DETECTION_NAME, "true");
-      properties.put("disable-auto-reconnect", "true");
-      properties.put(DistributionConfig.ENABLE_CLUSTER_CONFIGURATION_NAME, "false");
-      File logFile = new File("");
-      locator = Locator.startLocatorAndDS(port1, logFile, properties);
-
-      final Properties properties2 = new Properties();
-      properties2.put("mcast-port", "0");
-      properties2.put("locators", locators);
-      properties2.put(DistributionConfig.ENABLE_NETWORK_PARTITION_DETECTION_NAME, "false");
-      properties2.put(DistributionConfig.ENABLE_CLUSTER_CONFIGURATION_NAME, "false");
-      properties2.put("disable-auto-reconnect", "true");
-
-      vm1.invoke(new SerializableRunnable("try to connect") {
-        public void run() {
-          DistributedSystem s = null;
-          try {
-            s = DistributedSystem.connect(properties2);
-            boolean enabled = ((InternalDistributedSystem) s).getConfig().getEnableNetworkPartitionDetection();
-            s.disconnect();
-            if (!enabled) {
-              fail("should not have been able to connect with different enable-network-partition-detection
settings");
-            }
-          } catch (GemFireConfigException e) {
-            fail("should have been able to connect and have enable-network-partion-detection
enabled");
-          }
-        }
-      });
-
-      locator.stop();
-
-      // now start the locator with enable-network-partition-detection=false
-      logFile = new File("");
-      locator = Locator.startLocatorAndDS(port1, logFile, properties2);
-
-      vm1.invoke(new SerializableRunnable("try to connect") {
-        public void run() {
-          DistributedSystem s = null;
-          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
-          }
-        }
-      });
-
-      locator.stop();
-      locator = null;
-    } finally {
-      if (locator != null) {
-        locator.stop();
-      }
-    }
-  }
-
-  /**
    * Tests that a single VM can NOT host multiple locators
    */
   public void testHostingMultipleLocators() throws Exception {

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/872f955c/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/membership/GMSJoinLeaveTestHelper.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/membership/GMSJoinLeaveTestHelper.java
b/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/membership/GMSJoinLeaveTestHelper.java
old mode 100644
new mode 100755
index bf13420..bc7324c
--- a/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/membership/GMSJoinLeaveTestHelper.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/membership/GMSJoinLeaveTestHelper.java
@@ -80,7 +80,7 @@ public class GMSJoinLeaveTestHelper {
     return getGmsJoinLeave().getView().getViewId();
   }
 
-  private static InternalDistributedSystem getInternalDistributedSystem() {
+  public static InternalDistributedSystem getInternalDistributedSystem() {
     waitCriterion();
     return getIDS();
   }



Mime
View raw message