srkukarni 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_r186422524
########## 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: Actually the spawners never join. Thus shutdown hook is much safer. ---------------------------------------------------------------- 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