Search in sources :

Example 46 with IStormClusterState

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;
}
Also used : StormTopology(org.apache.storm.generated.StormTopology) IStormClusterState(org.apache.storm.cluster.IStormClusterState)

Example 47 with IStormClusterState

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);
    }
}
Also used : TException(org.apache.storm.thrift.TException) IStormClusterState(org.apache.storm.cluster.IStormClusterState) WrappedAuthorizationException(org.apache.storm.utils.WrappedAuthorizationException) IOException(java.io.IOException) IllegalStateException(org.apache.storm.generated.IllegalStateException) AlreadyAliveException(org.apache.storm.generated.AlreadyAliveException) WrappedNotAliveException(org.apache.storm.utils.WrappedNotAliveException) WrappedInvalidTopologyException(org.apache.storm.utils.WrappedInvalidTopologyException) AuthorizationException(org.apache.storm.generated.AuthorizationException) NotAliveException(org.apache.storm.generated.NotAliveException) WrappedAlreadyAliveException(org.apache.storm.utils.WrappedAlreadyAliveException) InterruptedIOException(java.io.InterruptedIOException) KeyAlreadyExistsException(org.apache.storm.generated.KeyAlreadyExistsException) TException(org.apache.storm.thrift.TException) WrappedIllegalStateException(org.apache.storm.utils.WrappedIllegalStateException) KeyNotFoundException(org.apache.storm.generated.KeyNotFoundException) InvalidTopologyException(org.apache.storm.generated.InvalidTopologyException) BindException(java.net.BindException) LogConfig(org.apache.storm.generated.LogConfig)

Example 48 with IStormClusterState

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);
    }
}
Also used : TException(org.apache.storm.thrift.TException) StormBase(org.apache.storm.generated.StormBase) IStormClusterState(org.apache.storm.cluster.IStormClusterState) DebugOptions(org.apache.storm.generated.DebugOptions) WrappedNotAliveException(org.apache.storm.utils.WrappedNotAliveException) WrappedAuthorizationException(org.apache.storm.utils.WrappedAuthorizationException) IOException(java.io.IOException) IllegalStateException(org.apache.storm.generated.IllegalStateException) AlreadyAliveException(org.apache.storm.generated.AlreadyAliveException) WrappedNotAliveException(org.apache.storm.utils.WrappedNotAliveException) WrappedInvalidTopologyException(org.apache.storm.utils.WrappedInvalidTopologyException) AuthorizationException(org.apache.storm.generated.AuthorizationException) NotAliveException(org.apache.storm.generated.NotAliveException) WrappedAlreadyAliveException(org.apache.storm.utils.WrappedAlreadyAliveException) InterruptedIOException(java.io.InterruptedIOException) KeyAlreadyExistsException(org.apache.storm.generated.KeyAlreadyExistsException) TException(org.apache.storm.thrift.TException) WrappedIllegalStateException(org.apache.storm.utils.WrappedIllegalStateException) KeyNotFoundException(org.apache.storm.generated.KeyNotFoundException) InvalidTopologyException(org.apache.storm.generated.InvalidTopologyException) BindException(java.net.BindException)

Example 49 with IStormClusterState

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;
}
Also used : Assignment(org.apache.storm.generated.Assignment) SchedulerAssignment(org.apache.storm.scheduler.SchedulerAssignment) IStormClusterState(org.apache.storm.cluster.IStormClusterState) TopologyDetails(org.apache.storm.scheduler.TopologyDetails) KeyNotFoundException(org.apache.storm.generated.KeyNotFoundException)

Aggregations

IStormClusterState (org.apache.storm.cluster.IStormClusterState)49 KeyNotFoundException (org.apache.storm.generated.KeyNotFoundException)24 IOException (java.io.IOException)23 AuthorizationException (org.apache.storm.generated.AuthorizationException)21 KeyAlreadyExistsException (org.apache.storm.generated.KeyAlreadyExistsException)21 NotAliveException (org.apache.storm.generated.NotAliveException)21 InterruptedIOException (java.io.InterruptedIOException)20 BindException (java.net.BindException)20 AlreadyAliveException (org.apache.storm.generated.AlreadyAliveException)20 InvalidTopologyException (org.apache.storm.generated.InvalidTopologyException)20 WrappedNotAliveException (org.apache.storm.utils.WrappedNotAliveException)20 HashMap (java.util.HashMap)19 TException (org.apache.storm.thrift.TException)19 IllegalStateException (org.apache.storm.generated.IllegalStateException)18 WrappedAlreadyAliveException (org.apache.storm.utils.WrappedAlreadyAliveException)18 WrappedAuthorizationException (org.apache.storm.utils.WrappedAuthorizationException)18 WrappedIllegalStateException (org.apache.storm.utils.WrappedIllegalStateException)18 WrappedInvalidTopologyException (org.apache.storm.utils.WrappedInvalidTopologyException)18 ArrayList (java.util.ArrayList)12 HashSet (java.util.HashSet)10