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

ssh fasta searches fix

git-svn-id: svn+ssh://svn.internal.sanger.ac.uk/repos/svn/pathsoft/artemis/trunk@3794 ee4ac58c-ac51-4696-9907-e4b3aa274f04
parent d7b7c74a
No related branches found
No related tags found
No related merge requests found
...@@ -82,9 +82,17 @@ public class SshFileManager ...@@ -82,9 +82,17 @@ public class SshFileManager
private void rescue() private void rescue()
{ {
ssh.disconnect(); try
SshLogin sshLogin = new SshLogin(); {
ssh = sshLogin.getSshClient(); ssh.disconnect();
SshLogin sshLogin = new SshLogin();
ssh = sshLogin.getSshClient();
}
catch(Exception exp)
{
System.out.println("SshFileManager.rescue()");
exp.printStackTrace();
}
} }
...@@ -279,6 +287,17 @@ public class SshFileManager ...@@ -279,6 +287,17 @@ public class SshFileManager
return false; return false;
} }
} }
catch(SshException sshe)
{
if(System.getProperty("debug") != null)
{
System.out.println("put() ");
sshe.printStackTrace();
}
rescue();
return put(dir, local_file, monitor, force);
}
catch(IOException ioe) catch(IOException ioe)
{ {
// remote file doesn't exist // remote file doesn't exist
...@@ -296,6 +315,11 @@ public class SshFileManager ...@@ -296,6 +315,11 @@ public class SshFileManager
} }
catch(SshException sshe) catch(SshException sshe)
{ {
if(System.getProperty("debug") != null)
{
System.out.println("put() 2");
sshe.printStackTrace();
}
rescue(); rescue();
return put(dir, local_file, monitor, true); return put(dir, local_file, monitor, true);
} }
...@@ -305,6 +329,7 @@ public class SshFileManager ...@@ -305,6 +329,7 @@ public class SshFileManager
ioe.printStackTrace(); ioe.printStackTrace();
return false; return false;
} }
} }
private boolean putTransfer(final SftpClient sftp, private boolean putTransfer(final SftpClient sftp,
......
...@@ -104,9 +104,17 @@ public class SshPSUClient extends Thread ...@@ -104,9 +104,17 @@ public class SshPSUClient extends Thread
private SshClient rescue() private SshClient rescue()
{ {
ssh.disconnect(); try
SshLogin sshLogin = new SshLogin(); {
ssh = sshLogin.getSshClient(); ssh.disconnect();
SshLogin sshLogin = new SshLogin();
ssh = sshLogin.getSshClient();
}
catch(Exception exp)
{
System.out.println("SshPSUClient.rescue()");
exp.printStackTrace();
}
return ssh; return ssh;
} }
...@@ -177,32 +185,51 @@ public class SshPSUClient extends Thread ...@@ -177,32 +185,51 @@ public class SshPSUClient extends Thread
* Wait until a file appears on the server. * Wait until a file appears on the server.
* *
*/ */
private boolean waitUntilFileAppears(SftpClient sftp, String file) private boolean waitUntilFileAppears(String file)
throws InterruptedException, IOException throws InterruptedException, IOException
{ {
SftpClient sftp;
for(int i=0; i < 100; i++) for(int i=0; i < 100; i++)
{ {
Thread.currentThread().sleep(10000); Thread.currentThread().sleep(10000);
sftp = getSftpClient();
try try
{ {
Object list[] = sftp.ls(wdir).toArray(); if(fileExists(sftp, file))
return true;
for(int j=0; j<list.length;j++)
{
if( ((SftpFile)list[j]).getFilename().equals(file) )
return true;
}
} }
catch(SshException sshe) catch(SshException sshe)
{ {
if(System.getProperty("debug") != null)
{
System.out.println("waitUntilFileAppears()");
sshe.printStackTrace();
}
rescue(); rescue();
sftp = getSftpClient();
try
{
if(fileExists(sftp, file))
return true;
} catch(SshException sshe2) {}
} }
} }
return false; return false;
} }
private boolean fileExists(SftpClient sftp, String file)
throws SshException, IOException
{
Object list[] = sftp.ls(wdir).toArray();
for(int j=0; j<list.length;j++)
{
if( ((SftpFile)list[j]).getFilename().equals(file) )
return true;
}
return false;
}
/** /**
* *
...@@ -300,7 +327,13 @@ public class SshPSUClient extends Thread ...@@ -300,7 +327,13 @@ public class SshPSUClient extends Thread
} }
catch(SshException sshe) catch(SshException sshe)
{ {
if(System.getProperty("debug") != null)
{
System.out.println("runBlastOrFasta()");
sshe.printStackTrace();
}
rescue(); rescue();
sftp = getSftpClient();
} }
catch(IOException ioe) catch(IOException ioe)
{ {
...@@ -317,7 +350,13 @@ public class SshPSUClient extends Thread ...@@ -317,7 +350,13 @@ public class SshPSUClient extends Thread
} }
catch(SshException ioe) catch(SshException ioe)
{ {
if(System.getProperty("debug") != null)
{
System.out.println("runBlastOrFasta() - 2");
ioe.printStackTrace();
}
rescue(); rescue();
sftp = getSftpClient();
sftp.put(filepath, wdir+filename); sftp.put(filepath, wdir+filename);
} }
...@@ -335,6 +374,11 @@ public class SshPSUClient extends Thread ...@@ -335,6 +374,11 @@ public class SshPSUClient extends Thread
} }
catch(IOException exp) catch(IOException exp)
{ {
if(System.getProperty("debug") != null)
{
System.out.println("runBlastOrFasta() - 3");
exp.printStackTrace();
}
rescue(); rescue();
} }
...@@ -375,13 +419,15 @@ public class SshPSUClient extends Thread ...@@ -375,13 +419,15 @@ public class SshPSUClient extends Thread
while(stdouth.isAlive() || stderrh.isAlive()) while(stdouth.isAlive() || stderrh.isAlive())
Thread.currentThread().sleep(10); Thread.currentThread().sleep(10);
isFile = waitUntilFileAppears(sftp, filename+".out"); isFile = waitUntilFileAppears(filename+".out");
} }
catch(InterruptedException ie) catch(InterruptedException ie)
{ {
ie.printStackTrace(); ie.printStackTrace();
} }
sftp = getSftpClient();
if(System.getProperty("debug") != null) if(System.getProperty("debug") != null)
{ {
// stdout & stderr // stdout & stderr
...@@ -403,6 +449,11 @@ public class SshPSUClient extends Thread ...@@ -403,6 +449,11 @@ public class SshPSUClient extends Thread
} }
catch(Exception ioe) catch(Exception ioe)
{ {
if(System.getProperty("debug") != null)
{
System.out.println("runBlastOrFasta() - 3");
ioe.printStackTrace();
}
rescue(); rescue();
sftp.get(outputfile, filepath+".out"); sftp.get(outputfile, filepath+".out");
} }
...@@ -437,6 +488,11 @@ public class SshPSUClient extends Thread ...@@ -437,6 +488,11 @@ public class SshPSUClient extends Thread
} }
catch(IOException ioe) catch(IOException ioe)
{ {
if(System.getProperty("debug") != null)
{
System.out.println("getSftpClient()");
ioe.printStackTrace();
}
rescue(); rescue();
} }
return ssh.openSftpClient(); return ssh.openSftpClient();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment