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
}
}
}
}
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;
}
}
}
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);
}
}
}
Aggregations