You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@helix.apache.org by GitBox <gi...@apache.org> on 2021/06/27 18:33:53 UTC

[GitHub] [helix] huizhilu opened a new pull request #1807: Add REST APIs for management mode

huizhilu opened a new pull request #1807:
URL: https://github.com/apache/helix/pull/1807


   ### 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?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:
   
   (If CI test fails due to known issue, please specify the issue and test PR locally. Then copy & paste the result of "mvn test" to here.)
   
   ### 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](http://chris.beams.io/posts/git-commit/)":
     1. Subject is separated from body by a blank line
     1. Subject is limited to 50 characters (not including Jira issue reference)
     1. Subject does not end with a period
     1. Subject uses the imperative mood ("add", not "adding")
     1. Body wraps at 72 characters
     1. 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)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


[GitHub] [helix] huizhilu merged pull request #1807: Add REST APIs for management mode

Posted by GitBox <gi...@apache.org>.
huizhilu merged pull request #1807:
URL: https://github.com/apache/helix/pull/1807


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


[GitHub] [helix] junkaixue commented on a change in pull request #1807: Add REST APIs for management mode

Posted by GitBox <gi...@apache.org>.
junkaixue commented on a change in pull request #1807:
URL: https://github.com/apache/helix/pull/1807#discussion_r660194035



