Запись информации о текущих задачах в лог.
This commit is contained in:
@@ -6,8 +6,8 @@ import SapforTestingSystem.Json.SapforConfiguration_json;
|
||||
import SapforTestingSystem.Json.SapforTasksPackage_json;
|
||||
import SapforTestingSystem.Json.SapforTasksResults_json;
|
||||
import SapforTestingSystem.Json.SapforTest_json;
|
||||
import SapforTestingSystem.PerformSapforTask;
|
||||
import SapforTestingSystem.SapforTask.SapforTask;
|
||||
import SapforTestingSystem.TaskThread;
|
||||
import SapforTestingSystem.ThreadsPlanner.ThreadsPlanner;
|
||||
import Visual_DVM_2021.Passes.PassCode_2021;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
@@ -39,26 +39,22 @@ public class PackageModeSupervisor extends ThreadsPlanner {
|
||||
task.sapfortaskspackage_id = new File(Global.Home).getName();
|
||||
results_json.tasks.add(task);
|
||||
Vector<String> codes_s = new Vector<>();
|
||||
for (PassCode_2021 code: sapforConfiguration_json.codes){
|
||||
for (PassCode_2021 code : sapforConfiguration_json.codes) {
|
||||
codes_s.add(code.toString());
|
||||
}
|
||||
task.codes = String.join(" ", codes_s);
|
||||
//---
|
||||
addThread(() -> {
|
||||
while (!task.state.isComplete()) {
|
||||
task.Reset();
|
||||
new PerformSapforTask().Do(
|
||||
sapfor_drv,
|
||||
sapforConfiguration_json,
|
||||
task
|
||||
);
|
||||
}
|
||||
});
|
||||
addThread(new TaskThread(task, sapfor_drv, sapforConfiguration_json));
|
||||
}
|
||||
}
|
||||
interruptThread.start();
|
||||
}
|
||||
@Override
|
||||
public String printThread(Integer id) {
|
||||
TaskThread taskThread = (TaskThread) threads.get(id);
|
||||
return taskThread.task.getSummary();
|
||||
}
|
||||
@Override
|
||||
protected void finalize() {
|
||||
results_json.EndDate = new Date().getTime();
|
||||
//записать результаты всех задач.
|
||||
|
||||
@@ -22,7 +22,8 @@ import static java.lang.Character.isDigit;
|
||||
public class PerformSapforTask extends Pass_2021<SapforTask> {
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Запуск задачи SAPFOR";
|
||||
return "";
|
||||
// "Запуск задачи SAPFOR"; Оставляем пустое описание чтобы не засорять журнал.
|
||||
}
|
||||
@Override
|
||||
protected boolean needsAnimation() {
|
||||
@@ -359,14 +360,4 @@ public class PerformSapforTask extends Pass_2021<SapforTask> {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
protected void performFinish() throws Exception {
|
||||
/*
|
||||
//теперь строим деревья версий. нельзя делать в body. так как могут быть исключения например неверный код процесса.
|
||||
for (SapforVersion_json version : target.versions)
|
||||
createVersionProjectData(version, true);
|
||||
for (SapforVersion_json version : target.variants)
|
||||
createVersionProjectData(version, false);
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,6 +58,14 @@ public class SapforTask extends DBObject {
|
||||
public String getUniqueKey() {
|
||||
return sapfor_configuration_id + "_" + group_description + "_" + test_description;
|
||||
}
|
||||
public String getSummary() {
|
||||
Vector<String> lines = new Vector<>();
|
||||
lines.add(group_description);
|
||||
lines.add(test_description);
|
||||
lines.add(codes);
|
||||
lines.add(flags);
|
||||
return String.join(" ", lines);
|
||||
}
|
||||
//-----------
|
||||
public SapforTask() {
|
||||
}
|
||||
|
||||
21
src/SapforTestingSystem/TaskThread.java
Normal file
21
src/SapforTestingSystem/TaskThread.java
Normal file
@@ -0,0 +1,21 @@
|
||||
package SapforTestingSystem;
|
||||
import SapforTestingSystem.Json.SapforConfiguration_json;
|
||||
import SapforTestingSystem.SapforTask.SapforTask;
|
||||
|
||||
import java.io.File;
|
||||
public class TaskThread extends Thread {
|
||||
public SapforTask task = null;
|
||||
public TaskThread(SapforTask task_, File sapfor_drv, SapforConfiguration_json sapforConfiguration_json) {
|
||||
super(() -> {
|
||||
while (!task_.state.isComplete()) {
|
||||
task_.Reset();
|
||||
new PerformSapforTask().Do(
|
||||
sapfor_drv,
|
||||
sapforConfiguration_json,
|
||||
task_
|
||||
);
|
||||
}
|
||||
});
|
||||
task = task_;
|
||||
}
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
package SapforTestingSystem.ThreadTask;
|
||||
import Common.Constants;
|
||||
public class ThreadTask {
|
||||
public int id = Constants.Nan;
|
||||
public Thread thread;
|
||||
public ThreadTask(int id_in, Runnable runnable){
|
||||
id = id_in;
|
||||
thread = new Thread(runnable);
|
||||
}
|
||||
}
|
||||
@@ -27,17 +27,31 @@ public abstract class ThreadsPlanner {
|
||||
public ThreadsPlanner(int wait_ms_in) {
|
||||
wait_ms = wait_ms_in;
|
||||
}
|
||||
public void setMaxKernels(int maxKernels_in){
|
||||
public void setMaxKernels(int maxKernels_in) {
|
||||
maxKernels = maxKernels_in;
|
||||
kernels = maxKernels;
|
||||
}
|
||||
public String printThread(Integer id) {
|
||||
return "thread id = "+id;
|
||||
}
|
||||
public String getThreadsSummary() {
|
||||
Vector<String> lines = new Vector<>();
|
||||
lines.add("Planner summary:");
|
||||
lines.add("Waiting: " + waitingThreads.size());
|
||||
lines.add("Running: " + activeThreads.size());
|
||||
for (Integer id : activeThreads) {
|
||||
lines.add(printThread(id));
|
||||
}
|
||||
lines.add("");
|
||||
return String.join("\n", lines);
|
||||
}
|
||||
//--
|
||||
public void Start() {
|
||||
Global.Log.Print("Planner started");
|
||||
try {
|
||||
//--
|
||||
while (!waitingThreads.isEmpty() || !activeThreads.isEmpty()) {
|
||||
Global.Log.Print("Waiting: " + waitingThreads.size() + "; Running: " + activeThreads.size() + ".");
|
||||
Global.Log.Print(getThreadsSummary());
|
||||
checkActiveThreads();
|
||||
tryStartThreads();
|
||||
Thread.sleep(wait_ms);
|
||||
@@ -45,8 +59,7 @@ public abstract class ThreadsPlanner {
|
||||
//--
|
||||
} catch (Exception exception) {
|
||||
Global.Log.PrintException(exception);
|
||||
}
|
||||
finally {
|
||||
} finally {
|
||||
Global.Log.Print("Planner finished");
|
||||
finalize();
|
||||
}
|
||||
@@ -82,8 +95,7 @@ public abstract class ThreadsPlanner {
|
||||
}
|
||||
protected void finalize() {
|
||||
}
|
||||
protected void addThread(Runnable runnable) {
|
||||
Thread thread = new Thread(runnable);
|
||||
protected void addThread(Thread thread) {
|
||||
threads.put(threadMaxId, thread);
|
||||
waitingThreads.add(threadMaxId);
|
||||
threadMaxId++;
|
||||
|
||||
Reference in New Issue
Block a user