|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectfr.ifremer.isisfish.simulator.launcher.SSHSimulatorLauncher
public class SSHSimulatorLauncher
Use a remote simulation server. Upload zip simulation file on server and launch simulation on that file. Isis-Fish must be installed on remote server. Caparmor file layout ($i = plan/as increment) :
$shortid is id of parent job (without increment), they are not
deleted after result download.
JSch| Nested Class Summary | |
|---|---|
protected static class |
SSHSimulatorLauncher.ControlProgressMonitor
Redefine a custom progress monitor that update control. |
| Field Summary | |
|---|---|
protected freemarker.template.Configuration |
freemarkerConfiguration
Freemarker configuration |
protected static org.apache.commons.logging.Log |
log
Class logger |
protected static java.lang.String |
QSUB_SCRIPT_TEMPLATE
Freemarker qsub template. |
protected static com.jcraft.jsch.Session |
sshSession
Opened session to ssh service. |
protected static com.jcraft.jsch.Session |
sshSftpSession
Opened session to sftp service. |
| Constructor Summary | |
|---|---|
SSHSimulatorLauncher()
Constructor. |
|
| Method Summary | |
|---|---|
protected void |
clearSimulationFiles(com.jcraft.jsch.Session session,
SimulationControl control)
Remove all $ISIS-TMP/simulation-$id-* files on caparmor. |
protected void |
closeSSHSession(com.jcraft.jsch.Session session)
Close ssh session. |
protected java.io.File |
downloadResultsArchive(com.jcraft.jsch.Session session,
SimulationControl simulationControl,
java.lang.String md5sum)
Download simulation zip results. |
protected java.io.File |
downloadResultsMD5File(com.jcraft.jsch.Session sshSession,
java.lang.String simulationId)
Download remote simulation md5 control file and store its content into temp file. |
protected java.io.File |
downloadSimulationFile(com.jcraft.jsch.Session sshSession,
java.lang.String simulationId,
java.lang.String fileName)
Download remote simulation control file and store its content into temp file. |
int |
getCheckProgressionInterval()
Retourne l'intervalle de temps a utiliser entre deux verification de progresssion. |
protected java.io.File |
getLaunchSimulationScriptFile(java.lang.String simuationId,
java.lang.String simulationZip,
boolean standaloneZip,
java.lang.String simulationResultZip,
java.lang.String preScriptPath,
boolean multipleSimulationScript)
Retourne un fichier temporaire contenant le script de lancement de simulation. |
protected java.lang.String |
getRemoteResultArchivePath(java.lang.String simulationId)
Get remote simulation zip path. |
protected java.lang.String |
getRemoteTempDirectory()
Get remote directory absolute path. |
protected java.lang.String |
getSimulationScriptLaunchContent(java.lang.String templateName,
java.lang.String simuationId,
java.lang.String simulationZip,
boolean standaloneZip,
java.lang.String simulationZipResult,
java.lang.String preScriptPath,
boolean multipleSimulationScript)
Utilise freemarker pour recuperer le contenu du script. |
SimulationStorage |
getSimulationStorage(SimulationService simulationService,
SimulationControl control)
Retourne le storage où est stockée la simulation. |
protected com.jcraft.jsch.Session |
getSSHSession()
Get opened ssh session or try to open a new one. |
protected void |
initFreemarker()
Init freemarker configuration. |
int |
maxSimulationThread()
Retourne le nombre maximal de thread de simulations simultanées supporté. |
protected void |
message(SimulationControl control,
java.lang.String message)
Display message both in commons-logging and control text progress. |
protected com.jcraft.jsch.Session |
openSSHSession()
Connect to remote server throw SSH, and return session. |
protected void |
putSshKeyOnRemoteServer(com.jcraft.jsch.Session session,
java.io.File sshKey)
Add ssh key into $HOME/.ssh/authorized_keys file. |
protected void |
sendStartSimulationRequest(com.jcraft.jsch.Session session,
java.lang.String simulationId,
java.lang.String scriptRemotePath,
int lastSimulationNumber)
Add script in remote qsub queue. |
protected void |
sendStopSimulationRequest(com.jcraft.jsch.Session session,
java.lang.String simulationId)
Send qdel request on job. |
void |
simulate(SimulationService simulationService,
SimulationItem simulationItem)
Execute une simulation. |
void |
simulationStopRequest(SimulationJob job)
Called if a started simulation has been ask to stop. |
protected void |
startSimulation(SimulationItem simulationItem,
java.lang.String simulationid,
java.lang.String simulationRemoteZipPath,
java.lang.String remoteResultZip,
java.lang.String simulationPreScriptPath)
Start simulation if necessary. |
java.lang.String |
toString()
|
void |
updateControl(SimulationService simulationService,
SimulationControl control)
Met à jour la progression. |
protected java.lang.String |
uploadPreScriptIfNecessary(com.jcraft.jsch.Session session,
java.lang.String simulationId,
java.lang.String simulationPreScript)
Upload pre script on remote server. |
protected void |
uploadSimulation(com.jcraft.jsch.Session session,
java.lang.String remoteDirectory,
java.lang.String remoteSimulationZipPath,
java.io.File simulationFile)
Perform simulation upload. |
protected java.lang.String |
uploadSimulationIfNecessary(com.jcraft.jsch.Session session,
SimulationItem simulationItem,
java.lang.String simulationid,
java.io.File simulationFile)
Upload simulation if necessary and always return the remote simulation zip path to use. |
protected java.lang.String |
uploadSimulationScript(com.jcraft.jsch.Session session,
java.lang.String simulationid,
java.io.File simulationScript)
Upload script on remote server. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected static org.apache.commons.logging.Log log
protected freemarker.template.Configuration freemarkerConfiguration
protected static final java.lang.String QSUB_SCRIPT_TEMPLATE
protected static com.jcraft.jsch.Session sshSession
protected static com.jcraft.jsch.Session sshSftpSession
| Constructor Detail |
|---|
public SSHSimulatorLauncher()
| Method Detail |
|---|
protected void initFreemarker()
protected void message(SimulationControl control,
java.lang.String message)
control - controlmessage - message to displaypublic int maxSimulationThread()
SimulatorLauncher
maxSimulationThread in interface SimulatorLauncherpublic int getCheckProgressionInterval()
SimulatorLauncher
getCheckProgressionInterval in interface SimulatorLauncherpublic java.lang.String toString()
toString in class java.lang.Object
public void simulationStopRequest(SimulationJob job)
throws java.rmi.RemoteException
simulationStopRequest in interface SimulatorLauncherjob - job to stop
java.rmi.RemoteException - Si pour l'execution de la simulation
on utilise des resources distantes (serveurs) et que ceux si non pas pu
etre contacte.
public void simulate(SimulationService simulationService,
SimulationItem simulationItem)
throws java.rmi.RemoteException
simulate in interface SimulatorLaunchersimulationService - le SimulationService qui a initie
la simulationsimulationItem - l'item contenant toutes les infos nécessaire au
lancement de la simulation
IMPORTANT Quoi qu'il arrive
java.rmi.RemoteException - Si pour l'execution de la simulation
on utilise des resources distantes (serveurs) et que ceux si non pas pu
etre contacte. Dans ce cas la simulation n'a pas ete faite et cette
exception est levee.
public SimulationStorage getSimulationStorage(SimulationService simulationService,
SimulationControl control)
throws java.rmi.RemoteException
updateControl(SimulationService, SimulationControl) before calling
this method.
getSimulationStorage in interface SimulatorLaunchersimulationService - le SimulationService qui a initie
la simulationcontrol - le control de la simulation
java.rmi.RemoteException - Si pour l'execution de la simulation
on utilise des resources distantes (serveurs) et que ceux si non pas pu
etre contacte.
public void updateControl(SimulationService simulationService,
SimulationControl control)
throws java.rmi.RemoteException
SimulationControl.
Essaye aussi de telecharger le fichier md5 de la simulation, et, s'il
est present, l'archive de résultat.
Supprime tous les fichiers de la simulations apres avoir télécharger les
résultats.
updateControl in interface SimulatorLaunchersimulationService - le SimulationService qui a initie
la simulationcontrol - le control de la simulation
java.rmi.RemoteException - Si pour l'execution de la simulation
on utilise des resources distantes (serveurs) et que ceux si non pas pu
etre contacte.
protected com.jcraft.jsch.Session getSSHSession()
throws com.jcraft.jsch.JSchException
com.jcraft.jsch.JSchException
protected com.jcraft.jsch.Session openSSHSession()
throws com.jcraft.jsch.JSchException
com.jcraft.jsch.JSchExceptionprotected void closeSSHSession(com.jcraft.jsch.Session session)
session - session to close
protected void putSshKeyOnRemoteServer(com.jcraft.jsch.Session session,
java.io.File sshKey)
throws com.jcraft.jsch.JSchException
session - opened sessionsshKey -
com.jcraft.jsch.JSchException
protected java.lang.String uploadSimulationIfNecessary(com.jcraft.jsch.Session session,
SimulationItem simulationItem,
java.lang.String simulationid,
java.io.File simulationFile)
throws SSHException
session - already open valid ssh sessionsimulationItem - simulation itemsimulationid - simulation idsimulationFile - simulation file to upload
SSHException - if upload fail
protected void uploadSimulation(com.jcraft.jsch.Session session,
java.lang.String remoteDirectory,
java.lang.String remoteSimulationZipPath,
java.io.File simulationFile)
throws SSHException
session - already open valid ssh sessionremoteDirectory - remoteSimulationZipPath -
SSHException
protected java.io.File downloadResultsArchive(com.jcraft.jsch.Session session,
SimulationControl simulationControl,
java.lang.String md5sum)
throws SSHException,
java.io.IOException
SSHException - if download fail (can happen if remote file doesn't exist
java.io.IOException - if download fail (can happen if remote file doesn't exist
protected java.io.File downloadSimulationFile(com.jcraft.jsch.Session sshSession,
java.lang.String simulationId,
java.lang.String fileName)
throws java.io.IOException,
SSHException
sshSession - valid opened ssh sessionsimulationId - id de la simulationfileName - nom du fichier a telecharger
java.io.IOException
SSHException - if remote file doesn't exists
protected java.io.File downloadResultsMD5File(com.jcraft.jsch.Session sshSession,
java.lang.String simulationId)
throws java.io.IOException,
SSHException
sshSession - valid opened ssh sessionsimulationId - id de la simulation
java.io.IOException
SSHException - if remote file doesn't exists
protected void clearSimulationFiles(com.jcraft.jsch.Session session,
SimulationControl control)
throws java.io.IOException,
SSHException
$ISIS-TMP/simulation-$id-* files on caparmor.
session - valid opened ssh sessioncontrol - simulation control
java.io.IOException
SSHException
protected java.lang.String uploadSimulationScript(com.jcraft.jsch.Session session,
java.lang.String simulationid,
java.io.File simulationScript)
throws SSHException
session - valid opened ssh sessionsimulationScript - file to upload
SSHException - if upload failprotected java.lang.String getRemoteResultArchivePath(java.lang.String simulationId)
simulationId - simulation id
protected java.lang.String uploadPreScriptIfNecessary(com.jcraft.jsch.Session session,
java.lang.String simulationId,
java.lang.String simulationPreScript)
throws SSHException,
java.io.IOException
session - valid opened ssh sessionsimulationId - simulation idsimulationPreScript - script content
SSHException - if upload fail
java.io.IOException - if upload fail
protected void startSimulation(SimulationItem simulationItem,
java.lang.String simulationid,
java.lang.String simulationRemoteZipPath,
java.lang.String remoteResultZip,
java.lang.String simulationPreScriptPath)
throws java.lang.Exception
simulationItem - simulation item (needed for additionnal info, simulation, number, indenpendant, etc...)simulationid - simulation idsimulationRemoteZipPath - simulation preparation (input) zip pathremoteResultZip - simulation result (output) zip pathsimulationPreScriptPath - simulation prescript
java.lang.Exception
protected java.io.File getLaunchSimulationScriptFile(java.lang.String simuationId,
java.lang.String simulationZip,
boolean standaloneZip,
java.lang.String simulationResultZip,
java.lang.String preScriptPath,
boolean multipleSimulationScript)
throws java.io.IOException
simuationId - id de la simulationsimulationZip - zip de la simulationstandaloneZip - standalone simulation zippreScriptPath - simulation pre script path (can be null)multipleSimulationScript - if true build a multijob simulation script
null en cas d'exception
java.io.IOException - if can't build script
protected java.lang.String getSimulationScriptLaunchContent(java.lang.String templateName,
java.lang.String simuationId,
java.lang.String simulationZip,
boolean standaloneZip,
java.lang.String simulationZipResult,
java.lang.String preScriptPath,
boolean multipleSimulationScript)
throws java.io.IOException
templateName - url du templatesimuationId - id de la simulationsimulationZip - zip de la simulationstandaloneZip - standalone simulation zipsimulationZipResult - zip resultat de la simulationpreScriptPath - simulation pre script path (can be null)multipleSimulationScript - if true build a multijob simulation script
java.io.IOException - if can't get script content
protected void sendStartSimulationRequest(com.jcraft.jsch.Session session,
java.lang.String simulationId,
java.lang.String scriptRemotePath,
int lastSimulationNumber)
throws SSHException
session - valid opened sessionsimulationId - simulation id (short version for a multiple job)scriptRemotePath - remote script pathlastSimulationNumber - if >=0 start a multiple pbs job form 0 to lastSimulationNumber
SSHException - if call fail
protected void sendStopSimulationRequest(com.jcraft.jsch.Session session,
java.lang.String simulationId)
throws SSHException
session - valid opened sessionsimulationId - simulation id
SSHException - if call failprotected java.lang.String getRemoteTempDirectory()
java.io.File.separator here, caparmor is always unix.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||