sijie commented on a change in pull request #1734: Print periodic status of 
instances in localrun
URL: https://github.com/apache/incubator-pulsar/pull/1734#discussion_r186358316
 
 

 ##########
 File path: 
pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/CmdFunctions.java
 ##########
 @@ -655,6 +652,32 @@ public void run() {
                         }
                     }
                 });
+                Timer statusCheckTimer = new Timer();
+                statusCheckTimer.scheduleAtFixedRate(new TimerTask() {
+                    @Override
+                    public void run() {
+                        CompletableFuture<String>[] futures = new 
CompletableFuture[spawners.size()];
+                        int index = 0;
+                        for (RuntimeSpawner spawner : spawners) {
+                            futures[index++] = 
spawner.getFunctionStatusAsJson();
+                        }
+                        try {
+                            CompletableFuture.allOf(futures).get(5, 
TimeUnit.SECONDS);
+                            for (index = 0; index < futures.length; ++index) {
+                                String json = futures[index].get();
+                                Gson gson = new 
GsonBuilder().setPrettyPrinting().create();
+                                log.info(gson.toJson(new 
JsonParser().parse(json)));
+                            }
+                        } catch (Exception ex) {
+                            log.error("Could not get status from all local 
instances");
+                        }
+                    }
+                }, 30000, 30000);
+                Runtime.getRuntime().addShutdownHook(new Thread() {
 
 Review comment:
   can't we just add `statusCheckTimer.cancel` at line 684 after joining all 
the spawners?

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to