Github user srdo commented on a diff in the pull request: https://github.com/apache/storm/pull/1642#discussion_r78993658 --- Diff: storm-core/src/jvm/org/apache/storm/daemon/supervisor/Supervisor.java --- @@ -163,15 +259,94 @@ public Integer call() throws Exception { } }); } + + @Override + public void close() { + try { + LOG.info("Shutting down supervisor {}", getId()); + this.active = false; + heartbeatTimer.close(); + eventTimer.close(); + blobUpdateTimer.close(); + if (eventManager != null) { + eventManager.close(); + } + if (readState != null) { + readState.close(); + } + getStormClusterState().disconnect(); + } catch (Exception e) { + LOG.error("Error Shutting down", e); + } + } + + void killWorkers(Collection<String> workerIds, ContainerLauncher launcher) throws InterruptedException, IOException { + HashSet<Killable> containers = new HashSet<>(); + for (String workerId : workerIds) { + try { + Killable k = launcher.recoverContainer(workerId, localState); + if (!k.areAllProcessesDead()) { + k.kill(); + containers.add(k); + } else { + k.cleanUp(); + } + } catch (Exception e) { + LOG.error("Error trying to kill {}", workerId, e); + } + } + int shutdownSleepSecs = Utils.getInt(conf.get(Config.SUPERVISOR_WORKER_SHUTDOWN_SLEEP_SECS), 1); + if (!containers.isEmpty()) { + Time.sleepSecs(shutdownSleepSecs); + } + for (Killable k: containers) { + try { + k.forceKill(); + while(!k.areAllProcessesDead()) { --- End diff -- Just in case a bug is introduced at some point, you may want to cap how long this is allowed to loop before it starts error logging
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---