diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index d4bc05fc..6a496413 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -7,13 +7,13 @@
+
+
+
-
-
-
-
-
+
+
@@ -36,8 +36,8 @@
-
+
diff --git a/src/Common/Global.java b/src/Common/Global.java
index 245ec455..e1aa9b30 100644
--- a/src/Common/Global.java
+++ b/src/Common/Global.java
@@ -119,6 +119,7 @@ public class Global {
Utils.CheckDirectory(DVMPackagesDirectory = Paths.get(Home, DVMPackages).toFile());
//через пару версий заменить на clean.
Utils.CheckDirectory(SapforPackagesDirectory = Paths.get(Home, "SapforPackages").toFile());
+ Utils.CheckDirectory(MachinesDirectory = Paths.get(Home, "Machines").toFile());
}
public static void CheckServerDirectories() {
Utils.CheckDirectory(ComponentsDirectory = Paths.get(Home, components).toFile());
@@ -127,6 +128,7 @@ public class Global {
//-
Utils.CheckDirectory(BugReportsDirectory = Paths.get(Home, Bugs).toFile());
Utils.CheckDirectory(DataBackUpsDirectory = Paths.get(Home, DataBackUps).toFile());
+ Utils.CheckDirectory(MachinesDirectory = Paths.get(Home, "Machines").toFile());
}
public static void CheckTestingSystemDirectories() {
Utils.CheckDirectory(ComponentsDirectory = Paths.get(Home, components).toFile());
@@ -383,6 +385,12 @@ public class Global {
PackageModeSupervisor planner = new PackageModeSupervisor();
planner.Start();
}
+ public static void MachineQueueMode(String... args) throws Exception {
+ MachineQueueSupervisor supervisor = new MachineQueueSupervisor(args);
+ while (true) {
+ supervisor.Perform();
+ }
+ }
//---
public static void Init(String... args) {
System.out.println("VisualSapfor.jar started..");
@@ -407,10 +415,8 @@ public class Global {
PackageMode();
break;
case MachineQueue:
- MachineQueueSupervisor supervisor = new MachineQueueSupervisor(args);
- while (true) {
- supervisor.Perform();
- }
+ MachineQueueMode(args);
+ break;
case Undefined:
break;
}
diff --git a/src/TestingSystem/Common/MachineProcess/MachineProcess.java b/src/TestingSystem/Common/MachineProcess/MachineProcess.java
new file mode 100644
index 00000000..e40b6620
--- /dev/null
+++ b/src/TestingSystem/Common/MachineProcess/MachineProcess.java
@@ -0,0 +1,85 @@
+package TestingSystem.Common.MachineProcess;
+import Common.Constants;
+import Common.Current;
+import Common.Database.DBObject;
+import Common.Database.iDBObject;
+import Common.Global;
+import Common.GlobalProperties;
+import Common.Utils.Utils;
+import com.sun.org.glassfish.gmbal.Description;
+import org.apache.commons.io.FileUtils;
+
+import java.io.File;
+import java.util.Vector;
+public class MachineProcess extends iDBObject {
+ @Description("DEFAULT ''")
+ public String machineAddress = "";
+ @Description("DEFAULT -1")
+ public int machinePort = Constants.Nan;
+ @Description("DEFAULT ''")
+ public String userName = "";
+ @Description("DEFAULT ''")
+ public String userPassword = "";
+ @Description("DEFAULT ''")
+ public String userWorkspace = "";
+ @Description("DEFAULT ''")
+ public String testingSystemRoot = "";
+ @Description("DEFAULT 'Inactive'")
+ public MachineProcessState state = MachineProcessState.Inactive; //0 неактивен
+ //--
+ public MachineProcess() {
+ }
+ public MachineProcess(MachineProcess p) {
+ SynchronizeFields(p);
+ }
+ @Override
+ public void SynchronizeFields(DBObject src) {
+ super.SynchronizeFields(src);
+ MachineProcess p = (MachineProcess) src;
+ machineAddress = p.machineAddress;
+ machinePort = p.machinePort;
+ userName = p.userName;
+ userPassword = p.userPassword;
+ userWorkspace = p.userWorkspace;
+ testingSystemRoot = p.testingSystemRoot;
+ }
+ public File getWorkspace() {
+ return new File(Global.MachinesDirectory, String.valueOf(id));
+ }
+ public File getAbortedFile() {
+ return new File(getWorkspace(), Constants.ABORTED);
+ }
+ //---
+ public void Start() {
+ try {
+ File workspace = getWorkspace();
+ Utils.CheckAndCleanDirectory(workspace);
+ //копирование визуализатора
+ File src = new File(Global.Home, "TestingSystem.jar");
+ File supervisor = new File(workspace, "VisualSapfor.jar");
+ FileUtils.copyFile(Global.visualiser.getFile(), supervisor);
+ //создание настроек
+ GlobalProperties properties = new GlobalProperties();
+ properties.Mode = Current.Mode.MachineQueue;
+ Utils.jsonToFile(properties, new File(workspace, "properties"));
+ Vector args = new Vector<>();
+ args.add(Utils.DQuotes(machineAddress));
+ args.add(Utils.DQuotes(machinePort));
+ args.add(Utils.DQuotes(userName));
+ args.add(Utils.DQuotes(userPassword));
+ args.add(Utils.DQuotes(testingSystemRoot));
+ //--
+ //подготовка пакетного режима. Запустит его уже очередь.
+ Utils.createScript(workspace, workspace,
+ "start",
+ "java -jar VisualSapfor.jar " + String.join(" ", args));
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ }
+ }
+ //---
+ public boolean isAborted() {
+ File aborted = getAbortedFile();
+ return aborted.exists();
+ }
+}
diff --git a/src/TestingSystem/Common/MachineProcess/MachineProcessDBTable.java b/src/TestingSystem/Common/MachineProcess/MachineProcessDBTable.java
new file mode 100644
index 00000000..934073fe
--- /dev/null
+++ b/src/TestingSystem/Common/MachineProcess/MachineProcessDBTable.java
@@ -0,0 +1,31 @@
+package TestingSystem.Common.MachineProcess;
+import Common.Database.iDBTable;
+
+import java.util.Vector;
+public class MachineProcessDBTable extends iDBTable {
+ public MachineProcessDBTable() {
+ super(MachineProcess.class);
+ }
+ @Override
+ public String getSingleDescription() {
+ return "процесс машины";
+ }
+ @Override
+ public String getPluralDescription() {
+ return "процессы машины";
+ }
+ public void checkProcesses() throws Exception {
+ Vector toUpdate = new Vector<>();
+ for (MachineProcess machineProcess : Data.values()) {
+ if (machineProcess.isAborted()) {
+ toUpdate.add(machineProcess);
+ }
+ }
+ getDb().BeginTransaction();
+ for (MachineProcess machineProcess: toUpdate){
+ machineProcess.state = MachineProcessState.Aborted;
+ getDb().Update(machineProcess);
+ }
+ getDb().Commit();
+ }
+}
diff --git a/src/TestingSystem/Common/MachineProcess/MachineProcessState.java b/src/TestingSystem/Common/MachineProcess/MachineProcessState.java
new file mode 100644
index 00000000..0125af68
--- /dev/null
+++ b/src/TestingSystem/Common/MachineProcess/MachineProcessState.java
@@ -0,0 +1,6 @@
+package TestingSystem.Common.MachineProcess;
+public enum MachineProcessState {
+ Inactive,
+ Active,
+ Aborted
+}
diff --git a/src/TestingSystem/Common/TestingServer.java b/src/TestingSystem/Common/TestingServer.java
index 22bd5fa6..cb0d4297 100644
--- a/src/TestingSystem/Common/TestingServer.java
+++ b/src/TestingSystem/Common/TestingServer.java
@@ -575,5 +575,6 @@ public class TestingServer extends RepositoryServer {
response = new ServerExchangeUnit_2021(ServerCode.OK);
response.object = db.getFirstActiveDVMPackageCopyForMachineURL(request.arg);
}
+ //-----
}
diff --git a/src/TestingSystem/Common/TestsDatabase.java b/src/TestingSystem/Common/TestsDatabase.java
index 3fc5e6df..d568acbf 100644
--- a/src/TestingSystem/Common/TestsDatabase.java
+++ b/src/TestingSystem/Common/TestsDatabase.java
@@ -8,6 +8,7 @@ import Repository.Component.Sapfor.Sapfor;
import Repository.RepositoryRefuseException;
import TestingSystem.Common.Group.Group;
import TestingSystem.Common.Group.GroupsDBTable;
+import TestingSystem.Common.MachineProcess.MachineProcessDBTable;
import TestingSystem.Common.Test.Test;
import TestingSystem.Common.Test.TestDBTable;
import TestingSystem.Common.TestingPackageToKill.TestingPackagesToKillDBTable;
@@ -47,6 +48,8 @@ public class TestsDatabase extends SQLiteDatabase {
//---
public DVMRunTasksSet dvmRunTasks = new DVMRunTasksSet(); //задачи текущего пакета тестирования DVM
//--
+ public MachineProcessDBTable machinesProcesses;
+ //--
public TestsDatabase() {
super(Paths.get(System.getProperty("user.dir"), "Data", Constants.tests_db_name + ".sqlite").toFile());
}
@@ -62,6 +65,7 @@ public class TestsDatabase extends SQLiteDatabase {
addTable(sapforConfigurations = new SapforConfigurationDBTable());
addTable(sapforConfigurationCommands = new SapforConfigurationCommandsDBTable());
addTable(serverSapfors = new ServerSapforsDBTable());
+ addTable(machinesProcesses = new MachineProcessDBTable());
}
@Override
public PassCode_2021 getSynchronizePassCode() {
diff --git a/src/TestingSystem/DVM/MachineQueueSupervisor.java b/src/TestingSystem/DVM/MachineQueueSupervisor.java
index 4b4815e3..0fbdde1b 100644
--- a/src/TestingSystem/DVM/MachineQueueSupervisor.java
+++ b/src/TestingSystem/DVM/MachineQueueSupervisor.java
@@ -479,495 +479,4 @@ public class MachineQueueSupervisor extends TestingPlanner {
packageRemoteWorkspace = new RemoteFile(user.workspace + "/tests", String.valueOf(testingPackage.id), true);
packageLocalWorkspace = new File(Global.DVMPackagesDirectory, String.valueOf(testingPackage.id));
}
-
- /*
-
- //--
- DVMPackage testingPackage = null; //текущий пакет.
- RemoteFile packageRemoteWorkspace = null;
- File packageLocalWorkspace = null;
- //--
- protected int getSleepMillis() {
- return 5000;
- }
- //--
- protected boolean isPrintOn() {
- return true;
- }
- protected void Print(String message) {
- try {
- if (isPrintOn()) {
- System.out.println(message);
- Global.Log.Print(message);
- }
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- }
- //--
- protected Object ServerCommand(ServerCode code_in, String arg, Serializable object_in) throws Exception {
- TestingSystemPass