no message
This commit is contained in:
@@ -12,12 +12,12 @@ import Repository.Server.ServerCode;
|
||||
import Repository.Server.ServerExchangeUnit_2021;
|
||||
import TestingSystem.Common.Group.Group;
|
||||
import TestingSystem.Common.MachineProcess.MachineProcess;
|
||||
import TestingSystem.Common.MachineProcess.MachineProcessSet;
|
||||
import TestingSystem.Common.Test.Test;
|
||||
import TestingSystem.Common.Test.TestType;
|
||||
import TestingSystem.Common.TestingPackageToKill.TestingPackageToKill;
|
||||
import TestingSystem.DVM.DVMPackage.DVMPackage;
|
||||
import TestingSystem.DVM.DVMPackage.DVMPackage_json;
|
||||
import TestingSystem.DVM.DVMTestingChecker;
|
||||
import TestingSystem.SAPFOR.Json.SapforPackage_json;
|
||||
import TestingSystem.SAPFOR.SapforConfiguration.SapforConfiguration;
|
||||
import TestingSystem.SAPFOR.SapforConfigurationCommand.SapforConfigurationCommand;
|
||||
@@ -37,6 +37,43 @@ import java.nio.file.Paths;
|
||||
import java.util.*;
|
||||
public class TestingServer extends RepositoryServer<TestsDatabase> {
|
||||
public String name = "?";
|
||||
public static MachineProcessSet machinesProcesses= new MachineProcessSet();
|
||||
void StartNecessaryMachines() {
|
||||
try {
|
||||
Vector<String> aborted = new Vector<>();
|
||||
for (MachineProcess process : machinesProcesses.Data.values()) {
|
||||
if (process.isAborted()) {
|
||||
aborted.add(process.id);
|
||||
}
|
||||
}
|
||||
//---
|
||||
for (String key : aborted) {
|
||||
machinesProcesses.Data.remove(key);
|
||||
}
|
||||
//---
|
||||
LinkedHashMap<String, MachineProcess> processes_to_start = new LinkedHashMap<>();
|
||||
//1. Получить список всех пакетов, которые активны, и взять из них машины.
|
||||
for (DVMPackage dvmPackage : db.dvmPackages.Data.values()) {
|
||||
if (dvmPackage.state.isActive()) {
|
||||
//-
|
||||
if (!machinesProcesses.hasProcessForPackage(dvmPackage)) {
|
||||
MachineProcess new_process = new MachineProcess(dvmPackage);
|
||||
processes_to_start.put(new_process.getUniqueKey(), new_process);
|
||||
}
|
||||
}
|
||||
}
|
||||
//запуск.
|
||||
for (MachineProcess process : processes_to_start.values()) {
|
||||
process.Start();
|
||||
if (Utils.checkFileCreation(process.getStartedFile())) {
|
||||
machinesProcesses.Data.put(process.id, process);
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterPublishAction(DBObject object) throws Exception {
|
||||
if (object instanceof Test) {
|
||||
@@ -55,6 +92,8 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
|
||||
//--
|
||||
dvmPackage.saveJson();
|
||||
dvmPackage.package_json = null; // объект больше не нужен.
|
||||
//--
|
||||
|
||||
} else if (object instanceof SapforPackage) {
|
||||
((SapforPackage) object).init();
|
||||
}
|
||||
@@ -120,12 +159,12 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
|
||||
testingThread.start();
|
||||
}
|
||||
|
||||
DVMTestingChecker dvmTestingChecker = new DVMTestingChecker();
|
||||
// DVMTestingChecker dvmTestingChecker = new DVMTestingChecker();
|
||||
SapforTestingPlanner sapforTestingPlanner = new SapforTestingPlanner();
|
||||
//--
|
||||
protected Thread testingThread = new Thread(() -> {
|
||||
while (true) {
|
||||
dvmTestingChecker.Perform();
|
||||
// dvmTestingChecker.Perform();
|
||||
sapforTestingPlanner.Perform();
|
||||
System.out.println("sleep...");
|
||||
Utils.sleep(5000);
|
||||
@@ -586,46 +625,6 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
|
||||
response.object = db.getFirstActiveDVMPackageCopyForMachineURL(request.arg);
|
||||
}
|
||||
//-----
|
||||
void StartNecessaryMachines() {
|
||||
Print("Проверка процессов машин...");
|
||||
try {
|
||||
Vector<String> aborted = new Vector<>();
|
||||
for (MachineProcess process : db.machinesProcesses.Data.values()) {
|
||||
if (process.isAborted()) {
|
||||
aborted.add(process.id);
|
||||
}
|
||||
}
|
||||
//---
|
||||
for (String key : aborted) {
|
||||
Print(key + " остановлен");
|
||||
db.machinesProcesses.Data.remove(key);
|
||||
}
|
||||
//---
|
||||
Print(db.machinesProcesses.size() + " активных процессов");
|
||||
//--
|
||||
LinkedHashMap<String, MachineProcess> processes_to_start = new LinkedHashMap<>();
|
||||
//1. Получить список всех пакетов, которые активны, и взять из них машины.
|
||||
for (DVMPackage dvmPackage : db.dvmPackages.Data.values()) {
|
||||
if (dvmPackage.state.isActive()) {
|
||||
//-
|
||||
if (!db.machinesProcesses.hasProcessForPackage(dvmPackage)) {
|
||||
MachineProcess new_process = new MachineProcess(dvmPackage);
|
||||
processes_to_start.put(new_process.getUniqueKey(), new_process);
|
||||
}
|
||||
}
|
||||
}
|
||||
Print("Ожидающие запуск процессы: " + processes_to_start.size());
|
||||
//запуск.
|
||||
for (MachineProcess process : processes_to_start.values()) {
|
||||
process.Start();
|
||||
if (Utils.checkFileCreation(process.getStartedFile())) {
|
||||
db.machinesProcesses.Data.put(process.id, process);
|
||||
Print(process.getUniqueKey()+" запущен");
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user