Files
VisualSapfor/src/TestingSystem/DVM/MachineQueueSupervisor.java

72 lines
2.5 KiB
Java
Raw Normal View History

2024-04-13 20:09:26 +03:00
package TestingSystem.DVM;
import Common.Global;
import Common.Utils.Utils;
import GlobalData.Machine.Machine;
import GlobalData.Machine.MachineType;
import GlobalData.User.User;
import Repository.Server.ServerCode;
import Repository.Server.ServerExchangeUnit_2021;
import TestingSystem.DVM.DVMPackage.DVMPackage;
import Visual_DVM_2021.Passes.PassException;
import Visual_DVM_2021.Passes.Server.TestingSystemPass;
import java.io.Serializable;
import java.util.Vector;
public class MachineQueueSupervisor {
//--
Machine machine = null;
User user = null;
//--
DVMPackage testingPackage = null; //текущий пакет.
//--
protected int getSleepMillis() {
return 2000;
}
protected Object ServerCommand(ServerCode code_in, String arg, Serializable object_in) throws Exception {
TestingSystemPass<Object> pass = new TestingSystemPass<Object>() {
@Override
public String getDescription() {
return "";
}
@Override
protected void ServerAction() throws Exception {
Command(new ServerExchangeUnit_2021(code_in, arg, object_in));
target = response.object;
}
};
if (!pass.Do()) throw new PassException("Ошибка взаимодействия с сервером " + code_in);
return pass.target;
}
protected Object ServerCommand(ServerCode code_in, Serializable object_in) throws Exception {
return ServerCommand(code_in, "", object_in);
}
protected Object ServerCommand(ServerCode code_in) throws Exception {
return ServerCommand(code_in, "", null);
}
//--
public MachineQueueSupervisor(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];
//---
machine = new Machine(machineAddress, machineAddress, machinePort, MachineType.Server);
user = new User(userName, userPassword, userWorkspace);
//---
}
public void Start() {
try {
testingPackage = null;
testingPackage = (DVMPackage) ServerCommand(ServerCode.GetFirstActiveDVMPackageForMachineURL, machine.getURL(), null);
} catch (Exception ex) {
ex.printStackTrace();
} finally {
Utils.sleep(getSleepMillis());
}
}
}