Search in sources :

Example 1 with WorkerHeartbeatRunable

use of com.alibaba.jstorm.daemon.worker.hearbeat.WorkerHeartbeatRunable in project jstorm by alibaba.

the class Worker method execute.

public WorkerShutdown execute() throws Exception {
    List<AsyncLoopThread> threads = new ArrayList<>();
    // create recv connection, reduce the count of netty client reconnect
    AsyncLoopThread controlRvthread = startDispatchThread();
    threads.add(controlRvthread);
    // create client before create task
    // so create client connection before create task
    // refresh connection
    RefreshConnections refreshConn = makeRefreshConnections();
    AsyncLoopThread refreshconn = new AsyncLoopThread(refreshConn, false, Thread.MIN_PRIORITY, true);
    threads.add(refreshconn);
    // refresh ZK active status
    RefreshActive refreshZkActive = new RefreshActive(workerData);
    AsyncLoopThread refreshZk = new AsyncLoopThread(refreshZkActive, false, Thread.MIN_PRIORITY, true);
    threads.add(refreshZk);
    // create send control message thread
    DrainerCtrlRunable drainerCtrlRunable;
    drainerCtrlRunable = new DrainerCtrlRunable(workerData, MetricDef.SEND_THREAD);
    AsyncLoopThread controlSendThread = new AsyncLoopThread(drainerCtrlRunable, false, Thread.MAX_PRIORITY, true);
    threads.add(controlSendThread);
    // Sync heartbeat to Apsara Container
    AsyncLoopThread syncContainerHbThread = SyncContainerHb.mkWorkerInstance(workerData.getStormConf());
    if (syncContainerHbThread != null) {
        threads.add(syncContainerHbThread);
    }
    JStormMetricsReporter metricReporter = new JStormMetricsReporter(workerData);
    metricReporter.init();
    workerData.setMetricsReporter(metricReporter);
    // refresh heartbeat to Local dir
    RunnableCallback heartbeatFn = new WorkerHeartbeatRunable(workerData);
    AsyncLoopThread hb = new AsyncLoopThread(heartbeatFn, false, null, Thread.NORM_PRIORITY, true);
    threads.add(hb);
    // shutdown task callbacks
    List<TaskShutdownDameon> shutdownTasks = createTasks();
    workerData.setShutdownTasks(shutdownTasks);
    // create worker serializes/deserialize threads
    List<AsyncLoopThread> serializeThreads = workerData.setSerializeThreads();
    threads.addAll(serializeThreads);
    List<AsyncLoopThread> deserializeThreads = workerData.setDeserializeThreads();
    threads.addAll(deserializeThreads);
    return new WorkerShutdown(workerData, threads);
}
Also used : WorkerHeartbeatRunable(com.alibaba.jstorm.daemon.worker.hearbeat.WorkerHeartbeatRunable) RunnableCallback(com.alibaba.jstorm.callback.RunnableCallback) TaskShutdownDameon(com.alibaba.jstorm.task.TaskShutdownDameon) AsyncLoopThread(com.alibaba.jstorm.callback.AsyncLoopThread)

Aggregations

AsyncLoopThread (com.alibaba.jstorm.callback.AsyncLoopThread)1 RunnableCallback (com.alibaba.jstorm.callback.RunnableCallback)1 WorkerHeartbeatRunable (com.alibaba.jstorm.daemon.worker.hearbeat.WorkerHeartbeatRunable)1 TaskShutdownDameon (com.alibaba.jstorm.task.TaskShutdownDameon)1