Search in sources :

Example 6 with IRunningExecutor

use of org.apache.storm.executor.IRunningExecutor in project storm by apache.

the class Worker method shutdown.

@Override
public void shutdown() {
    try {
        LOG.info("Shutting down worker {} {} {}", topologyId, assignmentId, port);
        if (workerState != null) {
            for (IConnection socket : workerState.cachedNodeToPortSocket.get().values()) {
                // this will do best effort flushing since the linger period
                // was set on creation
                socket.close();
            }
            LOG.info("Terminating messaging context");
            LOG.info("Shutting down executors");
            for (IRunningExecutor executor : executorsAtom.get()) {
                ((ExecutorShutdown) executor).shutdown();
            }
            LOG.info("Shut down executors");
            LOG.info("Shutting down transfer thread");
            workerState.haltWorkerTransfer();
            if (transferThread != null) {
                transferThread.interrupt();
                transferThread.join();
                LOG.info("Shut down transfer thread");
            }
            workerState.heartbeatTimer.close();
            workerState.refreshConnectionsTimer.close();
            workerState.refreshCredentialsTimer.close();
            workerState.checkForUpdatedBlobsTimer.close();
            workerState.refreshActiveTimer.close();
            workerState.executorHeartbeatTimer.close();
            workerState.userTimer.close();
            workerState.refreshLoadTimer.close();
            workerState.resetLogLevelsTimer.close();
            workerState.flushTupleTimer.close();
            workerState.backPressureCheckTimer.close();
            // this is fine because the only time this is shared is when it's a local context,
            // in which case it's a noop
            workerState.mqContext.term();
            workerState.closeResources();
            LOG.info("Trigger any worker shutdown hooks");
            workerState.runWorkerShutdownHooks();
            workerState.stormClusterState.removeWorkerHeartbeat(topologyId, assignmentId, (long) port);
            LOG.info("Disconnecting from storm cluster state context");
            workerState.stormClusterState.disconnect();
            workerState.stateStorage.close();
        } else {
            LOG.error("workerState is null");
        }
        metricRegistry.stop();
        SharedMetricRegistries.remove(WORKER_METRICS_REGISTRY);
        LOG.info("Shut down worker {} {} {}", topologyId, assignmentId, port);
    } catch (Exception ex) {
        throw Utils.wrapInRuntime(ex);
    }
}
Also used : ExecutorShutdown(org.apache.storm.executor.ExecutorShutdown) IConnection(org.apache.storm.messaging.IConnection) IRunningExecutor(org.apache.storm.executor.IRunningExecutor) IOException(java.io.IOException) UnknownHostException(java.net.UnknownHostException)

Example 7 with IRunningExecutor

use of org.apache.storm.executor.IRunningExecutor in project storm by apache.

the class Worker method doRefreshLoad.

public void doRefreshLoad() {
    workerState.refreshLoad(executorsAtom.get());
    final List<IRunningExecutor> executors = executorsAtom.get();
    for (IRunningExecutor executor : executors) {
        executor.loadChanged(workerState.getLoadMapping());
    }
}
Also used : IRunningExecutor(org.apache.storm.executor.IRunningExecutor)

Aggregations

IRunningExecutor (org.apache.storm.executor.IRunningExecutor)7 IOException (java.io.IOException)3 UnknownHostException (java.net.UnknownHostException)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 AtomicLong (java.util.concurrent.atomic.AtomicLong)1 IStormClusterState (org.apache.storm.cluster.IStormClusterState)1 Executor (org.apache.storm.executor.Executor)1 ExecutorShutdown (org.apache.storm.executor.ExecutorShutdown)1 LocalExecutor (org.apache.storm.executor.LocalExecutor)1 Credentials (org.apache.storm.generated.Credentials)1 Load (org.apache.storm.grouping.Load)1 IConnection (org.apache.storm.messaging.IConnection)1 IAutoCredentials (org.apache.storm.security.auth.IAutoCredentials)1 WorkerBackpressureCallback (org.apache.storm.utils.WorkerBackpressureCallback)1