r2139 - in isis-fish/trunk/src/main/java/fr/ifremer/isisfish: . simulator/launcher
Author: chatellier Date: 2009-04-23 15:27:52 +0000 (Thu, 23 Apr 2009) New Revision: 2139 Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/IsisConfig.java isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/launcher/InProcessSimulatorLauncher.java isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/launcher/IsisFishServerSimulationLauncher.java isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/launcher/SSHSimulatorLauncher.java isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/launcher/SimulationMonitor.java isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/launcher/SimulatorLauncher.java isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/launcher/SubProcessSimulationLauncher.java Log: Comment previous commit. Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/IsisConfig.java =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/IsisConfig.java 2009-04-23 14:08:36 UTC (rev 2138) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/IsisConfig.java 2009-04-23 15:27:52 UTC (rev 2139) @@ -364,10 +364,15 @@ } /** - * TODO comment + * Retourne le nombre simultané de simulations authorisées sur + * caparmor. + * + * Utilisé pour l'envoie des simulations. + * + * @return le nombre de simulations authorisé */ public int getSimulatorSshMaxSimulteaneousSimulation() { - int result = getOptionAsInt(Option.SIMULATOR_SSH_MAX_SIMULTEANEOUS_SIMULATION.key); + int result = getOptionAsInt(Option.SIMULATOR_SSH_MAX_SIMULTANEOUS_SIMULATION.key); return result; } @@ -661,7 +666,10 @@ }; - log.info("Check configuration change"); + if (log.isInfoEnabled()) { + log.info("Check configuration change"); + } + for(int i=0; i<keys.length;) { String oldKey = keys[i++]; String newKey = keys[i++]; @@ -679,7 +687,9 @@ } if (mustSave) { saveForUser(); - log.info("Config file migration done"); + if (log.isInfoEnabled()) { + log.info("Config file migration done"); + } } if (log.isDebugEnabled()) { printConfig(); @@ -736,7 +746,7 @@ /** Serveur accessible par SSH : interval de check du fichier de control */ SIMULATOR_SSH_CONTROLCHECKINTERVAL("simulation.ssh.control.check.interval", _("isisfish.config.main.simulation.ssh.control.check.interval.description"), "5"), /** Serveur accessible par SSH : nombre de simulations simultanées sur caparmor */ - SIMULATOR_SSH_MAX_SIMULTEANEOUS_SIMULATION("simulation.ssh.max.simultaneous.simulation", _("isisfish.config.main.simulation.max.simultaneous.simulation.description"), "20"), + SIMULATOR_SSH_MAX_SIMULTANEOUS_SIMULATION("simulation.ssh.max.simultaneous.simulation", _("isisfish.config.main.simulation.max.simultaneous.simulation.description"), "20"), LOCALE("locale", _("isisfish.config.main.locale.description"), "fr_FR"), // REGION_MAP("regionMap", _("isisfish.config.main.regionMap.description"), "maps"), Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/launcher/InProcessSimulatorLauncher.java =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/launcher/InProcessSimulatorLauncher.java 2009-04-23 14:08:36 UTC (rev 2138) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/launcher/InProcessSimulatorLauncher.java 2009-04-23 15:27:52 UTC (rev 2139) @@ -527,22 +527,24 @@ } } - /* - * @see fr.ifremer.isisfish.simulator.launcher.SimulatorLauncher#simulationEnded() + /** + * {@inheritDoc} + * + * Do nothing (no restriction on inprocess launcher). */ @Override public void simulationEnded() { - // TODO Auto-generated method stub - + } - /* - * @see fr.ifremer.isisfish.simulator.launcher.SimulatorLauncher#simulationStarted() + /** + * {@inheritDoc} + * + * Do nothing (no restriction on inprocess launcher). */ @Override public void simulationStarted() { - // TODO Auto-generated method stub - + } } Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/launcher/IsisFishServerSimulationLauncher.java =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/launcher/IsisFishServerSimulationLauncher.java 2009-04-23 14:08:36 UTC (rev 2138) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/launcher/IsisFishServerSimulationLauncher.java 2009-04-23 15:27:52 UTC (rev 2139) @@ -233,7 +233,6 @@ public SimulationStorage getSimulationStorage( SimulationService simulationService, SimulationControl control) throws RemoteException { - // TODO Auto-generated method stub return null; } @@ -243,25 +242,26 @@ @Override public void updateControl(SimulationService simulationService, SimulationControl control) throws RemoteException { - // TODO Auto-generated method stub } - /* - * @see fr.ifremer.isisfish.simulator.launcher.SimulatorLauncher#simulationEnded() + /** + * {@inheritDoc} + * + * Do nothing (no restriction on xml rpc launcher). */ @Override public void simulationEnded() { - // TODO Auto-generated method stub - + } - /* - * @see fr.ifremer.isisfish.simulator.launcher.SimulatorLauncher#simulationStarted() + /** + * {@inheritDoc} + * + * Do nothing (no restriction on xml rpc launcher). */ @Override public void simulationStarted() { - // TODO Auto-generated method stub - + } } 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-04-23 14:08:36 UTC (rev 2138) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/launcher/SSHSimulatorLauncher.java 2009-04-23 15:27:52 UTC (rev 2139) @@ -82,8 +82,6 @@ protected static final String QSUB_SCRIPT_TEMPLATE = "templates/ssh/launch-isis-qsub.seq"; //protected static final String QSUB_SCRIPT_TEMPLATE = "templates/ssh/launch-isis-cron.seq"; - protected static Semaphore semaphore = new Semaphore(IsisFish.config.getSimulatorSshMaxSimulteaneousSimulation()); - /** * Opened session. Stored in static context to not reask passphrase at each * connection. @@ -91,6 +89,12 @@ protected static Session sshSession; /** + * Semaphore used to upload only 20 (default) simulations at a time. + */ + protected static Semaphore semaphore = new Semaphore(IsisFish.config + .getSimulatorSshMaxSimulteaneousSimulation()); + + /** * Constructor. * * Init freemarker. @@ -99,29 +103,7 @@ initFreemarker(); } - /** - * @return the semaphore - */ - public static Semaphore getSemaphore() { - return semaphore; - } - - public void simulationStarted() { - try { - semaphore.acquire(); - } catch (InterruptedException e) { - if (log.isErrorEnabled()) { - log.error("Semaphore aquiere has been interrupted", e); - } - } - } - - public void simulationEnded() { - semaphore.release(); - } - - /** * Init freemarker configuration. */ protected void initFreemarker() { @@ -195,6 +177,34 @@ /** * {@inheritDoc} * + * Use semaphore to limit simultaneous simulation number on caparmor. + * + * @see Semaphore + */ + @Override + public void simulationStarted() { + try { + semaphore.acquire(); + } catch (InterruptedException e) { + if (log.isErrorEnabled()) { + log.error("Semaphore aquiere has been interrupted", e); + } + } + } + + /** + * {@inheritDoc} + * + * Release one resource onr semaphore. + */ + @Override + public void simulationEnded() { + semaphore.release(); + } + + /** + * {@inheritDoc} + * * Dans le cas de ssh: - upload la simulation - construit le script pour * qsub - upload le script qsub - ajoute le script a qsub * @@ -206,6 +216,7 @@ String simulationPrescript) throws RemoteException { // ask for available resources on caparmor + // bloquin until available simulationStarted(); // start ssh session @@ -243,7 +254,7 @@ /** * {@inheritDoc} * - * Se connecte au serveur distance et tétécharge les résultats de la + * Se connecte au serveur distant et télécharge les résultats de la * simulation. */ @Override @@ -273,7 +284,7 @@ /** * {@inheritDoc} * - * Se connecte au serveur distance et télécharge le fichier de control. + * Se connecte au serveur distant et télécharge le fichier de control. * Injecte ensuite ce fichier dans le {@link SimulationControl}. */ @Override @@ -455,8 +466,7 @@ * * Just connect and do an "echo xx >> .ssh/authorized_keys" * - * @param session - * opened session + * @param session opened session * @param sshKey * @throws JSchException */ @@ -469,8 +479,10 @@ // command to : // - make ssh directory // - add key to authorized_keys - String command = "if [ ! -d .ssh ] ; then mkdir .ssh; fi ; echo \"%s\" >> .ssh/authorized_keys"; + // tested on bash/csh + String command = "test -d .ssh||mkdir .ssh;echo \"%s\" >> .ssh/authorized_keys"; + try { // use usefull readLines from commons-io @SuppressWarnings("unchecked") @@ -491,16 +503,12 @@ } } catch (IOException e) { if (log.isErrorEnabled()) { - log - .error( - _("Error while uploading public key to remote serveur authorized_keys"), + log.error(_("Error while uploading public key to remote serveur authorized_keys"), e); } } catch (SSHException e) { if (log.isErrorEnabled()) { - log - .error( - _("Error while uploading public key to remote serveur authorized_keys"), + log.error(_("Error while uploading public key to remote serveur authorized_keys"), e); } } @@ -509,14 +517,11 @@ /** * Upload simulation file to server. * - * @param session - * already open valid ssh session - * @param simulationFile - * simulation file to upload + * @param session already open valid ssh session + * @param simulationFile simulation file to upload * * @return remote file path or <tt>null</tt> if errors - * @throws SSHException - * if upload fail + * @throws SSHException if upload fail */ protected String uploadSimulation(Session session, File simulationFile) throws SSHException { @@ -526,12 +531,10 @@ // first check that remote directory exists String remotePath = IsisFish.config.getSimulatorSshTmpPath(); - // FIXME This is a workaround to make the simulations work on caparmor - // FIXME We need to find a way to make it work the old way. - - String command = "test -d \"" + remotePath + "\"||mkdir \"" + remotePath + "\""; - //String command = "if ( ! -d \"" + remotePath + "\" ) mkdir \"" - // + remotePath + "\""; + // following command work on bash and csh + String command = "test -d \"" + remotePath + "\"||mkdir \"" + + remotePath + "\""; + if (log.isInfoEnabled()) { log.info("Creating remote temp directory (if not exists) " + remotePath); @@ -610,14 +613,11 @@ * Download remote simulation control file and store its content into temp * file. * - * @param simulationId - * id de la simulation - * @param fileName - * nom du fichier a telecharger + * @param simulationId id de la simulation + * @param fileName nom du fichier a telecharger * @return downloaded temp file (file have to be manually deleted) * @throws IOException - * @throws SSHException - * if remote file doesn't exists + * @throws SSHException if remote file doesn't exists */ protected File downloadSimulationFile(String simulationId, String fileName) throws IOException, SSHException { @@ -647,13 +647,10 @@ /** * Upload script on remote server. * - * @param session - * valid opened ssh session - * @param simulationScript - * file to upload + * @param session valid opened ssh session + * @param simulationScript file to upload * - * @throws SSHException - * if upload fail + * @throws SSHException if upload fail */ protected String uploadSimulationScript(Session session, File simulationScript) throws SSHException { @@ -687,15 +684,11 @@ * * Return path if uploaded or null if no upload needed. * - * @param session - * valid opened ssh session - * @param simulationPreScript - * script content + * @param session valid opened ssh session + * @param simulationPreScript script content * - * @throws SSHException - * if upload fail - * @throws IOException - * if upload fail + * @throws SSHException if upload fail + * @throws IOException if upload fail */ protected String uploadPreScriptIfNecessary(Session session, String simulationId, String simulationPreScript) @@ -739,17 +732,13 @@ * * Le fichier temporaire est configuré pour se supprimer tout seul. * - * @param simuationId - * id de la simulation - * @param simulationZip - * zip de la simulation - * @param preScriptPath - * simulation pre script path (can be null) + * @param simuationId id de la simulation + * @param simulationZip zip de la simulation + * @param preScriptPath simulation pre script path (can be null) * * @return un Fichier temporaire ou <tt>null</tt> en cas d'exception * - * @throws IOException - * if can't build script + * @throws IOException if can't build script */ protected File getSimulationScriptFile(String simuationId, String simulationZip, String preScriptPath) throws IOException { @@ -769,17 +758,12 @@ * * Remplace aussi la variable $simulation du template. * - * @param templateName - * url du template - * @param simuationId - * id de la simulation - * @param simulationZip - * zip de la simulation - * @param preScriptPath - * simulation pre script path (can be null) + * @param templateName url du template + * @param simuationId id de la simulation + * @param simulationZip zip de la simulation + * @param preScriptPath simulation pre script path (can be null) * - * @throws IOException - * if can't get script content + * @throws IOException if can't get script content */ protected String getSimulationScriptLaunchContent(String templateName, String simuationId, String simulationZip, String preScriptPath) @@ -825,13 +809,10 @@ /** * Add script in remote qsub queue. * - * @param session - * valid opened session - * @param scriptRemotePath - * remote script path + * @param session valid opened session + * @param scriptRemotePath remote script path * - * @throws SSHException - * if call fail + * @throws SSHException if call fail */ protected void addScriptToQsubQueue(Session session, String scriptRemotePath) throws SSHException { Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/launcher/SimulationMonitor.java =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/launcher/SimulationMonitor.java 2009-04-23 14:08:36 UTC (rev 2138) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/launcher/SimulationMonitor.java 2009-04-23 15:27:52 UTC (rev 2139) @@ -453,7 +453,7 @@ SimulationService service = SimulationService.getService(); SimulationControl control = job.getItem().getControl(); - // TODO comment + // Release one available resource on launcher launcher.simulationEnded(); if (log.isInfoEnabled()) { Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/launcher/SimulatorLauncher.java =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/launcher/SimulatorLauncher.java 2009-04-23 14:08:36 UTC (rev 2138) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/launcher/SimulatorLauncher.java 2009-04-23 15:27:52 UTC (rev 2139) @@ -107,7 +107,17 @@ SimulationControl control) throws RemoteException; + /** + * Call it before starting a simulation. + * + * This call is bloquing until available resources. + */ public void simulationStarted(); + /** + * Call it after simulation end. + * + * Release one resources. + */ public void simulationEnded(); } Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/launcher/SubProcessSimulationLauncher.java =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/launcher/SubProcessSimulationLauncher.java 2009-04-23 14:08:36 UTC (rev 2138) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/launcher/SubProcessSimulationLauncher.java 2009-04-23 15:27:52 UTC (rev 2139) @@ -309,21 +309,23 @@ } - /* - * @see fr.ifremer.isisfish.simulator.launcher.SimulatorLauncher#simulationEnded() + /** + * {@inheritDoc} + * + * Do nothing (no restriction on subprocess launcher). */ @Override public void simulationEnded() { - // TODO Auto-generated method stub - + } - /* - * @see fr.ifremer.isisfish.simulator.launcher.SimulatorLauncher#simulationStarted() + /** + * {@inheritDoc} + * + * Do nothing (no restriction on subprocess launcher). */ @Override public void simulationStarted() { - // TODO Auto-generated method stub - + } }
participants (1)
-
chatellier@users.labs.libre-entreprise.org