diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 96a479da..560cf09a 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -10,6 +10,8 @@
+
+
diff --git a/src/_VisualDVM/ComponentsServer/Component/Sapfor/Sapfor.java b/src/_VisualDVM/ComponentsServer/Component/Sapfor/Sapfor.java
index 6b170430..e2c3f9ea 100644
--- a/src/_VisualDVM/ComponentsServer/Component/Sapfor/Sapfor.java
+++ b/src/_VisualDVM/ComponentsServer/Component/Sapfor/Sapfor.java
@@ -207,8 +207,10 @@ public abstract class Sapfor extends OSDComponent {
Utils_.CheckDirectory(data_workspace);
File outputFile = new File(data_workspace, outName);
File errorsFile = new File(data_workspace, errName);
+ // File logFile = new File(data_workspace, "log.txt");
Utils_.forceDeleteWithCheck(outputFile);
Utils_.forceDeleteWithCheck(errorsFile);
+ // Utils_.forceDeleteWithCheck(logFile);
//---
File file = new File(data_workspace, name + (Utils_.isWindows() ? ".bat" : ".sh"));
FileUtils.write(file,
@@ -224,33 +226,36 @@ public abstract class Sapfor extends OSDComponent {
if (!file.setExecutable(true))
throw new Exception("Не удалось сделать файл скрипта " + name + " исполняемым!");
//-- Windows
- boolean flag = false;
+ //запустить процесс
+ boolean process_started = false;
do {
try {
ProcessBuilder procBuilder = new ProcessBuilder(file.getAbsolutePath());
procBuilder.directory(workspace);
process = procBuilder.start();
- //-
- for (int i=0; i<40; ++i){
- if (process.waitFor(1, TimeUnit.SECONDS)){
- //дождались. все хорошо.
- exit_code=0;
- break;
- }
- }
- //-
- if (exit_code!=0){
- //процесс все еще не завершен. Убить.
- process.destroyForcibly();
- }
- //-
- flag = true; //флаг означал что запуск процесса состоялся. не столь важно успешно или нет.
+ process_started = true;
} catch (Exception ex) {
Utils_.MainLog.PrintException(ex);
Utils_.sleep(1000);
}
}
- while (!flag);
+ while (!process_started);
+ //--
+ for (int i=0; i<40; ++i){
+ if (process.waitFor(1, TimeUnit.SECONDS)){
+ //дождались. все хорошо.
+ exit_code=0;
+ // FileUtils.writeStringToFile(logFile,sapfor_drv.getName()+" done for "+i+" seconds");
+ break;
+ }
+ }
+ if (exit_code!=0){
+ // FileUtils.writeStringToFile(logFile,sapfor_drv.getName()+" timeout");
+ //-
+ Process killer = Runtime.getRuntime().exec("pkill -SIGKILL -f "+sapfor_drv.getName());
+ killer.waitFor();
+ //-
+ }
process = null;
//---
Vector outputLines = new Vector<>(FileUtils.readLines(outputFile));
diff --git a/src/_VisualDVM/TestingSystem/SAPFOR/PackageModeSupervisor.java b/src/_VisualDVM/TestingSystem/SAPFOR/PackageModeSupervisor.java
index 7046bc32..e6da2395 100644
--- a/src/_VisualDVM/TestingSystem/SAPFOR/PackageModeSupervisor.java
+++ b/src/_VisualDVM/TestingSystem/SAPFOR/PackageModeSupervisor.java
@@ -11,29 +11,32 @@ import org.apache.commons.io.FileUtils;
import java.io.File;
import java.nio.charset.Charset;
+import java.nio.file.Files;
import java.util.Date;
public class PackageModeSupervisor extends ThreadsPlanner {
SapforPackage_json package_json = null;
- File sapfor_drv = null;
+ // File sapfor_drv = null;
public PackageModeSupervisor() throws Exception {
super(2000);
package_json = (SapforPackage_json) Utils_.jsonFromFile(new File(Constants.package_json), SapforPackage_json.class);
//--
File sapfor_src = new File(package_json.sapfor_drv);
- sapfor_drv = new File(Utils_.getHomeDirectory(), Utils_.getDateName("SAPFOR_F"));
- FileUtils.copyFile(sapfor_src, sapfor_drv);
- if (!sapfor_drv.setExecutable(true))
- throw new Exception("Не удалось сделать файл " + sapfor_drv.getName() + " исполняемым!");
+ //--
+ String pid_prefix = Utils_.getDateName("SAPFOR_F");
+ //--
File PID = new File("PID");
- FileUtils.writeStringToFile(PID, sapfor_drv.getName(), Charset.defaultCharset());
+ FileUtils.writeStringToFile(PID, pid_prefix, Charset.defaultCharset());
//---
Date startDate = new Date();
File started = new File(CommonConstants.STARTED);
FileUtils.writeStringToFile(started, String.valueOf(startDate));
//формирование списка задач.
setMaxKernels(package_json.kernels);
- for (SapforTask task : package_json.tasks)
- addThread(new TaskThread(task, sapfor_drv));
+ for (SapforTask task : package_json.tasks) {
+ File task_drv = new File(Utils_.getHomeDirectory(),pid_prefix+"_"+task.id);
+ Files.createSymbolicLink(task_drv.toPath(), sapfor_src.toPath());
+ addThread(new TaskThread(task, task_drv));
+ }
interruptThread.start();
}
@Override
@@ -55,8 +58,8 @@ public class PackageModeSupervisor extends ThreadsPlanner {
// ,"sh", "exe", "bat"
);
//удаление сапфора exception
- if (sapfor_drv.exists())
- FileUtils.forceDelete(sapfor_drv);
+ // if (sapfor_drv.exists())
+ // FileUtils.forceDelete(sapfor_drv);
} catch (Exception e) {
Utils_.MainLog.PrintException(e);
}
diff --git a/src/_VisualDVM/TestingSystem/SAPFOR/SapforTestingPlanner.java b/src/_VisualDVM/TestingSystem/SAPFOR/SapforTestingPlanner.java
index 280b4356..5e57186c 100644
--- a/src/_VisualDVM/TestingSystem/SAPFOR/SapforTestingPlanner.java
+++ b/src/_VisualDVM/TestingSystem/SAPFOR/SapforTestingPlanner.java
@@ -22,6 +22,7 @@ import _VisualDVM.TestingSystem.SAPFOR.ServerSapfor.ServerSapforState;
import org.apache.commons.io.FileUtils;
import java.io.File;
+import java.io.FileFilter;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Paths;
@@ -148,6 +149,7 @@ public class SapforTestingPlanner extends TestingPlanner {
}
@Override
protected void DownloadResults() throws Exception {
+ //-
UpdatePackageState(TasksPackageState.Analysis);
}
@Override
@@ -155,6 +157,16 @@ public class SapforTestingPlanner extends TestingPlanner {
//не требуется.
testingPackage.progress = 100;
testingPackage.checkFinishState();
+ //--
+ File workspace = testingPackage.getLocalWorkspace();
+ File[] links = workspace.listFiles();
+ if (links!=null){
+ Print("files found: "+links.length);
+ for (File file: links) {
+ if (file.isFile() && file.getName().startsWith("SAPFOR"))
+ FileUtils.forceDelete(file);
+ }
+ }
//--для эталона
if (testingPackage.ethalon_id != CommonConstants.Nan) {
TextLog log = new TextLog();
@@ -218,7 +230,8 @@ public class SapforTestingPlanner extends TestingPlanner {
Thread.sleep(1000);
} while (!aborted_file.exists());
Print("coup de grace..");
- String kill_command = "killall -SIGKILL " + testingPackage.PID;
+ // String kill_command = "killall -SIGKILL " + testingPackage.PID;
+ String kill_command = "pkill -SIGKILL -f " + testingPackage.PID;
Print(kill_command);
Process killer = Runtime.getRuntime().exec(kill_command);
killer.waitFor();