no message
This commit is contained in:
33
src/_VisualDVM/Passes/SSH/ConnectionPass.java
Normal file
33
src/_VisualDVM/Passes/SSH/ConnectionPass.java
Normal file
@@ -0,0 +1,33 @@
|
||||
package _VisualDVM.Passes.SSH;
|
||||
import _VisualDVM.GlobalData.Machine.Machine;
|
||||
import _VisualDVM.GlobalData.User.User;
|
||||
import _VisualDVM.TestingSystem.DVM.UserConnection;
|
||||
import Common.Passes.Pass;
|
||||
public class ConnectionPass<T> extends Pass<T> {
|
||||
protected Machine machine = null;
|
||||
public User user = null;
|
||||
//--
|
||||
protected void Connect() throws Exception{
|
||||
user.connection = null;
|
||||
user.connection = new UserConnection(machine, user);
|
||||
}
|
||||
void Disconnect(){
|
||||
if (user.connection!=null){
|
||||
user.connection.Disconnect();
|
||||
user.connection = null;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
protected void body() throws Exception {
|
||||
Connect();
|
||||
ServerAction();
|
||||
}
|
||||
@Override
|
||||
protected void performFinish() throws Exception {
|
||||
Disconnect();
|
||||
}
|
||||
//--
|
||||
protected void ServerAction() throws Exception{
|
||||
|
||||
}
|
||||
}
|
||||
20
src/_VisualDVM/Passes/SSH/CurrentConnectionPass.java
Normal file
20
src/_VisualDVM/Passes/SSH/CurrentConnectionPass.java
Normal file
@@ -0,0 +1,20 @@
|
||||
package _VisualDVM.Passes.SSH;
|
||||
import _VisualDVM.Current;
|
||||
import _VisualDVM.Global;
|
||||
//завязан на текущие машину и юзера
|
||||
public abstract class CurrentConnectionPass<T> extends ConnectionPass<T> {
|
||||
@Override
|
||||
protected boolean needsAnimation() {
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
protected boolean canStart(Object... args) {
|
||||
return Global.mainModule.Check(Log, Current.User);
|
||||
}
|
||||
@Override
|
||||
public void Connect() throws Exception {
|
||||
machine = Global.mainModule.getMachine();
|
||||
user = Global.mainModule.getUser();
|
||||
super.Connect();
|
||||
}
|
||||
}
|
||||
82
src/_VisualDVM/Passes/SSH/RepositoryServerSSHPass.java
Normal file
82
src/_VisualDVM/Passes/SSH/RepositoryServerSSHPass.java
Normal file
@@ -0,0 +1,82 @@
|
||||
package _VisualDVM.Passes.SSH;
|
||||
import Common.Utils.Utils_;
|
||||
import _VisualDVM.Constants;
|
||||
import _VisualDVM.Global;
|
||||
import _VisualDVM.GlobalData.Machine.Machine;
|
||||
import _VisualDVM.GlobalData.Machine.MachineType;
|
||||
import _VisualDVM.GlobalData.RemoteFile.RemoteFile;
|
||||
import _VisualDVM.GlobalData.User.User;
|
||||
|
||||
import java.util.Date;
|
||||
public abstract class RepositoryServerSSHPass extends ConnectionPass {
|
||||
protected abstract String getServerFileName();
|
||||
protected abstract String getServerHomeName();
|
||||
@Override
|
||||
public String getButtonText() {
|
||||
return "";
|
||||
}
|
||||
//--
|
||||
protected RemoteFile userHome;
|
||||
protected RemoteFile serverHome;
|
||||
@Override
|
||||
protected boolean needsAnimation() {
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public void Connect() throws Exception {
|
||||
userHome = null;
|
||||
serverHome = 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);
|
||||
serverHome = new RemoteFile(userHome, getServerHomeName());
|
||||
//-
|
||||
}
|
||||
//--
|
||||
protected void StartServer() throws Exception {
|
||||
user.connection.startShellProcess(serverHome,"server_out.txt", "java -jar " + getServerFileName());
|
||||
//--
|
||||
RemoteFile StartLog = new RemoteFile(serverHome, Constants.STARTED +
|
||||
"_by_" +
|
||||
Global.mainModule.getAccount().email +
|
||||
"_" +
|
||||
new Date().toString()
|
||||
);
|
||||
user.connection.writeToFile("", StartLog);
|
||||
//--
|
||||
RemoteFile[] files = new RemoteFile[]{
|
||||
new RemoteFile(serverHome, Constants.script),
|
||||
new RemoteFile(serverHome, Constants.out_file),
|
||||
new RemoteFile(serverHome, Constants.err_file)
|
||||
};
|
||||
//-
|
||||
for (RemoteFile file : files) {
|
||||
user.connection.tryRM(file);
|
||||
}
|
||||
}
|
||||
protected void ShutdownServer() throws Exception {
|
||||
RemoteFile INTERRUPT = new RemoteFile(serverHome, Constants.INTERRUPT);
|
||||
RemoteFile ABORTED = new RemoteFile(serverHome, 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(serverHome, Constants.ABORTED +
|
||||
"_by_" +
|
||||
Global.mainModule.getAccount().email +
|
||||
"_" +
|
||||
new Date().toString()
|
||||
);
|
||||
user.connection.sftpChannel.rename(ABORTED.full_name, AbortLog.full_name);
|
||||
}
|
||||
}
|
||||
44
src/_VisualDVM/Passes/SSH/TaskConnectionPass.java
Normal file
44
src/_VisualDVM/Passes/SSH/TaskConnectionPass.java
Normal file
@@ -0,0 +1,44 @@
|
||||
package _VisualDVM.Passes.SSH;
|
||||
import Common.Utils.Utils_;
|
||||
import _VisualDVM.Global;
|
||||
import _VisualDVM.GlobalData.Tasks.Supervisor.Remote.RemoteTaskSupervisor;
|
||||
public abstract class TaskConnectionPass<S extends RemoteTaskSupervisor> extends ConnectionPass {
|
||||
public S supervisor; //инициализация идет в конструкторе потомка.
|
||||
public TaskConnectionPass(Class<S> s_class) {
|
||||
try {
|
||||
supervisor = s_class.newInstance();
|
||||
} catch (Exception e) {
|
||||
Utils_.MainLog.PrintException(e);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
protected boolean needsAnimation() {
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public void Connect() throws Exception {
|
||||
machine = supervisor.task.getMachine();
|
||||
user = supervisor.task.getUser();
|
||||
super.Connect();
|
||||
user.connection.CheckUserInitialization(Global.mainModule.getAccount().email);
|
||||
/*
|
||||
String log = user.connection.CheckModulesVersion();
|
||||
if (!log.isEmpty()) {
|
||||
throw new PassException("Сборка модулей не выполнена");
|
||||
}
|
||||
*/
|
||||
}
|
||||
@Override
|
||||
protected void ServerAction() throws Exception {
|
||||
supervisor.PerformTask();
|
||||
}
|
||||
@Override
|
||||
protected void performFinish() throws Exception {
|
||||
supervisor.UpdateTask();
|
||||
super.performFinish(); //disconnect
|
||||
}
|
||||
@Override
|
||||
public void Interrupt() throws Exception {
|
||||
Global.mainModule.getProject().CreateInterruptFile();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package _VisualDVM.Passes.SSH;
|
||||
public class WorkspaceNotFoundException extends Exception{
|
||||
public WorkspaceNotFoundException(String message_in){
|
||||
super(message_in);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user