/** * 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(); this.supervisorPort = supervisor.getThriftServerPort(); this.iSuper = supervisor.getiSupervisor();
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.syncSupEventManager = supervisor.getEventManger(); this.assignmentVersions = new AtomicReference<Map<String, VersionedData<Assignment>>>(new HashMap<String, VersionedData<Assignment>>()); this.assignmentId = supervisor.getAssignmentId(); this.iSuper = supervisor.getiSupervisor(); this.localizer = supervisor.getAsyncLocalizer();
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; }