fr.ifremer.isisfish.simulator.launcher
Class SimulationMonitor

java.lang.Object
  extended by java.lang.Thread
      extended by fr.ifremer.isisfish.simulator.launcher.SimulationMonitor
All Implemented Interfaces:
Runnable

public class SimulationMonitor
extends Thread

Moniteur singleton pour pouvoir sauvegarder localement la liste des simulations démarrées et permettre de continuer le monitoring au relancemenent d'Isis. Depuis la version 3.3, elle sauvegarde en plus les zip pour pouvoir relancer une simulation même si isis a été arreté entre temps. Cette classe n'implemente pas SimulationServiceListener car elle ne doit pas écouter toutes les simulations, mais seulement celle dit simple, c'est-à-dire "master plan" du plan d'analyse. Il faut bien faire attention lors du relancement des simulations a copier le zip a un autre endroit. Il est important d'avoir deux zip car celui de la sauvegarde est supprimé des que la simulation est arrete.

Since:
3.2.0.4
Version:
$Revision: 3061 $ Last update : $Date: 2010-06-17 14:02:34 +0200 (jeu., 17 juin 2010) $ By : $Author: chatellier $
Author:
chatellier

Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
 
Field Summary
protected  Timer checkScheduler
          Check scheduler.
protected  SortedSet<AbstractMap.SimpleEntry<Date,SimulationJob>> checkSet
          Map to remember when a simulation have to be checked.
protected static SimulationMonitor instance
          Instance.
protected  File monitorFolder
          Simulation information saving file.
protected static String PROPERTIES_FILE
           
protected static String PROPERTY_DATE
           
protected static String PROPERTY_LASTSIMULATION
           
protected static String PROPERTY_LAUNCHER
           
protected static String PROPERTY_STANDALONE
           
protected static String PROPERTY_ZIP
           
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
protected SimulationMonitor()
          Constructeur.
 
Method Summary
protected  void analyzeSensitivityResult(SimulationJob job, SimulationStorage simulation)
          For each finished simulation, check that all sensitivity simulation are available (in case of sensitivity simulation only).
protected  boolean checkProgression(SimulationJob job, SimulatorLauncher launcher)
          Check progression.
protected  boolean doPostSimulationOperation(SimulationJob job, SimulatorLauncher launcher)
          Operation to do after simulation end
static SimulationMonitor getInstance()
          Instance getter.
protected  int getNumberOfFinishedSimulation(String asPrefixName, int numberOfSimulation)
          Parcourt le dossier de toutes les simulation commencant par le prefix donné, et retourne le nombre de simulation terminées.
protected  List<SimulationStorage> getStorageListForSecondPass(String asPrefixName, int numberOfSimulation)
          Parcourt les dossiers et instancie les storages une fois qu'on est sur qu'on a toutes les simulations.
 void reloadConfig(SimulationService service)
          Reload config and read non simulation job into simulation service.
protected  void restartSimulation(SimulationService service, File simulationFolder, String simulationId, Properties propertiesFile)
          Restart a single simulation.
protected  void restartSimulationProgression(SimulationService service)
          Take all simulation in loaded file.
 void run()
           
 void simulationStart(SimulationJob job)
          Save simulation informations for started simulations.
 void simulationStop(SimulationJob job)
          Mark a simulation as stopped.
protected  void waitAndCheckProgression()
          Wait a little time, and check for first simulation progression, if first simulation time is reached.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

PROPERTIES_FILE

protected static final String PROPERTIES_FILE
See Also:
Constant Field Values

PROPERTY_LAUNCHER

protected static final String PROPERTY_LAUNCHER
See Also:
Constant Field Values

PROPERTY_DATE

protected static final String PROPERTY_DATE
See Also:
Constant Field Values

PROPERTY_ZIP

protected static final String PROPERTY_ZIP
See Also:
Constant Field Values

PROPERTY_STANDALONE

protected static final String PROPERTY_STANDALONE
See Also:
Constant Field Values

PROPERTY_LASTSIMULATION

protected static final String PROPERTY_LASTSIMULATION
See Also:
Constant Field Values

instance

protected static SimulationMonitor instance
Instance.


monitorFolder

protected File monitorFolder
Simulation information saving file.


checkSet

protected SortedSet<AbstractMap.SimpleEntry<Date,SimulationJob>> checkSet
Map to remember when a simulation have to be checked. Sorted on date ASC.


checkScheduler

protected Timer checkScheduler
Check scheduler.

Constructor Detail

SimulationMonitor

protected SimulationMonitor()
Constructeur.

Method Detail

getInstance

public static SimulationMonitor getInstance()
Instance getter.

Returns:
instance

reloadConfig

public void reloadConfig(SimulationService service)
Reload config and read non simulation job into simulation service.

Parameters:
service - SimulationService

restartSimulationProgression

protected void restartSimulationProgression(SimulationService service)
Take all simulation in loaded file. And add it into simulation service.


restartSimulation

protected void restartSimulation(SimulationService service,
                                 File simulationFolder,
                                 String simulationId,
                                 Properties propertiesFile)
                          throws IOException
Restart a single simulation.

Parameters:
service - simulation service
simulationFolder - simulation information folder
simulationId - simulation id
propertiesFile - simulation properties file
Throws:
IOException

simulationStart

public void simulationStart(SimulationJob job)
Save simulation informations for started simulations.

Parameters:
job - started job

simulationStop

public void simulationStop(SimulationJob job)
Mark a simulation as stopped. Remove it from save file.

Parameters:
job - job that control the simulation

run

public void run()
Specified by:
run in interface Runnable
Overrides:
run in class Thread

waitAndCheckProgression

protected void waitAndCheckProgression()
Wait a little time, and check for first simulation progression, if first simulation time is reached.


checkProgression

protected boolean checkProgression(SimulationJob job,
                                   SimulatorLauncher launcher)
Check progression.

Parameters:
job - job to check progression
launcher - SimulatorLauncher that manage simulation
Returns:
true is simulation is finished, false otherwise

doPostSimulationOperation

protected boolean doPostSimulationOperation(SimulationJob job,
                                            SimulatorLauncher launcher)
Operation to do after simulation end. - get simulation result - do result export

Parameters:
job - job
launcher - SimulatorLauncher that manage simulation
Returns:
true if post operation complete and job has be removed from queue

analyzeSensitivityResult

protected void analyzeSensitivityResult(SimulationJob job,
                                        SimulationStorage simulation)
For each finished simulation, check that all sensitivity simulation are available (in case of sensitivity simulation only).

Parameters:
job - job
simulation - simulation

getNumberOfFinishedSimulation

protected int getNumberOfFinishedSimulation(String asPrefixName,
                                            int numberOfSimulation)
Parcourt le dossier de toutes les simulation commencant par le prefix donné, et retourne le nombre de simulation terminées.

Parameters:
asPrefixName - simulation name (without number suffix)
numberOfSimulation - total simulation number
Returns:
le nombre de simulation réellement terminée

getStorageListForSecondPass

protected List<SimulationStorage> getStorageListForSecondPass(String asPrefixName,
                                                              int numberOfSimulation)
Parcourt les dossiers et instancie les storages une fois qu'on est sur qu'on a toutes les simulations.

Parameters:
asPrefixName - simulation name (without number suffix)
numberOfSimulation - total simulation number
Returns:
la liste des storages


Copyright © 1999-2010 CodeLutin. All Rights Reserved.