From: secher Date: Tue, 9 Sep 2008 13:02:28 +0000 (+0000) Subject: manage messages X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=bdb4be1eeabb701acded01711b54f466f87d923d;p=modules%2Fkernel.git manage messages --- diff --git a/src/Launcher/Launcher.cxx b/src/Launcher/Launcher.cxx index 9c242dbf2..057b0f665 100644 --- a/src/Launcher/Launcher.cxx +++ b/src/Launcher/Launcher.cxx @@ -40,7 +40,9 @@ using namespace std; Launcher_cpp::Launcher_cpp() { - cerr << "Launcher_cpp constructor" << endl; +#if defined(_DEBUG_) || defined(_DEBUG) + cout << "Launcher_cpp constructor" << endl; +#endif } //============================================================================= @@ -51,7 +53,9 @@ Launcher_cpp::Launcher_cpp() Launcher_cpp::~Launcher_cpp() { - cerr << "Launcher_cpp destructor" << endl; +#if defined(_DEBUG_) || defined(_DEBUG) + cout << "Launcher_cpp destructor" << endl; +#endif std::map < string, Batch::BatchManager_eClient * >::const_iterator it1; for(it1=_batchmap.begin();it1!=_batchmap.end();it1++) delete it1->second; @@ -70,7 +74,9 @@ Launcher_cpp::~Launcher_cpp() long Launcher_cpp::submitJob( const std::string xmlExecuteFile, const std::string clusterName) throw(LauncherException) { - cerr << "BEGIN OF Launcher_cpp::submitJob" << endl; +#if defined(_DEBUG_) || defined(_DEBUG) + cout << "BEGIN OF Launcher_cpp::submitJob" << endl; +#endif long jobId; vector aMachineList; @@ -100,7 +106,9 @@ long Launcher_cpp::submitJob( const std::string xmlExecuteFile, ParserResourcesType p = _ResManager->GetResourcesList(aMachineList[0]); string cname(p.Alias); - cerr << "Choose cluster: " << cname << endl; +#if defined(_DEBUG_) || defined(_DEBUG) + cout << "Choose cluster: " << cname << endl; +#endif // search batch manager for that cluster in map or instanciate one map < string, Batch::BatchManager_eClient * >::const_iterator it2 = _batchmap.find(cname); @@ -179,7 +187,9 @@ long Launcher_cpp::submitSalomeJob( const string fileToExecute , const batchParams& batch_params, const machineParams& params) throw(LauncherException) { - cerr << "BEGIN OF Launcher_cpp::submitSalomeJob" << endl; +#if defined(_DEBUG_) || defined(_DEBUG) + cout << "BEGIN OF Launcher_cpp::submitSalomeJob" << endl; +#endif long jobId; vector aMachineList; @@ -203,7 +213,9 @@ long Launcher_cpp::submitSalomeJob( const string fileToExecute , ParserResourcesType p = _ResManager->GetResourcesList(aMachineList[0]); string clustername(p.Alias); - cerr << "Choose cluster: " << clustername << endl; +#if defined(_DEBUG_) || defined(_DEBUG) + cout << "Choose cluster: " << clustername << endl; +#endif // search batch manager for that cluster in map or instanciate one map < string, Batch::BatchManager_eClient * >::const_iterator it = _batchmap.find(clustername); @@ -437,22 +449,32 @@ Batch::BatchManager_eClient *Launcher_cpp::FactoryBatchManager( const ParserReso throw LauncherException("unknown mpi implementation"); break; } - cerr << "Instanciation of batch manager" << endl; +#if defined(_DEBUG_) || defined(_DEBUG) + cout << "Instanciation of batch manager" << endl; +#endif switch( params.Batch ){ case pbs: - cerr << "Instantiation of PBS batch manager" << endl; +#if defined(_DEBUG_) || defined(_DEBUG) + cout << "Instantiation of PBS batch manager" << endl; +#endif fact = new Batch::FactBatchManager_ePBS; break; case lsf: - cerr << "Instantiation of LSF batch manager" << endl; +#if defined(_DEBUG_) || defined(_DEBUG) + cout << "Instantiation of LSF batch manager" << endl; +#endif fact = new Batch::FactBatchManager_eLSF; break; case sge: - cerr << "Instantiation of SGE batch manager" << endl; +#if defined(_DEBUG_) || defined(_DEBUG) + cout << "Instantiation of SGE batch manager" << endl; +#endif fact = new Batch::FactBatchManager_eSGE; break; default: - cerr << "BATCH = " << params.Batch << endl; +#if defined(_DEBUG_) || defined(_DEBUG) + cout << "BATCH = " << params.Batch << endl; +#endif throw LauncherException("no batchmanager for that cluster"); } return (*fact)(hostname.c_str(),protocol.c_str(),mpi.c_str()); @@ -562,7 +584,9 @@ string Launcher_cpp::buildSalomeCouplingScript(const string fileToExecute, const tempOutputFile.flush(); tempOutputFile.close(); chmod(TmpFileName.c_str(), 0x1ED); - cerr << TmpFileName.c_str() << endl; +#if defined(_DEBUG_) || defined(_DEBUG) + cout << TmpFileName.c_str() << endl; +#endif delete mpiImpl; @@ -627,8 +651,10 @@ string Launcher_cpp::getRemoteFile( std::string remoteDir, std::string localFile bool Launcher_cpp::check(const batchParams& batch_params) { bool rtn = true; - cerr << "Job parameters are :" << endl; - cerr << "Directory : $HOME/Batch/$date" << endl; +#if defined(_DEBUG_) || defined(_DEBUG) + cout << "Job parameters are :" << endl; + cout << "Directory : $HOME/Batch/$date" << endl; +#endif // check expected_during_time (check the format) std::string edt_info = batch_params.expected_during_time; @@ -665,7 +691,9 @@ bool Launcher_cpp::check(const batchParams& batch_params) else { edt_info = "No value given"; } - cerr << "Expected during time : " << edt_info << endl;; +#if defined(_DEBUG_) || defined(_DEBUG) + cout << "Expected during time : " << edt_info << endl;; +#endif // check memory (check the format) std::string mem_info; @@ -691,7 +719,9 @@ bool Launcher_cpp::check(const batchParams& batch_params) else { mem_info = "No value given"; } - cerr << "Memory : " << mem_info << endl; +#if defined(_DEBUG_) || defined(_DEBUG) + cout << "Memory : " << mem_info << endl; +#endif // check nb_proc std::string nb_proc_info; @@ -705,7 +735,9 @@ bool Launcher_cpp::check(const batchParams& batch_params) else { nb_proc_info = nb_proc_value.str(); } - cerr << "Nb of processors : " << nb_proc_info << endl; +#if defined(_DEBUG_) || defined(_DEBUG) + cout << "Nb of processors : " << nb_proc_info << endl; +#endif return rtn; } @@ -764,16 +796,22 @@ void Launcher_cpp::ParseXmlFile(string xmlExecuteFile) if (aDoc != NULL) handler->ProcessXmlDocument(aDoc); - else - cerr << "ResourcesManager_cpp: could not parse file "<< aFilePath << endl; + else{ +#if defined(_DEBUG_) || defined(_DEBUG) + cout << "ResourcesManager_cpp: could not parse file "<< aFilePath << endl; +#endif + } // Free the document xmlFreeDoc(aDoc); fclose(aFile); } - else - cerr << "Launcher_cpp: file "< ResourcesManager_cpp::GetFittingResources(const machineParams& params, const std::vector& componentList) throw(ResourcesException) { -// cerr << "ResourcesManager_cpp::GetFittingResources" << endl; vector vec; ParseXmlFile(); const char *hostname = params.hostname.c_str(); - cerr << "GetFittingResources " << hostname << " " << GetHostname().c_str() << endl; +#if defined(_DEBUG_) || defined(_DEBUG) + cout << "GetFittingResources " << hostname << " " << GetHostname().c_str() << endl; +#endif if (hostname[0] != '\0'){ - // cerr << "ResourcesManager_cpp::GetFittingResources : hostname specified" << endl; if ( strcmp(hostname, "localhost") == 0 || strcmp(hostname, GetHostname().c_str()) == 0 ) { - // cerr << "ResourcesManager_cpp::GetFittingResources : localhost" << endl; vec.push_back(GetHostname().c_str()); - // cerr << "ResourcesManager_cpp::GetFittingResources : " << vec.size() << endl; } else if (_resourcesList.find(hostname) != _resourcesList.end()) @@ -151,15 +157,15 @@ ResourcesManager_cpp::GetFittingResources(const machineParams& params, if( (*iter).second.DataForSort._nbOfNodes > 1 ){ if( strncmp(hostname,(*iter).first.c_str(),strlen(hostname)) == 0 ){ vec.push_back((*iter).first.c_str()); - //cerr << "SALOME_ResourcesManager_cpp::GetFittingResources vector[" - // << cpt << "] = " << (*iter).first.c_str() << endl ; cpt++; } } } if(cpt==0){ // --- user specified an unknown hostame so notify him. - cerr << "ResourcesManager_cpp::GetFittingResources : SALOME_Exception" << endl; +#if defined(_DEBUG_) || defined(_DEBUG) + cout << "ResourcesManager_cpp::GetFittingResources : SALOME_Exception" << endl; +#endif throw ResourcesException("unknown host"); } } @@ -275,7 +281,9 @@ void ResourcesManager_cpp::WriteInXmlFile() if (aFile == NULL) { - cerr << "Error opening file !" << endl; +#if defined(_DEBUG_) || defined(_DEBUG) + cout << "Error opening file !" << endl; +#endif return; } @@ -290,14 +298,18 @@ void ResourcesManager_cpp::WriteInXmlFile() int isOk = xmlSaveFile(aFilePath, aDoc); if (!isOk) - cerr << "Error while XML file saving." << endl; +#if defined(_DEBUG_) || defined(_DEBUG) + cout << "Error while XML file saving." << endl; +#endif // Free the document xmlFreeDoc(aDoc); fclose(aFile); - cerr << "WRITING DONE!" << endl; +#if defined(_DEBUG_) || defined(_DEBUG) + cout << "WRITING DONE!" << endl; +#endif } //============================================================================= @@ -321,7 +333,9 @@ const MapOfParserResourcesType& ResourcesManager_cpp::ParseXmlFile() if (aDoc != NULL) handler->ProcessXmlDocument(aDoc); else - cerr << "ResourcesManager_cpp: could not parse file "<< aFilePath << endl; +#if defined(_DEBUG_) || defined(_DEBUG) + cout << "ResourcesManager_cpp: could not parse file "<< aFilePath << endl; +#endif // Free the document xmlFreeDoc(aDoc); @@ -329,7 +343,9 @@ const MapOfParserResourcesType& ResourcesManager_cpp::ParseXmlFile() fclose(aFile); } else - cerr << "ResourcesManager_cpp: file "<