|
|
|
@ -40,6 +40,7 @@ import java.util.LinkedList;
|
|
|
|
|
import java.util.List; |
|
|
|
|
import java.util.concurrent.ExecutorService; |
|
|
|
|
import java.util.concurrent.Executors; |
|
|
|
|
import java.util.concurrent.LinkedBlockingQueue; |
|
|
|
|
import java.util.concurrent.ThreadFactory; |
|
|
|
|
import java.util.concurrent.TimeUnit; |
|
|
|
|
import java.util.function.Consumer; |
|
|
|
@ -68,7 +69,7 @@ public abstract class AbstractCommandExecutor {
|
|
|
|
|
/** |
|
|
|
|
* log handler |
|
|
|
|
*/ |
|
|
|
|
protected Consumer<List<String>> logHandler; |
|
|
|
|
protected Consumer<LinkedBlockingQueue<String>> logHandler; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* logger |
|
|
|
@ -78,7 +79,7 @@ public abstract class AbstractCommandExecutor {
|
|
|
|
|
/** |
|
|
|
|
* log list |
|
|
|
|
*/ |
|
|
|
|
protected List<String> logBuffer; |
|
|
|
|
protected LinkedBlockingQueue<String> logBuffer; |
|
|
|
|
|
|
|
|
|
protected boolean logOutputIsSuccess = false; |
|
|
|
|
|
|
|
|
@ -92,16 +93,16 @@ public abstract class AbstractCommandExecutor {
|
|
|
|
|
*/ |
|
|
|
|
protected TaskRequest taskRequest; |
|
|
|
|
|
|
|
|
|
public AbstractCommandExecutor(Consumer<List<String>> logHandler, |
|
|
|
|
public AbstractCommandExecutor(Consumer<LinkedBlockingQueue<String>> logHandler, |
|
|
|
|
TaskRequest taskRequest, |
|
|
|
|
Logger logger) { |
|
|
|
|
this.logHandler = logHandler; |
|
|
|
|
this.taskRequest = taskRequest; |
|
|
|
|
this.logger = logger; |
|
|
|
|
this.logBuffer = Collections.synchronizedList(new ArrayList<>()); |
|
|
|
|
this.logBuffer = new LinkedBlockingQueue<>(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public AbstractCommandExecutor(List<String> logBuffer) { |
|
|
|
|
public AbstractCommandExecutor(LinkedBlockingQueue<String> logBuffer) { |
|
|
|
|
this.logBuffer = logBuffer; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -290,15 +291,15 @@ public abstract class AbstractCommandExecutor {
|
|
|
|
|
*/ |
|
|
|
|
private void clear() { |
|
|
|
|
|
|
|
|
|
List<String> markerList = new ArrayList<>(); |
|
|
|
|
markerList.add(ch.qos.logback.classic.ClassicConstants.FINALIZE_SESSION_MARKER.toString()); |
|
|
|
|
LinkedBlockingQueue<String> markerLog = new LinkedBlockingQueue<>(1); |
|
|
|
|
markerLog.add(ch.qos.logback.classic.ClassicConstants.FINALIZE_SESSION_MARKER.toString()); |
|
|
|
|
|
|
|
|
|
if (!logBuffer.isEmpty()) { |
|
|
|
|
// log handle
|
|
|
|
|
logHandler.accept(logBuffer); |
|
|
|
|
logBuffer.clear(); |
|
|
|
|
} |
|
|
|
|
logHandler.accept(markerList); |
|
|
|
|
logHandler.accept(markerLog); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|