прерывание по образцу двм, однотипное.
This commit is contained in:
11
.idea/workspace.xml
generated
11
.idea/workspace.xml
generated
@@ -7,16 +7,11 @@
|
|||||||
</component>
|
</component>
|
||||||
<component name="ChangeListManager">
|
<component name="ChangeListManager">
|
||||||
<list default="true" id="e42177c3-2328-4b27-8a01-35779b2beb99" name="Default Changelist" comment="">
|
<list default="true" id="e42177c3-2328-4b27-8a01-35779b2beb99" name="Default Changelist" comment="">
|
||||||
<change afterPath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/All/AbortSapforTaskPackage.java" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/src/Common/Current.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Common/Current.java" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/src/SapforTestingSystem/SapforTasksPackage/SapforTasksPackage.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/SapforTestingSystem/SapforTasksPackage/SapforTasksPackage.java" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/src/Common/UI/Menus_2023/SapforTasksPackagesBar/SapforTasksPackagesBar.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Common/UI/Menus_2023/SapforTasksPackagesBar/SapforTasksPackagesBar.java" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/src/SapforTestingSystem/SapforTasksPackageSupervisor/SapforTasksPackageSupervisor.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/SapforTestingSystem/SapforTasksPackageSupervisor/SapforTasksPackageSupervisor.java" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/src/Common/UI/Menus_2023/TestingBar/TestingBar.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Common/UI/Menus_2023/TestingBar/TestingBar.java" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/src/Repository/Server/ServerCode.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Repository/Server/ServerCode.java" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/src/SapforTestingSystem/SapforTasksPackage/SapforTasksPackagesDBTable.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/SapforTestingSystem/SapforTasksPackage/SapforTasksPackagesDBTable.java" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/src/TestingSystem/Group/GroupInterface.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/TestingSystem/Group/GroupInterface.java" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/src/TestingSystem/TestingServer.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/TestingSystem/TestingServer.java" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/src/TestingSystem/TestingServer.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/TestingSystem/TestingServer.java" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/PassCode_2021.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/PassCode_2021.java" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/All/AbortSapforTaskPackage.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/All/AbortSapforTaskPackage.java" afterDir="false" />
|
||||||
</list>
|
</list>
|
||||||
<option name="SHOW_DIALOG" value="false" />
|
<option name="SHOW_DIALOG" value="false" />
|
||||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||||
|
|||||||
@@ -70,6 +70,5 @@ public enum ServerCode {
|
|||||||
InstallSapforForTesting,
|
InstallSapforForTesting,
|
||||||
StartSapforTests,
|
StartSapforTests,
|
||||||
GetFirstActiveSapforTasksPackage,
|
GetFirstActiveSapforTasksPackage,
|
||||||
AbortSapforTasksPackage,
|
|
||||||
OLD
|
OLD
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ public class SapforTasksPackage extends nDBObject {
|
|||||||
public String sapfor_version = "?"; //тестируемая версия SAPFOR
|
public String sapfor_version = "?"; //тестируемая версия SAPFOR
|
||||||
public long sapfor_build_date = 0;
|
public long sapfor_build_date = 0;
|
||||||
public String sapfor_drv="";
|
public String sapfor_drv="";
|
||||||
|
public String sapfor_process_name="";
|
||||||
//---
|
//---
|
||||||
public String workspace = ""; //домашняя папка
|
public String workspace = ""; //домашняя папка
|
||||||
//---
|
//---
|
||||||
@@ -46,6 +47,7 @@ public class SapforTasksPackage extends nDBObject {
|
|||||||
StartDate = p.StartDate;
|
StartDate = p.StartDate;
|
||||||
ChangeDate = p.ChangeDate;
|
ChangeDate = p.ChangeDate;
|
||||||
kernels = p.kernels;
|
kernels = p.kernels;
|
||||||
|
sapfor_process_name = p.sapfor_process_name;
|
||||||
state = p.state;
|
state = p.state;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,12 +18,13 @@ import org.apache.commons.io.FileUtils;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
public class SapforTasksPackageSupervisor {
|
public class SapforTasksPackageSupervisor {
|
||||||
protected TestingPlanner planner; //планировщик.
|
protected TestingPlanner planner; //планировщик.
|
||||||
SapforTasksPackage sapforTasksPackage = null;
|
SapforTasksPackage sapforTasksPackage = null;
|
||||||
public SapforTasksPackageSupervisor(TestingPlanner planner_in, SapforTasksPackage sapforTasksPackage_in){
|
public SapforTasksPackageSupervisor(TestingPlanner planner_in, SapforTasksPackage sapforTasksPackage_in) {
|
||||||
planner = planner_in;
|
planner = planner_in;
|
||||||
sapforTasksPackage = sapforTasksPackage_in;
|
sapforTasksPackage = sapforTasksPackage_in;
|
||||||
}
|
}
|
||||||
@@ -78,7 +79,7 @@ public class SapforTasksPackageSupervisor {
|
|||||||
FileUtils.copyFile(new File(sapforTasksPackage.sapfor_drv), sapforFile);
|
FileUtils.copyFile(new File(sapforTasksPackage.sapfor_drv), sapforFile);
|
||||||
if (!sapforFile.setExecutable(true))
|
if (!sapforFile.setExecutable(true))
|
||||||
throw new Exception("Не удалось сделать файл " + sapforFile.getName() + " исполняемым!");
|
throw new Exception("Не удалось сделать файл " + sapforFile.getName() + " исполняемым!");
|
||||||
package_json.sapfor_drv = sapforFile.getName();
|
sapforTasksPackage.sapfor_process_name = package_json.sapfor_drv = sapforFile.getName();
|
||||||
//--->>
|
//--->>
|
||||||
//копирование визуализатора
|
//копирование визуализатора
|
||||||
File visualiser = new File(sapforTasksPackage.workspace, "VisualSapfor.jar");
|
File visualiser = new File(sapforTasksPackage.workspace, "VisualSapfor.jar");
|
||||||
@@ -94,7 +95,6 @@ public class SapforTasksPackageSupervisor {
|
|||||||
Utils.createScript(packageWorkspace, packageWorkspace, "start", "java -jar VisualSapfor.jar");
|
Utils.createScript(packageWorkspace, packageWorkspace, "start", "java -jar VisualSapfor.jar");
|
||||||
//--
|
//--
|
||||||
}
|
}
|
||||||
|
|
||||||
void PackageStart() throws Exception {
|
void PackageStart() throws Exception {
|
||||||
System.out.println("start sapfor package " + sapforTasksPackage.id);
|
System.out.println("start sapfor package " + sapforTasksPackage.id);
|
||||||
File workspace = new File(sapforTasksPackage.workspace);
|
File workspace = new File(sapforTasksPackage.workspace);
|
||||||
@@ -104,7 +104,7 @@ public class SapforTasksPackageSupervisor {
|
|||||||
procBuilder.start();
|
procBuilder.start();
|
||||||
//--->>
|
//--->>
|
||||||
File started = new File(sapforTasksPackage.workspace, Constants.STARTED);
|
File started = new File(sapforTasksPackage.workspace, Constants.STARTED);
|
||||||
while (!started.exists()){
|
while (!started.exists()) {
|
||||||
System.out.println("waiting for package start...");
|
System.out.println("waiting for package start...");
|
||||||
Utils.sleep(1000);
|
Utils.sleep(1000);
|
||||||
}
|
}
|
||||||
@@ -130,21 +130,48 @@ public class SapforTasksPackageSupervisor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
//--
|
//--
|
||||||
|
public boolean packageNeedsKill() throws Exception {
|
||||||
|
return (boolean) planner.ServerCommand(ServerCode.CheckPackageToKill, sapforTasksPackage.id);
|
||||||
|
}
|
||||||
|
public void killPackage() throws Exception {
|
||||||
|
//----
|
||||||
|
File interrupt_file = new File(sapforTasksPackage.workspace, Constants.INTERRUPT);
|
||||||
|
//----
|
||||||
|
FileUtils.writeStringToFile(interrupt_file, new Date().toString());
|
||||||
|
File aborted_file = new File(sapforTasksPackage.workspace, Constants.ABORTED);
|
||||||
|
do {
|
||||||
|
System.out.println("waiting for interrupt...");
|
||||||
|
Thread.sleep(1000);
|
||||||
|
} while (!aborted_file.exists());
|
||||||
|
System.out.println("coup de grace..");
|
||||||
|
String kill_command = "killall -SIGKILL " + sapforTasksPackage.sapfor_process_name;
|
||||||
|
System.out.println(kill_command);
|
||||||
|
Process killer = Runtime.getRuntime().exec(kill_command);
|
||||||
|
killer.waitFor();
|
||||||
|
System.out.println("done!");
|
||||||
|
}
|
||||||
public void Perform() throws Exception {
|
public void Perform() throws Exception {
|
||||||
switch (sapforTasksPackage.state) {
|
if (packageNeedsKill()) {
|
||||||
case TestsSynchronize:
|
System.out.println("PACKAGE " + sapforTasksPackage.id + " NEEDS TO KILL");
|
||||||
TestsSynchronize();
|
killPackage();
|
||||||
sapforTasksPackage.state = TasksPackageState.RunningPreparation;
|
sapforTasksPackage.state = TasksPackageState.Aborted;
|
||||||
planner.UpdateSapforPackage(sapforTasksPackage);
|
planner.UpdateSapforPackage(sapforTasksPackage);
|
||||||
break;
|
} else {
|
||||||
case RunningPreparation:
|
switch (sapforTasksPackage.state) {
|
||||||
PackageStart();
|
case TestsSynchronize:
|
||||||
break;
|
TestsSynchronize();
|
||||||
case RunningExecution:
|
sapforTasksPackage.state = TasksPackageState.RunningPreparation;
|
||||||
CheckPackageState();
|
planner.UpdateSapforPackage(sapforTasksPackage);
|
||||||
break;
|
break;
|
||||||
default:
|
case RunningPreparation:
|
||||||
break;
|
PackageStart();
|
||||||
|
break;
|
||||||
|
case RunningExecution:
|
||||||
|
CheckPackageState();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
package TestingSystem;
|
package TestingSystem;
|
||||||
import Common.Constants;
|
|
||||||
import Common.Database.DBObject;
|
import Common.Database.DBObject;
|
||||||
import Common.Database.rDBObject;
|
import Common.Database.rDBObject;
|
||||||
import Common.Global;
|
import Common.Global;
|
||||||
@@ -22,7 +21,6 @@ import TestingSystem.Tasks.TestCompilationTask;
|
|||||||
import TestingSystem.Tasks.TestRunTask;
|
import TestingSystem.Tasks.TestRunTask;
|
||||||
import TestingSystem.Tasks.TestTask;
|
import TestingSystem.Tasks.TestTask;
|
||||||
import TestingSystem.TasksPackage.TasksPackage;
|
import TestingSystem.TasksPackage.TasksPackage;
|
||||||
import TestingSystem.TasksPackage.TasksPackageState;
|
|
||||||
import TestingSystem.TasksPackageToKill.TasksPackageToKill;
|
import TestingSystem.TasksPackageToKill.TasksPackageToKill;
|
||||||
import TestingSystem.Test.Test;
|
import TestingSystem.Test.Test;
|
||||||
import TestingSystem.Test.TestInterface;
|
import TestingSystem.Test.TestInterface;
|
||||||
@@ -39,7 +37,6 @@ import javax.swing.*;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.Date;
|
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
@@ -314,31 +311,7 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
|
|||||||
groups.sort(Comparator.comparing(o -> o.description));
|
groups.sort(Comparator.comparing(o -> o.description));
|
||||||
return groups;
|
return groups;
|
||||||
}
|
}
|
||||||
private void AbortSapforTasksPackage(SapforTasksPackage object) throws Exception {
|
|
||||||
|
|
||||||
if (object.state.equals(TasksPackageState.RunningExecution)) {
|
|
||||||
File workspace = new File(object.workspace);
|
|
||||||
//----
|
|
||||||
File interrupt_file = new File(object.workspace, Constants.INTERRUPT);
|
|
||||||
//----
|
|
||||||
FileUtils.writeStringToFile(interrupt_file, new Date().toString());
|
|
||||||
File aborted_file = new File(object.workspace, Constants.ABORTED);
|
|
||||||
do {
|
|
||||||
System.out.println("waiting for interrupt...");
|
|
||||||
Thread.sleep(1000);
|
|
||||||
} while (!aborted_file.exists());
|
|
||||||
System.out.println("coup de grace..");
|
|
||||||
File[] files = workspace.listFiles((dir, name) -> name.startsWith("SAPFOR_F_"));
|
|
||||||
if ((files != null) && (files.length > 0)) {
|
|
||||||
File sapfor = files[0];
|
|
||||||
String kill_command = "killall -SIGKILL " + sapfor.getName();
|
|
||||||
System.out.println(kill_command);
|
|
||||||
Process killer = Runtime.getRuntime().exec(kill_command);
|
|
||||||
killer.waitFor();
|
|
||||||
System.out.println("done!");
|
|
||||||
} else throw new Exception("Не найдена копия SAPFOR");
|
|
||||||
}else throw new RepositoryRefuseException()
|
|
||||||
}
|
|
||||||
@Override
|
@Override
|
||||||
protected void Session() throws Exception {
|
protected void Session() throws Exception {
|
||||||
DBObject dbObject = null;
|
DBObject dbObject = null;
|
||||||
@@ -351,16 +324,6 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
|
|||||||
//------------->>
|
//------------->>
|
||||||
response = new ServerExchangeUnit_2021(ServerCode.OK);
|
response = new ServerExchangeUnit_2021(ServerCode.OK);
|
||||||
break;
|
break;
|
||||||
case AbortSapforTasksPackage:
|
|
||||||
Print("Прервать пакет тестов SAPFOR");
|
|
||||||
SetCurrentAccountDB(request.arg);
|
|
||||||
if (account_db.sapforTasksPackages.containsKey(request.object)) {
|
|
||||||
SapforTasksPackage sapforTasksPackage = account_db.sapforTasksPackages.get(request.object);
|
|
||||||
AbortSapforTasksPackage(sapforTasksPackage);
|
|
||||||
response = new ServerExchangeUnit_2021(ServerCode.OK);
|
|
||||||
} else throw new RepositoryRefuseException("Не существует пакета " + Utils.Brackets(request.object));
|
|
||||||
break;
|
|
||||||
//--
|
|
||||||
case CheckPackageToKill:
|
case CheckPackageToKill:
|
||||||
SetCurrentAccountDB(request.arg);
|
SetCurrentAccountDB(request.arg);
|
||||||
String packageName = (String) request.object;
|
String packageName = (String) request.object;
|
||||||
|
|||||||
@@ -3,8 +3,12 @@ import Common.Current;
|
|||||||
import Repository.Server.ServerCode;
|
import Repository.Server.ServerCode;
|
||||||
import Repository.Server.ServerExchangeUnit_2021;
|
import Repository.Server.ServerExchangeUnit_2021;
|
||||||
import SapforTestingSystem.SapforTasksPackage.SapforTasksPackage;
|
import SapforTestingSystem.SapforTasksPackage.SapforTasksPackage;
|
||||||
|
import TestingSystem.TasksPackageToKill.TasksPackageToKill;
|
||||||
import Visual_DVM_2021.Passes.TestingSystemPass;
|
import Visual_DVM_2021.Passes.TestingSystemPass;
|
||||||
|
|
||||||
|
import java.util.Vector;
|
||||||
public class AbortSapforTaskPackage extends TestingSystemPass<SapforTasksPackage> {
|
public class AbortSapforTaskPackage extends TestingSystemPass<SapforTasksPackage> {
|
||||||
|
Vector<TasksPackageToKill> packagesToKill;
|
||||||
@Override
|
@Override
|
||||||
public String getIconPath() {
|
public String getIconPath() {
|
||||||
return "/icons/Ban.PNG";
|
return "/icons/Ban.PNG";
|
||||||
@@ -15,14 +19,25 @@ public class AbortSapforTaskPackage extends TestingSystemPass<SapforTasksPackage
|
|||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
protected boolean canStart(Object... args) throws Exception {
|
protected boolean canStart(Object... args) throws Exception {
|
||||||
if (Current.Check(Log, Current.SapforTasksPackage)){
|
if (Current.Check(Log, Current.SapforTasksPackage)) {
|
||||||
|
packagesToKill = new Vector<>();
|
||||||
target = Current.getSapforTasksPackage();
|
target = Current.getSapforTasksPackage();
|
||||||
return true;
|
switch (target.state) {
|
||||||
};
|
case Done:
|
||||||
|
case Aborted:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
TasksPackageToKill tasksPackageToKill = new TasksPackageToKill();
|
||||||
|
tasksPackageToKill.packageName = target.id;
|
||||||
|
packagesToKill.add(tasksPackageToKill);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
protected void ServerAction() throws Exception {
|
protected void ServerAction() throws Exception {
|
||||||
Command(new ServerExchangeUnit_2021(ServerCode.AbortSapforTasksPackage, Current.getAccount().email, target.id));
|
Command(new ServerExchangeUnit_2021(ServerCode.PublishAccountObjects, Current.getAccount().email, packagesToKill));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user