v++
рефакторинг. Исправлен баг. если прервать локальную задачу, не удалялся файл interrupt.
This commit is contained in:
@@ -5,7 +5,7 @@ import GlobalData.RemoteFile.RemoteFile;
|
||||
import GlobalData.Tasks.Supervisor.TaskSupervisor;
|
||||
import GlobalData.Tasks.Task;
|
||||
import GlobalData.Tasks.TaskState;
|
||||
import files.ConnectionPass;
|
||||
import Visual_DVM_2021.Passes.SSH.ConnectionPass;
|
||||
public abstract class RemoteTaskSupervisor<T extends Task> extends TaskSupervisor<T, ConnectionPass> {
|
||||
protected RemoteFile getRemoteProjectsPath() {
|
||||
return new RemoteFile(pass.user.getRemoteProjectsPath(), true);
|
||||
@@ -16,6 +16,9 @@ public abstract class RemoteTaskSupervisor<T extends Task> extends TaskSuperviso
|
||||
protected RemoteFile getBinary() {
|
||||
return new RemoteFile(getRemoteProject().full_name, "0");
|
||||
}
|
||||
protected RemoteFile getPID() {
|
||||
return new RemoteFile(getRemoteProject().full_name, "PID");
|
||||
}
|
||||
protected RemoteFile getRemoteTime() {
|
||||
return new RemoteFile(getRemoteProject().full_name, Constants.time_file);
|
||||
}
|
||||
@@ -34,40 +37,48 @@ public abstract class RemoteTaskSupervisor<T extends Task> extends TaskSuperviso
|
||||
@Override
|
||||
protected void PrepareWorkspace() throws Exception {
|
||||
super.PrepareWorkspace(); //локальная подготовка
|
||||
pass.tryRM(getDONE_file());
|
||||
pass.tryRM(getTIMEOUT_file());
|
||||
pass.tryRM(getRemoteOutput());
|
||||
pass.tryRM(getRemoteErrors());
|
||||
pass.tryRM(getRemoteTime());
|
||||
pass.user.connection.tryRM(getDONE_file());
|
||||
pass.user.connection.tryRM(getPID());
|
||||
pass.user.connection.tryRM(getTIMEOUT_file());
|
||||
pass.user.connection.tryRM(getRemoteOutput());
|
||||
pass.user.connection.tryRM(getRemoteErrors());
|
||||
pass.user.connection.tryRM(getRemoteTime());
|
||||
}
|
||||
@Override
|
||||
protected void CheckTask() throws Exception {
|
||||
RemoteFile DONE = new RemoteFile(getRemoteProject(), Constants.DONE);
|
||||
RemoteFile TIMEOUT = new RemoteFile(getRemoteProject(), Constants.TIMEOUT);
|
||||
if (pass.Exists(DONE))
|
||||
if (pass.user.connection.Exists(DONE))
|
||||
task.state = TaskState.Finished;
|
||||
else if (pass.Exists(TIMEOUT))
|
||||
else if (pass.user.connection.Exists(TIMEOUT))
|
||||
task.state = TaskState.AbortedByTimeout;
|
||||
}
|
||||
@Override
|
||||
protected void AchieveResults() throws Exception {
|
||||
pass.tryGetSingleFileWithMaxSize(getRemoteOutput(), task.getOutputFile(), 10240);
|
||||
pass.tryGetSingleFileWithMaxSize(getRemoteErrors(), task.getErrorsFile(), 10240);
|
||||
pass.user.connection.tryGetSingleFileWithMaxSize(getRemoteOutput(), task.getOutputFile(), 10240);
|
||||
pass.user.connection.tryGetSingleFileWithMaxSize(getRemoteErrors(), task.getErrorsFile(), 10240);
|
||||
}
|
||||
@Override
|
||||
protected void AbortTask() throws Exception {
|
||||
pass.ShellCommand("kill -2 " + task.PID);
|
||||
pass.user.connection.ShellCommand("kill -2 " + task.PID);
|
||||
}
|
||||
@Override
|
||||
protected void CalculatePerformanceTime() throws Exception {
|
||||
if (pass.tryGetSingleFileWithMaxSize(getRemoteTime(), task.getTimeFile(), 0))
|
||||
if (pass.user.connection.tryGetSingleFileWithMaxSize(getRemoteTime(), task.getTimeFile(), 0))
|
||||
task.RefreshTime();
|
||||
}
|
||||
public String getStarter() {
|
||||
return String.join("/", pass.user.workspace, "modules", "starter");
|
||||
}
|
||||
public String getLauncher() {
|
||||
return String.join("/", pass.user.workspace, "modules", "launcher");
|
||||
}
|
||||
|
||||
protected String getStartCommand() {
|
||||
String res =
|
||||
String.join(" ",
|
||||
Utils.DQuotes(pass.getStarter()),
|
||||
Utils.DQuotes(pass.getLauncher()),
|
||||
Utils.DQuotes(getStarter()),
|
||||
Utils.DQuotes(getLauncher()),
|
||||
String.valueOf(task.maxtime),
|
||||
Utils.DQuotes(getCoupDeGrace()),
|
||||
task.getFullCommand()
|
||||
|
||||
Reference in New Issue
Block a user