доработка остановки сервера, добавлен проход запроса активности сервера, перед созданием файла interrupt
This commit is contained in:
21
src/Visual_DVM_2021/Passes/All/PingTestingServer.java
Normal file
21
src/Visual_DVM_2021/Passes/All/PingTestingServer.java
Normal file
@@ -0,0 +1,21 @@
|
||||
package Visual_DVM_2021.Passes.All;
|
||||
import Repository.Server.ServerCode;
|
||||
import Repository.Server.ServerExchangeUnit_2021;
|
||||
import Visual_DVM_2021.Passes.Server.TestingSystemPass;
|
||||
public class PingTestingServer extends TestingSystemPass {
|
||||
boolean flag;
|
||||
@Override
|
||||
protected boolean canStart(Object... args) throws Exception {
|
||||
flag=false;
|
||||
return super.canStart(args);
|
||||
}
|
||||
@Override
|
||||
protected void ServerAction() throws Exception {
|
||||
Command(new ServerExchangeUnit_2021(ServerCode.Ping));
|
||||
flag=true;
|
||||
}
|
||||
@Override
|
||||
protected boolean validate() {
|
||||
return flag;
|
||||
}
|
||||
}
|
||||
21
src/Visual_DVM_2021/Passes/All/ShutdownTestingServer.java
Normal file
21
src/Visual_DVM_2021/Passes/All/ShutdownTestingServer.java
Normal file
@@ -0,0 +1,21 @@
|
||||
package Visual_DVM_2021.Passes.All;
|
||||
import Visual_DVM_2021.Passes.PassCode_2021;
|
||||
import Visual_DVM_2021.Passes.SSH.TestingServerSSHPass;
|
||||
public class ShutdownTestingServer extends TestingServerSSHPass {
|
||||
@Override
|
||||
public String getIconPath() {
|
||||
return "/icons/Stop25.png";
|
||||
}
|
||||
@Override
|
||||
public String getButtonText() {
|
||||
return "";
|
||||
}
|
||||
@Override
|
||||
protected boolean canStart(Object... args) throws Exception {
|
||||
return passes.get(PassCode_2021.PingTestingServer).Do();
|
||||
}
|
||||
@Override
|
||||
protected void ServerAction() throws Exception {
|
||||
Shutdown();
|
||||
}
|
||||
}
|
||||
@@ -1,52 +0,0 @@
|
||||
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");
|
||||
}
|
||||
}
|
||||
@@ -323,13 +323,16 @@ public enum PassCode_2021 {
|
||||
CompareSapforPackages,
|
||||
CreateDVMPackageFromCurrentProject,
|
||||
//--
|
||||
StopTestingServer
|
||||
PingTestingServer,
|
||||
ShutdownTestingServer
|
||||
;
|
||||
public String getDescription() {
|
||||
switch (this) {
|
||||
case Undefined:
|
||||
return "?";
|
||||
case StopTestingServer:
|
||||
case PingTestingServer:
|
||||
return "Проверить активность тестового сервера";
|
||||
case ShutdownTestingServer:
|
||||
return "Остановить серверный компонент тестирования";
|
||||
case CreateDVMPackageFromCurrentProject:
|
||||
return "Тестировать текущий проект";
|
||||
|
||||
@@ -1,18 +1,59 @@
|
||||
package Visual_DVM_2021.Passes.SSH;
|
||||
import Common.Constants;
|
||||
import Common.Current;
|
||||
import Common.Global;
|
||||
import Common.Utils.Utils;
|
||||
import GlobalData.Machine.Machine;
|
||||
import GlobalData.Machine.MachineType;
|
||||
import GlobalData.RemoteFile.RemoteFile;
|
||||
import GlobalData.User.User;
|
||||
|
||||
import java.util.Date;
|
||||
public class TestingServerSSHPass extends ConnectionPass {
|
||||
protected RemoteFile userHome;
|
||||
protected RemoteFile testingHome;
|
||||
@Override
|
||||
protected boolean needsAnimation() {
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public void Connect() throws Exception {
|
||||
userHome =null;
|
||||
testingHome =null;
|
||||
//--
|
||||
machine = new Machine("alex", Global.properties.ServerAddress,Global.properties.ServerUserSHHPort,MachineType.Server);
|
||||
user = new User(Global.properties.ServerUserName, "mprit_2011");
|
||||
super.Connect();
|
||||
//--
|
||||
userHome = new RemoteFile(user.connection.sftpChannel.getHome(), true);
|
||||
testingHome = new RemoteFile(userHome, Constants.testingSystemHomeName);
|
||||
//-
|
||||
System.out.println("userHome="+ Utils.Brackets(userHome.full_name));
|
||||
System.out.println("testingHome="+Utils.Brackets(testingHome.full_name));
|
||||
}
|
||||
//--
|
||||
protected void Shutdown() throws Exception{
|
||||
//--
|
||||
RemoteFile INTERRUPT = new RemoteFile(testingHome, Constants.INTERRUPT);
|
||||
RemoteFile ABORTED = new RemoteFile(testingHome, Constants.ABORTED);
|
||||
//--
|
||||
ShowMessage1("Создание файла INTERRUPT..");
|
||||
user.connection.writeToFile("+", INTERRUPT);
|
||||
ShowMessage1("Ожидание остановки сервера тестирования");
|
||||
do {
|
||||
Utils.sleep(1000);
|
||||
ShowMessage2("Проверка признака остановки..");
|
||||
} while (!user.connection.Exists(ABORTED));
|
||||
//--
|
||||
ShowMessage2("");
|
||||
ShowMessage1("Журнализация");
|
||||
RemoteFile AbortLog = new RemoteFile(testingHome, Constants.ABORTED+
|
||||
"_by_"+
|
||||
Current.getAccount().email+
|
||||
"_"+
|
||||
new Date().toString()
|
||||
);
|
||||
user.connection.sftpChannel.rename(ABORTED.full_name, AbortLog.full_name);
|
||||
System.out.println("Done");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user