You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by jl...@apache.org on 2019/08/13 23:26:00 UTC
[incubator-pinot] 01/01: Handle NPE from getting live instance
This is an automated email from the ASF dual-hosted git repository.
jlli pushed a commit to branch fix-NPE-from-live-instance
in repository https://gitbox.apache.org/repos/asf/incubator-pinot.git
commit 447c6326313159e6f56e82f5641366659cc51231
Author: jackjlli <jl...@linkedin.com>
AuthorDate: Tue Aug 13 16:25:40 2019 -0700
Handle NPE from getting live instance
---
.../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..58d746d 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);
}
+ /**
+ * Gets the current state from live instance.
+ * Note: Live instance node can be null.
+ * @param resourceName resource name
+ */
@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: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org