Search in sources :

Example 6 with TaskShutdownDameon

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

the class WorkerDeserializeRunnable method run.

@Override
public void run() {
    LOG.info("Successfully start " + getThreadName());
    while (AsyncLoopRunnable.getShutdown().get() == false) {
        int loopCount = shutdownTasks.size();
        //note: avoid to cpu idle
        boolean isIdling = true;
        for (int i = 0; i < loopCount; i++) {
            try {
                if (startRunTaskIndex >= shutdownTasks.size())
                    startRunTaskIndex = 0;
                TaskShutdownDameon taskShutdownDameon = shutdownTasks.get(startRunTaskIndex);
                boolean ret = taskShutdownDameon.getTask().getTaskReceiver().deserializer(deserializer, false);
                if (ret == false) {
                    isIdling = false;
                }
                startRunTaskIndex++;
            } catch (IndexOutOfBoundsException e) {
                //ingore
                continue;
            }
        }
        if (isIdling) {
            try {
                if (startRunTaskIndex >= shutdownTasks.size())
                    startRunTaskIndex = 0;
                TaskShutdownDameon taskShutdownDameon = shutdownTasks.get(startRunTaskIndex);
                taskShutdownDameon.getTask().getTaskReceiver().deserializer(deserializer, true);
                startRunTaskIndex++;
            } catch (IndexOutOfBoundsException e) {
            //inore
            }
        }
    }
}
Also used : TaskShutdownDameon(com.alibaba.jstorm.task.TaskShutdownDameon)

Example 7 with TaskShutdownDameon

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

the class WorkerSerializeRunnable method run.

@Override
public void run() {
    LOG.info("Successfully worker-serializer-{}", threadIndex);
    while (true) {
        try {
            TaskShutdownDameon taskShutdownDameon = shutdownTasks.get(startRunTaskIndex);
            taskShutdownDameon.getTask().getTaskTransfer().serializer(serializer);
            startRunTaskIndex++;
        } catch (IndexOutOfBoundsException e) {
            startRunTaskIndex = 0;
            continue;
        }
    }
}
Also used : TaskShutdownDameon(com.alibaba.jstorm.task.TaskShutdownDameon)

Example 8 with TaskShutdownDameon

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

the class RefreshConnections method createTasks.

private void createTasks(Set<Integer> tasks) {
    if (tasks == null)
        return;
    for (Integer taskId : tasks) {
        try {
            TaskShutdownDameon shutdown = Task.mk_task(workerData, taskId);
            workerData.addShutdownTask(shutdown);
        } catch (Exception e) {
            LOG.error("Failed to create task-" + taskId, e);
            throw new RuntimeException(e);
        }
    }
}
Also used : TaskShutdownDameon(com.alibaba.jstorm.task.TaskShutdownDameon) FileNotFoundException(java.io.FileNotFoundException)

Aggregations

TaskShutdownDameon (com.alibaba.jstorm.task.TaskShutdownDameon)8 FileNotFoundException (java.io.FileNotFoundException)3 AsyncLoopThread (com.alibaba.jstorm.callback.AsyncLoopThread)2 IConnection (backtype.storm.messaging.IConnection)1 WorkerSlot (backtype.storm.scheduler.WorkerSlot)1 RunnableCallback (com.alibaba.jstorm.callback.RunnableCallback)1 StormBase (com.alibaba.jstorm.cluster.StormBase)1 StatusType (com.alibaba.jstorm.daemon.nimbus.StatusType)1 WorkerHeartbeatRunable (com.alibaba.jstorm.daemon.worker.hearbeat.WorkerHeartbeatRunable)1 Assignment (com.alibaba.jstorm.schedule.Assignment)1 ResourceWorkerSlot (com.alibaba.jstorm.schedule.default_assign.ResourceWorkerSlot)1 Task (com.alibaba.jstorm.task.Task)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 Future (java.util.concurrent.Future)1