промежуточный. пилотный вариант планировщика в качестве отдельного процесса

This commit is contained in:
2024-04-15 22:09:10 +03:00
parent 5d09ae430c
commit 56f97584ef
10 changed files with 955 additions and 59 deletions

View File

@@ -27,7 +27,6 @@ import javafx.util.Pair;
import org.apache.commons.io.FileUtils;
import java.io.File;
import java.io.Serializable;
import java.nio.file.Paths;
import java.util.Comparator;
import java.util.LinkedHashMap;
@@ -210,13 +209,13 @@ public class TestsDatabase extends SQLiteDatabase {
Group group = groupData.getKey();
Vector<File> files = groupData.getValue();
//--
Group oldGroup = groups.getGroupByDescription(group.language,group.description);
Group oldGroup = groups.getGroupByDescription(group.language, group.description);
if (oldGroup == null) {
System.out.println("group "+Utils.Brackets(group.description)+" not found. create.");
System.out.println("group " + Utils.Brackets(group.description) + " not found. create.");
Insert(group);
for (File file : files) {
String testDescription = Utils.getNameWithoutExtension(file.getName()) + "_" + group.language.getDVMCompile();
System.out.println("test "+Utils.Brackets(testDescription) + " create"); //добавить тест.
System.out.println("test " + Utils.Brackets(testDescription) + " create"); //добавить тест.
CreateTestFromSingleFile(account, sapfor, group, file, testDescription);
}
} else {
@@ -224,7 +223,7 @@ public class TestsDatabase extends SQLiteDatabase {
String testDescription = Utils.getNameWithoutExtension(file.getName()) + "_" + group.language.getDVMCompile();
Test oldTest = tests.getTestByDescription(oldGroup.id, testDescription);
if (oldTest == null) {
System.out.println("test "+Utils.Brackets(testDescription) + " not found. create"); //добавить тест.
System.out.println("test " + Utils.Brackets(testDescription) + " not found. create"); //добавить тест.
CreateTestFromSingleFile(account, sapfor, oldGroup, file, testDescription);
} else {
System.out.println(Utils.Brackets(testDescription) + " found. rewrite"); //добавить тест.
@@ -233,7 +232,43 @@ public class TestsDatabase extends SQLiteDatabase {
}
}
}
public DVMPackage getFirstActiveDVMPackagesCopiesForMachineURL(String arg) {
return null;
public Vector<DVMPackage> getFirstActiveDVMPackageCopyForMachineURL(String arg) {
Vector<DVMPackage> res = new Vector<>();
Vector<DVMPackage> machinePackages = new Vector<>();
//--
//1. Получить список активных пакетов для машины.
for (DVMPackage dvmPackage : dvmPackages.Data.values()) {
switch (dvmPackage.state) {
case Done:
case Aborted:
case Draft:
case ConnectionError:
break;
default:
if (dvmPackage.getMachine().getURL().equals(arg))
machinePackages.add(dvmPackage);
break;
}
}
if (!machinePackages.isEmpty()) {
machinePackages.sort(new Comparator<DVMPackage>() {
@Override
public int compare(DVMPackage o1, DVMPackage o2) {
return Integer.compare(o1.state.ordinal(), o2.state.ordinal());
}
});
//-
DVMPackage activePackage = machinePackages.lastElement();
if (activePackage.state.equals(TasksPackageState.Queued)) {
activePackage.state = TasksPackageState.TestsSynchronize;
try {
Update(activePackage);
} catch (Exception ex) {
ex.printStackTrace();
}
}
res.add(activePackage);
}
return res;
}
}