this case, default value of the selected resource will be used.
*/
string maximum_during_time;
- MachineParameters resource_required;
+
// Memory is expressed in megabytes -> mem_mb
// Number of Processors -> nb_node
+ MachineParameters resource_required;
+
+ /*!
+ Name of the batch queue choosed - optional
+ */
+ string queue;
};
/*! \brief Interface of the %salomelauncher
Batch::CommunicationProtocolType protocol;
Batch::FactBatchManager_eClient* fact;
+ int nb_proc_per_node = params.DataForSort._nbOfProcPerNode;
+
hostname = params.Alias;
switch(params.Protocol){
case rsh:
#endif
throw LauncherException("no batchmanager for that cluster");
}
- return (*fact)(hostname.c_str(), protocol, mpi.c_str());
+ return (*fact)(hostname.c_str(), protocol, mpi.c_str(), nb_proc_per_node);
#else
throw LauncherException("Method Launcher_cpp::FactoryBatchManager is not available "
"(libBatch was not present at compilation time)");
_machine_required_params.mem_mb = -1;
_machine_required_params.parallelLib = "";
_machine_required_params.nb_component_nodes = -1;
+ _queue = "";
#ifdef WITH_LIBBATCH
_batch_job = new Batch::Job();
_machine_required_params = machine_required_params;
}
+void
+Launcher::Job::setQueue(const std::string & queue)
+{
+ _queue = queue;
+}
+
std::string
Launcher::Job::getWorkDirectory()
{
return _machine_required_params;
}
+std::string
+Launcher::Job::getQueue()
+{
+ return _queue;
+}
+
void
Launcher::Job::checkMaximumDuringTime(const std::string & maximum_during_time)
{
return ret;
}
+std::string
+Launcher::Job::getLaunchDate()
+{
+ time_t rawtime;
+ time(&rawtime);
+ std::string launch_date = ctime(&rawtime);
+ int i = 0 ;
+ for (;i < launch_date.size(); i++)
+ if (launch_date[i] == '/' or
+ launch_date[i] == '-' or
+ launch_date[i] == ':' or
+ launch_date[i] == ' ')
+ launch_date[i] = '_';
+ launch_date.erase(--launch_date.end()); // Last caracter is a \n
+
+ return launch_date;
+}
+
std::string
Launcher::Job::updateJobState()
{
if (_maximum_during_time_in_second != -1)
params[MAXWALLTIME] = _maximum_during_time_in_second;
+ // Queue
+ if (_queue != "")
+ params[QUEUE] = _queue;
+
return params;
}
#include "ResourcesManager.hxx"
#include <stdlib.h>
+#include <time.h>
+#include <sys/stat.h>
#include <string>
#include <list>
void add_out_file(const std::string & file);
void setMaximumDuringTime(const std::string & maximum_during_time);
void setMachineRequiredParams(const machineParams & machine_required_params);
+ void setQueue(const std::string & queue);
std::string getWorkDirectory();
std::string getLocalDirectory();
const std::list<std::string> & get_out_files();
std::string getMaximumDuringTime();
machineParams getMachineRequiredParams();
+ std::string getQueue();
std::string updateJobState();
// Helps
long convertMaximumDuringTime(const std::string & maximum_during_time);
+ std::string getLaunchDate();
// Abstract class
virtual void update_job() = 0;
std::string _maximum_during_time;
long _maximum_during_time_in_second;
machineParams _machine_required_params;
+ std::string _queue;
#ifdef WITH_LIBBATCH
// Connection with LIBBATCH
}
// log
- std::string log_file = "command.log";
+ std::string launch_date = getLaunchDate();
+ std::string log_file = "command_" + launch_date + ".log";
std::string log_local_file = _result_directory + "/" + log_file;
std::string log_remote_file = _work_directory + "/" + log_file;
params[OUTFILE] += Batch::Couple(log_local_file, log_remote_file);
- params[EXECUTABLE] = buildCommandScript(params);
+ params[EXECUTABLE] = buildCommandScript(params, launch_date);
_batch_job->setParametre(params);
#endif
}
#ifdef WITH_LIBBATCH
std::string
-Launcher::Job_Command::buildCommandScript(Batch::Parametre params)
+Launcher::Job_Command::buildCommandScript(Batch::Parametre params, std::string launch_date)
{
// parameters
std::string work_directory = params[WORKDIR].str();
std::string command_name = _command.substr(p1+1,p2-p1-1);
std::string command_file_name = _command.substr(p1+1);
- time_t rawtime;
- time(&rawtime);
- std::string launch_date = ctime(&rawtime);
- int i = 0 ;
- for (;i < launch_date.size(); i++)
- if (launch_date[i] == '/' or
- launch_date[i] == '-' or
- launch_date[i] == ':' or
- launch_date[i] == ' ')
- launch_date[i] = '_';
- launch_date.erase(--launch_date.end()); // Last caracter is a \n
-
std::string launch_date_port_file = launch_date;
std::string launch_script = "/tmp/runCommand_" + command_name + "_" + launch_date + ".sh";
std::ofstream launch_script_stream;
std::string::size_type last = _env_file.find_last_of("/");
launch_script_stream << "source " << _env_file.substr(last+1) << std::endl;
}
- launch_script_stream << "./" << command_file_name << " > command.log 2>&1" << std::endl;
+ launch_script_stream << "./" << command_file_name << " > command_" << launch_date << ".log 2>&1" << std::endl;
// Return
launch_script_stream.flush();
#ifdef WITH_LIBBATCH
protected:
- std::string buildCommandScript(Batch::Parametre params);
+ std::string buildCommandScript(Batch::Parametre params, std::string launch_date);
#endif
private:
#include "Launcher_Job_YACSFile.hxx"
-#include <time.h>
-#include <sys/stat.h>
Launcher::Job_YACSFile::Job_YACSFile(const std::string & yacs_file)
{
std::string::size_type p1 = _yacs_file.find_last_of("/");
std::string::size_type p2 = _yacs_file.find_last_of(".");
std::string yacs_file_name = _yacs_file.substr(p1+1,p2-p1-1);
-
- time_t rawtime;
- time(&rawtime);
- std::string launch_date = ctime(&rawtime);
- int i = 0 ;
- for (;i < launch_date.size(); i++)
- if (launch_date[i] == '/' or
- launch_date[i] == '-' or
- launch_date[i] == ':' or
- launch_date[i] == ' ')
- launch_date[i] = '_';
- launch_date.erase(--launch_date.end()); // Last caracter is a \n
+ std::string launch_date = getLaunchDate();
std::string launch_date_port_file = launch_date;
std::string launch_script = "/tmp/runSalome_" + yacs_file_name + "_" + launch_date + ".sh";
launch_script_stream << "export SALOME_TMP_DIR=" << work_directory << "/logs" << std::endl;
// -- Generates Catalog Resources
- // TODO
+ std::string machine_protocol = "ssh";
+ if (_machine_definition.Protocol == rsh)
+ machine_protocol = "rsh";
+ launch_script_stream << "CATALOG_FILE=" << work_directory << "/CatalogResources_" << launch_date << ".xml" << std::endl;
+ launch_script_stream << "export USER_CATALOG_RESOURCES_FILE=" << "$CATALOG_FILE" << std::endl;
+
+ launch_script_stream << "echo '<!DOCTYPE ResourcesCatalog>' > $CATALOG_FILE" << std::endl;
+ launch_script_stream << "echo '<resources>' >> $CATALOG_FILE" << std::endl;
+ launch_script_stream << "cat $LIBBATCH_NODEFILE | sort -u | while read host" << std::endl;
+ launch_script_stream << "do" << std::endl;
+ launch_script_stream << "echo '<machine hostname='\\\"$host\\\" >> $CATALOG_FILE" << std::endl;
+ launch_script_stream << "echo ' protocol=\"" << machine_protocol << "\"' >> $CATALOG_FILE" << std::endl;
+ launch_script_stream << "echo ' userName=\"" << _machine_definition.UserName << "\"' >> $CATALOG_FILE" << std::endl;
+ launch_script_stream << "echo ' appliPath=\"" << _machine_definition.AppliPath << "\"' >> $CATALOG_FILE" << std::endl;
+ launch_script_stream << "echo '/>' >> $CATALOG_FILE" << std::endl;
+ launch_script_stream << "done" << std::endl;
+ launch_script_stream << "echo '</resources>' >> $CATALOG_FILE" << std::endl;
// Launch SALOME with an appli
- launch_script_stream << _machine_definition.AppliPath << "/runAppli --terminal --ns-port-log=" << launch_date_port_file << " > logs/salome.log 2>&1" << std::endl;
+ launch_script_stream << _machine_definition.AppliPath << "/runAppli --terminal --ns-port-log=" << launch_date_port_file << " > logs/salome_" << launch_date << ".log 2>&1" << std::endl;
launch_script_stream << "current=0\n"
<< "stop=20\n"
<< "while ! test -f " << _machine_definition.AppliPath << "/" << launch_date_port_file << "\n"
<< " fi\n"
<< "done\n"
<< "port=`cat " << _machine_definition.AppliPath << "/" << launch_date_port_file << "`\n";
- launch_script_stream << _machine_definition.AppliPath << "/runSession driver " << yacs_file_name << ".xml > logs/yacs.log 2>&1" << std::endl;
+ launch_script_stream << _machine_definition.AppliPath << "/runSession driver " << yacs_file_name << ".xml > logs/yacs_" << launch_date << ".log 2>&1" << std::endl;
launch_script_stream << _machine_definition.AppliPath << "/runSession killSalomeWithPort.py $port" << std::endl;
// Return
INFOS(ex.msg.c_str());
THROW_SALOME_CORBA_EXCEPTION(ex.msg.c_str(),SALOME::INTERNAL_ERROR);
}
+
+ // Queue
+ std::string queue = job_parameters.queue.in();
+ if (queue != "")
+ new_job->setQueue(queue);
// Resources requirements
try