You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by ab...@apache.org on 2016/12/02 01:43:46 UTC
[03/31] incubator-geode git commit: GEODE-2137 client membership IDs
contain 17 bytes of useless information
GEODE-2137 client membership IDs contain 17 bytes of useless information
This removes the UUID and member-weight bytes from the serialized form
of event IDs, version tags and client IDs while retaining them for server
IDs in general.
Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/9de8732a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/9de8732a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/9de8732a
Branch: refs/heads/feature/GEODE-2156
Commit: 9de8732a950a385ed97bfffb1a3483c5a9e5eefc
Parents: b633f67
Author: Bruce Schuchardt <bs...@pivotal.io>
Authored: Wed Nov 30 10:44:01 2016 -0800
Committer: Bruce Schuchardt <bs...@pivotal.io>
Committed: Wed Nov 30 10:44:41 2016 -0800
----------------------------------------------------------------------
.../internal/DistributionLocatorConfigImpl.java | 3 +-
.../membership/InternalDistributedMember.java | 446 +++-----
.../internal/membership/MemberAttributes.java | 3 +
.../internal/membership/NetMember.java | 36 +
.../internal/membership/gms/GMSMember.java | 55 +-
.../membership/gms/GMSMemberFactory.java | 2 +-
.../java/org/apache/geode/internal/Version.java | 9 +-
.../internal/cache/persistence/DiskStoreID.java | 10 -
.../cache/tier/sockets/CommandInitializer.java | 7 +-
.../internal/cache/versions/VersionSource.java | 2 -
.../internal/cache/versions/VersionTag.java | 9 -
.../geode/distributed/LocatorDUnitTest.java | 30 +-
.../geode/distributed/LocatorJUnitTest.java | 7 +-
.../apache/geode/distributed/RoleDUnitTest.java | 3 +-
.../internal/DistributionManagerDUnitTest.java | 30 +-
.../InternalDistributedSystemJUnitTest.java | 61 +-
.../gms/fd/GMSHealthMonitorJUnitTest.java | 13 +-
.../test/dunit/standalone/ProcessManager.java | 3 +-
.../sanctionedDataSerializables.txt | 1080 +++++++++---------
19 files changed, 861 insertions(+), 948 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9de8732a/geode-core/src/main/java/org/apache/geode/admin/internal/DistributionLocatorConfigImpl.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/admin/internal/DistributionLocatorConfigImpl.java b/geode-core/src/main/java/org/apache/geode/admin/internal/DistributionLocatorConfigImpl.java
index 851693a..65a29a8 100644
--- a/geode-core/src/main/java/org/apache/geode/admin/internal/DistributionLocatorConfigImpl.java
+++ b/geode-core/src/main/java/org/apache/geode/admin/internal/DistributionLocatorConfigImpl.java
@@ -66,11 +66,10 @@ public class DistributionLocatorConfigImpl extends ManagedEntityConfigImpl
* @return <code>null</code> if the locator cannot be contacted
*/
static DistributionLocatorConfig createConfigFor(String host, int port, InetAddress bindAddress) {
- TcpClient client = new TcpClient();
String[] info = new String[] {"unknown", "unknown"};
try {
- client = new TcpClient();
+ TcpClient client = new TcpClient();
if (bindAddress != null) {
info = client.getInfo(bindAddress, port);
} else {
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9de8732a/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/InternalDistributedMember.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/InternalDistributedMember.java b/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/InternalDistributedMember.java
index 0d4fd9e..3404495 100755
--- a/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/InternalDistributedMember.java
+++ b/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/InternalDistributedMember.java
@@ -50,38 +50,12 @@ public class InternalDistributedMember implements DistributedMember, Externaliza
protected NetMember netMbr; // the underlying member object, e.g. from JGroups
/**
- * This is the direct channel port. The underlying NetMember must be able to serialize and deliver
- * this value.
- */
- private int dcPort = -1;
-
- /**
- * This is the process id of this member on its machine. The underlying NetMember must be able to
- * serialize and deliver this value.
- */
- private int vmPid = -1;
-
- /**
- * This is a representation of the type of VM. The underlying NetMember must be able to serialize
- * and deliver this value.
- */
- private int vmKind = DistributionManager.NORMAL_DM_TYPE;
-
- /**
- * This is the view identifier where this ID was born, or zero if this is a loner member
- */
- private int vmViewId = -1;
-
- /**
* whether this is a partial member ID (without roles, durable attributes). We use partial IDs in
* EventID objects to reduce their size. It would be better to use canonical IDs but there is
* currently no central mechanism that would allow that for both server and client identifiers
*/
private boolean isPartial;
- /** Internal list of group/role names for this member. */
- private String[] groups;
-
/**
* The roles, if any, of this member. Lazily created first time getRoles() is called.
*/
@@ -91,13 +65,6 @@ public class InternalDistributedMember implements DistributedMember, Externaliza
private final Object rolesLock = new Object();
/**
- * The name of this member's distributed system connection.
- *
- * @see org.apache.geode.distributed.DistributedSystem#getName
- */
- private String name = null;
-
- /**
* Unique tag (such as randomly generated bytes) to help enforce uniqueness. Note: this should be
* displayable.
*/
@@ -115,24 +82,21 @@ public class InternalDistributedMember implements DistributedMember, Externaliza
/** product version bit flag */
private static final int VERSION_BIT = 0x8;
+ /** additional membership data */
+ private static final int NETMBR_DATA_BIT = 0x10;
+
/**
* Representing the host name of this member.
*/
private String hostName = null;
- private transient short version = Version.CURRENT_ORDINAL;
private transient Version versionObj = Version.CURRENT;
- /**
- * User-defined attributes (id and timeout) used by durable clients.
- */
- private DurableClientAttributes durableClientAttributes = null;
-
/** The versions in which this message was modified */
- private static final Version[] dsfidVersions = new Version[] {Version.GFE_71, Version.GFE_90};
+ private static final Version[] dsfidVersions = new Version[] {Version.GFE_71};
private void defaultToCurrentHost() {
- this.vmPid = OSProcess.getId();
+ netMbr.setProcessId(OSProcess.getId());
try {
if (SocketCreator.resolve_dns) {
this.hostName = SocketCreator.getHostName(SocketCreator.getLocalHost());
@@ -142,14 +106,11 @@ public class InternalDistributedMember implements DistributedMember, Externaliza
} catch (UnknownHostException ee) {
throw new InternalGemFireError(ee);
}
- synchPayload();
}
// Used only by Externalization
- public InternalDistributedMember() {
- this.groups = new String[0];
- }
+ public InternalDistributedMember() {}
/**
* Construct a InternalDistributedMember. All fields are specified.
@@ -167,17 +128,13 @@ public class InternalDistributedMember implements DistributedMember, Externaliza
*/
public InternalDistributedMember(InetAddress i, int p, boolean splitBrainEnabled,
boolean canBeCoordinator, MemberAttributes attr) {
- this.dcPort = attr.getPort();
- this.vmPid = attr.getVmPid();
- this.vmKind = attr.getVmKind();
- this.vmViewId = attr.getVmViewId();
- this.name = attr.getName();
- this.groups = attr.getGroups();
- this.durableClientAttributes = attr.getDurableClientAttributes();
+
this.netMbr = MemberFactory.newNetMember(i, p, splitBrainEnabled, canBeCoordinator,
Version.CURRENT_ORDINAL, attr);
+
this.hostName = SocketCreator.resolve_dns ? SocketCreator.getHostName(i) : i.getHostAddress();
- this.version = netMbr.getVersionOrdinal();
+
+ short version = netMbr.getVersionOrdinal();
try {
this.versionObj = Version.fromOrdinal(version, false);
} catch (UnsupportedVersionException e) {
@@ -198,22 +155,11 @@ public class InternalDistributedMember implements DistributedMember, Externaliza
public InternalDistributedMember(NetMember m) {
netMbr = m;
- MemberAttributes attr = m.getAttributes();
this.hostName = SocketCreator.resolve_dns ? SocketCreator.getHostName(m.getInetAddress())
: m.getInetAddress().getHostAddress();
// checkHostName();
- if (attr == null) {
- // no extended information available, so this address is crippled
- } else {
- this.dcPort = attr.getPort();
- this.vmPid = attr.getVmPid();
- this.vmKind = attr.getVmKind();
- this.vmViewId = attr.getVmViewId();
- this.name = attr.getName();
- this.groups = attr.getGroups();
- this.durableClientAttributes = attr.getDurableClientAttributes();
- }
- this.version = m.getVersionOrdinal();
+
+ short version = m.getVersionOrdinal();
try {
this.versionObj = Version.fromOrdinal(version, false);
} catch (UnsupportedVersionException e) {
@@ -263,9 +209,10 @@ public class InternalDistributedMember implements DistributedMember, Externaliza
} catch (UnknownHostException e) {
throw new GemFireConfigException("Unable to resolve server location " + location, e);
}
- this.netMbr = MemberFactory.newNetMember(addr, location.getPort());
- this.vmKind = DistributionManager.NORMAL_DM_TYPE;
- this.versionObj = Version.CURRENT;
+ netMbr = MemberFactory.newNetMember(addr, location.getPort());
+ netMbr.setVmKind(DistributionManager.NORMAL_DM_TYPE);
+ versionObj = Version.CURRENT;
+ netMbr.setVersion(versionObj);
}
/**
@@ -297,8 +244,9 @@ public class InternalDistributedMember implements DistributedMember, Externaliza
public InternalDistributedMember(String i, int p, Version version, NetMember netMember) {
netMbr = netMember;
defaultToCurrentHost();
- this.vmKind = DistributionManager.NORMAL_DM_TYPE;
+ netMember.setVmKind(DistributionManager.NORMAL_DM_TYPE);
this.versionObj = version;
+ netMember.setVersion(version);
}
/**
@@ -328,14 +276,13 @@ public class InternalDistributedMember implements DistributedMember, Externaliza
InetAddress addr = SocketCreator.toInetAddress(host);
netMbr = MemberFactory.newNetMember(addr, p, false, true, Version.CURRENT_ORDINAL, mattr);
defaultToCurrentHost();
- this.name = n;
+ netMbr.setName(n);
this.uniqueTag = u;
- this.vmKind = vmKind;
- this.dcPort = p;
- this.durableClientAttributes = attr;
+ netMbr.setVmKind(vmKind);
+ netMbr.setDirectPort(p);
+ netMbr.setDurableClientAttributes(attr);
this.hostName = host;
- this.vmPid = OSProcess.getId();
- this.groups = groups;
+ netMbr.setGroups(groups);
}
/**
@@ -402,7 +349,7 @@ public class InternalDistributedMember implements DistributedMember, Externaliza
*/
public int getDirectChannelPort() {
assert !this.isPartial;
- return dcPort;
+ return netMbr.getDirectPort();
}
/**
@@ -412,7 +359,7 @@ public class InternalDistributedMember implements DistributedMember, Externaliza
* @see org.apache.geode.distributed.internal.DistributionManager#NORMAL_DM_TYPE
*/
public int getVmKind() {
- return vmKind;
+ return netMbr.getVmKind();
}
/**
@@ -420,7 +367,7 @@ public class InternalDistributedMember implements DistributedMember, Externaliza
* this is limited to 16 bits.
*/
public int getVmViewId() {
- return this.vmViewId;
+ return netMbr.getVmViewId();
}
/**
@@ -435,7 +382,7 @@ public class InternalDistributedMember implements DistributedMember, Externaliza
synchronized (this.rolesLock) {
tmpRolesSet = this.rolesSet;
if (tmpRolesSet == null) {
- final String[] tmpRoles = this.groups;
+ final String[] tmpRoles = netMbr.getGroups();
// convert array of string role names to array of Roles...
if (tmpRoles == null || tmpRoles.length == 0) {
tmpRolesSet = Collections.emptySet();
@@ -454,34 +401,26 @@ public class InternalDistributedMember implements DistributedMember, Externaliza
}
public List<String> getGroups() {
- return Collections.unmodifiableList(Arrays.asList(this.groups));
+ return Collections.unmodifiableList(Arrays.asList(netMbr.getGroups()));
}
public void setGroups(String[] newGroups) {
assert !this.isPartial;
assert newGroups != null;
synchronized (this.rolesLock) {
- this.groups = newGroups;
- synchPayload();
+ netMbr.setGroups(newGroups);
this.rolesSet = null;
this.cachedToString = null;
}
}
- private void synchPayload() {
- netMbr.setAttributes(new MemberAttributes(dcPort, vmPid, vmKind, vmViewId, name, groups,
- durableClientAttributes));
- }
-
public void setVmKind(int p) {
- vmKind = p;
- synchPayload();
+ netMbr.setVmKind(p);
cachedToString = null;
}
public void setVmViewId(int p) {
- this.vmViewId = p;
- synchPayload();
+ netMbr.setVmViewId(p);
cachedToString = null;
}
@@ -492,7 +431,7 @@ public class InternalDistributedMember implements DistributedMember, Externaliza
* @since GemFire 4.0
*/
public int getVmPid() {
- return vmPid;
+ return netMbr.getProcessId();
}
/**
@@ -501,8 +440,7 @@ public class InternalDistributedMember implements DistributedMember, Externaliza
* @since GemFire 4.0
*/
public void setVmPid(int p) {
- this.vmPid = p;
- synchPayload();
+ netMbr.setProcessId(p);
cachedToString = null;
}
@@ -513,7 +451,7 @@ public class InternalDistributedMember implements DistributedMember, Externaliza
* @see org.apache.geode.distributed.DistributedSystem#getName
*/
public String getName() {
- String result = this.name;
+ String result = netMbr.getName();
if (result == null) {
result = "";
}
@@ -533,7 +471,12 @@ public class InternalDistributedMember implements DistributedMember, Externaliza
*/
public DurableClientAttributes getDurableClientAttributes() {
assert !this.isPartial;
- return this.durableClientAttributes;
+ DurableClientAttributes attributes = netMbr.getDurableClientAttributes();
+ if (attributes == null) {
+ attributes = new DurableClientAttributes("", 300);
+ netMbr.setDurableClientAttributes(attributes);
+ }
+ return netMbr.getDurableClientAttributes();
}
/**
@@ -605,14 +548,16 @@ public class InternalDistributedMember implements DistributedMember, Externaliza
return 1; // same as far as they go, but longer...
}
- if (this.name == null && other.name == null) {
+ String myName = getName();
+ String otherName = other.getName();
+ if (myName == null && otherName == null) {
// do nothing
- } else if (this.name == null) {
+ } else if (myName == null) {
return -1;
- } else if (other.name == null) {
+ } else if (otherName == null) {
return 1;
} else {
- int i = this.name.compareTo(other.name);
+ int i = myName.compareTo(otherName);
if (i != 0) {
return i;
}
@@ -621,10 +566,12 @@ public class InternalDistributedMember implements DistributedMember, Externaliza
if (this.uniqueTag == null && other.uniqueTag == null) {
if (verifyViewId) {
// not loners, so look at P2P view ID
- if (this.vmViewId >= 0 && other.vmViewId >= 0) {
- if (this.vmViewId < other.vmViewId) {
+ int thisViewId = getVmViewId();
+ int otherViewId = other.getVmViewId();
+ if (thisViewId >= 0 && otherViewId >= 0) {
+ if (thisViewId < otherViewId) {
return -1;
- } else if (this.vmViewId > other.vmViewId) {
+ } else if (thisViewId > otherViewId) {
return 1;
} // else they're the same, so continue
}
@@ -641,7 +588,7 @@ public class InternalDistributedMember implements DistributedMember, Externaliza
}
if (checkNetMembersIfEqual && this.netMbr != null && other.netMbr != null) {
- return this.netMbr.compareTo(other.netMbr);
+ return this.netMbr.compareAdditionalData(other.netMbr);
} else {
return 0;
}
@@ -703,6 +650,8 @@ public class InternalDistributedMember implements DistributedMember, Externaliza
sb.append(host);
String myName = getName();
+ int vmPid = netMbr.getProcessId();
+ int vmKind = netMbr.getVmKind();
if (vmPid > 0 || vmKind != DistributionManager.NORMAL_DM_TYPE || !"".equals(myName)) {
sb.append("(");
@@ -740,8 +689,9 @@ public class InternalDistributedMember implements DistributedMember, Externaliza
if (vmKind != DistributionManager.LONER_DM_TYPE && netMbr.preferredForCoordinator()) {
sb.append("<ec>");
}
- if (this.vmViewId >= 0) {
- sb.append("<v" + this.vmViewId + ">");
+ int vmViewId = getVmViewId();
+ if (vmViewId >= 0) {
+ sb.append("<v" + vmViewId + ">");
}
sb.append(":");
sb.append(getPort());
@@ -757,14 +707,16 @@ public class InternalDistributedMember implements DistributedMember, Externaliza
if (this.uniqueTag != null && this.uniqueTag.length() != 0) {
sb.append(":").append(this.uniqueTag);
}
- if (this.name != null && this.name.length() != 0) {
- sb.append(":").append(this.name);
+ String name = getName();
+ if (name.length() != 0) {
+ sb.append(":").append(name);
}
}
// add version if not current
- if (this.version != Version.CURRENT.ordinal()) {
- sb.append("(version:").append(Version.toString(this.version)).append(')');
+ short version = netMbr.getVersionOrdinal();
+ if (version != Version.CURRENT.ordinal()) {
+ sb.append("(version:").append(Version.toString(version)).append(')');
}
if (SHOW_NETMEMBER) {
@@ -783,17 +735,19 @@ public class InternalDistributedMember implements DistributedMember, Externaliza
return result;
}
- private void readVersion(int flags, DataInput in) throws IOException {
+ private short readVersion(int flags, DataInput in) throws IOException {
if ((flags & VERSION_BIT) != 0) {
- this.version = Version.readOrdinal(in);
- this.versionObj = Version.fromOrdinalNoThrow(this.version, false);
+ short version = Version.readOrdinal(in);
+ this.versionObj = Version.fromOrdinalNoThrow(version, false);
+ return version;
} else {
// prior to 7.1 member IDs did not serialize their version information
Version v = InternalDataSerializer.getVersionForDataStreamOrNull(in);
if (v != null) {
this.versionObj = v;
- this.version = v.ordinal();
+ return v.ordinal();
}
+ return Version.CURRENT_ORDINAL;
}
}
@@ -803,7 +757,7 @@ public class InternalDistributedMember implements DistributedMember, Externaliza
* @see Externalizable
*/
public void writeExternal(ObjectOutput out) throws IOException {
- Assert.assertTrue(vmKind > 0);
+ Assert.assertTrue(netMbr.getVmKind() > 0);
// do it the way we like
byte[] address = getInetAddress().getAddress();
@@ -826,21 +780,19 @@ public class InternalDistributedMember implements DistributedMember, Externaliza
flags |= VERSION_BIT;
out.writeByte((byte) (flags & 0xff));
- out.writeInt(dcPort);
- out.writeInt(vmPid);
- out.writeInt(vmKind);
- out.writeInt(vmViewId);
- DataSerializer.writeStringArray(this.groups, out);
+ out.writeInt(netMbr.getDirectPort());
+ out.writeInt(netMbr.getProcessId());
+ out.writeInt(netMbr.getVmKind());
+ out.writeInt(netMbr.getVmViewId());
+ DataSerializer.writeStringArray(netMbr.getGroups(), out);
- DataSerializer.writeString(this.name, out);
+ DataSerializer.writeString(netMbr.getName(), out);
DataSerializer.writeString(this.uniqueTag, out);
- DataSerializer.writeString(
- this.durableClientAttributes == null ? "" : this.durableClientAttributes.getId(), out);
- DataSerializer.writeInteger(
- Integer.valueOf(
- this.durableClientAttributes == null ? 300 : this.durableClientAttributes.getTimeout()),
+ DurableClientAttributes attributes = netMbr.getDurableClientAttributes();
+ DataSerializer.writeString(attributes == null ? "" : attributes.getId(), out);
+ DataSerializer.writeInteger(Integer.valueOf(attributes == null ? 300 : attributes.getTimeout()),
out);
- Version.writeOrdinal(out, this.version, true);
+ Version.writeOrdinal(out, netMbr.getVersionOrdinal(), true);
netMbr.writeAdditionalData(out);
}
@@ -863,32 +815,33 @@ public class InternalDistributedMember implements DistributedMember, Externaliza
boolean elCoord = (flags & COORD_ENABLED_BIT) != 0;
this.isPartial = (flags & PARTIAL_ID_BIT) != 0;
- this.dcPort = in.readInt();
- this.vmPid = in.readInt();
- this.vmKind = in.readInt();
- this.vmViewId = in.readInt();
- this.groups = DataSerializer.readStringArray(in);
+ int dcPort = in.readInt();
+ int vmPid = in.readInt();
+ int vmKind = in.readInt();
+ int vmViewId = in.readInt();
+ String[] groups = DataSerializer.readStringArray(in);
- this.name = DataSerializer.readString(in);
+ String name = DataSerializer.readString(in);
this.uniqueTag = DataSerializer.readString(in);
String durableId = DataSerializer.readString(in);
int durableTimeout = DataSerializer.readInteger(in).intValue();
- this.durableClientAttributes = new DurableClientAttributes(durableId, durableTimeout);
+ DurableClientAttributes durableClientAttributes =
+ new DurableClientAttributes(durableId, durableTimeout);
- readVersion(flags, in);
+ short version = readVersion(flags, in);
netMbr = MemberFactory.newNetMember(inetAddr, port, sbEnabled, elCoord, version,
new MemberAttributes(dcPort, vmPid, vmKind, vmViewId, name, groups,
durableClientAttributes));
- if (this.version >= Version.GFE_90.ordinal()) {
+ if (version >= Version.GFE_90.ordinal()) {
try {
netMbr.readAdditionalData(in);
} catch (java.io.EOFException e) {
- // old version quand-meme
+ // old version
}
}
- Assert.assertTrue(this.vmKind > 0);
+ Assert.assertTrue(netMbr.getVmKind() > 0);
}
public int getDSFID() {
@@ -896,14 +849,6 @@ public class InternalDistributedMember implements DistributedMember, Externaliza
}
public void toData(DataOutput out) throws IOException {
- toDataPre_GFE_9_0_0_0(out);
- if (this.version >= Version.GFE_90.ordinal()) {
- getNetMember().writeAdditionalData(out);
- }
- }
-
-
- public void toDataPre_GFE_9_0_0_0(DataOutput out) throws IOException {
// Assert.assertTrue(vmKind > 0);
// NOTE: If you change the serialized format of this class
// then bump Connection.HANDSHAKE_VERSION since an
@@ -923,30 +868,39 @@ public class InternalDistributedMember implements DistributedMember, Externaliza
// always write product version but enable reading from older versions
// that do not have it
flags |= VERSION_BIT;
+ boolean writeNetMbrData = netMbr.hasAdditionalData();
+ if (writeNetMbrData) {
+ flags |= NETMBR_DATA_BIT;
+ }
out.writeByte((byte) (flags & 0xff));
- out.writeInt(dcPort);
- out.writeInt(vmPid);
+ out.writeInt(netMbr.getDirectPort());
+ out.writeInt(netMbr.getProcessId());
+ int vmKind = netMbr.getVmKind();
out.writeByte(vmKind);
- DataSerializer.writeStringArray(this.groups, out);
+ DataSerializer.writeStringArray(netMbr.getGroups(), out);
- DataSerializer.writeString(this.name, out);
- if (this.vmKind == DistributionManager.LONER_DM_TYPE) {
+ DataSerializer.writeString(netMbr.getName(), out);
+ if (vmKind == DistributionManager.LONER_DM_TYPE) {
DataSerializer.writeString(this.uniqueTag, out);
} else { // added in 6.5 for unique identifiers in P2P
- DataSerializer.writeString(String.valueOf(this.vmViewId), out);
+ DataSerializer.writeString(String.valueOf(netMbr.getVmViewId()), out);
+ }
+ DurableClientAttributes durableClientAttributes = netMbr.getDurableClientAttributes();
+ DataSerializer
+ .writeString(durableClientAttributes == null ? "" : durableClientAttributes.getId(), out);
+ DataSerializer.writeInteger(Integer.valueOf(
+ durableClientAttributes == null ? 300 : durableClientAttributes.getTimeout()), out);
+ short version = netMbr.getVersionOrdinal();
+ Version.writeOrdinal(out, version, true);
+
+ if (version >= Version.GFE_90.ordinal() && writeNetMbrData) {
+ getNetMember().writeAdditionalData(out);
}
- DataSerializer.writeString(
- this.durableClientAttributes == null ? "" : this.durableClientAttributes.getId(), out);
- DataSerializer.writeInteger(
- Integer.valueOf(
- this.durableClientAttributes == null ? 300 : this.durableClientAttributes.getTimeout()),
- out);
- Version.writeOrdinal(out, this.version, true);
}
public void toDataPre_GFE_7_1_0_0(DataOutput out) throws IOException {
- Assert.assertTrue(vmKind > 0);
+ Assert.assertTrue(netMbr.getVmKind() > 0);
// [bruce] disabled to allow post-connect setting of the port for loner systems
// Assert.assertTrue(getPort() > 0);
// if (this.getPort() == 0) {
@@ -971,40 +925,27 @@ public class InternalDistributedMember implements DistributedMember, Externaliza
flags |= PARTIAL_ID_BIT;
out.writeByte((byte) (flags & 0xff));
- out.writeInt(dcPort);
- out.writeInt(vmPid);
- out.writeByte(vmKind);
- DataSerializer.writeStringArray(this.groups, out);
+ out.writeInt(netMbr.getDirectPort());
+ out.writeInt(netMbr.getProcessId());
+ out.writeByte(netMbr.getVmKind());
+ DataSerializer.writeStringArray(netMbr.getGroups(), out);
- DataSerializer.writeString(this.name, out);
- if (this.vmKind == DistributionManager.LONER_DM_TYPE) {
+ DataSerializer.writeString(netMbr.getName(), out);
+ int vmKind = netMbr.getVmKind();
+ if (vmKind == DistributionManager.LONER_DM_TYPE) {
DataSerializer.writeString(this.uniqueTag, out);
} else { // added in 6.5 for unique identifiers in P2P
- DataSerializer.writeString(String.valueOf(this.vmViewId), out);
+ DataSerializer.writeString(String.valueOf(netMbr.getVmViewId()), out);
}
- DataSerializer.writeString(
- this.durableClientAttributes == null ? "" : this.durableClientAttributes.getId(), out);
- DataSerializer.writeInteger(
- Integer.valueOf(
- this.durableClientAttributes == null ? 300 : this.durableClientAttributes.getTimeout()),
- out);
-
+ DurableClientAttributes durableClientAttributes = netMbr.getDurableClientAttributes();
+ DataSerializer
+ .writeString(durableClientAttributes == null ? "" : durableClientAttributes.getId(), out);
+ DataSerializer.writeInteger(Integer.valueOf(
+ durableClientAttributes == null ? 300 : durableClientAttributes.getTimeout()), out);
}
- public void fromData(DataInput in) throws IOException, ClassNotFoundException {
- fromDataPre_GFE_9_0_0_0(in);
- // just in case this is just a non-versioned read
- // from a file we ought to check the version
- if (this.version >= Version.GFE_90.ordinal()) {
- try {
- netMbr.readAdditionalData(in);
- } catch (EOFException e) {
- // nope - it's from a pre-GEODE client or WAN site
- }
- }
- }
- public void fromDataPre_GFE_9_0_0_0(DataInput in) throws IOException, ClassNotFoundException {
+ public void fromData(DataInput in) throws IOException, ClassNotFoundException {
InetAddress inetAddr = DataSerializer.readInetAddress(in);
int port = in.readInt();
@@ -1018,35 +959,41 @@ public class InternalDistributedMember implements DistributedMember, Externaliza
boolean elCoord = (flags & COORD_ENABLED_BIT) != 0;
this.isPartial = (flags & PARTIAL_ID_BIT) != 0;
- this.dcPort = in.readInt();
- this.vmPid = in.readInt();
- this.vmKind = in.readUnsignedByte();
- this.groups = DataSerializer.readStringArray(in);
+ int dcPort = in.readInt();
+ int vmPid = in.readInt();
+ int vmKind = in.readUnsignedByte();
+ String[] groups = DataSerializer.readStringArray(in);
+ int vmViewId = -1;
- this.name = DataSerializer.readString(in);
- if (this.vmKind == DistributionManager.LONER_DM_TYPE) {
+ String name = DataSerializer.readString(in);
+ if (vmKind == DistributionManager.LONER_DM_TYPE) {
this.uniqueTag = DataSerializer.readString(in);
} else {
String str = DataSerializer.readString(in);
if (str != null) { // backward compatibility from earlier than 6.5
- this.vmViewId = Integer.parseInt(str);
+ vmViewId = Integer.parseInt(str);
}
}
String durableId = DataSerializer.readString(in);
int durableTimeout = DataSerializer.readInteger(in).intValue();
- this.durableClientAttributes = new DurableClientAttributes(durableId, durableTimeout);
+ DurableClientAttributes durableClientAttributes =
+ durableId.length() > 0 ? new DurableClientAttributes(durableId, durableTimeout) : null;
- readVersion(flags, in);
+ short version = readVersion(flags, in);
- MemberAttributes attr = new MemberAttributes(this.dcPort, this.vmPid, this.vmKind,
- this.vmViewId, this.name, this.groups, this.durableClientAttributes);
+ MemberAttributes attr = new MemberAttributes(dcPort, vmPid, vmKind, vmViewId, name, groups,
+ durableClientAttributes);
netMbr = MemberFactory.newNetMember(inetAddr, port, sbEnabled, elCoord, version, attr);
- synchPayload();
-
- Assert.assertTrue(this.vmKind > 0);
+ Assert.assertTrue(netMbr.getVmKind() > 0);
// Assert.assertTrue(getPort() > 0);
+
+ // just in case this is just a non-versioned read
+ // from a file we ought to check the version
+ if (version >= Version.GFE_90.ordinal() && (flags & NETMBR_DATA_BIT) == NETMBR_DATA_BIT) {
+ netMbr.readAdditionalData(in);
+ }
}
public void fromDataPre_GFE_7_1_0_0(DataInput in) throws IOException, ClassNotFoundException {
@@ -1054,6 +1001,7 @@ public class InternalDistributedMember implements DistributedMember, Externaliza
int port = in.readInt();
this.hostName = DataSerializer.readString(in);
+
this.hostName = SocketCreator.resolve_dns
? SocketCreator.getCanonicalHostName(inetAddr, hostName) : inetAddr.getHostAddress();
@@ -1062,36 +1010,37 @@ public class InternalDistributedMember implements DistributedMember, Externaliza
boolean elCoord = (flags & COORD_ENABLED_BIT) != 0;
this.isPartial = (flags & PARTIAL_ID_BIT) != 0;
- this.dcPort = in.readInt();
- this.vmPid = in.readInt();
- this.vmKind = in.readUnsignedByte();
- this.groups = DataSerializer.readStringArray(in);
+ int dcPort = in.readInt();
+ int vmPid = in.readInt();
+ int vmKind = in.readUnsignedByte();
+ String[] groups = DataSerializer.readStringArray(in);
+ int vmViewId = -1;
- this.name = DataSerializer.readString(in);
- if (this.vmKind == DistributionManager.LONER_DM_TYPE) {
+ String name = DataSerializer.readString(in);
+ if (vmKind == DistributionManager.LONER_DM_TYPE) {
this.uniqueTag = DataSerializer.readString(in);
} else {
String str = DataSerializer.readString(in);
if (str != null) { // backward compatibility from earlier than 6.5
- this.vmViewId = Integer.parseInt(str);
+ vmViewId = Integer.parseInt(str);
}
}
String durableId = DataSerializer.readString(in);
int durableTimeout = DataSerializer.readInteger(in).intValue();
- this.durableClientAttributes = new DurableClientAttributes(durableId, durableTimeout);
+ DurableClientAttributes durableClientAttributes =
+ durableId.length() > 0 ? new DurableClientAttributes(durableId, durableTimeout) : null;
- MemberAttributes attr = new MemberAttributes(this.dcPort, this.vmPid, this.vmKind,
- this.vmViewId, this.name, this.groups, this.durableClientAttributes);
- netMbr = MemberFactory.newNetMember(inetAddr, port, sbEnabled, elCoord,
- InternalDataSerializer.getVersionForDataStream(in).ordinal(), attr);
+ short version = readVersion(flags, in);
- synchPayload();
+ MemberAttributes attr = new MemberAttributes(dcPort, vmPid, vmKind, vmViewId, name, groups,
+ durableClientAttributes);
+ netMbr = MemberFactory.newNetMember(inetAddr, port, sbEnabled, elCoord, version, attr);
- Assert.assertTrue(this.vmKind > 0);
+ Assert.assertTrue(netMbr.getVmKind() > 0);
}
- /** this writes just the parts of the ID that are needed for comparisons and communications */
+ /** this reads an ID written with writeEssentialData */
public static InternalDistributedMember readEssentialData(DataInput in)
throws IOException, ClassNotFoundException {
final InternalDistributedMember mbr = new InternalDistributedMember();
@@ -1111,35 +1060,32 @@ public class InternalDistributedMember implements DistributedMember, Externaliza
boolean sbEnabled = (flags & NPD_ENABLED_BIT) != 0;
boolean elCoord = (flags & COORD_ENABLED_BIT) != 0;
- this.vmKind = in.readUnsignedByte();
-
+ int vmKind = in.readUnsignedByte();
+ int vmViewId = -1;
- if (this.vmKind == DistributionManager.LONER_DM_TYPE) {
+ if (vmKind == DistributionManager.LONER_DM_TYPE) {
this.uniqueTag = DataSerializer.readString(in);
} else {
String str = DataSerializer.readString(in);
if (str != null) { // backward compatibility from earlier than 6.5
- this.vmViewId = Integer.parseInt(str);
+ vmViewId = Integer.parseInt(str);
}
}
- this.name = DataSerializer.readString(in);
+ String name = DataSerializer.readString(in);
- MemberAttributes attr = new MemberAttributes(this.dcPort, this.vmPid, this.vmKind,
- this.vmViewId, this.name, this.groups, this.durableClientAttributes);
+ MemberAttributes attr = new MemberAttributes(-1, -1, vmKind, vmViewId, name, null, null);
netMbr = MemberFactory.newNetMember(inetAddr, port, sbEnabled, elCoord,
InternalDataSerializer.getVersionForDataStream(in).ordinal(), attr);
- synchPayload();
-
- if (InternalDataSerializer.getVersionForDataStream(in).compareTo(Version.GFE_90) >= 0) {
+ if (InternalDataSerializer.getVersionForDataStream(in).compareTo(Version.GFE_90) == 0) {
netMbr.readAdditionalData(in);
}
}
public void writeEssentialData(DataOutput out) throws IOException {
- Assert.assertTrue(vmKind > 0);
+ Assert.assertTrue(netMbr.getVmKind() > 0);
DataSerializer.writeInetAddress(getInetAddress(), out);
out.writeInt(getPort());
@@ -1152,17 +1098,18 @@ public class InternalDistributedMember implements DistributedMember, Externaliza
out.writeByte((byte) (flags & 0xff));
// out.writeInt(dcPort);
+ byte vmKind = netMbr.getVmKind();
out.writeByte(vmKind);
- if (this.vmKind == DistributionManager.LONER_DM_TYPE) {
+ if (vmKind == DistributionManager.LONER_DM_TYPE) {
DataSerializer.writeString(this.uniqueTag, out);
} else { // added in 6.5 for unique identifiers in P2P
- DataSerializer.writeString(String.valueOf(this.vmViewId), out);
+ DataSerializer.writeString(String.valueOf(netMbr.getVmViewId()), out);
}
// write name last to fix bug 45160
- DataSerializer.writeString(this.name, out);
+ DataSerializer.writeString(netMbr.getName(), out);
- if (InternalDataSerializer.getVersionForDataStream(out).compareTo(Version.GFE_90) >= 0) {
+ if (InternalDataSerializer.getVersionForDataStream(out).compareTo(Version.GFE_90) == 0) {
netMbr.writeAdditionalData(out);
}
}
@@ -1171,8 +1118,7 @@ public class InternalDistributedMember implements DistributedMember, Externaliza
* [GemStone] Set the direct channel port
*/
public void setDirectChannelPort(int p) {
- dcPort = p;
- synchPayload();
+ netMbr.setDirectPort(p);
}
/**
@@ -1180,9 +1126,8 @@ public class InternalDistributedMember implements DistributedMember, Externaliza
* information to help form a unique ID
*/
public void setPort(int p) {
- assert this.vmKind == DistributionManager.LONER_DM_TYPE;
+ assert netMbr.getVmKind() == DistributionManager.LONER_DM_TYPE;
this.netMbr.setPort(p);
- synchPayload();
cachedToString = null;
}
@@ -1196,7 +1141,7 @@ public class InternalDistributedMember implements DistributedMember, Externaliza
}
public int getProcessId() {
- return this.vmPid;
+ return netMbr.getProcessId();
}
public String getId() {
@@ -1216,7 +1161,6 @@ public class InternalDistributedMember implements DistributedMember, Externaliza
*/
public final void setVersionObjectForTest(Version v) {
- this.version = v.ordinal();
this.versionObj = v;
netMbr.setVersion(v);
}
@@ -1231,32 +1175,6 @@ public class InternalDistributedMember implements DistributedMember, Externaliza
}
- @Override
- public int getSizeInBytes() {
-
- int size = 0;
-
- // ipaddr: 1 byte length + 4 bytes (IPv4) or 16 bytes (IPv6)
- if (netMbr.getInetAddress() instanceof Inet4Address) {
- size += 5;
- } else {
- size += 17;
- }
-
- // port: 4 bytes
- // flags: 1 byte
- // vmKind: 1 byte
- size += 6;
-
- // viewID: String(1+1+numchars)
- size += (2 + String.valueOf(this.vmViewId).length());
-
- // empty name: String(1+1)
- size += 2;
-
- return size;
- }
-
public static class InternalDistributedMemberWrapper {
InternalDistributedMember mbr;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9de8732a/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/MemberAttributes.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/MemberAttributes.java b/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/MemberAttributes.java
index 75cdd49..f8ea15d 100755
--- a/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/MemberAttributes.java
+++ b/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/MemberAttributes.java
@@ -19,6 +19,7 @@ import java.util.List;
import java.util.StringTokenizer;
import org.apache.geode.distributed.DurableClientAttributes;
+import org.apache.geode.distributed.internal.DistributionManager;
/**
* The attributes of a distributed member. This is largely deprecated as GMSMember holds all of this
@@ -30,6 +31,8 @@ public class MemberAttributes {
public static final MemberAttributes INVALID =
new MemberAttributes(-1, -1, -1, -1, null, null, null);
+ public static final MemberAttributes DEFAULT =
+ new MemberAttributes(-1, -1, DistributionManager.NORMAL_DM_TYPE, -1, null, null, null);
private int dcPort;
private int vmPid;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9de8732a/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/NetMember.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/NetMember.java b/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/NetMember.java
index 4db207f..1f909f2 100755
--- a/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/NetMember.java
+++ b/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/NetMember.java
@@ -19,7 +19,9 @@ import java.io.DataOutput;
import java.io.IOException;
import java.net.InetAddress;
+import org.apache.geode.distributed.DurableClientAttributes;
import org.apache.geode.internal.Version;
+import org.apache.geode.internal.shared.StringPrintWriter;
/**
* This is the SPI for the basic element of membership provided in the GemFire system.
@@ -70,10 +72,44 @@ public interface NetMember extends Comparable<NetMember> {
public void setVersion(Version v);
+ public int getProcessId();
+
+ public void setProcessId(int id);
+
+ public byte getVmKind();
+
+ public void setVmKind(int kind);
+
+ public int getVmViewId();
+
+ public void setVmViewId(int id);
+
+ public int getDirectPort();
+
+ public void setDirectPort(int port);
+
+ public String getName();
+
+ public void setName(String name);
+
+ public DurableClientAttributes getDurableClientAttributes();
+
+ public void setDurableClientAttributes(DurableClientAttributes attributes);
+
+ public String[] getGroups();
+
+ public void setGroups(String[] groups);
+
+ /** whether this NetMember has additional data to be serialized as part of a DistributedMember */
+ public boolean hasAdditionalData();
+
/** write identity information not known by DistributedMember instances */
public void writeAdditionalData(DataOutput out) throws IOException;
/** read identity information not known by DistributedMember instances */
public void readAdditionalData(DataInput in) throws ClassNotFoundException, IOException;
+ /** compare data that is not known to DistributedMember instances */
+ public int compareAdditionalData(NetMember other);
+
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9de8732a/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/gms/GMSMember.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/gms/GMSMember.java b/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/gms/GMSMember.java
index 670d62b..b7079f8 100755
--- a/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/gms/GMSMember.java
+++ b/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/gms/GMSMember.java
@@ -22,11 +22,11 @@ import org.apache.geode.distributed.internal.membership.NetMember;
import org.apache.geode.internal.DataSerializableFixedID;
import org.apache.geode.internal.Version;
import org.apache.geode.internal.i18n.LocalizedStrings;
-
import org.jgroups.util.UUID;
import java.io.DataInput;
import java.io.DataOutput;
+import java.io.EOFException;
import java.io.IOException;
import java.net.InetAddress;
import java.net.UnknownHostException;
@@ -54,13 +54,13 @@ public class GMSMember implements NetMember, DataSerializableFixedID {
private byte memberWeight;
private InetAddress inetAddr;
private int processId;
- private int vmKind;
+ private byte vmKind;
private int vmViewId = -1;
private int directPort;
private String name;
private DurableClientAttributes durableClientAttributes;
private String[] groups;
- private short versionOrdinal;
+ private short versionOrdinal = Version.CURRENT_ORDINAL;
private long uuidLSBs;
private long uuidMSBs;
@@ -80,7 +80,7 @@ public class GMSMember implements NetMember, DataSerializableFixedID {
attr = MemberAttributes.INVALID;
}
processId = attr.getVmPid();
- vmKind = attr.getVmKind();
+ vmKind = (byte) attr.getVmKind();
directPort = attr.getPort();
vmViewId = attr.getVmViewId();
name = attr.getName();
@@ -260,6 +260,24 @@ public class GMSMember implements NetMember, DataSerializableFixedID {
}
@Override
+ public int compareAdditionalData(NetMember other) {
+ GMSMember his = (GMSMember) other;
+ int result = 0;
+ if (this.uuidMSBs != 0 && his.uuidMSBs != 0) {
+ if (this.uuidMSBs < his.uuidMSBs) {
+ result = -1;
+ } else if (his.uuidMSBs < this.uuidMSBs) {
+ result = 1;
+ } else if (this.uuidLSBs < his.uuidLSBs) {
+ result = -1;
+ } else if (his.uuidLSBs < this.uuidLSBs) {
+ result = 1;
+ }
+ }
+ return result;
+ }
+
+ @Override
public boolean equals(Object obj) {
// GemStone fix for 29125
if ((obj == null) || !(obj instanceof GMSMember)) {
@@ -309,7 +327,7 @@ public class GMSMember implements NetMember, DataSerializableFixedID {
return processId;
}
- public int getVmKind() {
+ public byte getVmKind() {
return vmKind;
}
@@ -317,6 +335,11 @@ public class GMSMember implements NetMember, DataSerializableFixedID {
return vmViewId;
}
+ @Override
+ public void setVmViewId(int id) {
+ this.vmViewId = id;
+ }
+
public int getDirectPort() {
return directPort;
}
@@ -354,7 +377,7 @@ public class GMSMember implements NetMember, DataSerializableFixedID {
}
public void setVmKind(int vmKind) {
- this.vmKind = vmKind;
+ this.vmKind = (byte) vmKind;
}
public void setVersion(Version v) {
@@ -377,6 +400,11 @@ public class GMSMember implements NetMember, DataSerializableFixedID {
this.durableClientAttributes = durableClientAttributes;
}
+ @Override
+ public String[] getGroups() {
+ return groups;
+ }
+
public void setGroups(String[] groups) {
this.groups = groups;
}
@@ -462,6 +490,11 @@ public class GMSMember implements NetMember, DataSerializableFixedID {
}
@Override
+ public boolean hasAdditionalData() {
+ return uuidMSBs != 0 || uuidLSBs != 0 || memberWeight != 0;
+ }
+
+ @Override
public void writeAdditionalData(DataOutput out) throws IOException {
out.writeLong(uuidMSBs);
out.writeLong(uuidLSBs);
@@ -470,8 +503,12 @@ public class GMSMember implements NetMember, DataSerializableFixedID {
@Override
public void readAdditionalData(DataInput in) throws ClassNotFoundException, IOException {
- this.uuidMSBs = in.readLong();
- this.uuidLSBs = in.readLong();
- memberWeight = (byte) (in.readByte() & 0xFF);
+ try {
+ this.uuidMSBs = in.readLong();
+ this.uuidLSBs = in.readLong();
+ memberWeight = (byte) (in.readByte() & 0xFF);
+ } catch (EOFException e) {
+ // some IDs do not have UUID or membership weight information
+ }
}
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9de8732a/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/gms/GMSMemberFactory.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/gms/GMSMemberFactory.java b/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/gms/GMSMemberFactory.java
index c84690a..bc94ab5 100755
--- a/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/gms/GMSMemberFactory.java
+++ b/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/gms/GMSMemberFactory.java
@@ -71,7 +71,7 @@ public class GMSMemberFactory implements MemberServices {
* @return the new NetMember
*/
public NetMember newNetMember(InetAddress i, int p) {
- return new GMSMember(MemberAttributes.INVALID, i, p, false, true, Version.CURRENT_ORDINAL, 0,
+ return new GMSMember(MemberAttributes.DEFAULT, i, p, false, true, Version.CURRENT_ORDINAL, 0,
0);
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9de8732a/geode-core/src/main/java/org/apache/geode/internal/Version.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/Version.java b/geode-core/src/main/java/org/apache/geode/internal/Version.java
index fabb3a7..5f7c5ba 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/Version.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/Version.java
@@ -59,7 +59,7 @@ public final class Version implements Comparable<Version> {
/** byte used as ordinal to represent this <code>Version</code> */
private final short ordinal;
- public static final int HIGHEST_VERSION = 45;
+ public static final int HIGHEST_VERSION = 50;
private static final Version[] VALUES = new Version[HIGHEST_VERSION + 1];
@@ -180,11 +180,16 @@ public final class Version implements Comparable<Version> {
public static final Version GFE_90 =
new Version("GFE", "9.0", (byte) 9, (byte) 0, (byte) 0, (byte) 0, GFE_90_ORDINAL);
+ private static final byte GFE_91_ORDINAL = 50;
+
+ public static final Version GFE_91 =
+ new Version("GFE", "9.1", (byte) 9, (byte) 1, (byte) 0, (byte) 0, GFE_91_ORDINAL);
+
/**
* This constant must be set to the most current version of the product. !!! NOTE: update
* HIGHEST_VERSION when changing CURRENT !!!
*/
- public static final Version CURRENT = GFE_90;
+ public static final Version CURRENT = GFE_91;
/**
* A lot of versioning code needs access to the current version's ordinal
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9de8732a/geode-core/src/main/java/org/apache/geode/internal/cache/persistence/DiskStoreID.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/persistence/DiskStoreID.java b/geode-core/src/main/java/org/apache/geode/internal/cache/persistence/DiskStoreID.java
index e94b081..c357e9b 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/persistence/DiskStoreID.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/persistence/DiskStoreID.java
@@ -150,14 +150,4 @@ public class DiskStoreID implements VersionSource<DiskStoreID>, Serializable {
return Long.toHexString(mostSig).substring(8);
}
- @Override
- public int getSizeInBytes() {
-
- int size = 0;
-
- // two longs
- size += 16;
-
- return size;
- }
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9de8732a/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/CommandInitializer.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/CommandInitializer.java b/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/CommandInitializer.java
index 0fe44cf..2f6b963 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/CommandInitializer.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/CommandInitializer.java
@@ -329,8 +329,13 @@ public class CommandInitializer {
ALL_COMMANDS.put(Version.GFE_90, gfe90Commands);
gfe90Commands.put(MessageType.QUERY_WITH_PARAMETERS, QueryWithParametersGeode10.getCommand());
gfe90Commands.put(MessageType.QUERY, QueryGeode10.getCommand());
-
}
+ {
+ Map<Integer, Command> gfe91Commands = new HashMap<Integer, Command>();
+ gfe91Commands.putAll(ALL_COMMANDS.get(Version.GFE_90));
+ ALL_COMMANDS.put(Version.GFE_91, gfe91Commands);
+ }
+
}
public static Map<Integer, Command> getCommands(Version version) {
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9de8732a/geode-core/src/main/java/org/apache/geode/internal/cache/versions/VersionSource.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/versions/VersionSource.java b/geode-core/src/main/java/org/apache/geode/internal/cache/versions/VersionSource.java
index bfbda2f..a53f999 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/versions/VersionSource.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/versions/VersionSource.java
@@ -35,6 +35,4 @@ public interface VersionSource<T> extends DataSerializableFixedID, Comparable<T>
public void writeEssentialData(DataOutput out) throws IOException;
- public int getSizeInBytes();
-
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9de8732a/geode-core/src/main/java/org/apache/geode/internal/cache/versions/VersionTag.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/versions/VersionTag.java b/geode-core/src/main/java/org/apache/geode/internal/cache/versions/VersionTag.java
index fa2c156..d502299 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/versions/VersionTag.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/versions/VersionTag.java
@@ -415,15 +415,6 @@ public abstract class VersionTag<T extends VersionSource>
public abstract void writeMember(T memberID, DataOutput out) throws IOException;
- public int getSizeInBytes() {
- int size =
- org.apache.geode.internal.cache.lru.Sizeable.PER_OBJECT_OVERHEAD + VersionTag.TAG_SIZE;
- // member size calculation
- size += memberID.getSizeInBytes();
- return size;
-
- }
-
@Override
public String toString() {
StringBuilder s = new StringBuilder();
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9de8732a/geode-core/src/test/java/org/apache/geode/distributed/LocatorDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/distributed/LocatorDUnitTest.java b/geode-core/src/test/java/org/apache/geode/distributed/LocatorDUnitTest.java
index 128f970..10c9238 100644
--- a/geode-core/src/test/java/org/apache/geode/distributed/LocatorDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/distributed/LocatorDUnitTest.java
@@ -451,8 +451,8 @@ public class LocatorDUnitTest extends JUnit4DistributedTestCase {
@Test
public void testStartTwoLocatorsOneWithSSLAndTheOtherNonSSL() throws Exception {
- IgnoredException expectedException =
- IgnoredException.addIgnoredException("Unrecognized SSL message, plaintext connection");
+ IgnoredException.addIgnoredException("Unrecognized SSL message, plaintext connection");
+ IgnoredException.addIgnoredException("LocatorCancelException");
disconnectAllFromDS();
Host host = Host.getHost(0);
VM loc1 = host.getVM(1);
@@ -496,7 +496,6 @@ public class LocatorDUnitTest extends JUnit4DistributedTestCase {
loc1.invoke("verifyLocatorNotInSplitBrain", () -> verifyLocatorNotInSplitBrain(1));
} finally {
loc1.invoke("stop locator", () -> stopLocator());
- expectedException.remove();
}
}
}
@@ -510,11 +509,10 @@ public class LocatorDUnitTest extends JUnit4DistributedTestCase {
@Test
public void testStartTwoLocatorsOneWithNonSSLAndTheOtherSSL() throws Exception {
- IgnoredException expectedException =
- IgnoredException.addIgnoredException("Remote host closed connection during handshake");
+ IgnoredException.addIgnoredException("Remote host closed connection during handshake");
+ IgnoredException.addIgnoredException("Unrecognized SSL message, plaintext connection");
+ IgnoredException.addIgnoredException("LocatorCancelException");
- IgnoredException expectedException2 =
- IgnoredException.addIgnoredException("Unrecognized SSL message, plaintext connection");
disconnectAllFromDS();
Host host = Host.getHost(0);
VM loc1 = host.getVM(1);
@@ -559,23 +557,19 @@ public class LocatorDUnitTest extends JUnit4DistributedTestCase {
loc1.invoke("verifyLocatorNotInSplitBrain", () -> verifyLocatorNotInSplitBrain(1));
} finally {
loc1.invoke("stop locator", () -> stopLocator());
- expectedException.remove();
- expectedException2.remove();
}
}
}
@Test
public void testStartTwoLocatorsWithDifferentSSLCertificates() throws Exception {
- IgnoredException expectedException =
- IgnoredException.addIgnoredException("Remote host closed connection during handshake");
- IgnoredException expectedException2 = IgnoredException
+ IgnoredException.addIgnoredException("Remote host closed connection during handshake");
+ IgnoredException
.addIgnoredException("unable to find valid certification path to requested target");
- IgnoredException expectedException3 =
- IgnoredException.addIgnoredException("Received fatal alert: certificate_unknown");
+ IgnoredException.addIgnoredException("Received fatal alert: certificate_unknown");
+ IgnoredException.addIgnoredException("LocatorCancelException");
disconnectAllFromDS();
- IgnoredException expectedException4 =
- IgnoredException.addIgnoredException("Unrecognized SSL message, plaintext connection");
+ IgnoredException.addIgnoredException("Unrecognized SSL message, plaintext connection");
disconnectAllFromDS();
Host host = Host.getHost(0);
VM loc1 = host.getVM(1);
@@ -622,10 +616,6 @@ public class LocatorDUnitTest extends JUnit4DistributedTestCase {
loc1.invoke("verifyLocatorNotInSplitBrain", () -> verifyLocatorNotInSplitBrain(1));
} finally {
loc1.invoke("stop locator", () -> stopLocator());
- expectedException.remove();
- expectedException2.remove();
- expectedException3.remove();
- expectedException4.remove();
}
}
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9de8732a/geode-core/src/test/java/org/apache/geode/distributed/LocatorJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/distributed/LocatorJUnitTest.java b/geode-core/src/test/java/org/apache/geode/distributed/LocatorJUnitTest.java
index d1e56c4..368b037 100644
--- a/geode-core/src/test/java/org/apache/geode/distributed/LocatorJUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/distributed/LocatorJUnitTest.java
@@ -45,6 +45,7 @@ import java.io.File;
import java.io.IOException;
import java.net.InetAddress;
import java.util.*;
+import java.util.concurrent.TimeUnit;
import java.util.function.IntSupplier;
import static org.apache.geode.distributed.ConfigurationProperties.*;
@@ -52,6 +53,8 @@ import static org.apache.geode.internal.AvailablePort.SOCKET;
import static org.apache.geode.internal.AvailablePort.getRandomAvailablePort;
import static org.junit.Assert.*;
+import com.jayway.awaitility.Awaitility;
+
@Category({IntegrationTest.class, MembershipTest.class})
@RunWith(Parameterized.class)
@Parameterized.UseParametersRunnerFactory(CategoryWithParameterizedRunnerFactory.class)
@@ -108,7 +111,7 @@ public class LocatorJUnitTest {
System.setProperty(DistributionConfig.GEMFIRE_PREFIX + "disableManagement", "false"); // not
// needed
try {
- locator = Locator.startLocatorAndDS(port, new File("testJmxManager.log"), dsprops);
+ locator = Locator.startLocatorAndDS(port, null, dsprops);
List<JmxManagerProfile> alreadyManaging =
GemFireCacheImpl.getInstance().getJmxManagerAdvisor().adviseAlreadyManaging();
assertEquals(1, alreadyManaging.size());
@@ -177,7 +180,7 @@ public class LocatorJUnitTest {
props.setProperty(MCAST_PORT, "0");
props.setProperty(ConfigurationProperties.ENABLE_CLUSTER_CONFIGURATION, "false");
- locator = Locator.startLocatorAndDS(port, tmpFile, null, props);
+ locator = Locator.startLocatorAndDS(port, new File(""), null, props);
assertTrue(locator.isPeerLocator());
assertTrue(locator.isServerLocator());
Thread.sleep(1000);
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9de8732a/geode-core/src/test/java/org/apache/geode/distributed/RoleDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/distributed/RoleDUnitTest.java b/geode-core/src/test/java/org/apache/geode/distributed/RoleDUnitTest.java
index d804703..77ad879 100755
--- a/geode-core/src/test/java/org/apache/geode/distributed/RoleDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/distributed/RoleDUnitTest.java
@@ -21,6 +21,7 @@ import java.util.Iterator;
import java.util.Properties;
import java.util.Set;
+import org.apache.geode.test.junit.categories.MembershipTest;
import org.junit.Test;
import org.junit.experimental.categories.Category;
@@ -36,7 +37,7 @@ import org.apache.geode.test.junit.categories.DistributedTest;
/**
* Tests the setting of Roles in a DistributedSystem
*/
-@Category(DistributedTest.class)
+@Category({DistributedTest.class, MembershipTest.class})
public class RoleDUnitTest extends JUnit4DistributedTestCase {
static Properties distributionProperties = new Properties();
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9de8732a/geode-core/src/test/java/org/apache/geode/distributed/internal/DistributionManagerDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/distributed/internal/DistributionManagerDUnitTest.java b/geode-core/src/test/java/org/apache/geode/distributed/internal/DistributionManagerDUnitTest.java
index b38a769..f7f4979 100644
--- a/geode-core/src/test/java/org/apache/geode/distributed/internal/DistributionManagerDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/distributed/internal/DistributionManagerDUnitTest.java
@@ -17,9 +17,12 @@ package org.apache.geode.distributed.internal;
import static org.apache.geode.distributed.ConfigurationProperties.*;
import static org.apache.geode.test.dunit.Assert.*;
+import com.jayway.awaitility.Awaitility;
+
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.Properties;
+import java.util.concurrent.TimeUnit;
import org.apache.geode.test.junit.categories.MembershipTest;
import org.apache.logging.log4j.Logger;
@@ -105,34 +108,21 @@ public class DistributionManagerDUnitTest extends JUnit4DistributedTestCase {
/**
* Send the distribution manager a message it can't deserialize
*/
- @Ignore("TODO: use Awaitility and reenable assertions")
@Test
public void testExceptionInThreads() throws InterruptedException {
- DM dm = getSystem().getDistributionManager();
+ DistributionManager dm = (DistributionManager) getSystem().getDistributionManager();
String p1 = "ItsOkayForMyClassNotToBeFound";
logger.info("<ExpectedException action=add>" + p1 + "</ExpectedException>");
DistributionMessage m = new ItsOkayForMyClassNotToBeFound();
dm.putOutgoing(m);
Thread.sleep(1 * 1000);
logger.info("<ExpectedException action=remove>" + p1 + "</ExpectedException>");
- // assertTrue(dm.exceptionInThreads());
- // dm.clearExceptionInThreads();
- // assertTrue(!dm.exceptionInThreads());
- }
-
- @Ignore("TODO: this passes when enabled")
- @Test
- public void testGetDistributionManagerIds() {
- int systemCount = 0;
- for (int h = 0; h < Host.getHostCount(); h++) {
- Host host = Host.getHost(h);
- systemCount += host.getSystemCount();
- }
-
- DM dm = getSystem().getDistributionManager();
- systemCount += 1;
-
- assertEquals(systemCount, dm.getNormalDistributionManagerIds().size());
+ Awaitility.await("waiting for exceptionInThreads to be true").atMost(15, TimeUnit.SECONDS)
+ .until(() -> {
+ return dm.exceptionInThreads();
+ });
+ dm.clearExceptionInThreads();
+ assertTrue(!dm.exceptionInThreads());
}
/**
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9de8732a/geode-core/src/test/java/org/apache/geode/distributed/internal/InternalDistributedSystemJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/distributed/internal/InternalDistributedSystemJUnitTest.java b/geode-core/src/test/java/org/apache/geode/distributed/internal/InternalDistributedSystemJUnitTest.java
index 49e8fa6..07c6f38 100644
--- a/geode-core/src/test/java/org/apache/geode/distributed/internal/InternalDistributedSystemJUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/distributed/internal/InternalDistributedSystemJUnitTest.java
@@ -279,26 +279,6 @@ public class InternalDistributedSystemJUnitTest {
}
/**
- * Test a configuration with an <code>mcastPort</code> of zero and an empty <code>locators</code>.
- *
- * @deprecated This test creates a "loner" distributed system
- */
- @Ignore
- @Test
- public void testEmptyLocators() {
- Properties props = new Properties();
- props.put(MCAST_PORT, String.valueOf(0));
- props.put(LOCATORS, "");
- try {
- createSystem(props);
- fail("Should have thrown an IllegalArgumentException");
-
- } catch (IllegalArgumentException ex) {
- // pass...
- }
- }
-
- /**
* Tests that getting the log level is what we expect.
*/
@Test
@@ -356,10 +336,10 @@ public class InternalDistributedSystemJUnitTest {
Properties props = new Properties();
props.setProperty(MCAST_PORT, "0");
props.setProperty(LOCATORS, "");
- props.setProperty(MEMBERSHIP_PORT_RANGE, "5100-5200");
+ props.setProperty(MEMBERSHIP_PORT_RANGE, "45100-45200");
DistributionConfig config = createSystem(props).getConfig();
- assertEquals(5100, config.getMembershipPortRange()[0]);
- assertEquals(5200, config.getMembershipPortRange()[1]);
+ assertEquals(45100, config.getMembershipPortRange()[0]);
+ assertEquals(45200, config.getMembershipPortRange()[1]);
}
@Test
@@ -389,41 +369,6 @@ public class InternalDistributedSystemJUnitTest {
assertEquals(fileName, config.getStatisticArchiveFile().getName());
}
- /**
- * @deprecated This test cannot be run because the gemfire.ack-wait-threshold system property is
- * set on this VM, thus overriding the value passed into the API.
- */
- @Ignore
- @Test
- public void testGetAckWaitThreshold() {
- String time = String.valueOf(DistributionConfig.MIN_ACK_WAIT_THRESHOLD);
- Properties props = new Properties();
- // a loner is all this test needs
- props.setProperty(MCAST_PORT, "0");
- props.setProperty(LOCATORS, "");
- props.put(ACK_WAIT_THRESHOLD, time);
- DistributionConfig config = createSystem(props).getConfig();
- assertEquals(Integer.parseInt(time), config.getAckWaitThreshold());
- }
-
- /**
- * @deprecated This test cannot be run because the gemfire.ack-wait-threshold system property is
- * set on this VM, thus overriding the value passed into the API.
- */
- @Ignore
- @Test
- public void testInvalidAckWaitThreshold() {
- Properties props = new Properties();
- props.put(ACK_WAIT_THRESHOLD, "blah");
- try {
- createSystem(props);
- fail("Should have thrown an IllegalArgumentException");
-
- } catch (IllegalArgumentException ex) {
- // pass...
- }
- }
-
@Test
public void testGetCacheXmlFile() {
String fileName = "blah";
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9de8732a/geode-core/src/test/java/org/apache/geode/distributed/internal/membership/gms/fd/GMSHealthMonitorJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/distributed/internal/membership/gms/fd/GMSHealthMonitorJUnitTest.java b/geode-core/src/test/java/org/apache/geode/distributed/internal/membership/gms/fd/GMSHealthMonitorJUnitTest.java
index ebf87be..792a1fd 100644
--- a/geode-core/src/test/java/org/apache/geode/distributed/internal/membership/gms/fd/GMSHealthMonitorJUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/distributed/internal/membership/gms/fd/GMSHealthMonitorJUnitTest.java
@@ -52,6 +52,7 @@ import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
+import java.util.concurrent.TimeUnit;
import static org.apache.geode.distributed.ConfigurationProperties.*;
import static org.junit.Assert.assertFalse;
@@ -60,6 +61,8 @@ import static org.mockito.Matchers.any;
import static org.mockito.Matchers.isA;
import static org.mockito.Mockito.*;
+import com.jayway.awaitility.Awaitility;
+
@Category({IntegrationTest.class, MembershipTest.class})
public class GMSHealthMonitorJUnitTest {
@@ -336,11 +339,11 @@ public class GMSHealthMonitorJUnitTest {
gmsHealthMonitor.processMessage(sm);
- Thread.sleep(2 * memberTimeout + 200);
-
- System.out.println("testRemoveMemberCalled ending");
- verify(joinLeave, atLeastOnce()).remove(any(InternalDistributedMember.class),
- any(String.class));
+ Awaitility.await("waiting for remove(member) to be invoked")
+ .atMost(3 * memberTimeout, TimeUnit.SECONDS).until(() -> {
+ verify(joinLeave, atLeastOnce()).remove(any(InternalDistributedMember.class),
+ any(String.class));
+ });
Assert.assertTrue(gmsHealthMonitor.getStats().getSuspectsReceived() > 0);
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9de8732a/geode-core/src/test/java/org/apache/geode/test/dunit/standalone/ProcessManager.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/test/dunit/standalone/ProcessManager.java b/geode-core/src/test/java/org/apache/geode/test/dunit/standalone/ProcessManager.java
index c3c33d0..7852db5 100644
--- a/geode-core/src/test/java/org/apache/geode/test/dunit/standalone/ProcessManager.java
+++ b/geode-core/src/test/java/org/apache/geode/test/dunit/standalone/ProcessManager.java
@@ -191,7 +191,8 @@ public class ProcessManager {
cmds.add("-Xmx512m");
cmds.add("-D" + DistributionConfig.GEMFIRE_PREFIX + "DEFAULT_MAX_OPLOG_SIZE=10");
cmds.add("-D" + DistributionConfig.GEMFIRE_PREFIX + "disallowMcastDefaults=true");
- cmds.add("-D" + DistributionConfig.RESTRICT_MEMBERSHIP_PORT_RANGE + "=true");
+ cmds.add("-D" + DistributionConfig.GEMFIRE_PREFIX
+ + DistributionConfig.RESTRICT_MEMBERSHIP_PORT_RANGE + "=true");
cmds.add("-ea");
cmds.add("-XX:MetaspaceSize=512m");
cmds.add("-XX:+PrintGC");