Наметил локальный вариант, но пока не уверен что он приоритетен..

This commit is contained in:
2024-04-27 18:44:36 +03:00
parent c84a648bb6
commit 002a8517e0
14 changed files with 421 additions and 292 deletions

View File

@@ -1,19 +1,32 @@
package TestingSystem.Common;
import Common.Constants;
import Common.Current;
import Common.Global;
import Common.Utils.Utils;
import GlobalData.Machine.Machine;
import GlobalData.Machine.MachineType;
import GlobalData.User.User;
import Repository.EmailMessage;
import Repository.Server.ServerCode;
import TestingSystem.Common.TestingPackage.TestingPackage;
import TestingSystem.Common.TestingPackageToKill.TestingPackageToKill;
import Repository.RepositoryClient;
import Visual_DVM_2021.Passes.PassException;
import Visual_DVM_2021.UI.Interface.Loggable;
import javafx.util.Pair;
import org.apache.commons.io.FileUtils;
import java.io.File;
import java.util.Date;
import java.util.Vector;
public abstract class TestingPlanner<P extends TestingPackage> extends RepositoryClient {
protected P testingPackage;
//---
protected File packageLocalWorkspace = null;
protected String serverName = "";
protected File supervisorHome = null;
protected Machine machine = null;
protected User user = null;
//----
void UpdatePackageState(TasksPackageState state_in) throws Exception {
testingPackage.state = state_in;
testingPackage.ChangeDate = new Date().getTime();
@@ -60,7 +73,6 @@ public abstract class TestingPlanner<P extends TestingPackage> extends Repositor
}
protected void MachineConnectionError() {
}
// ---
protected void PerformPackage(TestingPackage package_in) throws Exception {
testingPackage = (P) package_in;
//--
@@ -140,4 +152,77 @@ public abstract class TestingPlanner<P extends TestingPackage> extends Repositor
for (P activePackage : activePackages)
PerformPackage(activePackage);
}
protected void Finalize(String reason) {
Print(reason);
File stateFile = new File(supervisorHome, Constants.ABORTED);
try {
FileUtils.writeStringToFile(stateFile, reason);
} catch (Exception ex) {
ex.printStackTrace();
}
System.exit(0);
}
//---------------------------------------------
public String getPlanner() {
return String.join("/", user.workspace, "modules", "planner");
}
//---
public TestingPlanner(){}
public TestingPlanner(String... args) {
Global.isWindows = System.getProperty("os.name").startsWith("Windows");
//---
String machineAddress = args[0];
int machinePort = Integer.parseInt(args[1]);
String userName = args[2];
String userPassword = args[3];
String userWorkspace = args[4];
String testingSystemRoot = args[5];
serverName = args[6];
supervisorHome = new File(Global.Home); //при инициализации это текущая папка.
//---
Global.Log = new Loggable() {
@Override
public String getLogHomePath() {
return supervisorHome.getAbsolutePath();
}
@Override
public String getLogName() {
return Current.mode.toString();
}
};
Global.Log.ClearLog();
//--
Global.Home = testingSystemRoot;
Global.CheckTestingSystemDirectories();
System.out.println(Global.TestsDirectory.getAbsolutePath());
//---
machine = new Machine(machineAddress, machineAddress, machinePort, MachineType.Server);
user = new User(userName, userPassword, userWorkspace);
//---
Print("machineAddress=" + Utils.Brackets(machineAddress));
Print("machinePort=" + Utils.Brackets(String.valueOf(machinePort)));
Print("userName=" + Utils.Brackets(userName));
Print("userPassword=" + Utils.Brackets(userPassword));
Print("userWorkspace=" + Utils.Brackets(userWorkspace));
Print("root=" + Utils.Brackets(Global.Home));
Print("serverName=" + serverName);
Print("=====");
//----
Utils.createEmptyFile(Constants.STARTED);
}
/*
void CheckLocal() {
local = false;
try {
InetAddress address = InetAddress.getByName(machine.address);
InetAddress localAddress = InetAddress.getByName("alex-freenas.ddns.net");
Print("machine ip=" + Utils.Brackets(address.getHostAddress()));
Print("server ip=" + Utils.Brackets(localAddress.getHostAddress()));
local = localAddress.getHostAddress().equals(address.getHostAddress());
//todo в этом случае отдельный режим без ssh
} catch (Exception ex) {
Global.Log.PrintException(ex);
}
}
*/
}