Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IGNITE-23200 applyOnDefaultChannel logic fixes #11660

Open
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

FewJuho
Copy link
Contributor

@FewJuho FewJuho commented Nov 14, 2024

Thank you for submitting the pull request to the Apache Ignite.

In order to streamline the review of the contribution
we ask you to ensure the following steps have been taken:

The Contribution Checklist

  • There is a single JIRA ticket related to the pull request.
  • The web-link to the pull request is attached to the JIRA ticket.
  • The JIRA ticket has the Patch Available state.
  • The pull request body describes changes that have been made.
    The description explains WHAT and WHY was made instead of HOW.
  • The pull request title is treated as the final commit message.
    The following pattern must be used: IGNITE-XXXX Change summary where XXXX - number of JIRA issue.
  • A reviewer has been mentioned through the JIRA comments
    (see the Maintainers list)
  • The pull request has been checked by the Teamcity Bot and
    the green visa attached to the JIRA ticket (see TC.Bot: Check PR)

Notes

If you need any help, please email [email protected] or ask anу advice on http://asf.slack.com #ignite channel.

@@ -703,7 +703,8 @@ synchronized void initChannelHolders() {
curAddrs.putIfAbsent(addr, hld);
}

reinitHolders.add(hld);
if (!reinitHolders.contains(hld))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In most cases ArrayList#contains will traverse whole collection just to find that no such holder. Let's make the check more optimal.

int fixedAttemptsLimit = attemptsLimit;

// + 1 is only required if the failure list is empty/null
while (fixedAttemptsLimit + 1 > (failures == null ? 0 : failures.size())) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move +1 to var assignment.

while (attemptsLimit > (failures == null ? 0 : failures.size())) {
int fixedAttemptsLimit = attemptsLimit;

// + 1 is only required if the failure list is empty/null
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No valid comment.

@@ -681,6 +682,8 @@ synchronized void initChannelHolders() {
if (idx != -1)
currDfltHolder = holders.get(idx);

Set<ClientChannelHolder> uniqueHolders = new HashSet<>();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like, you don't need one more collection. You can base on existing logic:

  1. There is a loop over existing holders (see line 653)
  2. And there is a place where a new holder is created (see line 700)

public class ServicesFailoverTest extends AbstractThinClientTest {
/** */
@Test
public void test() throws Exception {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Let's add the test to existing test class - IgniteClientReconnectServicesTest.
  2. Name of the method must be somehow meaningful.

@@ -817,7 +819,11 @@ private <T> T applyOnDefaultChannel(
ClientOperation op,
@Nullable List<ClientConnectionException> failures
) {
while (attemptsLimit > (failures == null ? 0 : failures.size())) {
// +1 is required for the correct channel search if ReliableChannel#applyOnDefaultChannel#idx selects
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An additional attempt is needed because N+1 channels might be used for sending a message - first a random one, then each one from #channels in sequence.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't it be better to explain why this result of a random choice influences?

/** Test to verify service failover after a node failure. */
@Test
public void testServiceFailoverAfterNodeFailure() throws Exception {
String TEST_SRVC_NAME = "cluster-singleton-svc";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, you can use existing singleton service instead - CLUSTER_SINGLTON_SERVICE_NAME with TestServiceInterface.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants