default Map<String, StormBase> topologyBases() { Map<String, StormBase> stormBases = new HashMap<>(); for (String topologyId : activeStorms()) { StormBase base = stormBase(topologyId, null); if (base != null) { //race condition with delete stormBases.put(topologyId, base); } } return stormBases; } }
public void refreshStormActive(Runnable callback) { StormBase base = stormClusterState.stormBase(topologyId, callback); isTopologyActive.set( (null != base) && (base.get_status() == TopologyStatus.ACTIVE) && (isWorkerActive.get())); if (null != base) { Map<String, DebugOptions> debugOptionsMap = new HashMap<>(base.get_component_debug()); for (DebugOptions debugOptions : debugOptionsMap.values()) { if (!debugOptions.is_set_samplingpct()) { debugOptions.set_samplingpct(10); } if (!debugOptions.is_set_enable()) { debugOptions.set_enable(false); } } stormComponentToDebug.set(debugOptionsMap); LOG.debug("Events debug options {}", stormComponentToDebug.get()); } }
private void transition(String topoId, TopologyActions event, Object eventArg, boolean errorOnNoTransition) throws Exception { LOG.info("TRANSITION: {} {} {} {}", topoId, event, eventArg, errorOnNoTransition); assertIsLeader(); synchronized (submitLock) { IStormClusterState clusterState = stormClusterState; StormBase base = clusterState.stormBase(topoId, null); if (base == null || base.get_status() == null) { LOG.info("Cannot apply event {} to {} because topology no longer exists", event, topoId); } else { TopologyStatus status = base.get_status(); TopologyStateTransition transition = TOPO_STATE_TRANSITIONS.get(status).get(event); if (transition == null) { String message = "No transition for event: " + event + ", status: " + status + " storm-id: " + topoId; if (errorOnNoTransition) { throw new RuntimeException(message); } if (TopologyActions.STARTUP != event) { //STARTUP is a system event so don't log an issue LOG.info(message); } transition = NOOP_TRANSITION; } StormBase updates = transition.transition(eventArg, this, topoId, base); if (updates != null) { clusterState.updateStorm(topoId, updates); } } } }
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; }