}
public WorkerShutdown execute() throws Exception {
List<AsyncLoopThread> threads = new ArrayList<AsyncLoopThread>();
AsyncLoopThread dispatcher = startDispatchThread();
threads.add(dispatcher);
// 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);
TimeTick timeTick = new TimeTick(workerData);
AsyncLoopThread tick = new AsyncLoopThread(timeTick);
threads.add(tick);
// refresh ZK active status
RefreshActive refreshZkActive = new RefreshActive(workerData);
AsyncLoopThread refreshzk = new AsyncLoopThread(refreshZkActive, false,
Thread.MIN_PRIORITY, true);
threads.add(refreshzk);
BatchTupleRunable batchRunable = new BatchTupleRunable(workerData);
AsyncLoopThread batch = new AsyncLoopThread(batchRunable, false,
Thread.MAX_PRIORITY, true);
threads.add(batch);
// transferQueue, nodeportSocket, taskNodeport
DrainerRunable drainer = new DrainerRunable(workerData);
AsyncLoopThread dr = new AsyncLoopThread(drainer, false,
Thread.MAX_PRIORITY, true);
threads.add(dr);
// Sync heartbeat to Apsara Container
AsyncLoopThread syncContainerHbThread = SyncContainerHb
.mkWorkerInstance(workerData.getConf());
if (syncContainerHbThread != null) {
threads.add(syncContainerHbThread);
}
MetricReporter metricReporter = workerData.getMetricsReporter();
boolean isMetricsEnable = ConfigExtension
.isEnablePerformanceMetrics(workerData.getStormConf());
metricReporter.setEnable(isMetricsEnable);
metricReporter.start();
LOG.info("Start metrics reporter, enable performance metrics: "
+ isMetricsEnable);
// create task heartbeat
TaskHeartbeatRunable taskHB = new TaskHeartbeatRunable(workerData);
AsyncLoopThread taskHBThread = new AsyncLoopThread(taskHB);
threads.add(taskHBThread);
// refresh hearbeat to Local dir
RunnableCallback heartbeat_fn = new WorkerHeartbeatRunable(workerData);
AsyncLoopThread hb = new AsyncLoopThread(heartbeat_fn, false, null,
Thread.NORM_PRIORITY, true);
threads.add(hb);
// shutdown task callbacks
List<TaskShutdownDameon> shutdowntasks = createTasks();