This is an automated email from the ASF dual-hosted git repository.
jlli pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-pinot.git
The following commit(s) were added to refs/heads/master by this push:
new 6e209e4 Handle NPE from getting live instance (#4528)
6e209e4 is described below
commit 6e209e4e0ef138f8c21d597aeb20d1993fd1af2b
Author: Jialiang Li <[email protected]>
AuthorDate: Wed Aug 14 10:41:17 2019 -0700
Handle NPE from getting live instance (#4528)
---
.../java/org/apache/pinot/common/utils/ServiceStatus.java | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git
a/pinot-common/src/main/java/org/apache/pinot/common/utils/ServiceStatus.java
b/pinot-common/src/main/java/org/apache/pinot/common/utils/ServiceStatus.java
index 6f00981..2079dbe 100644
---
a/pinot-common/src/main/java/org/apache/pinot/common/utils/ServiceStatus.java
+++
b/pinot-common/src/main/java/org/apache/pinot/common/utils/ServiceStatus.java
@@ -24,6 +24,7 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
+import javax.annotation.Nullable;
import org.apache.helix.HelixAdmin;
import org.apache.helix.HelixDataAccessor;
import org.apache.helix.HelixManager;
@@ -209,6 +210,7 @@ public class ServiceStatus {
getResourceListAsString(), _instanceName);
}
+ @Nullable
protected abstract T getState(String resourceName);
protected abstract Map<String, String> getPartitionStateMap(T state);
@@ -381,12 +383,21 @@ public class ServiceStatus {
super(helixManager, clusterName, instanceName, resourcesToMonitor,
minResourcesStartPercent);
}
+ /**
+ * Returns the current state for the given resource, or {@code null} if
instance is not live or current state does
+ * not exist.
+ */
+ @Nullable
@Override
protected CurrentState getState(String resourceName) {
PropertyKey.Builder keyBuilder = _helixDataAccessor.keyBuilder();
LiveInstance liveInstance =
_helixDataAccessor.getProperty(keyBuilder.liveInstance(_instanceName));
- String sessionId = liveInstance.getSessionId();
- return
_helixDataAccessor.getProperty(keyBuilder.currentState(_instanceName,
sessionId, resourceName));
+ if (liveInstance == null) {
+ return null;
+ } else {
+ String sessionId = liveInstance.getSessionId();
+ return
_helixDataAccessor.getProperty(keyBuilder.currentState(_instanceName,
sessionId, resourceName));
+ }
}
@Override
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]