This is an automated email from the ASF dual-hosted git repository.
jxue pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/helix.git
The following commit(s) were added to refs/heads/master by this push:
new a133fd6 Fix ZNode does not exist in HealthCheck
a133fd6 is described below
commit a133fd6bfe669fb1086ec45eec89aa90cf1bd912
Author: Junkai Xue <[email protected]>
AuthorDate: Wed Aug 14 11:23:11 2019 -0700
Fix ZNode does not exist in HealthCheck
If the ZNode of PartitionHealth does not exist, REST will return failed
checks due to NPE. The fix will be adding the instance to be refreshed
entirely. Then REST can check based on API refreshed result.
---
.../helix/rest/server/json/cluster/PartitionHealth.java | 5 +++++
.../apache/helix/rest/server/service/InstanceServiceImpl.java | 11 ++++++++---
2 files changed, 13 insertions(+), 3 deletions(-)
diff --git
a/helix-rest/src/main/java/org/apache/helix/rest/server/json/cluster/PartitionHealth.java
b/helix-rest/src/main/java/org/apache/helix/rest/server/json/cluster/PartitionHealth.java
index a09e383..6e9e8e6 100644
---
a/helix-rest/src/main/java/org/apache/helix/rest/server/json/cluster/PartitionHealth.java
+++
b/helix-rest/src/main/java/org/apache/helix/rest/server/json/cluster/PartitionHealth.java
@@ -20,6 +20,7 @@ package org.apache.helix.rest.server.json.cluster;
*/
import java.util.ArrayList;
+import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -42,6 +43,10 @@ public class PartitionHealth {
.computeIfAbsent(instanceName, partitions -> new
ArrayList<>()).add(partitionName);
}
+ public void addInstanceThatNeedDirectCall(String instanceName) {
+ _instanceToPartitionsMap.put(instanceName, Collections.EMPTY_LIST);
+ }
+
public void addSinglePartitionHealthForInstance(String instanceName, String
partitionName,
Boolean isHealthy) {
_instanceToPartitionHealthMap.computeIfAbsent(instanceName, partitionMap
-> new HashMap<>())
diff --git
a/helix-rest/src/main/java/org/apache/helix/rest/server/service/InstanceServiceImpl.java
b/helix-rest/src/main/java/org/apache/helix/rest/server/service/InstanceServiceImpl.java
index b9ffc65..babce07 100644
---
a/helix-rest/src/main/java/org/apache/helix/rest/server/service/InstanceServiceImpl.java
+++
b/helix-rest/src/main/java/org/apache/helix/rest/server/service/InstanceServiceImpl.java
@@ -243,6 +243,8 @@ public class InstanceServiceImpl implements InstanceService
{
new HashMap<>();
for (Map.Entry<String, List<String>> entry :
expiredPartitionsByInstance.entrySet()) {
String instance = entry.getKey();
+ // If expiredPartitions list is empty, it means all the partition
statues need to be refreshed
+ // by directly calling the instance API.
List<String> expiredPartitions = entry.getValue();
Callable<Map<String, Boolean>> refreshTask =
() ->
_customRestClient.getPartitionStoppableCheck(getBaseUrl(instance, restConfig),
@@ -303,10 +305,13 @@ public class InstanceServiceImpl implements
InstanceService {
.collect(Collectors.toList()));
for (int i = 0; i < liveInstances.size(); i++) {
String instance = liveInstances.get(i);
- // TODO: Check ZNRecord is null or not. Need logic to check whether the
healthreports exist
- // or not. If it does not exist, we should query the participant
directly for the health
- // report.
ZNRecord customizedHealth = healthReports.get(i).getRecord();
+
+ // No partition health ZNode found for that instance
+ // Direct call the instance to get partition health report.
+ if (customizedHealth == null) {
+ partitionHealth.addInstanceThatNeedDirectCall(instance);
+ }
for (String partitionName : customizedHealth.getMapFields().keySet()) {
try {
Map<String, String> healthMap =
customizedHealth.getMapField(partitionName);