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

Change partitionAssignment API to handle ANY_LIVEINSTANCE #2817

Merged

Conversation

GrantPSpencer
Copy link
Contributor

@GrantPSpencer GrantPSpencer commented Jun 26, 2024

Issues

  • My PR addresses the following Helix issues and references them in the PR description:

#2816
partitionAssignment fails to calculate when there is FULL_AUTO resource that has ANY_LIVEINSTANCE for replica count.

Description

partitionAssignment fails due to Integer.parseInt(idealState.getReplicas()) in the getIdealAssignmentForFullAuto method. idealState.getReplicas() returns "ANY_LIVEINSTANCE" which then fails to be parsed to an int.

This change switches to the getReplicaCount() method which takes a default value if the replica count is ANY_LIVEINSTANCE.

Tests

  • The following tests are written for this issue:

Added a resource that utilizes ANY_LIVEINSTANCE into the testComputePartitionAssignmentMaintenanceMode test method. Without the changes to getReplicas()

  • The following is the result of the "mvn test" command on the appropriate module:
    $ mvn test -o -Dtest=TestPartitionAssignmentAPI.java -pl=helix-rest
[INFO] Tests run: 3, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 147.587 s - in org.apache.helix.rest.server.TestPartitionAssignmentAPI
[INFO] 
[INFO] Results:
[INFO] 
[INFO] Tests run: 3, Failures: 0, Errors: 0, Skipped: 0
[INFO] 
[INFO] 
[INFO] --- jacoco:0.8.6:report (generate-code-coverage-report) @ helix-rest ---
[INFO] Loading execution data file /Users/gspencer/Desktop/git-repos/helix/helix-rest/target/jacoco.exec
[INFO] Analyzed bundle 'Apache Helix :: Restful Interface' with 95 classes
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  02:34 min
[INFO] Finished at: 2024-06-26T16:23:02-07:00
[INFO] ------------------------------------------------------------------------

Changes that Break Backward Compatibility (Optional)

  • My PR contains changes that break backward compatibility or previous assumptions for certain methods or API. They include:

Change to the return value of getReplicas when called on a resource with ANY_LIVEINSTANCE as its replica count.

Commits

  • My commits all reference appropriate Apache Helix GitHub issues in their subject lines. In addition, my commits follow the guidelines from "How to write a good git commit message":
    1. Subject is separated from body by a blank line
    2. Subject is limited to 50 characters (not including Jira issue reference)
    3. Subject does not end with a period
    4. Subject uses the imperative mood ("add", not "adding")
    5. Body wraps at 72 characters
    6. Body explains "what" and "why", not "how"

Code Quality

  • My diff has been formatted using helix-style.xml
    (helix-style-intellij.xml if IntelliJ IDE is used)

@GrantPSpencer GrantPSpencer force-pushed the partitionassignment-anyliveinstance-fix branch from d378b76 to dd067eb Compare June 27, 2024 21:09
Copy link
Contributor

@junkaixue junkaixue left a comment

Choose a reason for hiding this comment

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

I am OK with the change. But have we double check other places in the code?

@GrantPSpencer GrantPSpencer changed the title make getReplicas always return int for ANY_LIVEINSTANCE Change partitionAssignment API to handle ANY_LIVEINSTANCE Jun 28, 2024
@GrantPSpencer
Copy link
Contributor Author

@junkaixue Updated 2 other areas where getReplicas was called without handling possible number format exception

@GrantPSpencer
Copy link
Contributor Author

Failed due to 2 flaky tests:
updateInstance - #2744

partitionAssignmentAPI afterTest - #2754

Error:  Test failed: updateInstance(org.apache.helix.rest.server.TestPerInstanceAccessor)  Time elapsed: 0.526 s  <<< FAILURE!
Error:  Test failed: afterTest(org.apache.helix.rest.server.TestPartitionAssignmentAPI)  Time elapsed: 12.493 s  <<< FAILURE!

@GrantPSpencer
Copy link
Contributor Author

Pull request approved @junkaixue
Commit message: Handle ANY_LIVEINSTANCE by calling getReplicaCount

@junkaixue junkaixue merged commit 2deef9d into apache:master Jul 17, 2024
1 of 2 checks passed
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