no message
This commit is contained in:
@@ -32,7 +32,9 @@ public abstract class TestingPlanner<P extends TestingPackage> {
|
||||
target = response.object;
|
||||
}
|
||||
};
|
||||
if (!pass.Do()) throw new PassException("Ошибка взаимодействия с сервером " + code_in);
|
||||
if (!pass.Do()) {
|
||||
ServerConnectionError(code_in);
|
||||
}
|
||||
return pass.target;
|
||||
}
|
||||
protected Object ServerCommand(ServerCode code_in, Serializable object_in) throws Exception {
|
||||
@@ -103,30 +105,10 @@ public abstract class TestingPlanner<P extends TestingPackage> {
|
||||
}
|
||||
protected void Disconnect() {
|
||||
}
|
||||
//жизненный цикл планировщика
|
||||
protected void Session() throws Exception {
|
||||
switch (testingPackage.state) {
|
||||
case TestsSynchronize:
|
||||
TestsSynchronize();
|
||||
UpdatePackageState(TasksPackageState.PackageWorkspaceCreation);
|
||||
break;
|
||||
case PackageWorkspaceCreation:
|
||||
PackageWorkspaceCreation();
|
||||
UpdatePackageState(TasksPackageState.PackageStart);
|
||||
break;
|
||||
case PackageStart:
|
||||
PackageStart();
|
||||
testingPackage.StartDate = new Date().getTime();
|
||||
UpdatePackageState(getStateAfterStart());
|
||||
break;
|
||||
case RunningEnd:
|
||||
DownloadResults();
|
||||
UpdatePackageState(TasksPackageState.Analysis);
|
||||
break;
|
||||
default:
|
||||
if (CheckNextState()) UpdatePackage();
|
||||
break;
|
||||
}
|
||||
protected void MachineConnectionError(){
|
||||
}
|
||||
protected void ServerConnectionError(ServerCode code_in) throws Exception{
|
||||
throw new PassException("Ошибка взаимодействия с сервером " + code_in);
|
||||
}
|
||||
// ---
|
||||
protected void PerformPackage(TestingPackage package_in) throws Exception{
|
||||
@@ -137,6 +119,7 @@ public abstract class TestingPlanner<P extends TestingPackage> {
|
||||
if (testingPackage.connectionErrosCount>=10){
|
||||
Print(testingPackage.id+" had 10 connection errors. stop");
|
||||
UpdatePackageState(TasksPackageState.ConnectionError);
|
||||
MachineConnectionError();
|
||||
}else {
|
||||
//--
|
||||
InitSessionCredentials();
|
||||
@@ -153,7 +136,30 @@ public abstract class TestingPlanner<P extends TestingPackage> {
|
||||
UpdatePackageState(TasksPackageState.Aborted);
|
||||
ServerCommand(ServerCode.DeleteObjectByPK, new Pair(TestingPackageToKill.class, ptk_id));
|
||||
} else {
|
||||
Session();
|
||||
//--
|
||||
switch (testingPackage.state) {
|
||||
case TestsSynchronize:
|
||||
TestsSynchronize();
|
||||
UpdatePackageState(TasksPackageState.PackageWorkspaceCreation);
|
||||
break;
|
||||
case PackageWorkspaceCreation:
|
||||
PackageWorkspaceCreation();
|
||||
UpdatePackageState(TasksPackageState.PackageStart);
|
||||
break;
|
||||
case PackageStart:
|
||||
PackageStart();
|
||||
testingPackage.StartDate = new Date().getTime();
|
||||
UpdatePackageState(getStateAfterStart());
|
||||
break;
|
||||
case RunningEnd:
|
||||
DownloadResults();
|
||||
UpdatePackageState(TasksPackageState.Analysis);
|
||||
break;
|
||||
default:
|
||||
if (CheckNextState()) UpdatePackage();
|
||||
break;
|
||||
}
|
||||
//--
|
||||
}
|
||||
} else {
|
||||
testingPackage.connectionErrosCount++;
|
||||
|
||||
@@ -29,6 +29,7 @@ import java.nio.charset.Charset;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.*;
|
||||
public class MachineQueueSupervisor extends TestingPlanner<DVMPackage> {
|
||||
File supervisorHome = null;
|
||||
Machine machine = null;
|
||||
User user = null;
|
||||
boolean local;
|
||||
@@ -44,12 +45,12 @@ public class MachineQueueSupervisor extends TestingPlanner<DVMPackage> {
|
||||
String userPassword = args[3];
|
||||
String userWorkspace = args[4];
|
||||
String testingSystemRoot = args[5];
|
||||
String supervisorHome = Global.Home; //при инициализации это текущая папка.
|
||||
supervisorHome = new File(Global.Home); //при инициализации это текущая папка.
|
||||
//---
|
||||
Global.Log = new Loggable() {
|
||||
@Override
|
||||
public String getLogHomePath() {
|
||||
return supervisorHome;
|
||||
return supervisorHome.getAbsolutePath();
|
||||
}
|
||||
@Override
|
||||
public String getLogName() {
|
||||
@@ -114,6 +115,25 @@ public class MachineQueueSupervisor extends TestingPlanner<DVMPackage> {
|
||||
Print("Соединение c " + machine.getURL() + " " + user.login + " сброшено.");
|
||||
}
|
||||
}
|
||||
@Override
|
||||
protected void Print(String message) {
|
||||
try {
|
||||
if (isPrintOn()) {
|
||||
Global.Log.Print(message);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
void Finalize(String reason){
|
||||
File stateFile = new File(supervisorHome, Constants.ABORTED);
|
||||
try {
|
||||
FileUtils.writeStringToFile(stateFile, reason);
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
System.exit(0);
|
||||
}
|
||||
//--
|
||||
//Получить ид тестов и их папки на сервере.
|
||||
LinkedHashMap<Integer, File> getTestsFromJson() {
|
||||
@@ -365,7 +385,7 @@ public class MachineQueueSupervisor extends TestingPlanner<DVMPackage> {
|
||||
Print("PID not found");
|
||||
Utils.sleep(1000);
|
||||
}
|
||||
testingPackage.PID = user.connection.readFromFile(PID).replace("\n","").replace("\r","");
|
||||
testingPackage.PID = user.connection.readFromFile(PID).replace("\n", "").replace("\r", "");
|
||||
//---
|
||||
System.out.println("PID=" + Utils.Brackets(testingPackage.PID));
|
||||
RemoteFile STARTED = new RemoteFile(packageRemoteWorkspace, "STARTED");
|
||||
@@ -422,8 +442,17 @@ public class MachineQueueSupervisor extends TestingPlanner<DVMPackage> {
|
||||
unzipFolderPass.Do(results_archive.getAbsolutePath(), packageLocalWorkspace.getAbsolutePath(), false);
|
||||
}
|
||||
//---
|
||||
// if (Global.properties.eraseTestingWorkspaces && user.connection.Exists(packageRemoteWorkspace))
|
||||
// user.connection.RMDIR(packageRemoteWorkspace.full_name);
|
||||
// if (Global.properties.eraseTestingWorkspaces && user.connection.Exists(packageRemoteWorkspace))
|
||||
// user.connection.RMDIR(packageRemoteWorkspace.full_name);
|
||||
}
|
||||
@Override
|
||||
protected void MachineConnectionError() {
|
||||
Finalize("Количество безуспешных попыток соединения с машиной " +machine.getURL()+
|
||||
" превысило 10");
|
||||
}
|
||||
@Override
|
||||
protected void ServerConnectionError(ServerCode code_in) throws Exception {
|
||||
Finalize("Не удалось выполнить команду " + code_in+ " на сервере тестирования");
|
||||
}
|
||||
@Override
|
||||
protected void Kill() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user