pkuwm commented on a change in pull request #1494:
URL: https://github.com/apache/helix/pull/1494#discussion_r513906307



##########
File path: 
helix-rest/src/main/java/org/apache/helix/rest/server/resources/helix/ClusterAccessor.java
##########
@@ -282,6 +282,17 @@ public Response updateCluster(@PathParam("clusterId") 
String clusterId,
           return badRequest(e.getMessage());
         }
         break;
+      case purgeOfflineParticipants:
+        Map<String, String> customizedPurgeMap = new HashMap<>();
+        try {
+          customizedPurgeMap =
+              OBJECT_MAPPER.readValue(content, new 
TypeReference<HashMap<String, String>>() {
+              });
+        } catch (Exception e) {
+          // NOP

Review comment:
       Can we have a warning log for why json parsing fails which could help us 
debug.
   Not sure if we have a unit test to test this kind of failure: content(eg. 
format) is incorret. Then we should not return OK, but a bad client request. 

##########
File path: 
helix-core/src/main/java/org/apache/helix/manager/zk/ZKHelixAdmin.java
##########
@@ -2061,4 +2070,45 @@ public ZKHelixAdmin build() {
               _zkAddress), false);
     }
   }
+
+  private Map<String, InstanceConfig> findTimeoutOfflineInstances(String 
clusterName,
+      Map<String, String> customizedPurgeMap) {

Review comment:
       From the API logic, it seems what is needed is only `timeout`? Then I 
think we don't have to pass along the map, but only the `timeout` value from 
the rest api layer: `timeout = 
customizedPurgeMap.get(OFFLINE_NODE_PURGE_TIMEOUT);`
   Then the APIs only need the timeout param, not a map.

##########
File path: 
helix-core/src/main/java/org/apache/helix/manager/zk/ZKHelixAdmin.java
##########
@@ -250,6 +252,13 @@ public void dropInstance(String clusterName, 
InstanceConfig instanceConfig) {
     }
   }
 
+  @Override
+  public void purgeOfflineInstances(String clusterName, Map<String, String> 
customizedPurgeMap) {
+    Map<String, InstanceConfig> timeoutOfflineInstances = 
findTimeoutOfflineInstances(clusterName,
+        customizedPurgeMap);
+    timeoutOfflineInstances.values().forEach(value -> 
dropInstance(clusterName, value));

Review comment:
       `value` -> `instanceConfig` to be clearer?




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to