use of org.apache.storm.cluster.IStormClusterState in project storm by apache.
the class Nimbus method getCommonTopoInfo.
private CommonTopoInfo getCommonTopoInfo(String topoId, String operation) throws NotAliveException, AuthorizationException, IOException, InvalidTopologyException {
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);
IStormClusterState state = stormClusterState;
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;
}
use of org.apache.storm.cluster.IStormClusterState in project storm by apache.
the class Nimbus method getLogConfig.
@Override
public LogConfig getLogConfig(String topoId) throws TException {
try {
getLogConfigCalls.mark();
Map<String, Object> topoConf = tryReadTopoConf(topoId, topoCache);
topoConf = Utils.merge(conf, topoConf);
String topoName = (String) topoConf.get(Config.TOPOLOGY_NAME);
checkAuthorization(topoName, topoConf, "getLogConfig");
IStormClusterState state = stormClusterState;
LogConfig logConfig = state.topologyLogConfig(topoId, null);
if (logConfig == null) {
logConfig = new LogConfig();
}
return logConfig;
} catch (Exception e) {
LOG.warn("get log conf topology exception. (topology id='{}')", topoId, e);
if (e instanceof TException) {
throw (TException) e;
}
throw new RuntimeException(e);
}
}
use of org.apache.storm.cluster.IStormClusterState in project storm by apache.
the class Nimbus method debug.
@Override
public void debug(String topoName, String componentId, boolean enable, double samplingPercentage) throws NotAliveException, AuthorizationException, TException {
debugCalls.mark();
try {
IStormClusterState state = stormClusterState;
String topoId = toTopoId(topoName);
Map<String, Object> topoConf = tryReadTopoConf(topoId, topoCache);
topoConf = Utils.merge(conf, topoConf);
// make sure samplingPct is within bounds.
double spct = Math.max(Math.min(samplingPercentage, 100.0), 0.0);
// while disabling we retain the sampling pct.
checkAuthorization(topoName, topoConf, "debug");
if (topoId == null) {
throw new WrappedNotAliveException(topoName);
}
DebugOptions options = new DebugOptions();
options.set_enable(enable);
if (enable) {
options.set_samplingpct(spct);
}
StormBase updates = new StormBase();
// For backwards compatability
updates.set_component_executors(Collections.emptyMap());
boolean hasCompId = componentId != null && !componentId.isEmpty();
String key = hasCompId ? componentId : topoId;
updates.put_to_component_debug(key, options);
LOG.info("Nimbus setting debug to {} for storm-name '{}' storm-id '{}' sanpling pct '{}'" + (hasCompId ? " component-id '" + componentId + "'" : ""), enable, topoName, topoId, spct);
synchronized (submitLock) {
state.updateStorm(topoId, updates);
}
} catch (Exception e) {
LOG.warn("debug topology exception. (topology name='{}')", topoName, e);
if (e instanceof TException) {
throw (TException) e;
}
throw new RuntimeException(e);
}
}
use of org.apache.storm.cluster.IStormClusterState in project storm by apache.
the class Nimbus method getResourcesForTopology.
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;
}
Aggregations