This commit is contained in:
2023-10-15 21:58:23 +03:00
parent d0daddd0f0
commit 044b8a6bf2
7 changed files with 35 additions and 42 deletions

View File

@@ -3,8 +3,8 @@ import Common.Constants;
import Common.Global;
import Common.Utils.Utils;
import SapforTestingSystem.Json.SapforConfiguration_json;
import SapforTestingSystem.Json.SapforTasksResults_json;
import SapforTestingSystem.Json.SapforTasksPackage_json;
import SapforTestingSystem.Json.SapforTasksResults_json;
import SapforTestingSystem.PerformSapforTask;
import SapforTestingSystem.SapforTask.SapforTask;
import SapforTestingSystem.ThreadsPlanner.ThreadsPlanner;
@@ -18,7 +18,10 @@ public class PackageModeSupervisor extends ThreadsPlanner {
public PackageModeSupervisor() throws Exception {
super(2000);
package_json = (SapforTasksPackage_json) Utils.jsonFromFile(new File(Global.Home, "package_json"), SapforTasksPackage_json.class);
results_json.StartDate = new Date().getTime();
Date startDate = new Date();
results_json.StartDate = startDate.getTime();
File started = new File(Constants.STARTED);
FileUtils.writeStringToFile(started, String.valueOf(startDate));
//формирование списка задач.
File sapfor_drv = new File(Global.Home, package_json.sapfor_drv);
setMaxKernels(package_json.kernels);
@@ -48,24 +51,21 @@ public class PackageModeSupervisor extends ThreadsPlanner {
killer.waitFor();
System.out.println("done!");
*/
//todo для надежности сделать еще один kill с внешнего процесса.
// может быть гонка, что нить успеет запустить процесс уже после интеррупта.
}
@Override
protected void finalize() {
results_json.EndDate = new Date().getTime();
//записать результаты всех задач.
try {
Utils.jsonToFile(results_json, new File(Global.Home, "results_json"));
//тут же и строить версии.
Utils.deleteFilesByExtensions(new File(Global.Home),"proj","dep"); //Потом txt тоже добавить.
Utils.deleteFilesByExtensions(new File(Global.Home), "proj", "dep"); //Потом txt тоже добавить.
FileUtils.writeStringToFile(new File(Constants.DONE), "");
} catch (Exception e) {
Global.Log.PrintException(e);
}
System.exit(0);
}
}

View File

@@ -1,4 +1,5 @@
package SapforTestingSystem.SapforTasksPackageSupervisor;
import Common.Constants;
import Common.Current;
import Common.Global;
import Common.GlobalProperties;
@@ -94,35 +95,41 @@ public class SapforTasksPackageSupervisor {
Utils.createScript(packageWorkspace, packageWorkspace, "start", "java -jar VisualSapfor.jar");
//--
}
/*
void SapforPackageStart() throws Exception {
void PackageStart() throws Exception {
System.out.println("start sapfor package " + sapforTasksPackage.id);
File workspace = new File(sapforTasksPackage.workspace);
File script = new File(sapforTasksPackage.workspace, "start");
ProcessBuilder procBuilder = new ProcessBuilder(script.getAbsolutePath());
procBuilder.directory(workspace);
procBuilder.start();
//--->>
File started = new File(sapforTasksPackage.workspace, Constants.STARTED);
while (!started.exists()){
System.out.println("waiting for package start...");
Utils.sleep(1000);
}
//-->>
sapforTasksPackage.state = TasksPackageState.RunningExecution;
UpdateSapforPackage(sapforTasksPackage);
planner.UpdateSapforPackage(sapforTasksPackage);
System.out.println("done");
}
void CheckSapforPackageState() throws Exception {
void CheckPackageState() throws Exception {
System.out.println("check sapfor package " + sapforTasksPackage.id);
File done = new File(sapforTasksPackage.workspace, Constants.DONE);
File aborted = new File(sapforTasksPackage.workspace, Constants.ABORTED);
if (done.exists()) {
sapforTasksPackage.state = TasksPackageState.Done;
UpdateSapforPackage(sapforTasksPackage);
planner.UpdateSapforPackage(sapforTasksPackage);
System.out.println("package done");
} else if (aborted.exists()) {
sapforTasksPackage.state = TasksPackageState.Aborted;
UpdateSapforPackage(sapforTasksPackage);
planner.UpdateSapforPackage(sapforTasksPackage);
System.out.println("package aborted");
} else {
System.out.println("package running");
}
}
*/
//--
public void Perform() throws Exception {
switch (sapforTasksPackage.state) {
@@ -131,14 +138,12 @@ public class SapforTasksPackageSupervisor {
sapforTasksPackage.state = TasksPackageState.RunningPreparation;
planner.UpdateSapforPackage(sapforTasksPackage);
break;
/*
case RunningPreparation:
SapforPackageStart();
PackageStart();
break;
case RunningExecution:
CheckSapforPackageState();
CheckPackageState();
break;
*/
default:
break;
}

View File

@@ -1,19 +0,0 @@
package SapforTestingSystem;
import Common.Constants;
import com.google.gson.annotations.Expose;
import java.io.Serializable;
import java.util.List;
import java.util.Vector;
public class SapforTasksPackage_info implements Serializable {
@Expose
public String email = "";
@Expose
public int sapforId = Constants.Nan; //файл с сапфором
@Expose
public int kernels = 1;
@Expose
public List<String> testsIds = new Vector<>();
@Expose
public List<String> configurationsIds = new Vector<>();
}