public class SSHSimulatorLauncher extends Object implements SimulatorLauncher
$shortid
is id of parent job (without increment), they are not
deleted after result download.JSch
Modifier and Type | Class and Description |
---|---|
protected static class |
SSHSimulatorLauncher.ControlProgressMonitor
Redefine a custom progress monitor that update control.
|
Modifier and Type | Field and Description |
---|---|
protected freemarker.template.Configuration |
freemarkerConfiguration
Freemarker configuration
|
protected static org.apache.commons.logging.Log |
log
Class logger
|
protected static 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 and Description |
---|
SSHSimulatorLauncher()
Constructor.
|
Modifier and Type | Method and Description |
---|---|
protected void |
clearSimulationFiles(com.jcraft.jsch.Session session,
SimulationControl control)
Remove all
$ISIS-TMP/simulation-$id-* files on datarmor. |
protected void |
closeSSHSession(com.jcraft.jsch.Session session)
Close ssh session.
|
protected File |
downloadResultsArchive(com.jcraft.jsch.Session session,
SimulationControl simulationControl,
String md5sum)
Download simulation zip results.
|
protected File |
downloadResultsMD5File(com.jcraft.jsch.Session sshSession,
String simulationId)
Download remote simulation md5 control file and store its content into temp
file.
|
protected File |
downloadSimulationFile(com.jcraft.jsch.Session sshSession,
String simulationId,
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 File |
getLaunchSimulationScriptFile(String simuationId,
String simulationZip,
boolean standaloneZip,
String simulationResultZip,
String preScriptPath,
boolean multipleSimulationScript)
Retourne un fichier temporaire contenant le script de lancement de
simulation.
|
protected String |
getRemoteResultArchivePath(String simulationId)
Get remote simulation zip path.
|
protected String |
getRemoteTempDirectory()
Get remote directory absolute path.
|
protected String |
getSimulationScriptLaunchContent(String templateName,
String simuationId,
String simulationZip,
boolean standaloneZip,
String simulationZipResult,
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,
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,
File sshKey)
Add ssh key into $HOME/.ssh/authorized_keys file.
|
protected void |
sendStartSimulationRequest(com.jcraft.jsch.Session session,
String simulationId,
String scriptRemotePath,
int lastSimulationNumber)
Add script in remote qsub queue.
|
protected void |
sendStopSimulationRequest(com.jcraft.jsch.Session session,
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(com.jcraft.jsch.Session session,
SimulationItem simulationItem,
String simulationid,
String simulationRemoteZipPath,
String remoteResultZip,
String simulationPreScriptPath)
Start simulation if necessary.
|
String |
toString() |
void |
updateControl(SimulationService simulationService,
SimulationControl control)
Met à jour la progression.
|
protected String |
uploadPreScriptIfNecessary(com.jcraft.jsch.Session session,
String simulationId,
String simulationPreScript)
Upload pre script on remote server.
|
protected void |
uploadSimulation(com.jcraft.jsch.Session session,
String remoteDirectory,
String remoteSimulationZipPath,
File simulationFile)
Perform simulation upload.
|
protected String |
uploadSimulationIfNecessary(com.jcraft.jsch.Session session,
SimulationItem simulationItem,
String simulationid,
File simulationFile)
Upload simulation if necessary and always return the remote
simulation zip path to use.
|
protected String |
uploadSimulationScript(com.jcraft.jsch.Session session,
String simulationid,
File simulationScript)
Upload script on remote server.
|
protected static org.apache.commons.logging.Log log
protected freemarker.template.Configuration freemarkerConfiguration
protected static final String QSUB_SCRIPT_TEMPLATE
protected static com.jcraft.jsch.Session sshSession
protected static com.jcraft.jsch.Session sshSftpSession
protected void initFreemarker()
protected void message(SimulationControl control, String message)
control
- controlmessage
- message to displaypublic int maxSimulationThread()
SimulatorLauncher
maxSimulationThread
in interface SimulatorLauncher
public int getCheckProgressionInterval()
SimulatorLauncher
getCheckProgressionInterval
in interface SimulatorLauncher
public void simulationStopRequest(SimulationJob job) throws RemoteException
simulationStopRequest
in interface SimulatorLauncher
job
- job to stopRemoteException
- 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 RemoteException
simulate
in interface SimulatorLauncher
simulationService
- le SimulationService
qui a initie
la simulationsimulationItem
- l'item contenant toutes les infos nécessaire au
lancement de la simulation
IMPORTANT Quoi qu'il arriveRemoteException
- 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 RemoteException
updateControl(SimulationService, SimulationControl)
before calling
this method.getSimulationStorage
in interface SimulatorLauncher
simulationService
- le SimulationService
qui a initie
la simulationcontrol
- le control de la simulationRemoteException
- 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 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 SimulatorLauncher
simulationService
- le SimulationService
qui a initie
la simulationcontrol
- le control de la simulationRemoteException
- 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.JSchException
protected void closeSSHSession(com.jcraft.jsch.Session session)
session
- session to closeprotected void putSshKeyOnRemoteServer(com.jcraft.jsch.Session session, File sshKey) throws com.jcraft.jsch.JSchException
session
- opened sessionsshKey
- com.jcraft.jsch.JSchException
protected String uploadSimulationIfNecessary(com.jcraft.jsch.Session session, SimulationItem simulationItem, String simulationid, File simulationFile) throws SSHException
session
- already open valid ssh sessionsimulationItem
- simulation itemsimulationid
- simulation idsimulationFile
- simulation file to uploadSSHException
- if upload failprotected void uploadSimulation(com.jcraft.jsch.Session session, String remoteDirectory, String remoteSimulationZipPath, File simulationFile) throws SSHException
session
- already open valid ssh sessionremoteDirectory
- remoteSimulationZipPath
- SSHException
protected File downloadResultsArchive(com.jcraft.jsch.Session session, SimulationControl simulationControl, String md5sum) throws SSHException, IOException
SSHException
- if download fail (can happen if remote file doesn't existIOException
- if download fail (can happen if remote file doesn't existprotected File downloadSimulationFile(com.jcraft.jsch.Session sshSession, String simulationId, String fileName) throws IOException, SSHException
sshSession
- valid opened ssh sessionsimulationId
- id de la simulationfileName
- nom du fichier a telechargerIOException
SSHException
- if remote file doesn't existsprotected File downloadResultsMD5File(com.jcraft.jsch.Session sshSession, String simulationId) throws IOException, SSHException
sshSession
- valid opened ssh sessionsimulationId
- id de la simulationIOException
SSHException
- if remote file doesn't existsprotected void clearSimulationFiles(com.jcraft.jsch.Session session, SimulationControl control) throws IOException, SSHException
$ISIS-TMP/simulation-$id-*
files on datarmor.session
- valid opened ssh sessioncontrol
- simulation controlIOException
SSHException
protected String uploadSimulationScript(com.jcraft.jsch.Session session, String simulationid, File simulationScript) throws SSHException
session
- valid opened ssh sessionsimulationScript
- file to uploadSSHException
- if upload failprotected String getRemoteResultArchivePath(String simulationId)
simulationId
- simulation idprotected String uploadPreScriptIfNecessary(com.jcraft.jsch.Session session, String simulationId, String simulationPreScript) throws SSHException, IOException
session
- valid opened ssh sessionsimulationId
- simulation idsimulationPreScript
- script contentSSHException
- if upload failIOException
- if upload failprotected void startSimulation(com.jcraft.jsch.Session session, SimulationItem simulationItem, String simulationid, String simulationRemoteZipPath, String remoteResultZip, String simulationPreScriptPath) throws Exception
session
- ssh sessionsimulationItem
- simulation item (needed for additionnal info, simulation, number, indenpendant, etc...)simulationid
- simulation idsimulationRemoteZipPath
- simulation preparation (input) zip pathremoteResultZip
- simulation result (output) zip pathsimulationPreScriptPath
- simulation prescriptException
protected File getLaunchSimulationScriptFile(String simuationId, String simulationZip, boolean standaloneZip, String simulationResultZip, String preScriptPath, boolean multipleSimulationScript) throws 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 scriptnull
en cas d'exceptionIOException
- if can't build scriptprotected String getSimulationScriptLaunchContent(String templateName, String simuationId, String simulationZip, boolean standaloneZip, String simulationZipResult, String preScriptPath, boolean multipleSimulationScript) throws 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 scriptIOException
- if can't get script contentprotected void sendStartSimulationRequest(com.jcraft.jsch.Session session, String simulationId, 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 failprotected void sendStopSimulationRequest(com.jcraft.jsch.Session session, String simulationId) throws SSHException
session
- valid opened sessionsimulationId
- simulation idSSHException
- if call failprotected String getRemoteTempDirectory()
File.separator
here, datarmor is always unix.Copyright © 1999–2020 CodeLutin. All rights reserved.