@Override public void run() { Map<String, Object> conf = supervisor.getConf(); LOG.info("Running supervisor healthchecks..."); int healthCode = HealthChecker.healthCheck(conf); if (healthCode != 0) { LOG.info("The supervisor healthchecks FAILED..."); supervisor.shutdownAllWorkers(null, null); throw new RuntimeException("Supervisor failed health check. Exiting."); } } }
/** * start distribute supervisor. */ public void launchDaemon() { LOG.info("Starting supervisor for storm version '{}'.", VersionInfo.getVersion()); try { Map<String, Object> conf = getConf(); if (ConfigUtils.isLocalMode(conf)) { throw new IllegalArgumentException("Cannot start server in local mode!"); } launch(); metricsRegistry.registerGauge("supervisor:num-slots-used-gauge", () -> SupervisorUtils.supervisorWorkerIds(conf).size()); //This will only get updated once metricsRegistry.registerMeter("supervisor:num-launched").mark(); metricsRegistry.registerMeter("supervisor:num-shell-exceptions", ShellUtils.numShellExceptions); metricsRegistry.startMetricsReporters(conf); Utils.addShutdownHookWithForceKillIn1Sec(() -> { metricsRegistry.stopMetricsReporters(); this.close(); }); // blocking call under the hood, must invoke after launch cause some services must be initialized launchSupervisorThriftServer(conf); } catch (Exception e) { LOG.error("Failed to start supervisor\n", e); System.exit(1); } }
/** * Used by {@link Supervisor} to fetch assignments when start up. * @param supervisor {@link Supervisor} */ public void getAssignmentsFromMasterUntilSuccess(Supervisor supervisor) { boolean success = false; while (!success) { try (NimbusClient master = NimbusClient.getConfiguredClient(supervisor.getConf())) { SupervisorAssignments assignments = master.getClient().getSupervisorAssignments(supervisor.getAssignmentId()); assignedAssignmentsToLocal(supervisor.getStormClusterState(), assignments); success = true; } catch (Exception t) { // just ignore the exception } if (!success) { LOG.info("Waiting for a success sync of assignments from master..."); try { Time.sleep(5000L); } catch (InterruptedException e) { throw new RuntimeException(e); } } } }
@Override public void run() { // first sync assignments to local, then sync processes. if (null == assignments) { getAssignmentsFromMaster(this.supervisor.getConf(), this.supervisor.getStormClusterState(), this.supervisor.getAssignmentId()); } else { assignedAssignmentsToLocal(this.supervisor.getStormClusterState(), assignments); } this.readClusterState.run(); }
public ReadClusterState(Supervisor supervisor) throws Exception { this.superConf = supervisor.getConf(); this.stormClusterState = supervisor.getStormClusterState(); this.assignmentId = supervisor.getAssignmentId();
public void shutdownAllWorkers(UniFunc<Slot> onWarnTimeout, UniFunc<Slot> onErrorTimeout) { if (readState != null) { readState.shutdownAllWorkers(onWarnTimeout, onErrorTimeout); } else { try { ContainerLauncher launcher = ContainerLauncher.make(getConf(), getId(), getThriftServerPort(), getSharedContext(), getMetricsRegistry(), getContainerMemoryTracker()); killWorkers(SupervisorUtils.supervisorWorkerIds(conf), launcher); } catch (Exception e) { throw Utils.wrapInRuntime(e); } } }
@Override public void run() { Map<String, Object> conf = supervisor.getConf(); int healthCode = HealthCheck.healthCheck(conf); if (healthCode != 0) { supervisor.shutdownAllWorkers(null, null); } } }
/** * start distribute supervisor */ public void launchDaemon() { LOG.info("Starting supervisor for storm version '{}'.", VersionInfo.getVersion()); try { Map<String, Object> conf = getConf(); if (ConfigUtils.isLocalMode(conf)) { throw new IllegalArgumentException("Cannot start server in local mode!"); } launch(); Utils.addShutdownHookWithForceKillIn1Sec(new Runnable(){ @Override public void run() { close(); } }); registerWorkerNumGauge("supervisor:num-slots-used-gauge", conf); StormMetricsRegistry.startMetricsReporters(conf); } catch (Exception e) { LOG.error("Failed to start supervisor\n", e); System.exit(1); } }
@Override public void run() { try { Map<String, Object> conf = supervisor.getConf(); Set<String> downloadedStormIds = SupervisorUtils.readDownloadedTopologyIds(conf); AtomicReference<Map<Long, LocalAssignment>> newAssignment = supervisor.getCurrAssignment();
public ReadClusterState(Supervisor supervisor) throws Exception { this.superConf = supervisor.getConf(); this.stormClusterState = supervisor.getStormClusterState(); this.syncSupEventManager = supervisor.getEventManger();
public void shutdownAllWorkers(UniFunc<Slot> onWarnTimeout, UniFunc<Slot> onErrorTimeout) { if (readState != null) { readState.shutdownAllWorkers(onWarnTimeout, onErrorTimeout); } else { try { ContainerLauncher launcher = ContainerLauncher.make(getConf(), getId(), getSharedContext()); killWorkers(SupervisorUtils.supervisorWorkerIds(conf), launcher); } catch (Exception e) { throw Utils.wrapInRuntime(e); } } }