@Override public Assignment getLocalAssignmentForStorm(String id) throws NotAliveException, AuthorizationException, TException { Map<String, Object> topoConf = null; try { topoConf = ConfigUtils.readSupervisorStormConf(conf, id); } catch (IOException e) { LOG.warn("Topology config is not localized yet..."); } checkAuthorization(id, topoConf, "getLocalAssignmentForStorm"); Assignment assignment = getStormClusterState().assignmentInfo(id, null); if (null == assignment) { throw new WrappedNotAliveException("No local assignment assigned for storm: " + id + " for node: " + getHostName()); } return assignment; }
this.iSuper = supervisor.getiSupervisor(); this.localizer = supervisor.getAsyncLocalizer(); this.host = supervisor.getHostName(); this.localState = supervisor.getLocalState(); this.cachedAssignments = supervisor.getCurrAssignment();
/** * 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()); }
private SupervisorInfo buildSupervisorInfo(Map<String, Object> conf, Supervisor supervisor) { SupervisorInfo supervisorInfo = new SupervisorInfo(); supervisorInfo.set_time_secs(Time.currentTimeSecs()); supervisorInfo.set_hostname(supervisor.getHostName()); supervisorInfo.set_assignment_id(supervisor.getAssignmentId()); supervisorInfo.set_server_port(supervisor.getThriftServerPort()); List<Long> usedPorts = new ArrayList<>(); usedPorts.addAll(supervisor.getCurrAssignment().get().keySet()); supervisorInfo.set_used_ports(usedPorts); List metaDatas = (List) supervisor.getiSupervisor().getMetadata(); List<Long> portList = new ArrayList<>(); if (metaDatas != null) { for (Object data : metaDatas) { Integer port = ObjectReader.getInt(data); if (port != null) { portList.add(port.longValue()); } } } supervisorInfo.set_meta(portList); supervisorInfo.set_scheduler_meta((Map<String, String>) conf.get(DaemonConfig.SUPERVISOR_SCHEDULER_META)); supervisorInfo.set_uptime_secs(supervisor.getUpTime().upTime()); supervisorInfo.set_version(supervisor.getStormVersion()); supervisorInfo.set_resources_map(mkSupervisorCapacities(conf)); return supervisorInfo; }
this.iSuper = supervisor.getiSupervisor(); this.localizer = supervisor.getAsyncLocalizer(); this.host = supervisor.getHostName(); this.localState = supervisor.getLocalState(); this.clusterState = supervisor.getStormClusterState();
private SupervisorInfo buildSupervisorInfo(Map<String, Object> conf, Supervisor supervisor) { SupervisorInfo supervisorInfo = new SupervisorInfo(); supervisorInfo.set_time_secs(Time.currentTimeSecs()); supervisorInfo.set_hostname(supervisor.getHostName()); supervisorInfo.set_assignment_id(supervisor.getAssignmentId()); List<Long> usedPorts = new ArrayList<>(); usedPorts.addAll(supervisor.getCurrAssignment().get().keySet()); supervisorInfo.set_used_ports(usedPorts); List metaDatas = (List)supervisor.getiSupervisor().getMetadata(); List<Long> portList = new ArrayList<>(); if (metaDatas != null){ for (Object data : metaDatas){ Integer port = Utils.getInt(data); if (port != null) portList.add(port.longValue()); } } supervisorInfo.set_meta(portList); supervisorInfo.set_scheduler_meta((Map<String, String>) conf.get(Config.SUPERVISOR_SCHEDULER_META)); supervisorInfo.set_uptime_secs(supervisor.getUpTime().upTime()); supervisorInfo.set_version(supervisor.getStormVersion()); supervisorInfo.set_resources_map(mkSupervisorCapacities(conf)); return supervisorInfo; }
LOG.info("Starting supervisor with id {} at host {}.", getId(), getHostName());