Search in sources :

Example 1 with Task

use of com.alibaba.jstorm.task.Task in project jstorm by alibaba.

the class Worker method createTasks.

private List<TaskShutdownDameon> createTasks() throws Exception {
    List<TaskShutdownDameon> shutdownTasks = new ArrayList<>();
    Set<Integer> taskIds = workerData.getTaskids();
    Set<Thread> threads = new HashSet<>();
    List<Task> taskArrayList = new ArrayList<>();
    for (int taskId : taskIds) {
        Task task = new Task(workerData, taskId);
        Thread thread = new Thread(task);
        threads.add(thread);
        taskArrayList.add(task);
        thread.start();
    }
    for (Thread thread : threads) {
        thread.join();
    }
    for (Task t : taskArrayList) {
        shutdownTasks.add(t.getTaskShutdownDameon());
    }
    return shutdownTasks;
}
Also used : Task(com.alibaba.jstorm.task.Task) TaskShutdownDameon(com.alibaba.jstorm.task.TaskShutdownDameon) AsyncLoopThread(com.alibaba.jstorm.callback.AsyncLoopThread)

Aggregations

AsyncLoopThread (com.alibaba.jstorm.callback.AsyncLoopThread)1 Task (com.alibaba.jstorm.task.Task)1 TaskShutdownDameon (com.alibaba.jstorm.task.TaskShutdownDameon)1