r1823 - isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/launcher
Author: chatellier Date: 2009-02-17 17:08:29 +0000 (Tue, 17 Feb 2009) New Revision: 1823 Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/launcher/SSHSimulatorLauncher.java Log: Check that downloaded directory not already exists. If so, remove it. 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-02-17 17:00:21 UTC (rev 1822) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/launcher/SSHSimulatorLauncher.java 2009-02-17 17:08:29 UTC (rev 1823) @@ -485,16 +485,29 @@ if (log.isDebugEnabled()) { log.debug("Downloading results in " + localFile.getAbsolutePath()); } - + + // Cant happen if result have already been downloded + // Or try to, but has been interrupted + // delete and download again + File simulationBaseDirectory = new File(localFile, simulationId); + if (simulationBaseDirectory.exists()) { + if (log.isWarnEnabled()) { + log.warn("Warning, simulation results " + simulationBaseDirectory.getAbsolutePath() + " already exists"); + log.warn("Delete it, and download again"); + } + + FileUtil.deleteRecursively(simulationBaseDirectory); + } + // build remote file path // FIXME this path should be given by remote IsisFish app - // TODO to change String remoteFile = IsisFish.config.getSimulatorSshDataPath(); remoteFile += "/" + SimulationStorage.SIMULATION_PATH; remoteFile += "/" + simulationId; + + SSHUtils.scpFrom(session, remoteFile, localFile); - } /** @@ -663,96 +676,4 @@ throw new SSHException(_("Command '%s' fail to execute", command)); } } - - // /** - // * Thread that check remote control file every 2s. - // */ - // protected class RemoteSSHControlThread implements Runnable { - // - // /** Sleep 1s */ - // protected static final int SLEEPTIME = 1000; - // - // /** Opened ssh session */ - // protected Session sshSession; - // - // /** Control (to update progression) */ - // protected SimulationControl control; - // - // /** - // * Constructor. - // * @param sshSession - // * - // * @param control control - // */ - // protected RemoteSSHControlThread(Session sshSession, - // SimulationControl control) { - // this.sshSession = sshSession; - // this.control = control; - // } - // - // /* - // * @see java.lang.Runnable#run() - // */ - // @Override - // public void run() { - // - // boolean running = true; - // while (running) { - // - // // wait - // try { - // Thread.sleep(SLEEPTIME); - // - // // log (to check if thread is still alive) - // if (log.isDebugEnabled()) { - // log.debug("Control thread wake up"); - // } - // - // try { - // // download control file - // File controlFile = downloadControlFile(control.getId()); - // - // if (log.isDebugEnabled()) { - // log.debug("Control have been downloaded : " - // + controlFile.getAbsolutePath()); - // } - // - // synchronized (control) { - // // le thread principal a pu le modifier pendant le sleep - // //if (control.isRunning()) { - // // on ne lit pas le stop, car le stop ne peut-etre appeler - // // que par l'utilisateur qui est de ce cote de la machine - // SimulationStorage.readControl(controlFile, - // control, "stop"); - // //} - // } - // - // // deleteTempFile - // controlFile.delete(); - // } catch (SSHException e) { - // // file doesn't exist - // if(log.isDebugEnabled()) { - // // not add ,e plz :) - // log.debug(_("Remote control file doesn't exists %s", e.getMessage())); - // } - // } - // - // } catch (InterruptedException e) { - // if (log.isErrorEnabled()) { - // log.error("Thread has been interrupted", e); - // } - // } catch (IOException e) { - // if (log.isErrorEnabled()) { - // log.error("Error while reading control file", e); - // } - // } - // - // synchronized (control) { - // running = control.getProgressMax() == 0 || (control.getProgress() < control.getProgressMax() - 1); - // } - // } - // } - // - // - // } }
participants (1)
-
chatellierï¼ users.labs.libre-entreprise.org