Запись информации о текущих задачах в лог.

This commit is contained in:
2023-11-14 16:19:31 +03:00
parent 38eea01f5c
commit 21914e3ba1
7 changed files with 63 additions and 52 deletions

19
.idea/workspace.xml generated
View File

@@ -7,20 +7,13 @@
</component> </component>
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="e42177c3-2328-4b27-8a01-35779b2beb99" name="Default Changelist" comment=""> <list default="true" id="e42177c3-2328-4b27-8a01-35779b2beb99" name="Default Changelist" comment="">
<change afterPath="$PROJECT_DIR$/src/SapforTestingSystem/TaskThread.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Common/Constants.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Common/Constants.java" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/SapforTestingSystem/PackageModeSupervisor/PackageModeSupervisor.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/SapforTestingSystem/PackageModeSupervisor/PackageModeSupervisor.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Repository/Component/UI/PublishFields.form" beforeDir="false" afterPath="$PROJECT_DIR$/src/Repository/Component/UI/PublishFields.form" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/SapforTestingSystem/PerformSapforTask.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/SapforTestingSystem/PerformSapforTask.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Repository/Component/UI/PublishFields.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Repository/Component/UI/PublishFields.java" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/SapforTestingSystem/SapforTask/SapforTask.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/SapforTestingSystem/SapforTask/SapforTask.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Repository/RepositoryServer.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Repository/RepositoryServer.java" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/SapforTestingSystem/ThreadTask/ThreadTask.java" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/src/Repository/Server/ComponentsServer.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Repository/Server/ComponentsServer.java" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/SapforTestingSystem/ThreadsPlanner/ThreadsPlanner.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/SapforTestingSystem/ThreadsPlanner/ThreadsPlanner.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Repository/Server/ServerCode.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Repository/Server/ServerCode.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/TestingSystem/TestingServer.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/TestingSystem/TestingServer.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/All/InstallServerSapfor.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/All/InstallServerSapfor.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/All/PublishComponent.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/All/PublishComponent.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/SSH/ConnectionPass.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/SSH/ConnectionPass.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Visual_DVM_2021/UI/Interface/TestingWindow.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Visual_DVM_2021/UI/Interface/TestingWindow.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Visual_DVM_2021/UI/Main/MainForm.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Visual_DVM_2021/UI/Main/MainForm.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Visual_DVM_2021/UI/Main/TestingForm.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Visual_DVM_2021/UI/Main/TestingForm.java" afterDir="false" />
</list> </list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" /> <option name="HIGHLIGHT_CONFLICTS" value="true" />

View File

@@ -6,8 +6,8 @@ import SapforTestingSystem.Json.SapforConfiguration_json;
import SapforTestingSystem.Json.SapforTasksPackage_json; import SapforTestingSystem.Json.SapforTasksPackage_json;
import SapforTestingSystem.Json.SapforTasksResults_json; import SapforTestingSystem.Json.SapforTasksResults_json;
import SapforTestingSystem.Json.SapforTest_json; import SapforTestingSystem.Json.SapforTest_json;
import SapforTestingSystem.PerformSapforTask;
import SapforTestingSystem.SapforTask.SapforTask; import SapforTestingSystem.SapforTask.SapforTask;
import SapforTestingSystem.TaskThread;
import SapforTestingSystem.ThreadsPlanner.ThreadsPlanner; import SapforTestingSystem.ThreadsPlanner.ThreadsPlanner;
import Visual_DVM_2021.Passes.PassCode_2021; import Visual_DVM_2021.Passes.PassCode_2021;
import org.apache.commons.io.FileUtils; import org.apache.commons.io.FileUtils;
@@ -44,21 +44,17 @@ public class PackageModeSupervisor extends ThreadsPlanner {
} }
task.codes = String.join(" ", codes_s); task.codes = String.join(" ", codes_s);
//--- //---
addThread(() -> { addThread(new TaskThread(task, sapfor_drv, sapforConfiguration_json));
while (!task.state.isComplete()) {
task.Reset();
new PerformSapforTask().Do(
sapfor_drv,
sapforConfiguration_json,
task
);
}
});
} }
} }
interruptThread.start(); interruptThread.start();
} }
@Override @Override
public String printThread(Integer id) {
TaskThread taskThread = (TaskThread) threads.get(id);
return taskThread.task.getSummary();
}
@Override
protected void finalize() { protected void finalize() {
results_json.EndDate = new Date().getTime(); results_json.EndDate = new Date().getTime();
//записать результаты всех задач. //записать результаты всех задач.

View File

@@ -22,7 +22,8 @@ import static java.lang.Character.isDigit;
public class PerformSapforTask extends Pass_2021<SapforTask> { public class PerformSapforTask extends Pass_2021<SapforTask> {
@Override @Override
public String getDescription() { public String getDescription() {
return "Запуск задачи SAPFOR"; return "";
// "Запуск задачи SAPFOR"; Оставляем пустое описание чтобы не засорять журнал.
} }
@Override @Override
protected boolean needsAnimation() { protected boolean needsAnimation() {
@@ -359,14 +360,4 @@ public class PerformSapforTask extends Pass_2021<SapforTask> {
break; 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);
*/
}
} }

View File

@@ -58,6 +58,14 @@ public class SapforTask extends DBObject {
public String getUniqueKey() { public String getUniqueKey() {
return sapfor_configuration_id + "_" + group_description + "_" + test_description; 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() { public SapforTask() {
} }

View 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_;
}
}

View File

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

View File

@@ -31,13 +31,27 @@ public abstract class ThreadsPlanner {
maxKernels = maxKernels_in; maxKernels = maxKernels_in;
kernels = maxKernels; 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() { public void Start() {
Global.Log.Print("Planner started"); Global.Log.Print("Planner started");
try { try {
//-- //--
while (!waitingThreads.isEmpty() || !activeThreads.isEmpty()) { while (!waitingThreads.isEmpty() || !activeThreads.isEmpty()) {
Global.Log.Print("Waiting: " + waitingThreads.size() + "; Running: " + activeThreads.size() + "."); Global.Log.Print(getThreadsSummary());
checkActiveThreads(); checkActiveThreads();
tryStartThreads(); tryStartThreads();
Thread.sleep(wait_ms); Thread.sleep(wait_ms);
@@ -45,8 +59,7 @@ public abstract class ThreadsPlanner {
//-- //--
} catch (Exception exception) { } catch (Exception exception) {
Global.Log.PrintException(exception); Global.Log.PrintException(exception);
} } finally {
finally {
Global.Log.Print("Planner finished"); Global.Log.Print("Planner finished");
finalize(); finalize();
} }
@@ -82,8 +95,7 @@ public abstract class ThreadsPlanner {
} }
protected void finalize() { protected void finalize() {
} }
protected void addThread(Runnable runnable) { protected void addThread(Thread thread) {
Thread thread = new Thread(runnable);
threads.put(threadMaxId, thread); threads.put(threadMaxId, thread);
waitingThreads.add(threadMaxId); waitingThreads.add(threadMaxId);
threadMaxId++; threadMaxId++;