Ejemplo n.º 1
0
/**
 * \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;
}
Ejemplo n.º 2
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;
}