/** * \brief The submitJob function submits job on a machine through a script pointed by scriptFilePath. * \param sessionKey : The session key * \param machineId : Is the id of the machine on which the job must be submitted * \param scriptFilePath : The path to the file containing the characteristics (job command, and batch scheduler directive required or optional) of the job to submit. * \param jobInfo : The Job object containing the output information (ex: jobId and jobPath) of the job to submit * \param options : Is an instance of the class SubmitOptions. Each option is associated to a set operation (e.g: setNbCpu(...)) in the class. If no set operation is not called on the instance object options, the job is submitted with the options defined in the scriptFilePath. Otherewise the job is submitted with the optionnal values set by the options object and optionnal values defined in the scriptFilePath, but optionnal values set by SubmitOptions object take precedence over those in scriptFilePath. With in the object options or within the scriptFilePath, the last occurance of an optionnal value takes precedence over earlier occurance. * \return int : an error code */ int vishnu::submitJob(const std::string& sessionKey, const std::string& machineId, const std::string& scriptFilePath, Job& jobInfo, const SubmitOptions& options) throw (UMSVishnuException, TMSVishnuException, UserException, SystemException) { checkEmptyString(sessionKey, "The session key"); checkEmptyString(machineId, "The machine id"); //To check options value nbNodesAndCpuPerNode checkJobNbNodesAndNbCpuPerNode(options.getNbNodesAndCpuPerNode()); SessionProxy sessionProxy(sessionKey); boost::filesystem::path completePath(scriptFilePath); std::string scriptFileCompletePath = (boost::filesystem::path(boost::filesystem::system_complete(completePath))).string(); jobInfo.setJobPath(scriptFileCompletePath); std::string scriptContent = vishnu::get_file_content(scriptFilePath); JobProxy jobProxy(sessionProxy , machineId , jobInfo); ListStrings fileParamsVec; std::string fileParamsStr = options.getFileParams() ; boost::trim(fileParamsStr) ; //TODO BUG when empty list boost::split(fileParamsVec, fileParamsStr, boost::is_any_of(" "), boost::token_compress_on) ; int ret = jobProxy.submitJob(scriptContent, options); jobInfo = jobProxy.getData(); return ret; }
/** * \brief The getJobInfo function gets a specific job's information bInfo function gets information on a job from its id * \param session : The session information * \param jobId : The id of the job * \param machineId: The id of the target machine. * Could be empty, in this case the request'll be routed to the dispatcher * \param jobInfos : The resulting information on the job * \return int : an error code */ int vishnu::getJobInfo(const std::string& sessionKey, const std::string& jobId, const std::string& machineId, TMS_Data::Job& job) throw (UMSVishnuException, TMSVishnuException, UserException, SystemException) { checkEmptyString(sessionKey, "The session key"); checkEmptyString(jobId, "The job id"); JobProxy jobProxy(sessionKey); job = jobProxy.getJobInfo(jobId, machineId); return 0; }
/** * \brief The listJobs function gets a list of all submitted jobs bInfo function gets information on a job from its id * \param sessionKey : The session key * \param machineId : The id of the machine * \param jobId : The id of the job * \param jobInfos : The resulting information on the job * \return int : an error code */ int vishnu::getJobInfo(const std::string& sessionKey, const std::string& machineId, const std::string& jobId, Job& jobInfo) throw (UMSVishnuException, TMSVishnuException, UserException, SystemException) { checkEmptyString(sessionKey, "The session key"); checkEmptyString(machineId, "The machine id"); checkEmptyString(jobId, "The job id"); SessionProxy sessionProxy(sessionKey); jobInfo.setJobId(jobId); JobProxy jobProxy(sessionProxy, machineId, jobInfo); jobInfo = jobProxy.getJobInfo(); return 0; }
/** * \brief The submitJob function submits job on a machine through a script pointed by scriptFilePath. * \param sessionKey : The session key * \param scriptFilePath : The path to the file containing the characteristics (job command, and batch scheduler directive required or optional) of the job to submit. * \param jobInfo : The Job object containing the output information (ex: jobId and jobPath) of the job to submit * \param options : Is an instance of the class SubmitOptions. Each option is associated to a set operation (e.g: setNbCpu(...)) in the class. If no set operation is not called on the instance object options, the job is submitted with the options defined in the scriptFilePath. Otherewise the job is submitted with the optionnal values set by the options object and optionnal values defined in the scriptFilePath, but optionnal values set by SubmitOptions object take precedence over those in scriptFilePath. With in the object options or within the scriptFilePath, the last occurance of an optionnal value takes precedence over earlier occurance. * \return int : an error code */ int vishnu::submitJob(const std::string& sessionKey, const std::string& scriptFilePath, TMS_Data::Job& jobInfo, const TMS_Data::SubmitOptions& options) throw (UMSVishnuException, TMSVishnuException, UserException, SystemException) { // Dirty cast to modify a const object because the loadcriterion field may not be allocated -> allocating him const void *optionPtr = &options; TMS_Data::SubmitOptions* optionstmp = (TMS_Data::SubmitOptions*)optionPtr; TMS_Data::LoadCriterion_ptr loadCriterion = new TMS_Data::LoadCriterion(); checkEmptyString(sessionKey, "The session key"); checkJobNbNodesAndNbCpuPerNode(optionstmp->getNbNodesAndCpuPerNode()); // Copy the option object because API -> const and we need to allocate the loadCriterion if not if (optionstmp->getCriterion()){ loadCriterion->setLoadType(optionstmp->getCriterion()->getLoadType()); } optionstmp->setCriterion(loadCriterion); boost::filesystem::path completePath(scriptFilePath); std::string scriptFileCompletePath = (boost::filesystem::path(boost::filesystem::system_complete(completePath))).string(); JobProxy jobProxy(sessionKey, optionstmp->getMachine()); std::vector<std::string> fileParamsVec; std::string fileParamsStr = optionstmp->getFileParams() ; boost::trim(fileParamsStr) ; //TODO BUG when empty list boost::split(fileParamsVec, fileParamsStr, boost::is_any_of(" "), boost::token_compress_on) ; std::string scriptContent = vishnu::get_file_content(scriptFilePath); int ret = jobProxy.submitJob(scriptFileCompletePath, scriptContent, *optionstmp); jobInfo = jobProxy.getData(); return ret; }