Search in sources :

Example 6 with AsyncLoopThread

use of com.alibaba.jstorm.callback.AsyncLoopThread in project jstorm by alibaba.

the class JStormMetricsReporter method init.

public void init() {
    if (JStormMetrics.enabled) {
        this.checkMetricMetaThread = new AsyncLoopThread(new CheckMetricMetaThread());
        this.flushMetricThread = new AsyncLoopThread(new FlushMetricThread());
    }
}
Also used : AsyncLoopThread(com.alibaba.jstorm.callback.AsyncLoopThread)

Example 7 with AsyncLoopThread

use of com.alibaba.jstorm.callback.AsyncLoopThread in project jstorm by alibaba.

the class NimbusServer method cleanup.

public void cleanup() {
    if (data == null || data.getIsShutdown().getAndSet(true)) {
        LOG.info("Notify to quit nimbus");
        return;
    }
    LOG.info("Begin to shutdown nimbus");
    AsyncLoopRunnable.getShutdown().set(true);
    data.getScheduExec().shutdownNow();
    for (AsyncLoopThread t : smartThreads) {
        t.cleanup();
        JStormUtils.sleepMs(10);
        t.interrupt();
        // try {
        // t.join();
        // } catch (InterruptedException e) {
        // LOG.error("join thread", e);
        // }
        LOG.info("Successfully cleanup " + t.getThread().getName());
    }
    if (serviceHandler != null) {
        serviceHandler.shutdown();
    }
    if (topologyAssign != null) {
        topologyAssign.cleanup();
        LOG.info("Successfully shutdown TopologyAssign thread");
    }
    if (follower != null) {
        follower.clean();
        LOG.info("Successfully shutdown follower thread");
    }
    if (data != null) {
        data.cleanup();
        LOG.info("Successfully shutdown NimbusData");
    }
    if (thriftServer != null) {
        thriftServer.stop();
        LOG.info("Successfully shutdown thrift server");
    }
    if (hs != null) {
        hs.shutdown();
        LOG.info("Successfully shutdown httpserver");
    }
    LOG.info("Successfully shutdown nimbus");
    // make sure shutdown nimbus
    JStormUtils.halt_process(0, "!!!Shutdown!!!");
}
Also used : AsyncLoopThread(com.alibaba.jstorm.callback.AsyncLoopThread)

Example 8 with AsyncLoopThread

use of com.alibaba.jstorm.callback.AsyncLoopThread in project jstorm by alibaba.

the class Task method execute.

public TaskShutdownDameon execute() throws Exception {
    taskSendTargets = echoToSystemBolt();
    // create thread to get tuple from zeroMQ,
    // and pass the tuple to bolt/spout
    taskTransfer = mkTaskSending(workerData);
    RunnableCallback baseExecutor = prepareExecutor();
    //set baseExecutors for update
    setBaseExecutors((BaseExecutors) baseExecutor);
    AsyncLoopThread executor_threads = new AsyncLoopThread(baseExecutor, false, Thread.MAX_PRIORITY, true);
    taskReceiver = mkTaskReceiver();
    List<AsyncLoopThread> allThreads = new ArrayList<AsyncLoopThread>();
    allThreads.add(executor_threads);
    LOG.info("Finished loading task " + componentId + ":" + taskId);
    taskShutdownDameon = getShutdown(allThreads, baseExecutor);
    return taskShutdownDameon;
}
Also used : ArrayList(java.util.ArrayList) RunnableCallback(com.alibaba.jstorm.callback.RunnableCallback) AsyncLoopThread(com.alibaba.jstorm.callback.AsyncLoopThread)

Example 9 with AsyncLoopThread

use of com.alibaba.jstorm.callback.AsyncLoopThread in project jstorm by alibaba.

the class NimbusServer method initMetricRunnable.

private void initMetricRunnable() {
    AsyncLoopThread thread = new AsyncLoopThread(ClusterMetricsRunnable.getInstance());
    smartThreads.add(thread);
}
Also used : AsyncLoopThread(com.alibaba.jstorm.callback.AsyncLoopThread)

Example 10 with AsyncLoopThread

use of com.alibaba.jstorm.callback.AsyncLoopThread in project jstorm by alibaba.

the class SupervisorManger method shutdown.

@Override
public void shutdown() {
    if (shutdown.getAndSet(true)) {
        LOG.info("Supervisor has been shutdown before " + supervisorId);
        return;
    }
    LOG.info("Shutting down supervisor " + supervisorId);
    AsyncLoopRunnable.getShutdown().set(true);
    for (AsyncLoopThread thread : threads) {
        thread.cleanup();
        JStormUtils.sleepMs(10);
        thread.interrupt();
        // try {
        // thread.join();
        // } catch (InterruptedException e) {
        // LOG.error(e.getMessage(), e);
        // }
        LOG.info("Successfully shutdown thread:" + thread.getThread().getName());
    }
    eventManager.shutdown();
    try {
        stormClusterState.disconnect();
    } catch (Exception e) {
        LOG.error("Failed to shutdown ZK client", e);
    }
    if (httpserver != null) {
        httpserver.shutdown();
    }
    // if (this.cgroupManager != null)
    // try {
    // this.cgroupManager.close();
    // } catch (IOException e) {
    // LOG.error("Fail to close cgroup", e);
    // }
    isFinishShutdown = true;
    JStormUtils.halt_process(0, "!!!Shutdown!!!");
}
Also used : AsyncLoopThread(com.alibaba.jstorm.callback.AsyncLoopThread) IOException(java.io.IOException)

Aggregations

AsyncLoopThread (com.alibaba.jstorm.callback.AsyncLoopThread)15 RunnableCallback (com.alibaba.jstorm.callback.RunnableCallback)3 IConnection (backtype.storm.messaging.IConnection)2 WorkerTopologyContext (backtype.storm.task.WorkerTopologyContext)2 ArrayList (java.util.ArrayList)2 ITaskHook (backtype.storm.hooks.ITaskHook)1 IContext (backtype.storm.messaging.IContext)1 WorkerSlot (backtype.storm.scheduler.WorkerSlot)1 TopologyContext (backtype.storm.task.TopologyContext)1 DisruptorQueue (backtype.storm.utils.DisruptorQueue)1 LocalState (backtype.storm.utils.LocalState)1 StormClusterState (com.alibaba.jstorm.cluster.StormClusterState)1 AsmGauge (com.alibaba.jstorm.common.metric.AsmGauge)1 QueueGauge (com.alibaba.jstorm.common.metric.QueueGauge)1 SupervisorRefreshConfig (com.alibaba.jstorm.config.SupervisorRefreshConfig)1 WorkerReportError (com.alibaba.jstorm.daemon.worker.WorkerReportError)1 WorkerHeartbeatRunable (com.alibaba.jstorm.daemon.worker.hearbeat.WorkerHeartbeatRunable)1 TaskHeartbeatTrigger (com.alibaba.jstorm.daemon.worker.timer.TaskHeartbeatTrigger)1 EventManagerImp (com.alibaba.jstorm.event.EventManagerImp)1 EventManagerPusher (com.alibaba.jstorm.event.EventManagerPusher)1