no message
This commit is contained in:
10
.idea/workspace.xml
generated
10
.idea/workspace.xml
generated
@@ -7,14 +7,10 @@
|
||||
</component>
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="e42177c3-2328-4b27-8a01-35779b2beb99" name="Default Changelist" comment="">
|
||||
<change afterPath="$PROJECT_DIR$/src/TestingSystem/Common/MachineProcess/MachineProcess.java" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/src/TestingSystem/Common/MachineProcess/MachineProcessDBTable.java" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/src/TestingSystem/Common/MachineProcess/MachineProcessState.java" 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/Global.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Common/Global.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/TestingSystem/Common/MachineProcess/MachineProcess.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/TestingSystem/Common/MachineProcess/MachineProcess.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/TestingSystem/Common/MachineProcess/MachineProcessDBTable.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/TestingSystem/Common/MachineProcess/MachineProcessDBTable.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/TestingSystem/Common/TestingServer.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/TestingSystem/Common/TestingServer.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/TestingSystem/Common/TestsDatabase.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/TestingSystem/Common/TestsDatabase.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/TestingSystem/DVM/MachineQueueSupervisor.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/TestingSystem/DVM/MachineQueueSupervisor.java" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
@@ -36,8 +32,8 @@
|
||||
<list>
|
||||
<option value="FxmlFile" />
|
||||
<option value="Interface" />
|
||||
<option value="Class" />
|
||||
<option value="Enum" />
|
||||
<option value="Class" />
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
|
||||
@@ -6,6 +6,7 @@ import Common.Database.iDBObject;
|
||||
import Common.Global;
|
||||
import Common.GlobalProperties;
|
||||
import Common.Utils.Utils;
|
||||
import TestingSystem.DVM.DVMPackage.DVMPackage;
|
||||
import com.sun.org.glassfish.gmbal.Description;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
|
||||
@@ -32,6 +33,14 @@ public class MachineProcess extends iDBObject {
|
||||
public MachineProcess(MachineProcess p) {
|
||||
SynchronizeFields(p);
|
||||
}
|
||||
public MachineProcess(DVMPackage p) {
|
||||
machineAddress = p.machine_address;
|
||||
machinePort = p.machine_port;
|
||||
userName = p.user_name;
|
||||
userPassword = p.user_password;
|
||||
userWorkspace = p.user_workspace;
|
||||
testingSystemRoot = Global.Home;
|
||||
}
|
||||
@Override
|
||||
public void SynchronizeFields(DBObject src) {
|
||||
super.SynchronizeFields(src);
|
||||
@@ -43,9 +52,18 @@ public class MachineProcess extends iDBObject {
|
||||
userWorkspace = p.userWorkspace;
|
||||
testingSystemRoot = p.testingSystemRoot;
|
||||
}
|
||||
public String getUniqueKey(){
|
||||
Vector<String> res = new Vector<>();
|
||||
res.add(machineAddress);
|
||||
res.add(String.valueOf(machinePort));
|
||||
res.add(userName);
|
||||
res.add(userWorkspace);
|
||||
return String.join("_", res);
|
||||
}
|
||||
public File getWorkspace() {
|
||||
return new File(Global.MachinesDirectory, String.valueOf(id));
|
||||
}
|
||||
|
||||
public File getAbortedFile() {
|
||||
return new File(getWorkspace(), Constants.ABORTED);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package TestingSystem.Common.MachineProcess;
|
||||
import Common.Database.iDBTable;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Vector;
|
||||
public class MachineProcessDBTable extends iDBTable<MachineProcess> {
|
||||
public MachineProcessDBTable() {
|
||||
@@ -14,18 +15,12 @@ public class MachineProcessDBTable extends iDBTable<MachineProcess> {
|
||||
public String getPluralDescription() {
|
||||
return "процессы машины";
|
||||
}
|
||||
public void checkProcesses() throws Exception {
|
||||
Vector<MachineProcess> toUpdate = new Vector<>();
|
||||
for (MachineProcess machineProcess : Data.values()) {
|
||||
if (machineProcess.isAborted()) {
|
||||
toUpdate.add(machineProcess);
|
||||
}
|
||||
public LinkedHashMap<String, MachineProcess> getActiveSortedByKeys(){
|
||||
LinkedHashMap<String, MachineProcess> res = new LinkedHashMap<>();
|
||||
for (MachineProcess process: Data.values()){
|
||||
if (process.state.equals(MachineProcessState.Active))
|
||||
res.put(process.getUniqueKey(), process);
|
||||
}
|
||||
getDb().BeginTransaction();
|
||||
for (MachineProcess machineProcess: toUpdate){
|
||||
machineProcess.state = MachineProcessState.Aborted;
|
||||
getDb().Update(machineProcess);
|
||||
}
|
||||
getDb().Commit();
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,8 @@ import Repository.RepositoryServer;
|
||||
import Repository.Server.ServerCode;
|
||||
import Repository.Server.ServerExchangeUnit_2021;
|
||||
import TestingSystem.Common.Group.Group;
|
||||
import TestingSystem.Common.MachineProcess.MachineProcess;
|
||||
import TestingSystem.Common.MachineProcess.MachineProcessState;
|
||||
import TestingSystem.Common.Test.Test;
|
||||
import TestingSystem.Common.Test.TestType;
|
||||
import TestingSystem.Common.TestingPackageToKill.TestingPackageToKill;
|
||||
@@ -118,10 +120,73 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
|
||||
protected DVMTestingPlanner DVMTestingPlanner = new DVMTestingPlanner();
|
||||
protected SapforTestingPlanner sapforTestingPlanner = new SapforTestingPlanner();
|
||||
//--
|
||||
void checkMachinesActivity() {
|
||||
System.out.println("Проверка активности нитей машин...");
|
||||
try {
|
||||
Vector<MachineProcess> toUpdate = new Vector<>();
|
||||
for (MachineProcess machineProcess : db.machinesProcesses.Data.values()) {
|
||||
if (machineProcess.isAborted()) {
|
||||
toUpdate.add(machineProcess);
|
||||
}
|
||||
}
|
||||
db.BeginTransaction();
|
||||
for (MachineProcess machineProcess : toUpdate) {
|
||||
machineProcess.state = MachineProcessState.Aborted;
|
||||
db.Update(machineProcess);
|
||||
}
|
||||
db.Commit();
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
System.out.println("done");
|
||||
}
|
||||
void startNecessaryMachines() {
|
||||
System.out.println("Запуск необходимых нитей машин...");
|
||||
//todo. когда БД машин будет перенесена только на сервер. просто идти по всем машинам.
|
||||
try {
|
||||
LinkedHashMap<String, MachineProcess> active_processes = db.machinesProcesses.getActiveSortedByKeys();
|
||||
LinkedHashMap<String, MachineProcess> processes_to_start = new LinkedHashMap<>();
|
||||
//1. Получить список всех пакетов, которые активны, и взять из них машины.
|
||||
for (DVMPackage dvmPackage : db.dvmPackages.Data.values()) {
|
||||
if (dvmPackage.state.isActive()) {
|
||||
//-
|
||||
Vector<String> k = new Vector<>();
|
||||
k.add(dvmPackage.machine_address);
|
||||
k.add(String.valueOf(dvmPackage.machine_port));
|
||||
k.add(dvmPackage.user_name);
|
||||
k.add(dvmPackage.user_workspace);
|
||||
//-
|
||||
String key = String.join("_", k);
|
||||
if (!active_processes.containsKey(key)) {
|
||||
MachineProcess new_process = new MachineProcess(dvmPackage);
|
||||
processes_to_start.put(key, new_process);
|
||||
}
|
||||
}
|
||||
}
|
||||
System.out.println("Активные процессы: "+active_processes.size());
|
||||
for (String key : active_processes.keySet()){
|
||||
System.out.println(key);
|
||||
}
|
||||
System.out.println("-------------------");
|
||||
System.out.println("Ожидающие запуск процессы: "+processes_to_start.size());
|
||||
for (String key : processes_to_start.keySet()){
|
||||
System.out.println(key);
|
||||
}
|
||||
System.out.println("-------------------");
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
System.out.println("done");
|
||||
}
|
||||
//--
|
||||
protected Thread testingThread = new Thread(() -> {
|
||||
while (true) {
|
||||
DVMTestingPlanner.Perform();
|
||||
sapforTestingPlanner.Perform();
|
||||
// DVMTestingPlanner.Perform();
|
||||
// sapforTestingPlanner.Perform();
|
||||
checkMachinesActivity();
|
||||
startNecessaryMachines();
|
||||
System.out.println("sleep...");
|
||||
Utils.sleep(5000);
|
||||
}
|
||||
});
|
||||
//------>>>
|
||||
@@ -310,7 +375,7 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
|
||||
private void GetFirstActiveDVMPackagesByMachines() {
|
||||
response = new ServerExchangeUnit_2021(ServerCode.OK);
|
||||
response.object = new Vector<>();
|
||||
// db.getFirstActiveDVMPackagesCopies(); //ЗАГЛУШКА. ЗА ПАКЕТЫ ДВМ ОТВЕЧАЕТ ОТДЕЛЬНЫЙ ПРОЦЕСС НА КАЖДУЮ МАШИНУ
|
||||
// db.getFirstActiveDVMPackagesCopies(); //ЗАГЛУШКА. ЗА ПАКЕТЫ ДВМ ОТВЕЧАЕТ ОТДЕЛЬНЫЙ ПРОЦЕСС НА КАЖДУЮ МАШИНУ
|
||||
}
|
||||
private void GetFirstActiveSapforPackages() throws Exception {
|
||||
response = new ServerExchangeUnit_2021(ServerCode.OK);
|
||||
@@ -540,7 +605,7 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
|
||||
//-
|
||||
Email(message, out, err);
|
||||
}
|
||||
private void GetDVMPackagesJson() throws Exception{
|
||||
private void GetDVMPackagesJson() throws Exception {
|
||||
Vector<Integer> packages_ids = (Vector<Integer>) request.object;
|
||||
Vector<DVMPackage_json> jsons = new Vector<>();
|
||||
for (int package_id : packages_ids) {
|
||||
|
||||
Reference in New Issue
Block a user