BmnRoot 26.10.0-210-gc52d34b0
Software framework of the BM@N experiment
Loading...
Searching...
No Matches
nica-scheduler.cpp File Reference
#include "batch_command.h"
#include "container_settings.h"
#include "function_set.h"
#include "TSQLResult.h"
#include "TSQLRow.h"
#include "TSQLServer.h"
#include "TString.h"
#include "TSystem.h"
#include <algorithm>
#include <array>
#include <cctype>
#include <condition_variable>
#include <fstream>
#include <getopt.h>
#include <glob.h>
#include <libxml/parser.h>
#include <libxml/tree.h>
#include <map>
#include <mutex>
#include <sstream>
#include <thread>
#include <unistd.h>
#include "../settings.h"
Include dependency graph for nica-scheduler.cpp:

Go to the source code of this file.

Classes

struct  struct_database_settings
class  Semaphore
class  nullString
struct  structFilePar
struct  structMacroPar
struct  structJobStackPar
struct  structJobPar
struct  structThreadPar
struct  structSubThreadPar

Functions

void ParseDatabaseParameters (string input, TString &sql, bool is_simulation)
bool ParseMacroFiles (xmlNodePtr sub_node, shared_ptr< structJobPar > job_par, shared_ptr< structMacroPar > macro_par, multimap< string, unique_ptr< vector< nullString > > > &map_job_output, batch_commands batch_com)
void info_message (const string msg, bool is_error=0)
string concatenate_job_ids (const vector< string > &vec_job_id, char separator)
int get_batch_queue_job_count (batch_commands batch_com)
bool wait_batch_queue_limit (batch_commands batch_com, int queue_limit)
void replace_string_in_text_ext (string &text, string old_substring, string new_substring)
string form_file_name (string out_name, string in_name, int counter, string batch_temp_dir)
vector< string > glob (const string &path)
void skip_json_spaces (const string &text, size_t &pos)
bool parse_json_file_string (const string &text, size_t &pos, string &value, string &error)
bool parse_json_file_list (const string &text, vector< string > &files, string &error)
bool append_input_files_from_json (const string &json_input_path, vector< string > &vecInputFiles)
string GenerateOutputFilePath (string path, int counter)
bool has_wildcards (const string &path)
bool is_relative_file_path (const string &path)
void CopyExtraGetFiles (structFilePar *cur_file)
void RunLocalCommandLine (shared_ptr< structThreadPar > thread_par, string command_line, int stack_counter)
void SubThreadProcessFile (shared_ptr< structSubThreadPar > subthread_par)
void ThreadLocalProcess (shared_ptr< structThreadPar > thread_par)
void ShowHelpMessage ()
int main (int argc, char **argv)

Variables

bool isDebugMode = false
static struct option long_options []

Function Documentation

◆ append_input_files_from_json()

bool append_input_files_from_json ( const string & json_input_path,
vector< string > & vecInputFiles )

Definition at line 679 of file nica-scheduler.cpp.

References expand_path(), TString::Format(), info_message(), isDebugMode, and parse_json_file_list().

Referenced by ParseMacroFiles().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ concatenate_job_ids()

string concatenate_job_ids ( const vector< string > & vec_job_id,
char separator )

Definition at line 401 of file nica-scheduler.cpp.

References i.

Referenced by main().

Here is the caller graph for this function:

◆ CopyExtraGetFiles()

void CopyExtraGetFiles ( structFilePar * cur_file)

Definition at line 745 of file nica-scheduler.cpp.

References TString::Data(), get_directory_path(), get_file_name_with_ext(), nullString::GetValue(), glob(), has_wildcards(), structFilePar::nstrFileOut, structFilePar::strGetCommand, and structFilePar::vecGetExtraPath.

Referenced by ThreadLocalProcess().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ form_file_name()

string form_file_name ( string out_name,
string in_name,
int counter,
string batch_temp_dir )

Definition at line 501 of file nica-scheduler.cpp.

References find_first_number(), find_last_number(), get_directory_name(), get_file_name(), get_file_name_with_ext(), replace_string_in_text(), and replace_string_in_text_ext().

Referenced by ParseMacroFiles().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GenerateOutputFilePath()

