You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2018/05/07 08:25:30 UTC

[GitHub] sijie commented on a change in pull request #1734: Print periodic status of instances in localrun

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


With regards,
Apache Git Services