Hisoka-X commented on code in PR #2366:
URL:
https://github.com/apache/incubator-seatunnel/pull/2366#discussion_r942129430
##########
seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/TaskExecutionService.java:
##########
@@ -156,7 +171,162 @@ private final class BlockingTaskThreadFactory implements
ThreadFactory {
@Override
public Thread newThread(@NonNull Runnable r) {
return new Thread(r,
- String.format("hz.%s.seaTunnel.blocking.thread-%d",
hzInstanceName, seq.getAndIncrement()));
+ String.format("hz.%s.seaTunnel.task.thread-%d",
hzInstanceName, seq.getAndIncrement()));
+ }
+ }
+
+ /**
+ * BusWork is used to poll the task call method,
+ * When a task times out, a new BusWork will be created to take over the
execution of the task
+ */
+ public final class BusWork implements Runnable {
+
+ AtomicBoolean keep = new AtomicBoolean(true);
+ public AtomicReference<TaskTracker> exclusiveTaskTracker = new
AtomicReference<>();
+ final TaskCallTimer timer;
+ public LinkedBlockingDeque<TaskTracker> taskqueue;
+
+ @SuppressWarnings("checkstyle:MagicNumber")
+ public BusWork(LinkedBlockingDeque<TaskTracker> taskqueue,
RunBusWorkSupplier runBusWorkSupplier) {
+ logger.info(String.format("Created new BusWork : %s",
this.hashCode()));
+ this.taskqueue = taskqueue;
+ this.timer = new TaskCallTimer(50, keep, runBusWorkSupplier, this);
+ }
+
+ @SneakyThrows
+ @Override
+ public void run() {
+ while (keep.get()) {
+ TaskTracker taskTracker = null != exclusiveTaskTracker.get() ?
+ exclusiveTaskTracker.get() :
+ taskqueue.takeFirst();
+ TaskGroupExecutionTracker taskGroupExecutionTracker =
taskTracker.taskGroupExecutionTracker;
+ if
(taskGroupExecutionTracker.executionCompletedExceptionally()) {
+ taskGroupExecutionTracker.taskDone();
+ if (null != exclusiveTaskTracker.get()) {
+ // If it's exclusive need to end the work
+ break;
+ } else {
+ // No action required and don't put back
+ continue;
+ }
+ }
+ //start timer, if it's exclusive, don't need to start
+ if (null == exclusiveTaskTracker.get()) {
+ timer.timerStart(taskTracker);
+ }
+ ProgressState call = null;
+ try {
+ //run task
+ call = taskTracker.task.call();
+ synchronized (timer) {
Review Comment:
Ok, I find it.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]