string GenerateOutputFilePath ( string path,
int counter )

Definition at line 717 of file nica-scheduler.cpp.

References int_to_string().

Referenced by main(), and ThreadLocalProcess().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_batch_queue_job_count()

int get_batch_queue_job_count ( batch_commands batch_com)

Definition at line 415 of file nica-scheduler.cpp.

References find_first_number(), and batch_commands::queue_count_command.

Referenced by wait_batch_queue_limit().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ glob()

vector< string > glob ( const string & path)
inline

Definition at line 527 of file nica-scheduler.cpp.

References glob(), and i.

Referenced by CopyExtraGetFiles(), glob(), CbmStsSensor::IntersectClusters(), ParseMacroFiles(), and MpdDecayerPyt8::SetGlobalPolar().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ has_wildcards()

bool has_wildcards ( const string & path)

Definition at line 731 of file nica-scheduler.cpp.

Referenced by CopyExtraGetFiles().

Here is the caller graph for this function:

◆ info_message()

void info_message ( const string msg,
bool is_error = 0 )

Definition at line 384 of file nica-scheduler.cpp.

Referenced by append_input_files_from_json(), main(), ParseMacroFiles(), SubThreadProcessFile(), ThreadLocalProcess(), and wait_batch_queue_limit().

Here is the caller graph for this function:

◆ is_relative_file_path()

bool is_relative_file_path ( const string & path)

Definition at line 738 of file nica-scheduler.cpp.

Referenced by ParseMacroFiles().

Here is the caller graph for this function:

◆ main()

int main ( int argc,
char ** argv )

Definition at line 1529 of file nica-scheduler.cpp.

References batch_commands::array_dependency_option, batch_commands::batch_task_id, byte_size_to_double(), batch_commands::cancel_command, batch_commands::check_status_command, concatenate_job_ids(), batch_commands::container_run_command, convert_pchar_to_lowercase_new(), TString::Data(), struct_database_settings::db_host, struct_database_settings::db_name, struct_database_settings::db_password, struct_database_settings::db_username, find_first_number(), TString::Format(), GenerateOutputFilePath(), get_app_dir_linux(), get_batch_processor_count(), get_directory_path(), get_file_name_with_ext(), get_linux_processor_count(), nullString::GetValue(), i, info_message(), int_to_string(), structFilePar::iParallelMode, is_string_number(), isDebugMode, structJobStackPar::iStackType, batch_commands::job_begin, batch_commands::job_dependency_option, batch_commands::job_dependency_separator, long_options, mapBS, mapContainerType, structJobStackPar::nstrCommandline, structFilePar::nstrFileOut, structMacroPar::nstrMacroPath, batch_commands::operative_memory1_option, ParseMacroFiles(), predefined_database_settings, replace_string_in_text(), batch_commands::run_command, batch_commands::scheduler_run_job, batch_commands::set_job_variables, nullString::SetValue(), SGE_BATCH_SYSTEM, batch_commands::sheduler_exclude_hosts_option, batch_commands::sheduler_hosts_option, batch_commands::sheduler_hosts_separation, batch_commands::sheduler_priority_option, batch_commands::sheduler_qos_option, batch_commands::sheduler_queue_option, batch_commands::sheduler_workdir_option, ShowHelpMessage(), SLURM_BATCH_SYSTEM, structJobStackPar::sptrMacroParameter, structFilePar::strParallelMode, ThreadLocalProcess(), TORQUE_BATCH_SYSTEM, trim(), UNI_DB_HOST, UNI_DB_NAME, UNI_DB_PASSWORD, UNI_DB_USERNAME, structMacroPar::vecFiles, and wait_batch_queue_limit().

Here is the call graph for this function:

◆ parse_json_file_list()

bool parse_json_file_list ( const string & text,
vector< string > & files,
string & error )

Definition at line 618 of file nica-scheduler.cpp.

References parse_json_file_string(), and skip_json_spaces().

Referenced by append_input_files_from_json().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ parse_json_file_string()

bool parse_json_file_string ( const string & text,
size_t & pos,
string & value,
string & error )

Definition at line 547 of file nica-scheduler.cpp.

References skip_json_spaces().

