use of org.apache.storm.cluster.IStormClusterState in project storm by apache.
the class Nimbus method setLogConfig.
@Override
public void setLogConfig(String topoId, LogConfig config) throws TException {
try {
setLogConfigCalls.mark();
Map<String, Object> topoConf = tryReadTopoConf(topoId, topoCache);
topoConf = Utils.merge(conf, topoConf);
String topoName = (String) topoConf.get(Config.TOPOLOGY_NAME);
checkAuthorization(topoName, topoConf, "setLogConfig");
IStormClusterState state = stormClusterState;
LogConfig mergedLogConfig = state.topologyLogConfig(topoId, null);
if (mergedLogConfig == null) {
mergedLogConfig = new LogConfig();
}
if (mergedLogConfig.is_set_named_logger_level()) {
Map<String, LogLevel> namedLoggers = mergedLogConfig.get_named_logger_level();
for (LogLevel level : namedLoggers.values()) {
level.set_action(LogLevelAction.UNCHANGED);
}
}
if (config.is_set_named_logger_level()) {
for (Entry<String, LogLevel> entry : config.get_named_logger_level().entrySet()) {
LogLevel logConfig = entry.getValue();
String loggerName = entry.getKey();
LogLevelAction action = logConfig.get_action();
if (loggerName.isEmpty()) {
throw new RuntimeException("Named loggers need a valid name. Use ROOT for the root logger");
}
switch(action) {
case UPDATE:
setLoggerTimeouts(logConfig);
mergedLogConfig.put_to_named_logger_level(loggerName, logConfig);
break;
case REMOVE:
Map<String, LogLevel> nl = mergedLogConfig.get_named_logger_level();
if (nl != null) {
nl.remove(loggerName);
}
break;
default:
// NOOP
break;
}
}
}
LOG.info("Setting log config for {}:{}", topoName, mergedLogConfig);
state.setTopologyLogConfig(topoId, mergedLogConfig, topoConf);
} catch (Exception e) {
LOG.warn("set log config 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 setWorkerProfiler.
@Override
public void setWorkerProfiler(String topoId, ProfileRequest profileRequest) throws TException {
try {
setWorkerProfilerCalls.mark();
Map<String, Object> topoConf = tryReadTopoConf(topoId, topoCache);
topoConf = Utils.merge(conf, topoConf);
String topoName = (String) topoConf.get(Config.TOPOLOGY_NAME);
checkAuthorization(topoName, topoConf, "setWorkerProfiler");
IStormClusterState state = stormClusterState;
state.setWorkerProfileRequest(topoId, profileRequest);
} catch (Exception e) {
LOG.warn("set worker profiler 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 getTopologyInfoByNameImpl.
private TopologyInfo getTopologyInfoByNameImpl(String name, GetInfoOptions options) throws NotAliveException, AuthorizationException, Exception {
IStormClusterState state = stormClusterState;
String id = state.getTopoId(name).orElseThrow(() -> new WrappedNotAliveException(name + " is not alive"));
return getTopologyInfoWithOptsImpl(id, options);
}
use of org.apache.storm.cluster.IStormClusterState in project storm by apache.
the class Nimbus method getTopologySummariesImpl.
private List<TopologySummary> getTopologySummariesImpl() throws IOException, TException {
IStormClusterState state = stormClusterState;
List<TopologySummary> topologySummaries = new ArrayList<>();
Map<String, StormBase> bases = state.topologyBases();
for (Entry<String, StormBase> entry : bases.entrySet()) {
StormBase base = entry.getValue();
if (base == null) {
continue;
}
String topoId = entry.getKey();
TopologySummary summary = getTopologySummaryImpl(topoId, base);
topologySummaries.add(summary);
}
return topologySummaries;
}
use of org.apache.storm.cluster.IStormClusterState in project storm by apache.
the class Nimbus method getTopologySummary.
@Override
public TopologySummary getTopologySummary(String id) throws NotAliveException, AuthorizationException, TException {
try {
getTopologySummaryCalls.mark();
IStormClusterState state = stormClusterState;
StormBase base = state.topologyBases().get(id);
if (base == null) {
throw new WrappedNotAliveException(id + " is not alive");
}
checkAuthorization(base.get_name(), null, "getTopologySummary");
return getTopologySummaryImpl(id, base);
} catch (Exception e) {
LOG.warn("Get TopologySummaryById info exception.", e);
if (e instanceof TException) {
throw (TException) e;
}
throw new RuntimeException(e);
}
}
Aggregations