##########
File path: helix-core/src/main/java/org/apache/helix/HelixAdmin.java
##########
@@ -381,6 +381,17 @@ void manuallyEnableMaintenanceMode(String clusterName, boolean enabled, String r
    */
   void setClusterManagementMode(ClusterManagementModeRequest request);
 
+  /**
+   * Gets cluster management status {@link ClusterManagementMode}: what mode the cluster is and
+   * whether the cluster has fully reached to that mode.
+   *
+   * @param clusterName cluster name
+   * @return {@link ClusterManagementMode}
+   */
+  default ClusterManagementMode getClusterManagementMode(String clusterName) {

Review comment:
       HelixAdmin is something not designed to let user implement. Even if they have different plugin, they should extend our implemented class.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


[GitHub] [helix] huizhilu merged pull request #1807: Add REST APIs for management mode

Posted by GitBox <gi...@apache.org>.
huizhilu merged pull request #1807:
URL: https://github.com/apache/helix/pull/1807


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


[GitHub] [helix] huizhilu commented on pull request #1807: Add REST APIs for management mode

Posted by GitBox <gi...@apache.org>.
huizhilu commented on pull request #1807:
URL: https://github.com/apache/helix/pull/1807#issuecomment-870136723


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


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


[GitHub] [helix] junkaixue commented on a change in pull request #1807: Add REST APIs for management mode

Posted by GitBox <gi...@apache.org>.
junkaixue commented on a change in pull request #1807:
URL: https://github.com/apache/helix/pull/1807#discussion_r659494208



##########
File path: helix-core/src/main/java/org/apache/helix/HelixAdmin.java
##########
@@ -381,6 +381,17 @@ void manuallyEnableMaintenanceMode(String clusterName, boolean enabled, String r
    */
   void setClusterManagementMode(ClusterManagementModeRequest request);
 
+  /**
+   * Gets cluster management status {@link ClusterManagementMode}: what mode the cluster is and
+   * whether the cluster has fully reached to that mode.
+   *
+   * @param clusterName cluster name
+   * @return {@link ClusterManagementMode}
+   */
+  default ClusterManagementMode getClusterManagementMode(String clusterName) {

Review comment:
       Why you need a default implementation here? We can make it in real implementation right? It is not necessary.

##########
File path: helix-core/src/main/java/org/apache/helix/manager/zk/ZKHelixAdmin.java
##########
@@ -521,6 +522,15 @@ public void setClusterManagementMode(ClusterManagementModeRequest request) {
     }
   }
 
+  @Override
+  public ClusterManagementMode getClusterManagementMode(String clusterName) {
+    HelixDataAccessor accessor =

Review comment:
       I remember we have getHelixDataAccessor()

##########
File path: helix-rest/src/main/java/org/apache/helix/rest/server/resources/helix/ClusterAccessor.java
##########
@@ -297,6 +305,113 @@ public Response updateCluster(@PathParam("clusterId") String clusterId,
     return OK();
   }
 
+  @ResponseMetered(name = HttpConstants.READ_REQUEST)
+  @Timed(name = HttpConstants.READ_REQUEST)
+  @GET
+  @Path("{clusterId}/management-mode")
+  public Response getClusterManagementMode(@PathParam("clusterId") String clusterId,
+      @QueryParam("showDetails") boolean showDetails) {
+    ClusterManagementMode mode = getHelixAdmin().getClusterManagementMode(clusterId);
+    if (mode == null) {
+      return notFound("Cluster " + clusterId + " is not in management mode");

Review comment:
       Better not return notFound. This is 404.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


[GitHub] [helix] huizhilu commented on a change in pull request #1807: Add REST APIs for management mode

Posted by GitBox <gi...@apache.org>.
huizhilu commented on a change in pull request #1807:
URL: https://github.com/apache/helix/pull/1807#discussion_r660195221



##########
File path: helix-core/src/main/java/org/apache/helix/HelixAdmin.java
##########
@@ -381,6 +381,17 @@ void manuallyEnableMaintenanceMode(String clusterName, boolean enabled, String r
    */
   void setClusterManagementMode(ClusterManagementModeRequest request);
 
+  /**
+   * Gets cluster management status {@link ClusterManagementMode}: what mode the cluster is and
+   * whether the cluster has fully reached to that mode.
+   *
+   * @param clusterName cluster name
+   * @return {@link ClusterManagementMode}
+   */
+  default ClusterManagementMode getClusterManagementMode(String clusterName) {

Review comment:
       Synced with JK.
   * we don’t expect users to implement (eg. user apis: HelixAdmin, HelixManager) -> no default
   * expect users to implement (eg. StateModel) -> default




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


[GitHub] [helix] huizhilu commented on a change in pull request #1807: Add REST APIs for management mode

Posted by GitBox <gi...@apache.org>.
huizhilu commented on a change in pull request #1807:
URL: https://github.com/apache/helix/pull/1807#discussion_r660195221



##########
File path: helix-core/src/main/java/org/apache/helix/HelixAdmin.java
##########
@@ -381,6 +381,17 @@ void manuallyEnableMaintenanceMode(String clusterName, boolean enabled, String r
    */
   void setClusterManagementMode(ClusterManagementModeRequest request);
 
+  /**
+   * Gets cluster management status {@link ClusterManagementMode}: what mode the cluster is and
+   * whether the cluster has fully reached to that mode.
+   *
+   * @param clusterName cluster name
+   * @return {@link ClusterManagementMode}
+   */
+  default ClusterManagementMode getClusterManagementMode(String clusterName) {

Review comment:
       Synced with JK.
   * we don’t expect users to implement (eg. user apis: HelixAdmin, HelixManager) -> no default
   * expect users to implement (eg. StateModel) -> default




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


[GitHub] [helix] huizhilu commented on a change in pull request #1807: Add REST APIs for management mode

Posted by GitBox <gi...@apache.org>.
huizhilu commented on a change in pull request #1807:
URL: https://github.com/apache/helix/pull/1807#discussion_r659510448



##########
File path: helix-core/src/main/java/org/apache/helix/HelixAdmin.java
##########
@@ -381,6 +381,17 @@ void manuallyEnableMaintenanceMode(String clusterName, boolean enabled, String r
    */
   void setClusterManagementMode(ClusterManagementModeRequest request);
 
+  /**
+   * Gets cluster management status {@link ClusterManagementMode}: what mode the cluster is and
+   * whether the cluster has fully reached to that mode.
+   *
+   * @param clusterName cluster name
+   * @return {@link ClusterManagementMode}
+   */
+  default ClusterManagementMode getClusterManagementMode(String clusterName) {

Review comment:
       It's for backwards compatibility. Because some users implements the `HelixAdmin` interface for MockHelixAdmin in their code, it would break the build when bumping up the new helix lib.

##########
File path: helix-rest/src/main/java/org/apache/helix/rest/server/resources/helix/ClusterAccessor.java
##########
@@ -297,6 +305,113 @@ public Response updateCluster(@PathParam("clusterId") String clusterId,
     return OK();
   }
 
+  @ResponseMetered(name = HttpConstants.READ_REQUEST)
+  @Timed(name = HttpConstants.READ_REQUEST)
+  @GET
+  @Path("{clusterId}/management-mode")
+  public Response getClusterManagementMode(@PathParam("clusterId") String clusterId,
+      @QueryParam("showDetails") boolean showDetails) {
+    ClusterManagementMode mode = getHelixAdmin().getClusterManagementMode(clusterId);
+    if (mode == null) {
+      return notFound("Cluster " + clusterId + " is not in management mode");

Review comment:
       It's aligned with the existing response for maintenance mode: `return notFound(String.format("Cluster %s is not in maintenance mode!", clusterId));`
   

##########
File path: helix-core/src/main/java/org/apache/helix/manager/zk/ZKHelixAdmin.java
##########
@@ -521,6 +522,15 @@ public void setClusterManagementMode(ClusterManagementModeRequest request) {
     }
   }
 
+  @Override
+  public ClusterManagementMode getClusterManagementMode(String clusterName) {
+    HelixDataAccessor accessor =

Review comment:
       That's in helix-rest, not in this ZKHelixAdmin implementation. In helix rest, we can use getHelixDataAccessor()




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


[GitHub] [helix] junkaixue commented on a change in pull request #1807: Add REST APIs for management mode

Posted by GitBox <gi...@apache.org>.
junkaixue commented on a change in pull request #1807:
URL: https://github.com/apache/helix/pull/1807#discussion_r660194035



##########
File path: helix-core/src/main/java/org/apache/helix/HelixAdmin.java
##########
@@ -381,6 +381,17 @@ void manuallyEnableMaintenanceMode(String clusterName, boolean enabled, String r
    */
   void setClusterManagementMode(ClusterManagementModeRequest request);
 
+  /**
+   * Gets cluster management status {@link ClusterManagementMode}: what mode the cluster is and
+   * whether the cluster has fully reached to that mode.
+   *
+   * @param clusterName cluster name
+   * @return {@link ClusterManagementMode}
+   */
+  default ClusterManagementMode getClusterManagementMode(String clusterName) {

Review comment:
       HelixAdmin is something not designed to let user implement. Even if they have different plugin, they should extend our implemented class.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


[GitHub] [helix] huizhilu commented on pull request #1807: Add REST APIs for management mode

Posted by GitBox <gi...@apache.org>.
huizhilu commented on pull request #1807:
URL: https://github.com/apache/helix/pull/1807#issuecomment-870136723


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


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org