реализация остановки сервера тестирования по кнопке
This commit is contained in:
52
src/Visual_DVM_2021/Passes/All/StopTestingServer.java
Normal file
52
src/Visual_DVM_2021/Passes/All/StopTestingServer.java
Normal file
@@ -0,0 +1,52 @@
|
||||
package Visual_DVM_2021.Passes.All;
|
||||
import Common.Constants;
|
||||
import Common.Current;
|
||||
import Common.UI.UI;
|
||||
import Common.Utils.Utils;
|
||||
import GlobalData.RemoteFile.RemoteFile;
|
||||
import Visual_DVM_2021.Passes.SSH.TestingServerSSHPass;
|
||||
import com.jcraft.jsch.ChannelSftp;
|
||||
import com.sun.corba.se.spi.orbutil.threadpool.Work;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Vector;
|
||||
public class StopTestingServer extends TestingServerSSHPass {
|
||||
@Override
|
||||
public String getIconPath() {
|
||||
return "/icons/Stop25.png";
|
||||
}
|
||||
@Override
|
||||
public String getButtonText() {
|
||||
return "";
|
||||
}
|
||||
@Override
|
||||
protected void ServerAction() throws Exception {
|
||||
RemoteFile Home = new RemoteFile(user.connection.sftpChannel.getHome(), true);
|
||||
RemoteFile Workspace = new RemoteFile(Home, Constants.testingSystemHomeName);
|
||||
//--
|
||||
RemoteFile INTERRUPT = new RemoteFile(Workspace, Constants.INTERRUPT);
|
||||
RemoteFile ABORTED = new RemoteFile(Workspace, Constants.ABORTED);
|
||||
|
||||
//--
|
||||
System.out.println("Home="+Utils.Brackets(Home.full_name));
|
||||
System.out.println("Workspace="+Utils.Brackets(Workspace.full_name));
|
||||
|
||||
ShowMessage1("Создание файла INTERRUPT..");
|
||||
user.connection.writeToFile("+", INTERRUPT);
|
||||
ShowMessage1("Ожидание остановки сервера тестирования");
|
||||
do {
|
||||
Utils.sleep(1000);
|
||||
ShowMessage2("Проверка признака остановки..");
|
||||
} while (!user.connection.Exists(ABORTED));
|
||||
//--
|
||||
RemoteFile AbortLog = new RemoteFile(Workspace, Constants.ABORTED+
|
||||
"_by_"+
|
||||
Current.getAccount().email+
|
||||
"_"+
|
||||
new Date().toString()
|
||||
);
|
||||
user.connection.writeToFile("+", AbortLog);
|
||||
user.connection.sftpChannel.rename(ABORTED.full_name, AbortLog.full_name);
|
||||
System.out.println("Done");
|
||||
}
|
||||
}
|
||||
@@ -322,11 +322,15 @@ public enum PassCode_2021 {
|
||||
CompareDVMRunTasks,
|
||||
CompareSapforPackages,
|
||||
CreateDVMPackageFromCurrentProject,
|
||||
//--
|
||||
StopTestingServer
|
||||
;
|
||||
public String getDescription() {
|
||||
switch (this) {
|
||||
case Undefined:
|
||||
return "?";
|
||||
case StopTestingServer:
|
||||
return "Остановить серверный компонент тестирования";
|
||||
case CreateDVMPackageFromCurrentProject:
|
||||
return "Тестировать текущий проект";
|
||||
case CompareSapforPackages:
|
||||
|
||||
18
src/Visual_DVM_2021/Passes/SSH/TestingServerSSHPass.java
Normal file
18
src/Visual_DVM_2021/Passes/SSH/TestingServerSSHPass.java
Normal file
@@ -0,0 +1,18 @@
|
||||
package Visual_DVM_2021.Passes.SSH;
|
||||
import Common.Current;
|
||||
import Common.Global;
|
||||
import GlobalData.Machine.Machine;
|
||||
import GlobalData.Machine.MachineType;
|
||||
import GlobalData.User.User;
|
||||
public class TestingServerSSHPass extends ConnectionPass {
|
||||
@Override
|
||||
protected boolean needsAnimation() {
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public void Connect() throws Exception {
|
||||
machine = new Machine("alex", Global.properties.ServerAddress,Global.properties.ServerUserSHHPort,MachineType.Server);
|
||||
user = new User(Global.properties.ServerUserName, "mprit_2011");
|
||||
super.Connect();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user