Search in sources :

Example 6 with WrappedNotAliveException

use of org.apache.storm.utils.WrappedNotAliveException in project storm by apache.

the class Supervisor method createSupervisorIface.

private org.apache.storm.generated.Supervisor.Iface createSupervisorIface() {
    return new org.apache.storm.generated.Supervisor.Iface() {

        @Override
        public void sendSupervisorAssignments(SupervisorAssignments assignments) throws AuthorizationException, TException {
            checkAuthorization("sendSupervisorAssignments");
            LOG.info("Got an assignments from master, will start to sync with assignments: {}", assignments);
            SynchronizeAssignments syn = new SynchronizeAssignments(getSupervisor(), assignments, getReadClusterState());
            getEventManger().add(syn);
        }

        @Override
        public Assignment getLocalAssignmentForStorm(String id) throws NotAliveException, AuthorizationException, TException {
            Map<String, Object> topoConf = null;
            try {
                topoConf = ConfigUtils.readSupervisorStormConf(conf, id);
            } catch (IOException e) {
                LOG.warn("Topology config is not localized yet...");
            }
            checkAuthorization(id, topoConf, "getLocalAssignmentForStorm");
            Assignment assignment = getStormClusterState().assignmentInfo(id, null);
            if (null == assignment) {
                throw new WrappedNotAliveException("No local assignment assigned for storm: " + id + " for node: " + getHostName());
            }
            return assignment;
        }

        @Override
        public void sendSupervisorWorkerHeartbeat(SupervisorWorkerHeartbeat heartbeat) throws AuthorizationException, NotAliveException, TException {
            // do nothing except validate heartbeat for now.
            String id = heartbeat.get_storm_id();
            Map<String, Object> topoConf = null;
            try {
                topoConf = ConfigUtils.readSupervisorStormConf(conf, id);
            } catch (IOException e) {
                LOG.warn("Topology config is not localized yet...");
                throw new WrappedNotAliveException(id + " does not appear to be alive, you should probably exit");
            }
            checkAuthorization(id, topoConf, "sendSupervisorWorkerHeartbeat");
        }
    };
}
Also used : Assignment(org.apache.storm.generated.Assignment) LocalAssignment(org.apache.storm.generated.LocalAssignment) SynchronizeAssignments(org.apache.storm.daemon.supervisor.timer.SynchronizeAssignments) SupervisorWorkerHeartbeat(org.apache.storm.generated.SupervisorWorkerHeartbeat) IOException(java.io.IOException) SupervisorAssignments(org.apache.storm.generated.SupervisorAssignments) WrappedNotAliveException(org.apache.storm.utils.WrappedNotAliveException)

Example 7 with WrappedNotAliveException

use of org.apache.storm.utils.WrappedNotAliveException 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);
}
Also used : IStormClusterState(org.apache.storm.cluster.IStormClusterState) WrappedNotAliveException(org.apache.storm.utils.WrappedNotAliveException)

Example 8 with WrappedNotAliveException

use of org.apache.storm.utils.WrappedNotAliveException 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);
    }
}
Also used : TException(org.apache.storm.thrift.TException) StormBase(org.apache.storm.generated.StormBase) IStormClusterState(org.apache.storm.cluster.IStormClusterState) 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 9 with WrappedNotAliveException

use of org.apache.storm.utils.WrappedNotAliveException 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)

Aggregations

WrappedNotAliveException (org.apache.storm.utils.WrappedNotAliveException)9 IOException (java.io.IOException)7 IStormClusterState (org.apache.storm.cluster.IStormClusterState)7 InterruptedIOException (java.io.InterruptedIOException)6 BindException (java.net.BindException)6 AlreadyAliveException (org.apache.storm.generated.AlreadyAliveException)6 AuthorizationException (org.apache.storm.generated.AuthorizationException)6 IllegalStateException (org.apache.storm.generated.IllegalStateException)6 InvalidTopologyException (org.apache.storm.generated.InvalidTopologyException)6 KeyAlreadyExistsException (org.apache.storm.generated.KeyAlreadyExistsException)6 KeyNotFoundException (org.apache.storm.generated.KeyNotFoundException)6 NotAliveException (org.apache.storm.generated.NotAliveException)6 TException (org.apache.storm.thrift.TException)6 WrappedAlreadyAliveException (org.apache.storm.utils.WrappedAlreadyAliveException)6 WrappedAuthorizationException (org.apache.storm.utils.WrappedAuthorizationException)6 WrappedIllegalStateException (org.apache.storm.utils.WrappedIllegalStateException)6 WrappedInvalidTopologyException (org.apache.storm.utils.WrappedInvalidTopologyException)6 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 List (java.util.List)3