Author: chatellier Date: 2009-10-29 13:57:48 +0000 (Thu, 29 Oct 2009) New Revision: 2713 Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/launcher/SSHSimulatorLauncher.java Log: Make semaphore deprecated. Prepare sftp use. Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/launcher/SSHSimulatorLauncher.java =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/launcher/SSHSimulatorLauncher.java 2009-10-29 13:40:45 UTC (rev 2712) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/launcher/SSHSimulatorLauncher.java 2009-10-29 13:57:48 UTC (rev 2713) @@ -91,13 +91,21 @@ //protected static final String QSUB_SCRIPT_TEMPLATE = "templates/ssh/isis-launch-with-cron.seq"; /** - * Opened session. Stored in static context to not reask passphrase at each + * Opened session to ssh service. Stored in static context to not reask passphrase at each * connection. */ protected static Session sshSession; + + /** + * Opened session to sftp service. Stored in static context to not reask passphrase at each + * connection. + */ + protected static Session sshSftpSession; /** * Semaphore used to upload only 20 (default) simulations at a time. + * + * @deprecated this just a hack to not crash PBS */ protected static Semaphore semaphore = new Semaphore(IsisFish.config .getSimulatorSshMaxSimultaneousSimulation()); @@ -126,8 +134,6 @@ TemplateLoader templateLoader = new ClasspathTemplateLoader(); freemarkerConfiguration.setTemplateLoader(templateLoader); - //freemarkerConfiguration.setObjectWrapper(new BeansWrapper()); - } /** @@ -258,7 +264,8 @@ try { // connection message(control, _("isisfish.simulation.remote.message.connection")); - Session sshSession = getSSHSession(); //openSSHSession(); + Session sshSession = getSSHSession(); + //Session sshSftpSession = getSSHSftpSession(); // upload simulation on server message(control, _("isisfish.simulation.remote.message.upload")); @@ -496,6 +503,23 @@ } /** + * Get opened ssh session or try to open a new one. + * + * This method must synchronized. + * + * @return opened ssh session. + * @throws JSchException + */ + protected synchronized Session getSSHSftpSession() throws JSchException { + + if (sshSftpSession == null || !sshSftpSession.isConnected()) { + sshSftpSession = openSSHSession(); + } + + return sshSftpSession; + } + + /** * Connect to remote server throw SSH, and return session. * * @return valid opened session