From 417839fc23daf3d64e32c6b3dacea1c22c320d2e Mon Sep 17 00:00:00 2001 From: "joe.fialli" Date: Fri, 8 Mar 2024 16:45:58 -0500 Subject: [PATCH] Enh 36384376 - [35575212->24.03] ENH: Improve JOINING member reporting version for 14c releases (main->ce-main) Remote remote.full on coherence-ce/main success, changes 107336, synced @107336, job.9.20240308195738.6601 [git-p4: depot-paths = "//dev/coherence-ce/main/": change = 107338] --- .../serviceMemberSet/MasterMemberSet.java | 24 +++++++-- .../component/net/MemberSetTest.java | 51 ++++++++++++++++++- 2 files changed, 70 insertions(+), 5 deletions(-) diff --git a/prj/coherence-core-components/src/main/java/com/tangosol/coherence/component/net/memberSet/actualMemberSet/serviceMemberSet/MasterMemberSet.java b/prj/coherence-core-components/src/main/java/com/tangosol/coherence/component/net/memberSet/actualMemberSet/serviceMemberSet/MasterMemberSet.java index 8e0a9bc2fe32a..953521b6a3257 100644 --- a/prj/coherence-core-components/src/main/java/com/tangosol/coherence/component/net/memberSet/actualMemberSet/serviceMemberSet/MasterMemberSet.java +++ b/prj/coherence-core-components/src/main/java/com/tangosol/coherence/component/net/memberSet/actualMemberSet/serviceMemberSet/MasterMemberSet.java @@ -1,6 +1,6 @@ /* - * Copyright (c) 2000, 2023, Oracle and/or its affiliates. + * Copyright (c) 2000, 2024, Oracle and/or its affiliates. * * Licensed under the Universal Permissive License v 1.0 as shown at * https://oss.oracle.com/licenses/upl. @@ -54,6 +54,14 @@ public class MasterMemberSet * absolute maximum is 255 * 32 = 8160.) */ public static final int MAX_MEMBERS = 8160; + + /** + * Property TRANSPORT_COMPATIBILITY + * + * Denotes that a Member's VERSION is not actual version, but transport compatibility version in Coherence log. + * @see #appendVersion(StringBuilder, int) + */ + public static final String TRANSPORT_COMPATIBILITY = "Compat["; /** * Property MaximumPacketLength @@ -265,8 +273,18 @@ protected void appendTransportHeader(StringBuilder sb) // Declared at the super level protected void appendVersion(StringBuilder sb, int nMember) { - sb.append('|') - .append(getServiceVersionExternal(nMember)); + int nState = getState(nMember); + + sb.append('|'); + if (nState <= MEMBER_JOINING) + { + sb.append(TRANSPORT_COMPATIBILITY); + } + sb.append(getServiceVersionExternal(nMember)); + if (nState <= MEMBER_JOINING) + { + sb.append("]"); + } } // Declared at the super level diff --git a/prj/test/unit/coherence-tests/src/test/java/com/tangosol/coherence/component/net/MemberSetTest.java b/prj/test/unit/coherence-tests/src/test/java/com/tangosol/coherence/component/net/MemberSetTest.java index b46df25d2c435..31e37badc23e1 100644 --- a/prj/test/unit/coherence-tests/src/test/java/com/tangosol/coherence/component/net/MemberSetTest.java +++ b/prj/test/unit/coherence-tests/src/test/java/com/tangosol/coherence/component/net/MemberSetTest.java @@ -1,19 +1,22 @@ /* - * Copyright (c) 2000, 2022, Oracle and/or its affiliates. + * Copyright (c) 2000, 2024, Oracle and/or its affiliates. * * Licensed under the Universal Permissive License v 1.0 as shown at - * http://oss.oracle.com/licenses/upl. + * https://oss.oracle.com/licenses/upl. */ package com.tangosol.coherence.component.net; import com.tangosol.coherence.component.net.memberSet.ActualMemberSet; +import com.tangosol.coherence.component.net.memberSet.actualMemberSet.ServiceMemberSet; +import com.tangosol.coherence.component.net.memberSet.actualMemberSet.serviceMemberSet.MasterMemberSet; import org.junit.Test; import java.util.HashSet; import java.util.Set; +import static com.tangosol.coherence.component.net.memberSet.actualMemberSet.serviceMemberSet.MasterMemberSet.TRANSPORT_COMPATIBILITY; import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.not; @@ -59,6 +62,40 @@ public void testRandom() assertThat(nMember, is(0)); } + // unit test for COH-28004 + @Test + public void validateCompatForMemberJoiningVersion() + { + MasterMemberSet setMembers = instantiateMasterMemberSet(new int[] {1,2,3,4,5}); + + // simulate various MEMBER states encountered during Coherence member joining cluster + setMembers.setState(1, ServiceMemberSet.MEMBER_JOINED); + setMembers.setState(2, ServiceMemberSet.MEMBER_JOINED); + setMembers.setState(3, ServiceMemberSet.MEMBER_JOINING); + setMembers.setState(4, ServiceMemberSet.MEMBER_NEW); + setMembers.setState(5, ServiceMemberSet.MEMBER_LEAVING); + + + // validate MasterMemberset.getDescription() from joined cluster log message + int nCompatCount = 0; + + for (String sLine : setMembers.getDescription().split("\\R")) + { + if (sLine.contains("JOINING") || sLine.contains("NEW")) + { + assertThat("validating " + sLine + " contains \" + TRANSPORT_COMPATIBILITY\"", + sLine.contains(TRANSPORT_COMPATIBILITY), is(true)); + nCompatCount++; + } + else if (sLine.contains("JOINED") || sLine.contains("LEAVING")) + { + assertThat("validating " + sLine + " does not contain " + TRANSPORT_COMPATIBILITY, + sLine.contains(TRANSPORT_COMPATIBILITY), is(false)); + } + } + assertThat(nCompatCount, is(2)); + } + protected static MemberSet instantiateMemberSet(int[] anMember) { MemberSet setMembers = new ActualMemberSet(); @@ -68,4 +105,14 @@ protected static MemberSet instantiateMemberSet(int[] anMember) } return setMembers; } + + protected static MasterMemberSet instantiateMasterMemberSet(int[] anMember) + { + MasterMemberSet setMembers = new MasterMemberSet(); + for (int nMember : anMember) + { + setMembers.add(MemberTest.instantiateMember(nMember)); + } + return setMembers; + } } \ No newline at end of file