команда запуска без shell канала а через exec
v++
This commit is contained in:
8
.idea/workspace.xml
generated
8
.idea/workspace.xml
generated
@@ -7,16 +7,10 @@
|
|||||||
</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/Common/Utils/TimerTask.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$/properties" beforeDir="false" afterPath="$PROJECT_DIR$/properties" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/properties" beforeDir="false" afterPath="$PROJECT_DIR$/properties" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/src/_VisualDVM/GlobalData/Tasks/Supervisor/Local/Linux/LinuxLocalTaskSupervisor.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/_VisualDVM/GlobalData/Tasks/Supervisor/Local/Linux/LinuxLocalTaskSupervisor.java" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/src/_VisualDVM/GlobalData/Tasks/Supervisor/Remote/RemoteCompilationSupervisor.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/_VisualDVM/GlobalData/Tasks/Supervisor/Remote/RemoteCompilationSupervisor.java" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/src/_VisualDVM/GlobalData/Tasks/Supervisor/Remote/RemoteTaskSupervisor.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/_VisualDVM/GlobalData/Tasks/Supervisor/Remote/RemoteTaskSupervisor.java" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/src/_VisualDVM/GlobalData/Tasks/Supervisor/Remote/ServerRunSupervisor.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/_VisualDVM/GlobalData/Tasks/Supervisor/Remote/ServerRunSupervisor.java" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/src/_VisualDVM/GlobalData/Tasks/Supervisor/TaskSupervisor.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/_VisualDVM/GlobalData/Tasks/Supervisor/TaskSupervisor.java" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/src/_VisualDVM/Repository/Component/Visualiser.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/_VisualDVM/Repository/Component/Visualiser.java" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/src/_VisualDVM/TestingSystem/DVM/UserConnection.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/_VisualDVM/TestingSystem/DVM/UserConnection.java" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/src/_VisualDVM/TestingSystem/DVM/UserConnection.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/_VisualDVM/TestingSystem/DVM/UserConnection.java" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/src/_VisualDVM/TestingSystem/SAPFOR/SapforTestingPlanner.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/_VisualDVM/TestingSystem/SAPFOR/SapforTestingPlanner.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" />
|
||||||
|
|||||||
85
src/Common/Utils/TimerTask.java
Normal file
85
src/Common/Utils/TimerTask.java
Normal file
@@ -0,0 +1,85 @@
|
|||||||
|
package Common.Utils;
|
||||||
|
import java.util.concurrent.Semaphore;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
public abstract class TimerTask {
|
||||||
|
int maxtime;
|
||||||
|
int attempts;
|
||||||
|
boolean success;
|
||||||
|
Semaphore semaphore = null;
|
||||||
|
Thread actionThread = null;
|
||||||
|
//--
|
||||||
|
public TimerTask(int maxtime_in, int attempts_in) {
|
||||||
|
maxtime = maxtime_in;
|
||||||
|
attempts = attempts_in;
|
||||||
|
semaphore = new Semaphore(1);
|
||||||
|
actionThread = new Thread(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
try {
|
||||||
|
Action();
|
||||||
|
} catch (Exception ex) {
|
||||||
|
System.out.println("Thread occured exception!");
|
||||||
|
ex.printStackTrace();
|
||||||
|
System.out.println("-------------------------");
|
||||||
|
} finally {
|
||||||
|
releaseSemaphore();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
//--
|
||||||
|
public abstract void Action() throws Exception;
|
||||||
|
public void finalizeThread() {
|
||||||
|
}
|
||||||
|
void acquireSemaphore() {
|
||||||
|
try {
|
||||||
|
semaphore.acquire();
|
||||||
|
System.out.println("semaphore acquired");
|
||||||
|
} catch (Exception ignore) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void releaseSemaphore() {
|
||||||
|
semaphore.release();
|
||||||
|
System.out.println("semaphore released");
|
||||||
|
}
|
||||||
|
void waitForThread() {
|
||||||
|
int i = 0;
|
||||||
|
success = false;
|
||||||
|
while (true) {
|
||||||
|
try {
|
||||||
|
++i;
|
||||||
|
if (semaphore.tryAcquire(1, TimeUnit.SECONDS)) {
|
||||||
|
System.out.println("thread finished for " + i + " seconds");
|
||||||
|
success = true;
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
System.out.println("thread active " + i + " seconds");
|
||||||
|
if (i >= maxtime) {
|
||||||
|
System.out.println("maxtime reached: " + i + " seconds");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception ex) {
|
||||||
|
System.out.println("waiting exception");
|
||||||
|
ex.printStackTrace();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public boolean Perform(int attempts) {
|
||||||
|
int i = 0;
|
||||||
|
while (i < attempts) {
|
||||||
|
acquireSemaphore();
|
||||||
|
actionThread.start();
|
||||||
|
waitForThread();
|
||||||
|
finalizeThread();
|
||||||
|
++i;
|
||||||
|
System.out.println("task finished for " + i + " attempts");
|
||||||
|
if (success) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
System.out.println("attempts overlimited");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -61,7 +61,7 @@ public class Visualiser extends Component {
|
|||||||
//http://www.seostella.com/ru/article/2012/02/05/formatirovanie-daty-v-java.html
|
//http://www.seostella.com/ru/article/2012/02/05/formatirovanie-daty-v-java.html
|
||||||
@Override
|
@Override
|
||||||
public void GetVersionInfo() {
|
public void GetVersionInfo() {
|
||||||
version = 1126;
|
version = 1127;
|
||||||
String pattern = "MMM dd yyyy HH:mm:ss";
|
String pattern = "MMM dd yyyy HH:mm:ss";
|
||||||
DateFormat df = new SimpleDateFormat(pattern, Locale.ENGLISH);
|
DateFormat df = new SimpleDateFormat(pattern, Locale.ENGLISH);
|
||||||
date_text = df.format(getClassBuildTime());
|
date_text = df.format(getClassBuildTime());
|
||||||
|
|||||||
@@ -413,6 +413,7 @@ public class UserConnection {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
//-----
|
//-----
|
||||||
|
/*
|
||||||
public void ShellConnect() throws Exception {
|
public void ShellConnect() throws Exception {
|
||||||
shellChannel = (ChannelShell) session.openChannel("shell");
|
shellChannel = (ChannelShell) session.openChannel("shell");
|
||||||
in = new PipedInputStream();
|
in = new PipedInputStream();
|
||||||
@@ -425,10 +426,6 @@ public class UserConnection {
|
|||||||
shellChannel.connect();
|
shellChannel.connect();
|
||||||
//-
|
//-
|
||||||
fromServer = new InputStreamReader(pout);
|
fromServer = new InputStreamReader(pout);
|
||||||
/*
|
|
||||||
ShellParser.setUserName(user.login);
|
|
||||||
ShellParser.ReadInvitation(fromServer); //прочитать первое приглашение от машины.
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
public void ShellDisconnect() throws Exception {
|
public void ShellDisconnect() throws Exception {
|
||||||
if (in != null) {
|
if (in != null) {
|
||||||
@@ -476,6 +473,8 @@ public class UserConnection {
|
|||||||
shellChannel = null;
|
shellChannel = null;
|
||||||
System.gc();
|
System.gc();
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
public void waitForFileCreation(RemoteFile file) throws Exception {
|
public void waitForFileCreation(RemoteFile file) throws Exception {
|
||||||
while (!Exists(file)) {
|
while (!Exists(file)) {
|
||||||
System.out.println(file.full_name + " NOT FOUND");
|
System.out.println(file.full_name + " NOT FOUND");
|
||||||
@@ -507,6 +506,16 @@ public class UserConnection {
|
|||||||
RemoteFile outFile = new RemoteFile(directory, outFileName);
|
RemoteFile outFile = new RemoteFile(directory, outFileName);
|
||||||
if (Exists(outFile))
|
if (Exists(outFile))
|
||||||
sftpChannel.rm(outFile.full_name);
|
sftpChannel.rm(outFile.full_name);
|
||||||
|
//--
|
||||||
|
System.out.println("nohup " + start_command + " &\r\n");
|
||||||
|
execChannel = (ChannelExec) session.openChannel("exec");
|
||||||
|
execChannel.setErrStream(System.err);
|
||||||
|
execChannel.setCommand("nohup " + start_command + " &\r\n");
|
||||||
|
execChannel.connect();
|
||||||
|
execChannel.disconnect();
|
||||||
|
System.out.println("done");
|
||||||
|
//--
|
||||||
|
/*
|
||||||
System.out.println("connecting shell");
|
System.out.println("connecting shell");
|
||||||
ShellConnect();
|
ShellConnect();
|
||||||
System.out.println("done");
|
System.out.println("done");
|
||||||
@@ -521,6 +530,7 @@ public class UserConnection {
|
|||||||
ShellDisconnect();
|
ShellDisconnect();
|
||||||
System.out.println("done");
|
System.out.println("done");
|
||||||
// return readFromFile(outFile).replace("\n", "").replace("\r", "");
|
// return readFromFile(outFile).replace("\n", "").replace("\r", "");
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
//-- проверка существования рабочего пространства.
|
//-- проверка существования рабочего пространства.
|
||||||
public void CheckUserInitialization(String email) throws Exception {
|
public void CheckUserInitialization(String email) throws Exception {
|
||||||
|
|||||||
Reference in New Issue
Block a user