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