private TopologyResources getResourcesForTopology(String topoId, StormBase base) throws NotAliveException, AuthorizationException, InvalidTopologyException, IOException { TopologyResources ret = idToResources.get().get(topoId); if (ret == null) { try { IStormClusterState state = stormClusterState; TopologyDetails details = readTopologyDetails(topoId, base); Assignment assignment = state.assignmentInfo(topoId, null); ret = new TopologyResources(details, assignment); } catch (KeyNotFoundException e) { //This can happen when a topology is first coming up // It's thrown by the blobstore code LOG.error("Failed to get topology details", e); ret = new TopologyResources(); } } return ret; }
private Map<WorkerSlot, WorkerResources> getWorkerResourcesForTopology(String topoId) { Map<WorkerSlot, WorkerResources> ret = idToWorkerResources.get().get(topoId); if (ret == null) { IStormClusterState state = stormClusterState; ret = new HashMap<>(); Assignment assignment = state.assignmentInfo(topoId, null); if (assignment != null && assignment.is_set_worker_resources()) { for (Entry<NodeInfo, WorkerResources> entry : assignment.get_worker_resources().entrySet()) { NodeInfo ni = entry.getKey(); WorkerSlot slot = new WorkerSlot(ni.get_node(), ni.get_port_iterator().next()); ret.put(slot, entry.getValue()); } idToWorkerResources.getAndUpdate(new Assoc<>(topoId, ret)); } } return ret; }
Assignment currentAssignment = state.assignmentInfo(id, null); if (!currentAssignment.is_set_owner()) { TopologyDetails td = tds.get(id);
@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; }
private CommonTopoInfo getCommonTopoInfo(String topoId, String operation) throws NotAliveException, AuthorizationException, IOException, InvalidTopologyException { IStormClusterState state = stormClusterState; CommonTopoInfo ret = new CommonTopoInfo(); ret.topoConf = tryReadTopoConf(topoId, topoCache); ret.topoName = (String) ret.topoConf.get(Config.TOPOLOGY_NAME); checkAuthorization(ret.topoName, ret.topoConf, operation); StormTopology topology = tryReadTopology(topoId, topoCache); ret.topology = StormCommon.systemTopology(ret.topoConf, topology); ret.taskToComponent = StormCommon.stormTaskInfo(topology, ret.topoConf); ret.base = state.stormBase(topoId, null); if (ret.base != null && ret.base.is_set_launch_time_secs()) { ret.launchTimeSecs = ret.base.get_launch_time_secs(); } else { ret.launchTimeSecs = 0; } ret.assignment = state.assignmentInfo(topoId, null); //get it from cluster state/zookeeper every time to collect the UI stats, may replace it with other StateStore later ret.beats = ret.assignment != null ? StatsUtil.convertExecutorBeats(state.executorBeats(topoId, ret.assignment .get_executor_node_port())) : Collections .emptyMap(); ret.allComponents = new HashSet<>(ret.taskToComponent.values()); return ret; }
() -> state.assignmentInfo(topoId, null) != null, () -> { try {
Assignment assignment = state.assignmentInfo(topoId, null);