Skip to content

Add REST APIs for management mode#1807

Merged
huizhilu merged 2 commits intoapache:cluster-pause-modefrom
huizhilu:freeze-rest
Jun 29, 2021
Merged

Add REST APIs for management mode#1807
huizhilu merged 2 commits intoapache:cluster-pause-modefrom
huizhilu:freeze-rest

Conversation

@huizhilu
Copy link
Contributor

@huizhilu huizhilu commented Jun 27, 2021

Issues

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

Resolves #1741

Description

  • Here are some details about my PR, including screenshots of any UI changes:

Helix provides JAVA and REST APIs to set management mode and get the management mode status.
This PR adds a java api to get management status in HelixAdmin:
ClusterManagementMode getClusterManagementMode(String clusterName)

REST APIs:

POST /clusters/<cluster>/management-mode

GET  /clusters/myCluster/management-mode
QueryParam: showDetails

Examples:

POST /clusters/<cluster>/management-mode -d \
'{
  "mode": "CLUSTER_FREEZE",
  "cancelPendingST": false,
  "reason": "Freeze cluster for maintenance and let pending ST finish"
}'
 
Status: 200
{
    "acknowledged": true
}


GET  /clusters/myCluster/management-mode 
// Sample 1: Fully frozen. No pending state transitions.
{
    "cluster": "myCluster",
    "mode": "CLUSTER_FREEZE",
    "status": "COMPLETED"
}


GET  /clusters/myCluster/management-mode?showDetails=true
{
  "cluster": "myCluster",
  "mode": "CLUSTER_FREEZE",
  "status": "IN_PROGRESS",
  "details": {
    "cluster": {
      "cluster": "myCluster",
      "status": "IN_PROGRESS"
    },
    "liveInstances": {
      "status": "IN_PROGRESS",
      "hasPendingStateTransition": false,
      "liveInstancesInProgress": [
        "node-1",
        "node-2"
      ]
    }
  }
}

Tests

  • The following tests are written for this issue:

TestClusterAccessor#testClusterFreezeMode

  • The following is the result of the "mvn test" command on the appropriate module:
17:27:24,990 [INFO] Tests run: 179, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 97.365 s - in TestSuite
17:27:25,437 [INFO]
17:27:25,437 [INFO] Results:
17:27:25,437 [INFO]
17:27:25,438 [INFO] Tests run: 179, Failures: 0, Errors: 0, Skipped: 0
17:27:25,438 [INFO]
17:27:25,445 [INFO]
17:27:25,445 [INFO] --- jacoco-maven-plugin:0.8.6:report (generate-code-coverage-report) @ helix-rest ---
17:27:25,480 [INFO] Loading execution data file /home/hulu/Projects/helix/helix-rest/target/jacoco.exec
17:27:25,633 [INFO] Analyzed bundle 'Apache Helix :: Restful Interface' with 79 classes
17:27:25,882 [INFO] ------------------------------------------------------------------------
17:27:25,883 [INFO] BUILD SUCCESS
17:27:25,883 [INFO] ------------------------------------------------------------------------
17:27:25,884 [INFO] Total time:  01:44 min
17:27:25,885 [INFO] Finished at: 2021-06-28T17:27:25-07:00
17:27:25,885 [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:

(Consider including all behavior changes for public methods or API. Also include these changes in merge description so that other developers are aware of these changes. This allows them to make relevant code changes in feature branches accounting for the new method/API behavior.)

Documentation (Optional)

  • In case of new functionality, my PR adds documentation in the following wiki page:

(Link the GitHub wiki you added)

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)

@huizhilu huizhilu marked this pull request as ready for review June 28, 2021 19:07
Copy link

@alirezazamani alirezazamani left a comment

Choose a reason for hiding this comment

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

LGTM

@huizhilu
Copy link
Contributor Author

This PR is ready to be merged, approved by @alirezazamani

@huizhilu huizhilu merged commit 793272b into apache:cluster-pause-mode Jun 29, 2021
@huizhilu huizhilu deleted the freeze-rest branch June 29, 2021 00:28
huizhilu added a commit to huizhilu/helix that referenced this pull request Jul 16, 2021
This commit adds JAVA and REST APIs to set cluster freeze mode and get the management mode status
huizhilu added a commit to huizhilu/helix that referenced this pull request Jul 16, 2021
This commit adds JAVA and REST APIs to set cluster freeze mode and get the management mode status
huizhilu added a commit that referenced this pull request Jul 16, 2021
This commit adds JAVA and REST APIs to set cluster freeze mode and get the management mode status
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants