public void addLocalSupervisor(Supervisor supervisor) { this.localSupervisors.put(supervisor.getId(), supervisor); }
/** * Get a specific Supervisor. This is intended mostly for internal testing. * * @param id the id of the supervisor */ public synchronized Supervisor getSupervisor(String id) { for (Supervisor s : supervisors) { if (id.equals(s.getId())) { return s; } } return null; }
public SupervisorHeartbeat(Map<String, Object> conf, Supervisor supervisor) { this.stormClusterState = supervisor.getStormClusterState(); this.supervisorId = supervisor.getId(); this.supervisor = supervisor; this.conf = conf; }
/** * Kill a specific supervisor. This is intended mostly for internal testing. * * @param id the id of the supervisor */ public synchronized void killSupervisor(String id) { for (Iterator<Supervisor> it = supervisors.iterator(); it.hasNext(); ) { Supervisor s = it.next(); if (id.equals(s.getId())) { it.remove(); s.close(); //tmpDir will be handled separately return; } } }
private SupervisorWorkerHeartbeats getSupervisorWorkerHeartbeatsFromLocal(Map<String, LSWorkerHeartbeat> localHeartbeats) { SupervisorWorkerHeartbeats supervisorWorkerHeartbeats = new SupervisorWorkerHeartbeats(); List<SupervisorWorkerHeartbeat> heartbeatList = new ArrayList<>(); for (LSWorkerHeartbeat lsWorkerHeartbeat : localHeartbeats.values()) { // local worker heartbeat can be null cause some error/exception if (null == lsWorkerHeartbeat) { continue; } SupervisorWorkerHeartbeat supervisorWorkerHeartbeat = new SupervisorWorkerHeartbeat(); supervisorWorkerHeartbeat.set_storm_id(lsWorkerHeartbeat.get_topology_id()); supervisorWorkerHeartbeat.set_executors(lsWorkerHeartbeat.get_executors()); supervisorWorkerHeartbeat.set_time_secs(lsWorkerHeartbeat.get_time_secs()); heartbeatList.add(supervisorWorkerHeartbeat); } supervisorWorkerHeartbeats.set_supervisor_id(this.supervisor.getId()); supervisorWorkerHeartbeats.set_worker_heartbeats(heartbeatList); return supervisorWorkerHeartbeats; }
@Override public void close() { try { LOG.info("Shutting down supervisor {}", getId()); this.active = false; heartbeatTimer.close(); workerHeartbeatTimer.close(); eventTimer.close(); if (eventManager != null) { eventManager.close(); } if (readState != null) { readState.close(); } asyncLocalizer.close(); getStormClusterState().disconnect(); if (thriftServer != null) { this.thriftServer.stop(); } } catch (Exception e) { LOG.error("Error Shutting down", e); } }
/** * Launch the supervisor. */ public void launch() throws Exception { LOG.info("Starting Supervisor with conf {}", ConfigUtils.maskPasswords(conf)); String path = ServerConfigUtils.supervisorTmpDir(conf); FileUtils.cleanDirectory(new File(path)); SupervisorHeartbeat hb = new SupervisorHeartbeat(conf, this); hb.run(); // should synchronize supervisor so it doesn't launch anything after being down (optimization) Integer heartbeatFrequency = ObjectReader.getInt(conf.get(DaemonConfig.SUPERVISOR_HEARTBEAT_FREQUENCY_SECS)); heartbeatTimer.scheduleRecurring(0, heartbeatFrequency, hb); this.eventManager = new EventManagerImp(false); this.readState = new ReadClusterState(this); asyncLocalizer.start(); if ((Boolean) conf.get(DaemonConfig.SUPERVISOR_ENABLE)) { // This isn't strictly necessary, but it doesn't hurt and ensures that the machine stays up // to date even if callbacks don't all work exactly right eventTimer.scheduleRecurring(0, 10, new EventManagerPushCallback(new SynchronizeAssignments(this, null, readState), eventManager)); // supervisor health check eventTimer.scheduleRecurring(30, 30, new SupervisorHealthCheck(this)); } ReportWorkerHeartbeats reportWorkerHeartbeats = new ReportWorkerHeartbeats(conf, this); Integer workerHeartbeatFrequency = ObjectReader.getInt(conf.get(Config.WORKER_HEARTBEAT_FREQUENCY_SECS)); workerHeartbeatTimer.scheduleRecurring(0, workerHeartbeatFrequency, reportWorkerHeartbeats); LOG.info("Starting supervisor with id {} at host {}.", getId(), getHostName()); }
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); } } }
public SupervisorHeartbeat(Map<String, Object> conf, Supervisor supervisor) { this.stormClusterState = supervisor.getStormClusterState(); this.supervisorId = supervisor.getId(); this.supervisor = supervisor; this.conf = conf; }
@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(); } asyncLocalizer.shutdown(); localizer.shutdown(); getStormClusterState().disconnect(); } catch (Exception e) { LOG.error("Error Shutting down", e); } }
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); } } }
LOG.info("Starting supervisor with id {} at host {}.", getId(), getHostName());