Skip to content
Snippets Groups Projects
Commit 1f99673f authored by tjc's avatar tjc
Browse files

make running searches more robust

git-svn-id: svn+ssh://svn.internal.sanger.ac.uk/repos/svn/pathsoft/artemis/trunk@3728 ee4ac58c-ac51-4696-9907-e4b3aa274f04
parent 2ffbf0b2
No related branches found
No related tags found
No related merge requests found
......@@ -44,6 +44,7 @@ import java.io.IOException;
import java.util.Vector;
import java.util.Properties;
import com.sshtools.j2ssh.SshException;
import com.sshtools.j2ssh.SshClient;
import com.sshtools.j2ssh.session.SessionChannelClient;
import com.sshtools.j2ssh.sftp.SftpFile;
......@@ -101,6 +102,14 @@ public class SshPSUClient extends Thread
user = sshLogin.getUser();
}
private SshClient rescue()
{
ssh.disconnect();
SshLogin sshLogin = new SshLogin();
ssh = sshLogin.getSshClient();
return ssh;
}
public void run()
{
String program = cmd;
......@@ -116,7 +125,7 @@ public class SshPSUClient extends Thread
if(System.getProperty("debug") != null)
System.out.println("RUN "+program);
completed = runBlastOrFasta(ssh, program);
completed = runBlastOrFasta(program);
// Quit
//ssh.disconnect();
......@@ -173,7 +182,10 @@ public class SshPSUClient extends Thread
{
for(int i=0; i < 100; i++)
{
Thread.currentThread().sleep(5000);
Thread.currentThread().sleep(10000);
try
{
Object list[] = sftp.ls(wdir).toArray();
for(int j=0; j<list.length;j++)
......@@ -182,6 +194,11 @@ public class SshPSUClient extends Thread
return true;
}
}
catch(SshException sshe)
{
rescue();
}
}
return false;
}
......@@ -243,7 +260,7 @@ public class SshPSUClient extends Thread
* Run fasta or blast on the server ssh'ed into
*
*/
private boolean runBlastOrFasta(SshClient ssh, String program)
private boolean runBlastOrFasta(String program)
throws IOException
{
Properties settings = getProperties();
......@@ -279,14 +296,50 @@ public class SshPSUClient extends Thread
wdir = wdir+"/"+program+"/";
sftp.mkdir(wdir);
sftp.put(filepath, wdir+filename);
// sftp.put(filepath, wdir+filename);
}
catch(SshException sshe)
{
rescue();
}
catch(IOException ioe)
{
ioe.printStackTrace();
// directory already created
}
try
{
sftp.put(filepath, wdir+filename);
if(System.getProperty("debug") != null)
System.out.println("PUT SUCCESS "+wdir+filename);
}
catch(SshException ioe)
{
rescue();
sftp.put(filepath, wdir+filename);
}
if(System.getProperty("debug") != null)
System.out.println("STARTING session");
SessionChannelClient session = null;
try
{
if(!ssh.isConnected())
rescue();
session = ssh.openSessionChannel();
}
catch(IOException exp)
{
rescue();
}
SessionChannelClient session = ssh.openSessionChannel();
if(System.getProperty("debug") != null)
System.out.println("STARTED session");
String outputfile = wdir+filename+".out";
final String actualCMD;
......@@ -340,7 +393,20 @@ public class SshPSUClient extends Thread
// sftp.get(outputfile, os);
// System.out.println(os.toString());
try
{
sftp.get(outputfile, filepath+".out");
if(System.getProperty("debug") != null)
System.out.println("GET SUCCESS "+filepath+".out");
}
catch(Exception ioe)
{
rescue();
sftp.get(outputfile, filepath+".out");
}
if(!keep)
{
......@@ -369,7 +435,10 @@ public class SshPSUClient extends Thread
sftp = ssh.getActiveSftpClient();
return sftp;
}
catch(IOException ioe){}
catch(IOException ioe)
{
rescue();
}
return ssh.openSftpClient();
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment