Skip to content

Commit

Permalink
Enh 36384376 - [35575212->24.03] ENH: Improve JOINING member reportin…
Browse files Browse the repository at this point in the history
…g 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]
  • Loading branch information
jfialli committed Mar 8, 2024
1 parent 56c40bd commit 417839f
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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;

Expand Down Expand Up @@ -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();
Expand All @@ -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;
}
}

0 comments on commit 417839f

Please sign in to comment.