_salome_launcher_id = -1;
_dump_yacs_state = 0;
_ll_jobtype = "";
+
+ // Parameters for COORM
+ _batch_params.launcher_file = "";
+ _batch_params.launcher_args = "";
}
BL::Job::Job(const std::string & name)
_salome_launcher_id = -1;
_dump_yacs_state = 0;
_ll_jobtype = "";
+
+ // Parameters for COORM
+ _batch_params.launcher_file = "";
+ _batch_params.launcher_args = "";
}
BL::Job::~Job()
_batch_params.maximum_duration = param.maximum_duration;
_batch_params.expected_memory = param.expected_memory;
_batch_params.nb_proc = param.nb_proc;
+
+ // Parameters for COORM
+ _batch_params.launcher_file = param.launcher_file;
+ _batch_params.launcher_args = param.launcher_args;
}
BL::Job::BatchParam &
std::string maximum_duration;
std::string expected_memory;
int nb_proc;
+
+ // Parameters for COORM
+ std::string launcher_file;
+ std::string launcher_args;
};
void setBatchParameters(BL::Job::BatchParam & param);
BL::Job::BatchParam & getBatchParameters();
else if (result_job != "")
{
if (object->_observer)
+ {
object->_observer->sendEvent("refresh_job", "Ok", job->getName(), result_job);
+
+ // get assigned hostnames when the job will start
+ if (result_job == "RUNNING")
+ {
+ std::string assigned_hostnames = object->_salome_services->get_assigned_hostnames(job);
+ if (assigned_hostnames != "")
+ {
+ // sent event "get_assigned_hostnames"
+ object->_observer->sendEvent("get_assigned_hostnames", "Ok", job->getName(), assigned_hostnames);
+ }
+ }
+ }
}
}
}
memory = memory * 1024;
job_parameters->resource_required.mem_mb = memory;
+ // Parameters for COORM
+ job_parameters->launcher_file = CORBA::string_dup(cpp_batch_params.launcher_file.c_str());
+ job_parameters->launcher_args = CORBA::string_dup(cpp_batch_params.launcher_args.c_str());
+
// Create Job
try
{
return ret;
}
+// Get names or ids of hosts assigned to the job
+std::string
+BL::SALOMEServices::get_assigned_hostnames(BL::Job * job)
+{
+ std::string ret = "";
+
+ try
+ {
+ CORBA::String_var result = _salome_launcher->getAssignedHostnames(job->getSalomeLauncherId());
+ ret = result.in();
+ }
+ catch (const SALOME::SALOME_Exception & ex)
+ {
+ DEBMSG("SALOME Exception in get_assigned_hostnames !");
+ ret = ex.details.text.in();
+ }
+ catch (const CORBA::SystemException& ex)
+ {
+ DEBMSG("Receive SALOME System Exception: " << ex);
+ DEBMSG("Check SALOME servers...");
+ ret = "SALOME System Exception - see logs";
+ }
+ return ret;
+}
+
std::string
BL::SALOMEServices::save_jobs(const std::string & file_name)
{
std::ostringstream mem_stream;
mem_stream << job_parameters->resource_required.mem_mb << "mb";
batch_param.expected_memory = mem_stream.str();
+
+ // Parameters for COORM
+ batch_param.launcher_file = job_parameters->launcher_file.in();
+ batch_param.launcher_args = job_parameters->launcher_args.in();
+
job_return->setBatchParameters(batch_param);
job_return->setResource(job_parameters->resource_required.name.in());
std::string delete_job(BL::Job * job);
std::string stop_job(BL::Job * job);
std::string get_results_job(BL::Job * job);
+ std::string get_assigned_hostnames(BL::Job * job); // Get names or ids of hosts assigned to the job
BL::Job * get_new_job(int job_number);
python_salome_file = "";
env_file = "";
batch_directory = "";
+
+ // For COORM
+ coorm_batch_directory = "";
+
maximum_duration = "";
expected_memory = "";
nb_proc = 1;
+ // Parameters for COORM
+ launcher_file = "";
+ launcher_args = "";
+
result_directory = "";
resource_choosed = "";
setPage(Page_JobName, _job_name_page);
setPage(Page_BatchParameters, new BL::BatchParametersPage(this, salome_services));
+
+ // For COORM
+ setPage(Page_COORM_BatchParameters, new BL::COORM_BatchParametersPage(this, salome_services));
+
setPage(Page_Files, new BL::FilesPage(this));
setPage(Page_Resource, new BL::ResourcePage(this, salome_services));
setPage(Page_Conclusion, new BL::ConclusionPage(this));
setField("env_PythonSalome_file", QString(job->getEnvFile().c_str()));
}
+
+ // For COORM
BL::Job::BatchParam batch_params = job->getBatchParameters();
- setField("batch_directory", QString(batch_params.batch_directory.c_str()));
+ BL::ResourceDescr resource_descr = _salome_services->getResourceDescr(job->getResource().c_str());
+ std::string batch = resource_descr.batch.c_str();
+ if (batch == "coorm")
+ {
+ setField("coorm_batch_directory", QString(batch_params.batch_directory.c_str()));
+ setField("launcher_file", QString(batch_params.launcher_file.c_str()));
+ setField("launcher_args", QString(batch_params.launcher_args.c_str()));
+ }
+ else
+ {
+ setField("batch_directory", QString(batch_params.batch_directory.c_str()));
+ }
+
QString proc_value;
proc_value.setNum(batch_params.nb_proc);
setField("proc_value", proc_value);
QString f_batch_directory = field("batch_directory").toString();
batch_directory = f_batch_directory.toStdString();
+ // For COORM
+ QString f_coorm_batch_directory = field("coorm_batch_directory").toString();
+ coorm_batch_directory = f_coorm_batch_directory.toStdString();
+
+ // For COORM
+ QString f_launcher_file = field("launcher_file").toString();
+ launcher_file = f_launcher_file.toStdString();
+ QString f_launcher_args = field("launcher_args").toString();
+ launcher_args = f_launcher_args.toStdString();
+
QString time_hour;
QString time_min;
if(field("duration_hour").toInt() == 0 && field("duration_min").toInt() == 0)
return BL::CreateJobWizard::Page_Files;
}
+BL::COORM_BatchParametersPage::COORM_BatchParametersPage(QWidget * parent, BL::SALOMEServices * salome_services)
+: QWizardPage(parent)
+{
+ setTitle("Enter COORM Parameters");
+ resource_choosed = "";
+
+ _salome_services = salome_services;
+
+ QLabel *label = new QLabel("In this step you define the parameters for COORM");
+ label->setWordWrap(true);
+ QVBoxLayout * main_layout = new QVBoxLayout;
+ main_layout->addWidget(label);
+
+ // coorm_batch_directory
+ QLabel * label_directory = new QLabel("Remote work directory: ");
+ QLineEdit * line_directory = new QLineEdit(this);
+ registerField("coorm_batch_directory", line_directory);
+
+ // launcher_file
+ QPushButton * launcher_file_button = new QPushButton(tr("Choose a launcher file"));
+ connect(launcher_file_button, SIGNAL(clicked()), this, SLOT(choose_launcher_file()));
+ _launcher_file_text = new QLineEdit(this);
+ _launcher_file_text->setText("");
+ registerField("launcher_file", _launcher_file_text);
+ _launcher_file_text->setReadOnly(true);
+
+ // launcher_args
+ QLabel * launcher_args_label = new QLabel("Launcher args:");
+ QLineEdit * launcher_args_text = new QLineEdit(this);
+ registerField("launcher_args", launcher_args_text);
+
+ QGridLayout * layout = new QGridLayout;
+ layout->addWidget(label_directory, 0, 0);
+ layout->addWidget(line_directory, 0, 1);
+ layout->addWidget(launcher_file_button, 1, 0);
+ layout->addWidget(_launcher_file_text, 1, 1);
+ layout->addWidget(launcher_args_label, 2, 0);
+ layout->addWidget(launcher_args_text, 2, 1);
+
+ main_layout->insertLayout(-1, layout);
+
+ setLayout(main_layout);
+};
+
+BL::COORM_BatchParametersPage::~COORM_BatchParametersPage()
+{}
+
+bool
+BL::COORM_BatchParametersPage::validatePage()
+{
+ QString coorm_batch_directory = field("coorm_batch_directory").toString();
+ if (coorm_batch_directory == "")
+ {
+ QMessageBox::warning(NULL, "Batch Directory Error", "Please enter a batch directory");
+ return false;
+ }
+
+ QString launcher_file = field("launcher_file").toString();
+ if (launcher_file == "")
+ {
+ QMessageBox::warning(NULL, "Launcher File Error", "Please enter a launcher file");
+ return false;
+ }
+
+ return true;
+}
+
+int
+BL::COORM_BatchParametersPage::nextId() const
+{
+ return BL::CreateJobWizard::Page_Files;
+}
+
+void
+BL::COORM_BatchParametersPage::choose_launcher_file()
+{
+ QString launcher_file = QFileDialog::getOpenFileName(this,
+ tr("Open launcher files"), "",
+ tr("Py (*.py);;All Files (*)"));
+ _launcher_file_text->setReadOnly(false);
+ _launcher_file_text->setText(launcher_file);
+ _launcher_file_text->setReadOnly(true);
+}
+
+void BL::COORM_BatchParametersPage::cleanupPage()
+{}
+
+void
+BL::COORM_BatchParametersPage::initializePage()
+{
+ QString f_resource_choosed = field("resource_choosed").toString();
+ if (f_resource_choosed != resource_choosed)
+ {
+ resource_choosed = f_resource_choosed;
+ // If choosed resource has a working_directory set
+ // Generates a default remote working directory
+ BL::ResourceDescr resource_descr = _salome_services->getResourceDescr(resource_choosed.toStdString());
+ QString res_work_dir = resource_descr.working_directory.c_str();
+ if (res_work_dir != "")
+ {
+ time_t rawtime;
+ time(&rawtime);
+ std::string launch_date = ctime(&rawtime);
+ for (int i = 0; i < launch_date.size(); i++)
+ if (launch_date[i] == '/' ||
+ launch_date[i] == '-' ||
+ launch_date[i] == ':' ||
+ launch_date[i] == ' ')
+ launch_date[i] = '_';
+ launch_date.erase(--launch_date.end()); // Last caracter is a \n
+ QString date = launch_date.c_str();
+ setField("coorm_batch_directory", res_work_dir + "/" + date);
+ }
+ }
+}
+
BL::FilesPage::FilesPage(BL::CreateJobWizard * parent)
: QWizardPage(parent)
{
_ll_label->show();
_ll_value->show();
}
+
+ // Initialize resource_choosed with first resource in resource list
+ if (field("resource_choosed").toString() == "")
+ {
+ std::list<std::string> resource_list = _salome_services->getResourceList(true);
+ std::list<std::string>::iterator it = resource_list.begin();
+ if (it != resource_list.end())
+ {
+ QString first_resource((*it).c_str());
+ setField("resource_choosed", first_resource);
+ }
+ }
}
bool
int
BL::ResourcePage::nextId() const
{
- return BL::CreateJobWizard::Page_BatchParameters;
+ BL::ResourceDescr resource_descr = _salome_services->getResourceDescr(_resource_choosed->text().toStdString());
+ std::string batch = resource_descr.batch.c_str();
+ if (batch == "coorm")
+ {
+ return BL::CreateJobWizard::Page_COORM_BatchParameters;
+ }
+ else
+ {
+ return BL::CreateJobWizard::Page_BatchParameters;
+ }
}
BL::PythonSalomeMainPage::PythonSalomeMainPage(QWidget * parent)
std::string env_file;
std::string batch_directory;
- std::string maximum_duration;
+
+ // For COORM
+ std::string coorm_batch_directory;
+
+ std::string maximum_duration;
std::string expected_memory;
int nb_proc;
+ // Parameters for COORM
+ std::string launcher_file;
+ std::string launcher_args;
+
std::string result_directory;
std::list<std::string> input_files_list;
std::list<std::string> output_files_list;
Page_Command_Main_Definitions,
Page_PythonSalome_Main_Definitions,
Page_BatchParameters,
+ Page_COORM_BatchParameters,
Page_Files,
Page_Resource,
Page_Conclusion};
QString resource_choosed;
};
+ // For COORM
+ class COORM_BatchParametersPage: public QWizardPage
+ {
+ Q_OBJECT
+
+ public:
+ COORM_BatchParametersPage(QWidget * parent, BL::SALOMEServices * salome_services);
+ virtual ~COORM_BatchParametersPage();
+
+ virtual bool validatePage();
+ virtual int nextId() const;
+ virtual void cleanupPage();
+ virtual void initializePage();
+
+ public slots:
+ void choose_launcher_file();
+
+ private:
+ BL::SALOMEServices * _salome_services;
+ QLineEdit * _launcher_file_text;
+ QString resource_choosed;
+ };
+
class FilesPage: public QWizardPage
{
Q_OBJECT
QLabel * job_nop_label = new QLabel("Number of processors:");
_job_nop_label_value = new QLabel("");
+ // Parameters for COORM
+ QLabel * job_lf_label = new QLabel("Launcher file:");
+ _job_lf_label_value = new QLabel("");
+ QLabel * job_la_label = new QLabel("Launcher args:");
+ _job_la_label_value = new QLabel("");
+
// Specific values
_batch_queue_label = new QLabel("Batch queue:");
_batch_queue_value = new QLabel("");
_run_values_form->insertRow(1, job_nof_label, _job_nof_label_value);
_run_values_form->insertRow(2, job_bd_label, _job_bd_label_value);
_run_values_form->insertRow(3, job_rd_label, _job_rd_label_value);
+
+ // Parameters for COORM
+ _run_values_form->insertRow(4, job_lf_label, _job_lf_label_value);
+
_other_run_values_form = new QFormLayout;
_other_run_values_form->insertRow(0, job_mdt_label, _job_mdt_label_value);
_other_run_values_form->insertRow(1, job_em_label, _job_em_label_value);
_other_run_values_form->insertRow(2, job_nop_label, _job_nop_label_value);
+
+ // Parameters for COORM
+ _other_run_values_form->insertRow(3, job_la_label, _job_la_label_value);
+
QHBoxLayout * box_layout = new QHBoxLayout();
box_layout->addLayout(_run_values_form);
box_layout->addLayout(_other_run_values_form);
_job_em_label_value->setText(QString(batch_params.expected_memory.c_str()));
_job_nop_label_value->setText(QVariant(batch_params.nb_proc).toString());
+ // Parameters for COORM
+ _job_lf_label_value->setText(QString(batch_params.launcher_file.c_str()));
+ _job_la_label_value->setText(QString(batch_params.launcher_args.c_str()));
+
_input_files_list->clear();
_output_files_list->clear();
std::list<std::string>::iterator it;
_yacs_dump_state_value->setText("");
_batch_queue_value->setText("");
_ll_jobtype_value->setText("");
+
+ // Parameters for COORM
+ _job_lf_label_value->setText("");
+ _job_la_label_value->setText("");
}
}
QListWidget * _input_files_list;
QListWidget * _output_files_list;
+
+ // Parameters for COORM
+ QLabel * _job_lf_label_value;
+ QLabel * _job_la_label_value;
};
}
#include "BL_JobsManager_QT.hxx"
#include "BL_GenericGui.hxx"
+#include <vector>
+
+using namespace std;
+
+// To tokenize a string
+static void Tokenize(const std::string& str, std::vector<std::string>& tokens, const std::string& delimiters = " ");
BL::JobManagerEvent::JobManagerEvent(const std::string & action_i,
const std::string & event_name_i,
// For all jobs
new_job->setEnvFile(wizard.env_file);
BL::Job::BatchParam param;
- param.batch_directory = wizard.batch_directory;
+
+ // For COORM
+ if (wizard.coorm_batch_directory != "")
+ {
+ param.batch_directory = wizard.coorm_batch_directory;
+ }
+ else if (wizard.batch_directory != "")
+ {
+ param.batch_directory = wizard.batch_directory;
+ }
+
param.maximum_duration = wizard.maximum_duration;
param.expected_memory = wizard.expected_memory;
param.nb_proc = wizard.nb_proc;
+
+ // Parameters for COORM
+ param.launcher_file = wizard.launcher_file;
+ param.launcher_args = wizard.launcher_args;
+
new_job->setBatchParameters(param);
BL::Job::FilesParam files_params;
files_params.result_directory = wizard.result_directory;
write_error_text(" ***\n");
}
}
+ else if (event->action == "get_assigned_hostnames")
+ {
+ if (event->event_name == "Ok")
+ {
+ QString str((event->job_name).c_str());
+
+ vector<string> hostnames;
+
+ Tokenize(event->data, hostnames, "+");
+
+ vector<string>::iterator it;
+
+ write_normal_text("Job " + str + " assigned hostnames are :\n");
+
+ for (it = hostnames.begin(); it < hostnames.end(); it++)
+ {
+ vector<string> hostname;
+ Tokenize(*it, hostname, ".");
+ QString assigned_hostname(hostname[0].c_str());
+ write_normal_text("+ " + assigned_hostname + "\n");
+ }
+ }
+ else
+ {
+ // Do nothing in case the batch manager does not support this
+ }
+ }
else if (event->action == "save_jobs")
{
if (event->event_name == "Error")
_log->setTextCursor(cursor);
_log->setReadOnly(true);
}
+
+// To tokenize a string
+void Tokenize(const std::string& str, std::vector<std::string>& tokens, const std::string& delimiters)
+{
+ // Skip delimiters at beginning.
+ string::size_type lastPos = str.find_first_not_of(delimiters, 0);
+ // Find first "non-delimiter".
+ string::size_type pos = str.find_first_of(delimiters, lastPos);
+
+ while (string::npos != pos || string::npos != lastPos)
+ {
+ // Found a token, add it to the vector.
+ tokens.push_back(str.substr(lastPos, pos - lastPos));
+ // Skip delimiters. Note the "not_of"
+ lastPos = str.find_first_not_of(delimiters, pos);
+ // Find next "non-delimiter"
+ pos = str.find_first_of(delimiters, lastPos);
+ }
+}
_batch_line->addItem("slurm");
_batch_line->addItem("ll");
_batch_line->addItem("vishnu");
+ _batch_line->addItem("oar");
+ _batch_line->addItem("coorm");
_batch_line->setCurrentIndex(-1);
QLabel * mpiImpl_label = new QLabel("MPI impl:");
_batch_line->setCurrentIndex(6);
else if (batch == "vishnu")
_batch_line->setCurrentIndex(7);
+ else if (batch == "oar")
+ _batch_line->setCurrentIndex(8);
+ else if (batch == "coorm")
+ _batch_line->setCurrentIndex(9);
else
_batch_line->setCurrentIndex(-1);