Search in sources :

Example 6 with StormBase

use of org.apache.storm.generated.StormBase in project storm by apache.

the class WorkerState method refreshStormActive.

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

Example 7 with StormBase

use of org.apache.storm.generated.StormBase in project storm by apache.

the class Nimbus method startTopology.

private void startTopology(String topoName, String topoId, TopologyStatus initStatus) throws KeyNotFoundException, AuthorizationException, IOException, InvalidTopologyException {
    assert (TopologyStatus.ACTIVE == initStatus || TopologyStatus.INACTIVE == initStatus);
    IStormClusterState state = stormClusterState;
    BlobStore store = blobStore;
    Map<String, Object> topoConf = readTopoConf(topoId, store);
    StormTopology topology = StormCommon.systemTopology(topoConf, readStormTopology(topoId, store));
    Map<String, Integer> numExecutors = new HashMap<>();
    for (Entry<String, Object> entry : StormCommon.allComponents(topology).entrySet()) {
        numExecutors.put(entry.getKey(), StormCommon.numStartExecutors(entry.getValue()));
    }
    LOG.info("Activating {}: {}", topoName, topoId);
    StormBase base = new StormBase();
    base.set_name(topoName);
    base.set_launch_time_secs(Time.currentTimeSecs());
    base.set_status(initStatus);
    base.set_num_workers(Utils.getInt(topoConf.get(Config.TOPOLOGY_WORKERS), 0));
    base.set_component_executors(numExecutors);
    base.set_owner((String) topoConf.get(Config.TOPOLOGY_SUBMITTER_USER));
    base.set_component_debug(new HashMap<>());
    state.activateStorm(topoId, base);
    notifyTopologyActionListener(topoName, "activate");
}
Also used : HashMap(java.util.HashMap) StormTopology(org.apache.storm.generated.StormTopology) StormBase(org.apache.storm.generated.StormBase) IStormClusterState(org.apache.storm.cluster.IStormClusterState) BlobStore(org.apache.storm.blobstore.BlobStore) LocalFsBlobStore(org.apache.storm.blobstore.LocalFsBlobStore)

Example 8 with StormBase

use of org.apache.storm.generated.StormBase 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, blobStore);
        // 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 NotAliveException(topoName);
        }
        boolean hasCompId = componentId != null && !componentId.isEmpty();
        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());
        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.thrift.TException) NotAliveException(org.apache.storm.generated.NotAliveException) StormBase(org.apache.storm.generated.StormBase) IStormClusterState(org.apache.storm.cluster.IStormClusterState) DebugOptions(org.apache.storm.generated.DebugOptions) AuthorizationException(org.apache.storm.generated.AuthorizationException) NotAliveException(org.apache.storm.generated.NotAliveException) InterruptedIOException(java.io.InterruptedIOException) TException(org.apache.thrift.TException) IOException(java.io.IOException) AlreadyAliveException(org.apache.storm.generated.AlreadyAliveException) KeyAlreadyExistsException(org.apache.storm.generated.KeyAlreadyExistsException) KeyNotFoundException(org.apache.storm.generated.KeyNotFoundException) InvalidTopologyException(org.apache.storm.generated.InvalidTopologyException) BindException(java.net.BindException)

Example 9 with StormBase

use of org.apache.storm.generated.StormBase in project storm by apache.

the class Nimbus method doRebalance.

void doRebalance(String topoId, StormBase stormBase) throws Exception {
    RebalanceOptions rbo = stormBase.get_topology_action_options().get_rebalance_options();
    StormBase updated = new StormBase();
    updated.set_topology_action_options(null);
    updated.set_component_debug(Collections.emptyMap());
    if (rbo.is_set_num_executors()) {
        updated.set_component_executors(rbo.get_num_executors());
    }
    if (rbo.is_set_num_workers()) {
        updated.set_num_workers(rbo.get_num_workers());
    }
    stormClusterState.updateStorm(topoId, updated);
    mkAssignments(topoId);
}
Also used : StormBase(org.apache.storm.generated.StormBase) RebalanceOptions(org.apache.storm.generated.RebalanceOptions)

Aggregations

StormBase (org.apache.storm.generated.StormBase)9 IStormClusterState (org.apache.storm.cluster.IStormClusterState)6 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 Assignment (org.apache.storm.generated.Assignment)3 DebugOptions (org.apache.storm.generated.DebugOptions)3 KeyNotFoundException (org.apache.storm.generated.KeyNotFoundException)3 DataPoint (org.apache.storm.metric.api.DataPoint)3 SchedulerAssignment (org.apache.storm.scheduler.SchedulerAssignment)3 ImmutableMap (com.google.common.collect.ImmutableMap)2 IOException (java.io.IOException)2 InterruptedIOException (java.io.InterruptedIOException)2 BindException (java.net.BindException)2 HashSet (java.util.HashSet)2 List (java.util.List)2 Map (java.util.Map)2 AtomicLong (java.util.concurrent.atomic.AtomicLong)2 AlreadyAliveException (org.apache.storm.generated.AlreadyAliveException)2 AuthorizationException (org.apache.storm.generated.AuthorizationException)2 InvalidTopologyException (org.apache.storm.generated.InvalidTopologyException)2