прерывание пакета. первый вариант.

This commit is contained in:
2023-10-17 00:22:06 +03:00
parent c822cc452b
commit 19f7230eb5
10 changed files with 90 additions and 9 deletions

13
.idea/workspace.xml generated
View File

@@ -6,7 +6,18 @@
</artifacts-to-build> </artifacts-to-build>
</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$/src/Common/Current.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Common/Current.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/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/Visual_DVM_2021/Passes/PassCode_2021.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/PassCode_2021.java" afterDir="false" />
</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" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" /> <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />

View File

@@ -33,7 +33,7 @@ public enum Current {
Undefined, Undefined,
//-- //--
ServerSapfor, ServerSapfor,
SapforScenario, SapforTasksPackage,
SapforEtalonTaskResult,//самый левый пакет SapforEtalonTaskResult,//самый левый пакет
SapforTaskResult, SapforTaskResult,
//-- //--
@@ -368,10 +368,10 @@ public enum Current {
return (GlobalData.SapforProfile.SapforProfile) get(Current.SapforProfile); return (GlobalData.SapforProfile.SapforProfile) get(Current.SapforProfile);
} }
public static boolean HasSapforTasksPackage() { public static boolean HasSapforTasksPackage() {
return get(Current.SapforScenario) != null; return get(Current.SapforTasksPackage) != null;
} }
public static SapforTestingSystem.SapforTasksPackage.SapforTasksPackage getSapforTasksPackage() { public static SapforTestingSystem.SapforTasksPackage.SapforTasksPackage getSapforTasksPackage() {
return (SapforTestingSystem.SapforTasksPackage.SapforTasksPackage) get(Current.SapforScenario); return (SapforTestingSystem.SapforTasksPackage.SapforTasksPackage) get(Current.SapforTasksPackage);
} }
//сапфоры установленные на тестовый сервер. //сапфоры установленные на тестовый сервер.
public static boolean HasServerSapfor() { public static boolean HasServerSapfor() {
@@ -385,7 +385,7 @@ public enum Current {
switch (this) { switch (this) {
case ServerSapfor: case ServerSapfor:
return "тестовая версия SAPFOR"; return "тестовая версия SAPFOR";
case SapforScenario: case SapforTasksPackage:
return "сценарий SAPFOR"; return "сценарий SAPFOR";
case SapforProfile: case SapforProfile:
return "Профиль SAPFOR"; return "Профиль SAPFOR";

View File

@@ -1,7 +1,8 @@
package Common.UI.Menus_2023.SapforTasksPackagesBar; package Common.UI.Menus_2023.SapforTasksPackagesBar;
import Common.UI.Menus_2023.DataMenuBar; import Common.UI.Menus_2023.DataMenuBar;
import Visual_DVM_2021.Passes.PassCode_2021;
public class SapforTasksPackagesBar extends DataMenuBar { public class SapforTasksPackagesBar extends DataMenuBar {
public SapforTasksPackagesBar() { public SapforTasksPackagesBar() {
super("пакеты задач"); super("пакеты задач", PassCode_2021.AbortSapforTaskPackage);
} }
} }

View File

@@ -25,7 +25,7 @@ public class TestingBar extends VisualiserMenuBar {
add(sKernels = new JSpinner()); add(sKernels = new JSpinner());
sKernels.setPreferredSize(new Dimension(60, 26)); sKernels.setPreferredSize(new Dimension(60, 26));
sKernels.setMaximumSize(new Dimension(60, 26)); sKernels.setMaximumSize(new Dimension(60, 26));
sKernels.setModel(new SpinnerNumberModel(TestingServer.kernels, 1, 16, 1)); sKernels.setModel(new SpinnerNumberModel(TestingServer.kernels, 1, 64, 1));
UI.MakeSpinnerRapid(sKernels, e -> { UI.MakeSpinnerRapid(sKernels, e -> {
TestingServer.kernels = (int) sKernels.getValue(); TestingServer.kernels = (int) sKernels.getValue();
}); });

View File

@@ -70,5 +70,6 @@ public enum ServerCode {
InstallSapforForTesting, InstallSapforForTesting,
StartSapforTests, StartSapforTests,
GetFirstActiveSapforTasksPackage, GetFirstActiveSapforTasksPackage,
AbortSapforTasksPackage,
OLD OLD
} }

View File

@@ -13,7 +13,7 @@ public class SapforTasksPackagesDBTable extends DBTable<String, SapforTasksPacka
} }
@Override @Override
public Current CurrentName() { public Current CurrentName() {
return Current.SapforScenario; return Current.SapforTasksPackage;
} }
@Override @Override
public String getSingleDescription() { public String getSingleDescription() {

View File

@@ -14,7 +14,7 @@ import java.util.Vector;
//https://stackoverflow.com/questions/2127318/java-how-can-i-do-dynamic-casting-of-a-variable-from-one-type-to-another //https://stackoverflow.com/questions/2127318/java-how-can-i-do-dynamic-casting-of-a-variable-from-one-type-to-another
public class GroupInterface { public class GroupInterface {
//- //-
public static boolean filterMyOnly = true; public static boolean filterMyOnly = false;
//-- //--
public static boolean isVisible(Group object) { public static boolean isVisible(Group object) {
return (!filterMyOnly || Current.getAccount().email.equals(object.sender_address)) && return (!filterMyOnly || Current.getAccount().email.equals(object.sender_address)) &&

View File

@@ -1,4 +1,5 @@
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;
@@ -21,6 +22,7 @@ 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;
@@ -37,6 +39,7 @@ 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;
@@ -311,6 +314,31 @@ 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;
@@ -323,6 +351,15 @@ 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);

View File

@@ -0,0 +1,28 @@
package Visual_DVM_2021.Passes.All;
import Common.Current;
import Repository.Server.ServerCode;
import Repository.Server.ServerExchangeUnit_2021;
import SapforTestingSystem.SapforTasksPackage.SapforTasksPackage;
import Visual_DVM_2021.Passes.TestingSystemPass;
public class AbortSapforTaskPackage extends TestingSystemPass<SapforTasksPackage> {
@Override
public String getIconPath() {
return "/icons/Ban.PNG";
}
@Override
public String getButtonText() {
return "";
}
@Override
protected boolean canStart(Object... args) throws Exception {
if (Current.Check(Log, Current.SapforTasksPackage)){
target = Current.getSapforTasksPackage();
return true;
};
return false;
}
@Override
protected void ServerAction() throws Exception {
Command(new ServerExchangeUnit_2021(ServerCode.AbortSapforTasksPackage, Current.getAccount().email, target.id));
}
}

View File

@@ -4,6 +4,7 @@ public enum PassCode_2021 {
//- //-
ShowAllParallelVariants, ShowAllParallelVariants,
ShowParallelVariantsCoverage, ShowParallelVariantsCoverage,
AbortSapforTaskPackage,
//- //-
DeleteServerSapfor, DeleteServerSapfor,
StartSapforTests, StartSapforTests,
@@ -307,6 +308,8 @@ public enum PassCode_2021 {
switch (this) { switch (this) {
case Undefined: case Undefined:
return "?"; return "?";
case AbortSapforTaskPackage:
return "Прервать пакет задач SAPFOR";
case ShowAllParallelVariants: case ShowAllParallelVariants:
return "Отобразить все параллельные варианты"; return "Отобразить все параллельные варианты";
case ShowParallelVariantsCoverage: case ShowParallelVariantsCoverage: