pulsar-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] srkukarni closed pull request #2728: [function][runtime] NPE at RuntimeSpawner
Date Fri, 05 Oct 2018 16:00:42 GMT
srkukarni closed pull request #2728: [function][runtime] NPE at RuntimeSpawner
URL: https://github.com/apache/pulsar/pull/2728
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/pulsar-functions/runtime/src/main/java/org/apache/pulsar/functions/runtime/RuntimeSpawner.java
b/pulsar-functions/runtime/src/main/java/org/apache/pulsar/functions/runtime/RuntimeSpawner.java
index 423ccd9903..5688411c60 100644
--- a/pulsar-functions/runtime/src/main/java/org/apache/pulsar/functions/runtime/RuntimeSpawner.java
+++ b/pulsar-functions/runtime/src/main/java/org/apache/pulsar/functions/runtime/RuntimeSpawner.java
@@ -32,6 +32,7 @@
 import lombok.extern.slf4j.Slf4j;
 
 import org.apache.commons.lang3.StringUtils;
+import org.apache.pulsar.common.util.FutureUtil;
 import org.apache.pulsar.functions.instance.InstanceConfig;
 import org.apache.pulsar.functions.proto.Function.FunctionDetails;
 import org.apache.pulsar.functions.proto.InstanceCommunication.FunctionStatus;
@@ -82,7 +83,8 @@ public void start() throws Exception {
             processLivenessCheckTimer.scheduleAtFixedRate(new TimerTask() {
                 @Override
                 public void run() {
-                    if (!runtime.isAlive()) {
+                    Runtime runtime = RuntimeSpawner.this.runtime;
+                    if (runtime != null && !runtime.isAlive()) {
                         log.error("{}/{}/{}-{} Function Container is dead with exception..
restarting", details.getTenant(),
                                 details.getNamespace(), details.getName(), runtime.getDeathException());
                         // Just for the sake of sanity, just destroy the runtime
@@ -108,6 +110,10 @@ public void join() throws Exception {
     }
 
     public CompletableFuture<FunctionStatus> getFunctionStatus(int instanceId) {
+        Runtime runtime = this.runtime;
+        if (null == runtime) {
+            return FutureUtil.failedFuture(new IllegalStateException("Function runtime is
not started yet"));
+        }
         return runtime.getFunctionStatus(instanceId).thenApply(f -> {
            FunctionStatus.Builder builder = FunctionStatus.newBuilder();
            builder.mergeFrom(f).setNumRestarts(numRestarts).setInstanceId(String.valueOf(instanceId));
@@ -131,6 +137,11 @@ public void join() throws Exception {
 
     @Override
     public void close() {
+        // cancel liveness checker before stopping runtime.
+        if (processLivenessCheckTimer != null) {
+            processLivenessCheckTimer.cancel();
+            processLivenessCheckTimer = null;
+        }
         if (null != runtime) {
             try {
                 runtime.stop();
@@ -139,9 +150,5 @@ public void close() {
             }
             runtime = null;
         }
-        if (processLivenessCheckTimer != null) {
-            processLivenessCheckTimer.cancel();
-            processLivenessCheckTimer = null;
-        }
     }
 }


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message