Referenced by parse_json_file_list().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ParseDatabaseParameters()

void ParseDatabaseParameters ( string input,
TString & sql,
bool is_simulation )

Definition at line 2969 of file nica-scheduler.cpp.

References TString::Format().

Referenced by ParseMacroFiles().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ParseMacroFiles()

bool ParseMacroFiles ( xmlNodePtr sub_node,
shared_ptr< structJobPar > job_par,
shared_ptr< structMacroPar > macro_par,
multimap< string, unique_ptr< vector< nullString > > > & map_job_output,
batch_commands batch_com )

Definition at line 3625 of file nica-scheduler.cpp.

References append_input_files_from_json(), batch_commands::batch_temp_directory, TSQLServer::Connect(), convert_pchar_to_lowercase_new(), expand_path(), form_file_name(), get_file_name_with_ext(), TSQLRow::GetField(), TSQLResult::GetRowCount(), nullString::GetValue(), glob(), i, info_message(), is_relative_file_path(), is_string_number(), isDebugMode, TSQLResult::Next(), structMacroPar::nstrMacroName, ParseDatabaseParameters(), TSQLServer::Query(), replace_string_in_text(), batch_commands::run_command, nullString::SetValue(), string_to_vector(), trim(), and structMacroPar::vecFiles.

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ replace_string_in_text_ext()

void replace_string_in_text_ext ( string & text,
string old_substring,
string new_substring )

Definition at line 466 of file nica-scheduler.cpp.

Referenced by form_file_name().

Here is the caller graph for this function:

◆ RunLocalCommandLine()

void RunLocalCommandLine ( shared_ptr< structThreadPar > thread_par,
string command_line,
int stack_counter )

Definition at line 786 of file nica-scheduler.cpp.

References isDebugMode.

Referenced by ThreadLocalProcess().

Here is the caller graph for this function:

◆ ShowHelpMessage()

void ShowHelpMessage ( )

Definition at line 1515 of file nica-scheduler.cpp.

Referenced by main().

Here is the caller graph for this function:

◆ skip_json_spaces()

void skip_json_spaces ( const string & text,
size_t & pos )

Definition at line 540 of file nica-scheduler.cpp.

Referenced by parse_json_file_list(), and parse_json_file_string().

Here is the caller graph for this function:

◆ SubThreadProcessFile()

void SubThreadProcessFile ( shared_ptr< structSubThreadPar > subthread_par)

Definition at line 837 of file nica-scheduler.cpp.

References get_directory_path(), nullString::GetValue(), info_message(), isDebugMode, and nullString::isNull().

Referenced by ThreadLocalProcess().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ThreadLocalProcess()

void ThreadLocalProcess ( shared_ptr< structThreadPar > thread_par)

Definition at line 972 of file nica-scheduler.cpp.

References CopyExtraGetFiles(), find_first_number(), TString::Format(), GenerateOutputFilePath(), get_app_dir_linux(), get_directory_path(), get_file_name_with_ext(), nullString::GetValue(), i, structFilePar::iMerge, info_message(), structFilePar::iParallelMode, isDebugMode, structFilePar::nstrFileOut, structFilePar::ptrEventCount, structFilePar::ptrStartEvent, replace_string_in_text(), RunLocalCommandLine(), nullString::SetValue(), structFilePar::strFileIn, structFilePar::strGetCommand, structFilePar::strGetPath, structFilePar::strPutCommand, structFilePar::strPutPath, SubThreadProcessFile(), and structFilePar::vecCleanPath.

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ wait_batch_queue_limit()

bool wait_batch_queue_limit ( batch_commands batch_com,
int queue_limit )

Definition at line 438 of file nica-scheduler.cpp.

References get_batch_queue_job_count(), info_message(), and isDebugMode.

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ isDebugMode

◆ long_options

struct option long_options[]
static
Initial value:
= {{"help", no_argument, 0, 'h'}, {"file", required_argument, 0, 'f'},
{"debug", no_argument, 0, 'd'}, {"db", required_argument, 0, 0},
{"database", required_argument, 0, 0}, {0, 0, 0, 0}}

Definition at line 1510 of file nica-scheduler.cpp.

Referenced by main().