# ---
-class ContainerManagerServer(Server):
+class LauncherServer(Server):
def __init__(self,args):
self.args=args
self.initArgs()
- self.SCMD1=['SALOME_ContainerManagerServer']
+ self.SCMD1=['SALOME_LauncherServer']
self.SCMD2=[]
if args["gui"] :
if 'registry' in self.args['embedded']:
clt.waitNSPID("/myStudyManager",myServer.PID)
#
- # Lancement ContainerManagerServer
+ # Lancement LauncherServer
#
- myCmServer = ContainerManagerServer(args)
+ myCmServer = LauncherServer(args)
myCmServer.setpath(modules_list,modules_root_dir)
myCmServer.run()
if obj != None:
ses = obj._narrow(SALOME.Session)
ses.StopSession()
-obj = clt.Resolve('ContainerManager')
+obj = clt.Resolve('SalomeLauncher')
if obj != None:
- cm = obj._narrow(Engines.ContainerManager)
+ cm = obj._narrow(Engines.SalomeLauncher)
cm.Shutdown()
obj = clt.Resolve('Kernel/ModulCatalog')
if obj != None:
./src/GenericObj/Makefile \
./src/HDFPersist/Makefile \
./src/KERNEL_PY/Makefile \
+ ./src/Launcher/Makefile \
./src/LifeCycleCORBA/Makefile \
./src/LifeCycleCORBA/Test/Makefile \
./src/LifeCycleCORBA_SWIG/Makefile \
{
/*!
- Type to describe properties of wanted resource.
+ Type to transmit list of machines.
+*/
+ typedef sequence<string> MachineList;
+ typedef sequence<string> CompoList;
+ typedef sequence<string> FilesList;
+ typedef sequence<string> ModulesList;
+
+/*!
+ Type to describe properties of resource.
*/
struct MachineParameters
{
string container_name;
string hostname;
+ string alias;
+ string protocol;
+ string username;
+ string applipath;
+ ModulesList modList;
string OS;
long mem_mb;
long cpu_clock;
long nb_proc_per_node;
long nb_node;
boolean isMPI;
+ string mpiImpl;
+ string batch;
};
-/*!
- Type to transmit list of machines.
-*/
- typedef sequence<string> MachineList;
- typedef sequence<string> CompoList;
- typedef sequence<string> FilesList;
-
/*!
exception thrown if a computer is not found in the catalog
*/
enum policy {P_FIRST,P_CYCL,P_BEST};
typedef policy ResPolicy;
+/*! \brief Interface of the %salomelauncher
+ This interface is used for interaction with the unique instance
+ of SalomeLauncher
+*/
+ interface SalomeLauncher
+ {
+ long submitSalomeJob( in string fileToExecute,
+ in FilesList filesToExport,
+ in FilesList filesToImport,
+ in long NumberOfProcessors,
+ in MachineParameters params ) raises (SALOME::SALOME_Exception);
+ string querySalomeJob( in long jobId, in MachineParameters params ) raises (SALOME::SALOME_Exception);
+ void deleteSalomeJob( in long jobId, in MachineParameters params ) raises (SALOME::SALOME_Exception);
+ void getResultSalomeJob( in string directory, in long jobId, in MachineParameters params ) raises (SALOME::SALOME_Exception);
+
+ void Shutdown();
+
+ } ;
+
/*! \brief Interface of the %containerManager
This interface is used for interaction with the unique instance
of ContainerManager
in ResPolicy policy,
in CompoList componentList );
- long submitSalomeJob( in string fileToExecute,
- in FilesList filesToExport,
- in FilesList filesToImport,
- in long NumberOfProcessors,
- in MachineParameters params ) raises (SALOME::SALOME_Exception);
- string querySalomeJob( in long jobId, in MachineParameters params ) raises (SALOME::SALOME_Exception);
- void deleteSalomeJob( in long jobId, in MachineParameters params ) raises (SALOME::SALOME_Exception);
- void getResultSalomeJob( in string directory, in long jobId, in MachineParameters params ) raises (SALOME::SALOME_Exception);
-
+ void ShutdownContainers();
+ } ;
+
+/*! \brief Interface of the %resourcesManager
+ This interface is used for interaction with the unique instance
+ of ResourcesManager
+*/
+ interface ResourcesManager
+ {
string FindFirst(in MachineList possibleComputers);
MachineList GetFittingResources( in MachineParameters params,
MachineParameters GetMachineParameters( in string hostname );
- void Shutdown();
-
- void ShutdownContainers();
} ;
};
{
BEGIN_OF("BatchManager_PBS::buildSalomeCouplingScript");
int status;
- int lenf = strlen( fileToExecute ) ;
- int i = lenf-1 ;
- while ( i >= 0 && fileToExecute[i] != '/' ) {
- i -= 1 ;
- }
- char * FileNameToExecute = new char[lenf-4-i] ;
- strncpy(FileNameToExecute , &fileToExecute[i+1] , lenf-4-i) ;
- _fileNameToExecute = string( FileNameToExecute ) ;
- delete FileNameToExecute ;
- SCRUTE(_fileNameToExecute) ;
+
+ string::size_type p1 = string(fileToExecute).find_last_of("/");
+ string::size_type p2 = string(fileToExecute).find_last_of(".");
+ _fileNameToExecute = string(fileToExecute).substr(p1+1,p2-p1-1);
_TmpFileName = BuildTemporaryFileName();
ofstream tempOutputFile;
tempOutputFile << _mpiImpl->rank() ;
tempOutputFile << " = 0; then" << endl ;
tempOutputFile << " ./runAppli --terminal --batch --modules=" ;
- for ( i = 0 ; i < _params.modulesList.size() ; i++ ) {
+ for ( int i = 0 ; i < _params.modulesList.size() ; i++ ) {
tempOutputFile << _params.modulesList[i] ;
if ( i != _params.modulesList.size()-1 )
tempOutputFile << "," ;
command += "/runSalome_" ;
command += _fileNameToExecute ;
command += "_Batch.sh" ;
+ SCRUTE(_fileNameToExecute) ;
SCRUTE(command.c_str());
status = system(command.c_str());
if(status)
{
BEGIN_OF("BatchManager_SLURM::buildSalomeCouplingScript");
int status;
- int lenf = strlen( fileToExecute ) ;
- int i = lenf-1 ;
- while ( i >= 0 && fileToExecute[i] != '/' ) {
- i -= 1 ;
- }
- char * FileNameToExecute = new char[lenf-4-i] ;
- strncpy(FileNameToExecute , &fileToExecute[i+1] , lenf-4-i) ;
- _fileNameToExecute = string( FileNameToExecute ) ;
- delete FileNameToExecute ;
- SCRUTE(_fileNameToExecute) ;
+
+ string::size_type p1 = string(fileToExecute).find_last_of("/");
+ string::size_type p2 = string(fileToExecute).find_last_of(".");
+ _fileNameToExecute = string(fileToExecute).substr(p1+1,p2-p1-1);
_TmpFileName = BuildTemporaryFileName();
ofstream tempOutputFile;
tempOutputFile << ":$PYTHONPATH" << endl ;
tempOutputFile << "if test $SLURM_PROCID = 0; then" << endl ;
tempOutputFile << " ./runAppli --terminal --batch --modules=" ;
- for ( i = 0 ; i < _params.modulesList.size() ; i++ ) {
+ for ( int i = 0 ; i < _params.modulesList.size() ; i++ ) {
tempOutputFile << _params.modulesList[i] ;
if ( i != _params.modulesList.size()-1 )
tempOutputFile << "," ;
# Executables targets
# ===============================================================
#
-bin_PROGRAMS = SALOME_Container SALOME_ContainerManagerServer
+bin_PROGRAMS = SALOME_Container
SALOME_Container_SOURCES =\
SALOME_Container.cxx \
SALOME_Container_SignalsHandler.cxx
$(COMMON_LIBS) \
../Basics/libSALOMEBasics.la \
../Batch/libSalomeBatch.la
-
-
-SALOME_ContainerManagerServer_SOURCES =\
- SALOME_ContainerManagerServer.cxx
-
-SALOME_ContainerManagerServer_CPPFLAGS=\
- $(COMMON_CPPFLAGS)
-
-SALOME_ContainerManagerServer_LDADD =\
- libSalomeContainer.la \
- $(COMMON_LIBS) \
- ../Basics/libSALOMEBasics.la \
- ../Batch/libSalomeBatch.la
-
-
*/
//=============================================================================
-SALOME_ContainerManager::SALOME_ContainerManager(CORBA::ORB_ptr orb)
+SALOME_ContainerManager::SALOME_ContainerManager(CORBA::ORB_ptr orb, PortableServer::POA_var poa, SALOME_ResourcesManager *rm, SALOME_NamingService *ns)
{
MESSAGE("constructor");
- _NS = new SALOME_NamingService(orb);
- _ResManager = new SALOME_ResourcesManager(orb);
+ _NS = ns;
+ _ResManager = rm;
_id=0;
- PortableServer::POA_var root_poa = PortableServer::POA::_the_root_poa();
- PortableServer::POAManager_var pman = root_poa->the_POAManager();
- PortableServer::POA_var my_poa;
+ PortableServer::POAManager_var pman = poa->the_POAManager();
_orb = CORBA::ORB::_duplicate(orb) ;
CORBA::PolicyList policies;
policies.length(1);
PortableServer::ThreadPolicy_var threadPol =
- root_poa->create_thread_policy(PortableServer::SINGLE_THREAD_MODEL);
+ poa->create_thread_policy(PortableServer::SINGLE_THREAD_MODEL);
policies[0] = PortableServer::ThreadPolicy::_duplicate(threadPol);
- my_poa =
- root_poa->create_POA("SThreadPOA",pman,policies);
+ _poa = poa->create_POA("SThreadPOA",pman,policies);
threadPol->destroy();
- PortableServer::ObjectId_var id = my_poa->activate_object(this);
- CORBA::Object_var obj = my_poa->id_to_reference(id);
+ PortableServer::ObjectId_var id = _poa->activate_object(this);
+ CORBA::Object_var obj = _poa->id_to_reference(id);
Engines::ContainerManager_var refContMan =
Engines::ContainerManager::_narrow(obj);
SALOME_ContainerManager::~SALOME_ContainerManager()
{
MESSAGE("destructor");
- delete _NS;
- delete _ResManager;
}
//=============================================================================
MESSAGE("Shutdown");
ShutdownContainers();
_NS->Destroy_Name(_ContainerManagerNameInNS);
- PortableServer::ObjectId_var oid = _default_POA()->servant_to_id(this);
- _default_POA()->deactivate_object(oid);
+ PortableServer::ObjectId_var oid = _poa->servant_to_id(this);
+ _poa->deactivate_object(oid);
_remove_ref();
- if(!CORBA::is_nil(_orb))
- _orb->shutdown(0);
}
//=============================================================================
Engines::ResPolicy policy,
const Engines::CompoList& componentList)
{
- Engines::MachineList_var possibleComputers = GetFittingResources(params,componentList);
+ Engines::MachineList_var possibleComputers = _ResManager->GetFittingResources(params,componentList);
return StartContainer(params,possibleComputers,policy);
}
return StartContainer(params,policy,componentList);
}
-
-//=============================================================================
-/*! CORBA Method:
- * Submit a batch job on a cluster and returns the JobId
- * \param fileToExecute : .py/.exe/.sh/... to execute on the batch cluster
- * \param filesToExport : to export on the batch cluster
- * \param NumberOfProcessors : Number of processors needed on the batch cluster
- * \param params : Constraints for the choice of the batch cluster
- */
-//=============================================================================
-CORBA::Long SALOME_ContainerManager::submitSalomeJob( const char * fileToExecute ,
- const Engines::FilesList& filesToExport ,
- const Engines::FilesList& filesToImport ,
- const CORBA::Long NumberOfProcessors ,
- const Engines::MachineParameters& params)
-{
- CORBA::Long jobId;
- try{
- jobId = _ResManager->submitSalomeJob(fileToExecute, filesToExport, filesToImport, NumberOfProcessors, params);
- }
- catch(const SALOME_Exception &ex){
- MESSAGE(ex.what());
- THROW_SALOME_CORBA_EXCEPTION(ex.what(),SALOME::INTERNAL_ERROR);
- }
- return jobId;
-}
-
-//=============================================================================
-/*! CORBA Method:
- * Query a batch job on a cluster and returns the status of job
- * \param jobId : identification of Salome job
- * \param params : Constraints for the choice of the batch cluster
- */
-//=============================================================================
-char* SALOME_ContainerManager::querySalomeJob( const CORBA::Long jobId,
- const Engines::MachineParameters& params)
-{
- string status;
- try{
- status = _ResManager->querySalomeJob( jobId, params);
- }
- catch(const SALOME_Exception &ex){
- INFOS("Caught exception.");
- THROW_SALOME_CORBA_EXCEPTION(ex.what(),SALOME::BAD_PARAM);
- }
- return CORBA::string_dup(status.c_str());
-}
-
-//=============================================================================
-/*! CORBA Method:
- * Delete a batch job on a cluster
- * \param jobId : identification of Salome job
- * \param params : Constraints for the choice of the batch cluster
- */
-//=============================================================================
-void SALOME_ContainerManager::deleteSalomeJob( const CORBA::Long jobId,
- const Engines::MachineParameters& params)
-{
- try{
- _ResManager->deleteSalomeJob( jobId, params);
- }
- catch(const SALOME_Exception &ex){
- INFOS("Caught exception.");
- THROW_SALOME_CORBA_EXCEPTION(ex.what(),SALOME::BAD_PARAM);
- }
-}
-
-//=============================================================================
-/*! CORBA Method:
- * Get result files of job on a cluster
- * \param jobId : identification of Salome job
- * \param params : Constraints for the choice of the batch cluster
- */
-//=============================================================================
-void SALOME_ContainerManager::getResultSalomeJob( const char *directory,
- const CORBA::Long jobId,
- const Engines::MachineParameters& params)
-{
- try{
- _ResManager->getResultSalomeJob( directory, jobId, params);
- }
- catch(const SALOME_Exception &ex){
- INFOS("Caught exception.");
- THROW_SALOME_CORBA_EXCEPTION(ex.what(),SALOME::BAD_PARAM);
- }
-}
-
-//=============================================================================
-/*!
- *
- */
-//=============================================================================
-
-Engines::MachineList *
-SALOME_ContainerManager::
-GetFittingResources(const Engines::MachineParameters& params,
- const Engines::CompoList& componentList)
-{
- MESSAGE("SALOME_ContainerManager::GetFittingResources");
- Engines::MachineList *ret=new Engines::MachineList;
- vector<string> vec;
- try
- {
- vec = _ResManager->GetFittingResources(params,componentList);
- }
- catch(const SALOME_Exception &ex)
- {
- INFOS("Caught exception.");
- THROW_SALOME_CORBA_EXCEPTION(ex.what(),SALOME::BAD_PARAM);
- //return ret;
- }
-
- // MESSAGE("Machine list length "<<vec.size());
- ret->length(vec.size());
- for(unsigned int i=0;i<vec.size();i++)
- {
- (*ret)[i]=(vec[i]).c_str();
- }
- return ret;
-}
-
-//=============================================================================
-/*!
- *
- */
-//=============================================================================
-
-char*
-SALOME_ContainerManager::
-FindFirst(const Engines::MachineList& possibleComputers)
-{
- string theMachine=_ResManager->FindFirst(possibleComputers);
- return CORBA::string_dup(theMachine.c_str());
-}
-
//=============================================================================
/*!
*
return _id;
}
-Engines::MachineParameters* SALOME_ContainerManager::GetMachineParameters(const char *hostname)
-{
- return _ResManager->GetMachineParameters(hostname);
-}
-
void SALOME_ContainerManager::fillBatchLaunchedContainers()
{
_batchLaunchedContainers.clear();
{
public:
- SALOME_ContainerManager(CORBA::ORB_ptr orb);
+ SALOME_ContainerManager(CORBA::ORB_ptr orb, PortableServer::POA_var poa, SALOME_ResourcesManager *rm, SALOME_NamingService *ns);
~SALOME_ContainerManager();
Engines::Container_ptr
Engines::ResPolicy policy,
const Engines::CompoList& componentList);
- CORBA::Long submitSalomeJob(const char * fileToExecute ,
- const Engines::FilesList& filesToExport ,
- const Engines::FilesList& filesToImport ,
- const CORBA::Long NumberOfProcessors ,
- const Engines::MachineParameters& params);
-
- char* querySalomeJob( const CORBA::Long jobId, const Engines::MachineParameters& params);
- void deleteSalomeJob( const CORBA::Long jobId, const Engines::MachineParameters& params);
- void getResultSalomeJob( const char * directory, const CORBA::Long jobId, const Engines::MachineParameters& params );
-
- Engines::MachineList *
- GetFittingResources(const Engines::MachineParameters& params,
- const Engines::CompoList& componentList);
-
- char* FindFirst(const Engines::MachineList& possibleComputers);
-
- Engines::MachineParameters* GetMachineParameters(const char *hostname);
-
void Shutdown();
void ShutdownContainers();
long GetIdForContainer(void);
long _id;
CORBA::ORB_var _orb;
+ PortableServer::POA_var _poa;
SALOME_ResourcesManager *_ResManager;
SALOME_NamingService *_NS;
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-#include "SALOME_ContainerManager.hxx"
-#include "utilities.h"
-
-int main(int argc, char* argv[])
-{
- PortableServer::POA_var root_poa;
- PortableServer::POAManager_var pman;
- CORBA::Object_var obj;
-
- CORBA::ORB_ptr orb = CORBA::ORB_init( argc , argv ) ;
- // LocalTraceCollector *myThreadTrace = SALOMETraceCollector::instance(orb);
- INFOS_COMPILATION;
- BEGIN_OF(argv[0]);
- try{
- obj = orb->resolve_initial_references("RootPOA");
- if(!CORBA::is_nil(obj))
- root_poa = PortableServer::POA::_narrow(obj);
- if(!CORBA::is_nil(root_poa))
- pman = root_poa->the_POAManager();
- }
- catch(CORBA::COMM_FAILURE&){
- MESSAGE( "Container: CORBA::COMM_FAILURE: Unable to contact the Naming Service" );
- }
- try{
- SALOME_ContainerManager *cmServ=new SALOME_ContainerManager(orb);
- pman->activate();
- orb->run();
- }catch(CORBA::SystemException&){
- MESSAGE("Caught CORBA::SystemException.");
- }catch(PortableServer::POA::WrongPolicy&){
- MESSAGE("Caught CORBA::WrongPolicyException.");
- }catch(PortableServer::POA::ServantAlreadyActive&){
- MESSAGE("Caught CORBA::ServantAlreadyActiveException");
- }catch(CORBA::Exception&){
- MESSAGE("Caught CORBA::Exception.");
- }catch(std::exception& exc){
- MESSAGE("Caught std::exception - "<<exc.what());
- }catch(...){
- MESSAGE("Caught unknown exception.");
- }
- END_OF(argv[0]);
- // delete myThreadTrace;
-}
-
--- /dev/null
+# SALOME Container : implementation of container and engine for Kernel
+#
+# Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+#
+#
+# File : Makefile.am
+# Author : Guillaume Boulant (CSSI)
+# Module : KERNEL
+# $Header$
+
+
+include $(top_srcdir)/salome_adm/unix/make_common_starter.am
+
+#
+# ===============================================================
+# Header to be installed
+# ===============================================================
+#
+# header files
+salomeinclude_HEADERS = \
+ SALOME_Launcher.hxx
+
+# Scripts to be installed
+dist_salomescript_DATA =
+
+# These files are executable scripts
+dist_salomescript_SCRIPTS=
+
+#
+# ===============================================================
+# Local definitions
+# ===============================================================
+#
+
+# This local variable defines the list of CPPFLAGS common to all target in this package.
+COMMON_CPPFLAGS=\
+ @PYTHON_INCLUDES@ \
+ @MPI_INCLUDES@ \
+ @CAS_CPPFLAGS@ @CAS_CXXFLAGS@ \
+ @QT_MT_INCLUDES@ \
+ -I$(srcdir)/../Batch \
+ -I$(srcdir)/../Basics \
+ -I$(srcdir)/../SALOMELocalTrace \
+ -I$(srcdir)/../NamingService \
+ -I$(srcdir)/../Utils \
+ -I$(srcdir)/../Registry \
+ -I$(srcdir)/../Notification \
+ -I$(srcdir)/../ResourcesManager \
+ -I$(srcdir)/../Container \
+ -I$(top_builddir)/salome_adm/unix \
+ -I$(top_builddir)/idl \
+ @CORBA_CXXFLAGS@ @CORBA_INCLUDES@
+
+# This local variable defines the list of dependant libraries common to all target in this package.
+COMMON_LIBS =\
+ ../Registry/libRegistry.la \
+ ../Notification/libSalomeNotification.la \
+ ../Container/libSalomeContainer.la \
+ ../ResourcesManager/libSalomeResourcesManager.la \
+ ../NamingService/libSalomeNS.la \
+ ../Utils/libOpUtil.la \
+ ../SALOMELocalTrace/libSALOMELocalTrace.la \
+ ../Basics/libSALOMEBasics.la \
+ ../Batch/libSalomeBatch.la \
+ $(top_builddir)/idl/libSalomeIDLKernel.la\
+ @MPI_LIBS@ \
+ @CORBA_LIBS@
+
+# @PYTHON_LIBS@
+
+#
+# ===============================================================
+# Libraries targets
+# ===============================================================
+#
+lib_LTLIBRARIES = libSalomeLauncher.la
+libSalomeLauncher_la_SOURCES=\
+ SALOME_Launcher.cxx
+
+libSalomeLauncher_la_CPPFLAGS =\
+ $(COMMON_CPPFLAGS)
+
+libSalomeLauncher_la_LDFLAGS =\
+ -no-undefined -version-info=0:0:0 \
+ @LDEXPDYNFLAGS@
+
+libSalomeLauncher_la_LIBADD =\
+ $(PYTHON_LIBS) \
+ $(COMMON_LIBS)
+
+
+#
+# ===============================================================
+# Executables targets
+# ===============================================================
+#
+bin_PROGRAMS = SALOME_LauncherServer
+
+SALOME_LauncherServer_SOURCES =\
+ SALOME_LauncherServer.cxx
+
+SALOME_LauncherServer_CPPFLAGS=\
+ $(COMMON_CPPFLAGS)
+
+SALOME_LauncherServer_LDADD =\
+ libSalomeLauncher.la \
+ $(COMMON_LIBS) \
+ ../Basics/libSALOMEBasics.la \
+ ../Batch/libSalomeBatch.la
+
+
--- /dev/null
+// Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+#include "BatchLight_BatchManager_PBS.hxx"
+#include "BatchLight_BatchManager_SLURM.hxx"
+#include "BatchLight_Job.hxx"
+#include "SALOME_Launcher.hxx"
+#include "OpUtil.hxx"
+#include <sys/types.h>
+#ifndef WNT
+#include <unistd.h>
+#endif
+#include <vector>
+#include "Utils_CorbaException.hxx"
+#include "Batch_Date.hxx"
+
+#define TIME_OUT_TO_LAUNCH_CONT 21
+
+using namespace std;
+
+const char *SALOME_Launcher::_LauncherNameInNS = "/SalomeLauncher";
+
+//=============================================================================
+/*!
+ * Constructor
+ * \param orb
+ * Define a CORBA single thread policy for the server, which avoid to deal
+ * with non thread-safe usage like Change_Directory in SALOME naming service
+ */
+//=============================================================================
+
+SALOME_Launcher::SALOME_Launcher(CORBA::ORB_ptr orb, PortableServer::POA_var poa)
+{
+ MESSAGE("constructor");
+ _NS = new SALOME_NamingService(orb);
+ _ResManager = new SALOME_ResourcesManager(orb,poa,_NS);
+ _ContManager = new SALOME_ContainerManager(orb,poa,_ResManager,_NS);
+
+ _orb = CORBA::ORB::_duplicate(orb) ;
+ _poa = PortableServer::POA::_duplicate(poa) ;
+ PortableServer::ObjectId_var id = _poa->activate_object(this);
+ CORBA::Object_var obj = _poa->id_to_reference(id);
+ Engines::SalomeLauncher_var refContMan = Engines::SalomeLauncher::_narrow(obj);
+
+ _NS->Register(refContMan,_LauncherNameInNS);
+ MESSAGE("constructor end");
+}
+
+//=============================================================================
+/*!
+ * destructor
+ */
+//=============================================================================
+
+SALOME_Launcher::~SALOME_Launcher()
+{
+ MESSAGE("destructor");
+ delete _NS;
+ delete _ResManager;
+ delete _ContManager;
+ std::map < string, BatchLight::BatchManager * >::const_iterator it;
+ for(it=_batchmap.begin();it!=_batchmap.end();it++)
+ delete it->second;
+}
+
+//=============================================================================
+/*! CORBA method:
+ * shutdown all the containers, then the ContainerManager servant
+ */
+//=============================================================================
+
+void SALOME_Launcher::Shutdown()
+{
+ MESSAGE("Shutdown");
+ _NS->Destroy_Name(_LauncherNameInNS);
+ _ContManager->Shutdown();
+ _ResManager->Shutdown();
+ PortableServer::ObjectId_var oid = _poa->servant_to_id(this);
+ _poa->deactivate_object(oid);
+ _remove_ref();
+ if(!CORBA::is_nil(_orb))
+ _orb->shutdown(0);
+}
+
+//=============================================================================
+/*! CORBA Method:
+ * Submit a batch job on a cluster and returns the JobId
+ * \param fileToExecute : .py/.exe/.sh/... to execute on the batch cluster
+ * \param filesToExport : to export on the batch cluster
+ * \param NumberOfProcessors : Number of processors needed on the batch cluster
+ * \param params : Constraints for the choice of the batch cluster
+ */
+//=============================================================================
+CORBA::Long SALOME_Launcher::submitSalomeJob( const char * fileToExecute ,
+ const Engines::FilesList& filesToExport ,
+ const Engines::FilesList& filesToImport ,
+ const CORBA::Long NumberOfProcessors ,
+ const Engines::MachineParameters& params)
+{
+ MESSAGE("BEGIN OF SALOME_Launcher::submitSalomeJob");
+ CORBA::Long jobId;
+ try{
+ // find a cluster matching the structure params
+ Engines::CompoList aCompoList ;
+ Engines::MachineList *aMachineList = _ResManager->GetFittingResources( params , aCompoList ) ;
+ const Engines::MachineParameters* p = _ResManager->GetMachineParameters((*aMachineList)[0]);
+ string clustername(p->alias);
+
+ // search batch manager for that cluster in map or instanciate one
+ std::map < string, BatchLight::BatchManager * >::const_iterator it = _batchmap.find(clustername);
+ SCRUTE(clustername);
+ if(it == _batchmap.end())
+ _batchmap[clustername] = FactoryBatchManager( p );
+
+ // submit job on cluster
+ BatchLight::Job* job = new BatchLight::Job( fileToExecute, filesToExport, filesToImport, NumberOfProcessors );
+ jobId = _batchmap[clustername]->submitJob(job);
+ }
+ catch(const SALOME_Exception &ex){
+ MESSAGE(ex.what());
+ THROW_SALOME_CORBA_EXCEPTION(ex.what(),SALOME::INTERNAL_ERROR);
+ }
+ return jobId;
+}
+
+//=============================================================================
+/*! CORBA Method:
+ * Query a batch job on a cluster and returns the status of job
+ * \param jobId : identification of Salome job
+ * \param params : Constraints for the choice of the batch cluster
+ */
+//=============================================================================
+char* SALOME_Launcher::querySalomeJob( const CORBA::Long jobId,
+ const Engines::MachineParameters& params)
+{
+ string status;
+ try{
+ // find a cluster matching params structure
+ Engines::CompoList aCompoList ;
+ Engines::MachineList * aMachineList = _ResManager->GetFittingResources( params , aCompoList ) ;
+ const Engines::MachineParameters* p = _ResManager->GetMachineParameters((*aMachineList)[0]);
+ string clustername(p->alias);
+
+ // search batch manager for that cluster in map
+ std::map < string, BatchLight::BatchManager * >::const_iterator it = _batchmap.find(clustername);
+ if(it == _batchmap.end())
+ throw SALOME_Exception("no batchmanager for that cluster");
+
+ status = _batchmap[clustername]->queryJob(jobId);
+ }
+ catch(const SALOME_Exception &ex){
+ INFOS("Caught exception.");
+ THROW_SALOME_CORBA_EXCEPTION(ex.what(),SALOME::BAD_PARAM);
+ }
+ return CORBA::string_dup(status.c_str());
+}
+
+//=============================================================================
+/*! CORBA Method:
+ * Delete a batch job on a cluster
+ * \param jobId : identification of Salome job
+ * \param params : Constraints for the choice of the batch cluster
+ */
+//=============================================================================
+void SALOME_Launcher::deleteSalomeJob( const CORBA::Long jobId,
+ const Engines::MachineParameters& params)
+{
+ try{
+ // find a cluster matching params structure
+ Engines::CompoList aCompoList ;
+ Engines::MachineList *aMachineList = _ResManager->GetFittingResources( params , aCompoList ) ;
+ const Engines::MachineParameters* p = _ResManager->GetMachineParameters((*aMachineList)[0]);
+ string clustername(p->alias);
+
+ // search batch manager for that cluster in map
+ std::map < string, BatchLight::BatchManager * >::const_iterator it = _batchmap.find(clustername);
+ if(it == _batchmap.end())
+ throw SALOME_Exception("no batchmanager for that cluster");
+
+ _batchmap[clustername]->deleteJob(jobId);
+ }
+ catch(const SALOME_Exception &ex){
+ INFOS("Caught exception.");
+ THROW_SALOME_CORBA_EXCEPTION(ex.what(),SALOME::BAD_PARAM);
+ }
+}
+
+//=============================================================================
+/*! CORBA Method:
+ * Get result files of job on a cluster
+ * \param jobId : identification of Salome job
+ * \param params : Constraints for the choice of the batch cluster
+ */
+//=============================================================================
+void SALOME_Launcher::getResultSalomeJob( const char *directory,
+ const CORBA::Long jobId,
+ const Engines::MachineParameters& params)
+{
+ try{
+ // find a cluster matching params structure
+ Engines::CompoList aCompoList ;
+ Engines::MachineList *aMachineList = _ResManager->GetFittingResources( params , aCompoList ) ;
+ const Engines::MachineParameters* p = _ResManager->GetMachineParameters((*aMachineList)[0]);
+ string clustername(p->alias);
+
+ // search batch manager for that cluster in map
+ std::map < string, BatchLight::BatchManager * >::const_iterator it = _batchmap.find(clustername);
+ if(it == _batchmap.end())
+ throw SALOME_Exception("no batchmanager for that cluster");
+
+ _batchmap[clustername]->importOutputFiles( directory, jobId );
+ }
+ catch(const SALOME_Exception &ex){
+ INFOS("Caught exception.");
+ THROW_SALOME_CORBA_EXCEPTION(ex.what(),SALOME::BAD_PARAM);
+ }
+}
+
+//=============================================================================
+/*!
+ * Factory to instanciate the good batch manager for choosen cluster.
+ */
+//=============================================================================
+
+BatchLight::BatchManager *SALOME_Launcher::FactoryBatchManager( const Engines::MachineParameters* params ) throw(SALOME_Exception)
+{
+ // Fill structure for batch manager
+ BatchLight::batchParams p;
+ p.hostname = params->alias;
+ p.protocol = params->protocol;
+ p.username = params->username;
+ p.applipath = params->applipath;
+ for(int i=0;i<params->modList.length();i++)
+ p.modulesList.push_back((const char*)params->modList[i]);
+ p.nbnodes = params->nb_node;
+ p.nbprocpernode = params->nb_proc_per_node;
+ p.mpiImpl = params->mpiImpl;
+
+ string sb = (const char*)params->batch;
+ if(sb == "pbs")
+ return new BatchLight::BatchManager_PBS(p);
+ else if(sb == "slurm")
+ return new BatchLight::BatchManager_SLURM(p);
+ else{
+ MESSAGE("BATCH = " << params->batch);
+ throw SALOME_Exception("no batchmanager for that cluster");
+ }
+}
+
--- /dev/null
+// Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+#ifndef __SALOME_LAUNCHER_HXX__
+#define __SALOME_LAUNCHER_HXX__
+
+#include <SALOMEconfig.h>
+#include CORBA_CLIENT_HEADER(SALOME_ContainerManager)
+#include "SALOME_ContainerManager.hxx"
+#include "BatchLight_BatchManager.hxx"
+
+#include <string>
+
+class SALOME_NamingService;
+
+#if defined LAUNCHER_EXPORTS
+#if defined WIN32
+#define LAUNCHER_EXPORT __declspec( dllexport )
+#else
+#define LAUNCHER_EXPORT
+#endif
+#else
+#if defined WNT
+#define LAUNCHER_EXPORT __declspec( dllimport )
+#else
+#define LAUNCHER_EXPORT
+#endif
+#endif
+
+class LAUNCHER_EXPORT SALOME_Launcher:
+ public POA_Engines::SalomeLauncher,
+ public PortableServer::RefCountServantBase
+{
+
+public:
+ SALOME_Launcher(CORBA::ORB_ptr orb, PortableServer::POA_var poa);
+ ~SALOME_Launcher();
+
+ CORBA::Long submitSalomeJob(const char * fileToExecute ,
+ const Engines::FilesList& filesToExport ,
+ const Engines::FilesList& filesToImport ,
+ const CORBA::Long NumberOfProcessors ,
+ const Engines::MachineParameters& params);
+
+ char* querySalomeJob( const CORBA::Long jobId, const Engines::MachineParameters& params);
+ void deleteSalomeJob( const CORBA::Long jobId, const Engines::MachineParameters& params);
+ void getResultSalomeJob( const char * directory, const CORBA::Long jobId, const Engines::MachineParameters& params );
+
+ void Shutdown();
+
+ static const char *_LauncherNameInNS;
+
+protected:
+ BatchLight::BatchManager *FactoryBatchManager( const Engines::MachineParameters* params ) throw(SALOME_Exception);
+
+ std::map <std::string,BatchLight::BatchManager*> _batchmap;
+ CORBA::ORB_var _orb;
+ PortableServer::POA_var _poa;
+ SALOME_ContainerManager *_ContManager;
+ SALOME_ResourcesManager *_ResManager;
+ SALOME_NamingService *_NS;
+};
+
+#endif
--- /dev/null
+// Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+#include "SALOME_Launcher.hxx"
+#include "utilities.h"
+
+int main(int argc, char* argv[])
+{
+ PortableServer::POA_var root_poa;
+ PortableServer::POAManager_var pman;
+ CORBA::Object_var obj;
+
+ CORBA::ORB_ptr orb = CORBA::ORB_init( argc , argv ) ;
+ // LocalTraceCollector *myThreadTrace = SALOMETraceCollector::instance(orb);
+ INFOS_COMPILATION;
+ BEGIN_OF(argv[0]);
+ try{
+ obj = orb->resolve_initial_references("RootPOA");
+ if(!CORBA::is_nil(obj))
+ root_poa = PortableServer::POA::_narrow(obj);
+ if(!CORBA::is_nil(root_poa))
+ pman = root_poa->the_POAManager();
+ }
+ catch(CORBA::COMM_FAILURE&){
+ MESSAGE( "Container: CORBA::COMM_FAILURE: Unable to contact the Naming Service" );
+ }
+ try{
+ SALOME_Launcher *lServ=new SALOME_Launcher(orb,root_poa);
+ pman->activate();
+ orb->run();
+ }catch(CORBA::SystemException&){
+ MESSAGE("Caught CORBA::SystemException.");
+ }catch(PortableServer::POA::WrongPolicy&){
+ MESSAGE("Caught CORBA::WrongPolicyException.");
+ }catch(PortableServer::POA::ServantAlreadyActive&){
+ MESSAGE("Caught CORBA::ServantAlreadyActiveException");
+ }catch(CORBA::Exception&){
+ MESSAGE("Caught CORBA::Exception.");
+ }catch(std::exception& exc){
+ MESSAGE("Caught std::exception - "<<exc.what());
+ }catch(...){
+ MESSAGE("Caught unknown exception.");
+ }
+ END_OF(argv[0]);
+ // delete myThreadTrace;
+}
+
SALOME_LifeCycleCORBA LCC;
Engines::ContainerManager_var contManager = LCC.getContainerManager();
+ Engines::ResourcesManager_var resManager = LCC.getResourcesManager();
Engines::MachineParameters params;
LCC.preSet(params);
Engines::CompoList clist;
Engines::MachineList_var listOfMachines =
- contManager->GetFittingResources(params, clist);
+ resManager->GetFittingResources(params, clist);
container = contManager->FindOrStartContainer(params,
listOfMachines);
_NS->Resolve(SALOME_ContainerManager::_ContainerManagerNameInNS);
ASSERT( !CORBA::is_nil(obj));
_ContManager=Engines::ContainerManager::_narrow(obj);
+
+ obj = _NS->Resolve(SALOME_ResourcesManager::_ResourcesManagerNameInNS);
+ ASSERT( !CORBA::is_nil(obj));
+ _ResManager=Engines::ResourcesManager::_narrow(obj);
}
//=============================================================================
clist.length(1);
clist[0] = componentName;
Engines::MachineList_var listOfMachines =
- _ContManager->GetFittingResources(params, clist);
+ _ResManager->GetFittingResources(params, clist);
Engines::Component_var compo = _FindComponent(params,
componentName,
clist.length(1);
clist[0] = componentName;
Engines::MachineList_var listOfMachines =
- _ContManager->GetFittingResources(params, clist);
+ _ResManager->GetFittingResources(params, clist);
Engines::Component_var compo = _LoadComponent(params,
componentName,
clist.length(1);
clist[0] = componentName;
Engines::MachineList_var listOfMachines =
- _ContManager->GetFittingResources(params,clist);
+ _ResManager->GetFittingResources(params,clist);
Engines::Component_var compo = _FindComponent(params,
componentName,
return contManager._retn();
}
+//=============================================================================
+/*! Public -
+ * \return the container Manager
+ */
+//=============================================================================
+
+Engines::ResourcesManager_ptr SALOME_LifeCycleCORBA::getResourcesManager()
+{
+ Engines::ResourcesManager_var resManager =
+ Engines::ResourcesManager::_duplicate(_ResManager);
+ return resManager._retn();
+}
+
//=============================================================================
/*! Protected -
if(lghtOfmachinesOK != 0)
{
machinesOK->length(lghtOfmachinesOK);
- CORBA::String_var bestMachine = _ContManager->FindFirst(machinesOK);
+ CORBA::String_var bestMachine = _ResManager->FindFirst(machinesOK);
CORBA::Object_var obj = _NS->ResolveComponent(bestMachine,
containerName,
componentName,
void preSet(Engines::MachineParameters& params);
Engines::ContainerManager_ptr getContainerManager();
+ Engines::ResourcesManager_ptr getResourcesManager();
protected:
SALOME_NamingService *_NS;
Engines::ContainerManager_var _ContManager;
+ Engines::ResourcesManager_var _ResManager;
} ;
{
SALOME_LifeCycleCORBA _LCC(&_NS);
- CORBA::Object_var obj = _NS.Resolve("/ContainerManager");
+ CORBA::Object_var obj = _NS.Resolve("/ResourcesManager");
CPPUNIT_ASSERT(!CORBA::is_nil(obj));
- Engines::ContainerManager_var containerManager =
- Engines::ContainerManager::_narrow(obj);
- CPPUNIT_ASSERT(!CORBA::is_nil(containerManager));
+ Engines::ResourcesManager_var resourcesManager =
+ Engines::ResourcesManager::_narrow(obj);
+ CPPUNIT_ASSERT(!CORBA::is_nil(resourcesManager));
Engines::MachineParameters params;
_LCC.preSet(params); // empty params to get all the machines
clist.length(1);
clist[0] = "SalomeTestComponent";
Engines::MachineList_var hostList =
- containerManager->GetFittingResources(params,clist);
+ resourcesManager->GetFittingResources(params,clist);
CPPUNIT_ASSERT(hostList->length() > 1);
string localHost = GetHostname();
cataServer.run()
clt.waitNS("/Kernel/ModulCatalog")
-# launch container manager server
+# launch launcher server
-myCmServer = runSalome.ContainerManagerServer(args)
+myCmServer = runSalome.LauncherServer(args)
myCmServer.setpath(modules_list,modules_root_dir)
myCmServer.run()
-clt.waitNS("/ContainerManager")
+clt.waitNS("/SalomeLauncher")
# execute Unit Test
# kill containers created by the Container Manager
import Engines
-containerManager = clt.waitNS("/ContainerManager",Engines.ContainerManager)
-containerManager.Shutdown()
+launcher = clt.waitNS("/SalomeLauncher",Engines.SalomeLauncher)
+launcher.Shutdown()
# kill Test process
CORBA::Object_var obj = _NS->Resolve(SALOME_ContainerManager::_ContainerManagerNameInNS);
ASSERT( !CORBA::is_nil(obj));
Engines::ContainerManager_var _ContManager=Engines::ContainerManager::_narrow(obj);
+ obj = _NS->Resolve(SALOME_ResourcesManager::_ResourcesManagerNameInNS);
+ ASSERT( !CORBA::is_nil(obj));
+ Engines::ResourcesManager_var _ResManager=Engines::ResourcesManager::_narrow(obj);
Engines::MachineParameters p;
Engines::CompoList clist;
int nbpmax;
for(map<string,int>::iterator iter=cycle.begin();iter!=cycle.end();iter++){
if(strcmp((*iter).first.c_str(),"localhost")!=0){
- Engines::MachineParameters *p = _ContManager->GetMachineParameters((*iter).first.c_str());
+ Engines::MachineParameters *p = _ResManager->GetMachineParameters((*iter).first.c_str());
int nbproc = p->nb_node * p->nb_proc_per_node;
if(cycle[(*iter).first]/nbproc<cmin) cmin=cycle[(*iter).first]/nbproc;
if(cycle[(*iter).first]/nbproc>cmax) cmax=cycle[(*iter).first]/nbproc;
# launch container manager server
-myCmServer = runSalome.ContainerManagerServer(args)
+myCmServer = runSalome.LauncherServer(args)
myCmServer.setpath(modules_list,modules_root_dir)
myCmServer.run()
-clt.waitNS("/ContainerManager")
+clt.waitNS("/SalomeLauncher")
# execute Unit Test
# kill containers created by the Container Manager
import Engines
-containerManager = clt.waitNS("/ContainerManager",Engines.ContainerManager)
-containerManager.Shutdown()
+launcher = clt.waitNS("/SalomeLauncher",Engines.SalomeLauncher)
+launcher.Shutdown()
# kill Test process
NOTIFICATION_SWIG \
Container \
TestContainer \
+ Launcher \
LifeCycleCORBA \
LifeCycleCORBA_SWIG \
SALOMEDSClient \
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
-#include "BatchLight_BatchManager_PBS.hxx"
-#include "BatchLight_BatchManager_SLURM.hxx"
#include "SALOME_ResourcesManager.hxx"
-#include "BatchLight_Job.hxx"
#include "Utils_ExceptHandlers.hxx"
+#include "Utils_CorbaException.hxx"
#include "OpUtil.hxx"
#include <qdom.h>
using namespace std;
+const char *SALOME_ResourcesManager::_ResourcesManagerNameInNS = "/ResourcesManager";
+
//=============================================================================
/*!
* just for test
//=============================================================================
SALOME_ResourcesManager::
-SALOME_ResourcesManager(CORBA::ORB_ptr orb,
+SALOME_ResourcesManager(CORBA::ORB_ptr orb,
+ PortableServer::POA_var poa,
+ SALOME_NamingService *ns,
const char *xmlFilePath) :
_path_resources(xmlFilePath)
{
- _NS = new SALOME_NamingService(orb);
+ MESSAGE("constructor");
+ _NS = ns;
+ _orb = CORBA::ORB::_duplicate(orb) ;
+ _poa = PortableServer::POA::_duplicate(poa) ;
+ PortableServer::ObjectId_var id = _poa->activate_object(this);
+ CORBA::Object_var obj = _poa->id_to_reference(id);
+ Engines::SalomeLauncher_var refContMan =
+ Engines::SalomeLauncher::_narrow(obj);
+
+ _NS->Register(refContMan,_ResourcesManagerNameInNS);
+ MESSAGE("constructor end");
}
//=============================================================================
*/
//=============================================================================
-SALOME_ResourcesManager::SALOME_ResourcesManager(CORBA::ORB_ptr orb)
+SALOME_ResourcesManager::SALOME_ResourcesManager(CORBA::ORB_ptr orb,
+ PortableServer::POA_var poa,
+ SALOME_NamingService *ns)
{
- _NS = new SALOME_NamingService(orb);
+ MESSAGE("constructor");
+ _NS = ns;
+ _orb = CORBA::ORB::_duplicate(orb) ;
+ _poa = PortableServer::POA::_duplicate(poa) ;
+ PortableServer::ObjectId_var id = _poa->activate_object(this);
+ CORBA::Object_var obj = _poa->id_to_reference(id);
+ Engines::ResourcesManager_var refContMan = Engines::ResourcesManager::_narrow(obj);
+ _NS->Register(refContMan,_ResourcesManagerNameInNS);
+
_isAppliSalomeDefined = (getenv("APPLI") != 0);
if (_isAppliSalomeDefined)
}
ParseXmlFile();
+ MESSAGE("constructor end");
}
//=============================================================================
SALOME_ResourcesManager::~SALOME_ResourcesManager()
{
- delete _NS;
- std::map < string, BatchLight::BatchManager * >::const_iterator it;
- for(it=_batchmap.begin();it!=_batchmap.end();it++)
- delete it->second;
+ MESSAGE("destructor");
+}
+
+
+//=============================================================================
+/*! CORBA method:
+ * shutdown all the containers, then the ContainerManager servant
+ */
+//=============================================================================
+
+void SALOME_ResourcesManager::Shutdown()
+{
+ MESSAGE("Shutdown");
+ _NS->Destroy_Name(_ResourcesManagerNameInNS);
+ PortableServer::ObjectId_var oid = _poa->servant_to_id(this);
+ _poa->deactivate_object(oid);
+ _remove_ref();
}
//=============================================================================
*/
//=============================================================================
-vector<string>
-SALOME_ResourcesManager::
-GetFittingResources(const Engines::MachineParameters& params,
- const Engines::CompoList& componentList)
+Engines::MachineList *
+SALOME_ResourcesManager::GetFittingResources(const Engines::MachineParameters& params,
+ const Engines::CompoList& componentList)
throw(SALOME_Exception)
{
// MESSAGE("ResourcesManager::GetFittingResources");
- vector <std::string> ret;
+ vector <std::string> vec;
+ Engines::MachineList *ret=new Engines::MachineList;
+ try{
+ // --- To be sure that we search in a correct list.
+ ParseXmlFile();
- // --- To be sure that we search in a correct list.
- ParseXmlFile();
-
- const char *hostname = (const char *)params.hostname;
- MESSAGE("GetFittingResources " << hostname << " " << GetHostname().c_str());
+ const char *hostname = (const char *)params.hostname;
+ MESSAGE("GetFittingResources " << hostname << " " << GetHostname().c_str());
- if (hostname[0] != '\0')
- {
+ if (hostname[0] != '\0')
+ {
// MESSAGE("ResourcesManager::GetFittingResources : hostname specified" );
- if ( strcmp(hostname, "localhost") == 0 ||
- strcmp(hostname, GetHostname().c_str()) == 0 )
- {
-// MESSAGE("ResourcesManager::GetFittingResources : localhost" );
- ret.push_back(GetHostname().c_str());
-// MESSAGE("ResourcesManager::GetFittingResources : " << ret.size());
- }
-
- else if (_resourcesList.find(hostname) != _resourcesList.end())
- {
- // --- params.hostname is in the list of resources so return it.
- ret.push_back(hostname);
- }
-
- else
- {
-// Cas d'un cluster: nombre de noeuds > 1
- int cpt=0;
- for (map<string, ParserResourcesType>::const_iterator iter = _resourcesList.begin(); iter != _resourcesList.end(); iter++){
- if( (*iter).second.DataForSort._nbOfNodes > 1 ){
- if( strncmp(hostname,(*iter).first.c_str(),strlen(hostname)) == 0 ){
- ret.push_back((*iter).first.c_str());
- //cout << "SALOME_ResourcesManager::GetFittingResources vector["
- // << cpt << "] = " << (*iter).first.c_str() << endl ;
- cpt++;
- }
- }
- }
- if(cpt==0){
- // --- user specified an unknown hostame so notify him.
- MESSAGE("ResourcesManager::GetFittingResources : SALOME_Exception");
- throw SALOME_Exception("unknown host");
- }
- }
- }
+ if ( strcmp(hostname, "localhost") == 0 ||
+ strcmp(hostname, GetHostname().c_str()) == 0 )
+ {
+ // MESSAGE("ResourcesManager::GetFittingResources : localhost" );
+ vec.push_back(GetHostname().c_str());
+ // MESSAGE("ResourcesManager::GetFittingResources : " << vec.size());
+ }
+
+ else if (_resourcesList.find(hostname) != _resourcesList.end())
+ {
+ // --- params.hostname is in the list of resources so return it.
+ vec.push_back(hostname);
+ }
+
+ else
+ {
+ // Cas d'un cluster: nombre de noeuds > 1
+ int cpt=0;
+ for (map<string, ParserResourcesType>::const_iterator iter = _resourcesList.begin(); iter != _resourcesList.end(); iter++){
+ if( (*iter).second.DataForSort._nbOfNodes > 1 ){
+ if( strncmp(hostname,(*iter).first.c_str(),strlen(hostname)) == 0 ){
+ vec.push_back((*iter).first.c_str());
+ //cout << "SALOME_ResourcesManager::GetFittingResources vector["
+ // << cpt << "] = " << (*iter).first.c_str() << endl ;
+ cpt++;
+ }
+ }
+ }
+ if(cpt==0){
+ // --- user specified an unknown hostame so notify him.
+ MESSAGE("ResourcesManager::GetFittingResources : SALOME_Exception");
+ throw SALOME_Exception("unknown host");
+ }
+ }
+ }
+
+ else
+ // --- Search for available resources sorted by priority
+ {
+ SelectOnlyResourcesWithOS(vec, params.OS);
+
+ KeepOnlyResourcesWithModule(vec, componentList);
+
+ if (vec.size() == 0)
+ SelectOnlyResourcesWithOS(vec, params.OS);
+
+ // --- set wanted parameters
+ ResourceDataToSort::_nbOfNodesWanted = params.nb_node;
+
+ ResourceDataToSort::_nbOfProcPerNodeWanted = params.nb_proc_per_node;
+
+ ResourceDataToSort::_CPUFreqMHzWanted = params.cpu_clock;
+
+ ResourceDataToSort::_memInMBWanted = params.mem_mb;
+
+ // --- end of set
+
+ list<ResourceDataToSort> li;
+
+ for (vector<string>::iterator iter = vec.begin();
+ iter != vec.end();
+ iter++)
+ li.push_back(_resourcesList[(*iter)].DataForSort);
+
+ li.sort();
+
+ unsigned int i = 0;
+
+ for (list<ResourceDataToSort>::iterator iter2 = li.begin();
+ iter2 != li.end();
+ iter2++)
+ vec[i++] = (*iter2)._hostName;
+ }
+
+ // MESSAGE("ResourcesManager::GetFittingResources : return" << ret.size());
+ ret->length(vec.size());
+ for(unsigned int i=0;i<vec.size();i++)
+ (*ret)[i]=(vec[i]).c_str();
- else
- // --- Search for available resources sorted by priority
+ }
+ catch(const SALOME_Exception &ex)
{
- SelectOnlyResourcesWithOS(ret, params.OS);
-
- KeepOnlyResourcesWithModule(ret, componentList);
-
- if (ret.size() == 0)
- SelectOnlyResourcesWithOS(ret, params.OS);
-
- // --- set wanted parameters
- ResourceDataToSort::_nbOfNodesWanted = params.nb_node;
-
- ResourceDataToSort::_nbOfProcPerNodeWanted = params.nb_proc_per_node;
-
- ResourceDataToSort::_CPUFreqMHzWanted = params.cpu_clock;
-
- ResourceDataToSort::_memInMBWanted = params.mem_mb;
-
- // --- end of set
-
- list<ResourceDataToSort> li;
-
- for (vector<string>::iterator iter = ret.begin();
- iter != ret.end();
- iter++)
- li.push_back(_resourcesList[(*iter)].DataForSort);
-
- li.sort();
-
- unsigned int i = 0;
-
- for (list<ResourceDataToSort>::iterator iter2 = li.begin();
- iter2 != li.end();
- iter2++)
- ret[i++] = (*iter2)._hostName;
- }
+ INFOS("Caught exception.");
+ THROW_SALOME_CORBA_EXCEPTION(ex.what(),SALOME::BAD_PARAM);
+ //return ret;
+ }
- // MESSAGE("ResourcesManager::GetFittingResources : return" << ret.size());
return ret;
}
*/
//=============================================================================
-string
+char *
SALOME_ResourcesManager::FindFirst(const Engines::MachineList& listOfMachines)
{
- return _dynamicResourcesSelecter.FindFirst(listOfMachines);
+ return CORBA::string_dup(_dynamicResourcesSelecter.FindFirst(listOfMachines).c_str());
}
//=============================================================================
return _dynamicResourcesSelecter.FindBest(listOfMachines);
}
-
-
//=============================================================================
/*!
* This is no longer valid (C++ container are also python containers)
return command;
}
-//=============================================================================
-/*! CORBA Method:
- * Submit a batch job on a cluster and returns the JobId
- * \param fileToExecute : .py/.exe/.sh/... to execute on the batch cluster
- * \param filesToExport : to export on the batch cluster
- * \param filesToExport : to import from the batch cluster after job
- * \param NumberOfProcessors : Number of processors needed on the batch cluster
- * \param params : Constraints for the choice of the batch cluster
- */
-//=============================================================================
-CORBA::Long SALOME_ResourcesManager::submitSalomeJob( const char * fileToExecute ,
- const Engines::FilesList& filesToExport ,
- const Engines::FilesList& filesToImport ,
- const CORBA::Long NumberOfProcessors ,
- const Engines::MachineParameters& params) throw(SALOME_Exception)
-{
- BEGIN_OF("SALOME_ResourcesManager::submitSalomeJob");
- CORBA::Long jobId;
-
- // find a cluster matching the structure params
- Engines::CompoList aCompoList ;
- vector<string> aMachineList = GetFittingResources( params , aCompoList ) ;
- const ParserResourcesType& resInfo = _resourcesList[aMachineList[0]];
- string clustername = resInfo.Alias;
-
- // search batch manager for that cluster in map or instanciate one
- std::map < string, BatchLight::BatchManager * >::const_iterator it = _batchmap.find(clustername);
- if(it == _batchmap.end())
- _batchmap[clustername] = FactoryBatchManager( resInfo );
-
- // submit job on cluster
- BatchLight::Job* job = new BatchLight::Job( fileToExecute, filesToExport, filesToImport, NumberOfProcessors );
- jobId = _batchmap[clustername]->submitJob(job);
-
- return(jobId);
- END_OF("SALOME_ResourcesManager::submitSalomeJob");
-}
-
-//=============================================================================
-/*!
- * Factory to instanciate the good batch manager for choosen cluster.
- */
-//=============================================================================
-
-BatchLight::BatchManager *SALOME_ResourcesManager::FactoryBatchManager( const ParserResourcesType& resInfo ) throw(SALOME_Exception)
-{
- // Fill structure for batch manager
- BatchLight::batchParams p;
- p.hostname = resInfo.Alias;
- if( resInfo.Protocol == rsh )
- p.protocol = "rsh";
- else if( resInfo.Protocol == ssh )
- p.protocol = "ssh";
- else
- throw SALOME_Exception("Unknown protocol");
- p.username = resInfo.UserName;
- p.applipath = resInfo.AppliPath;
- p.modulesList = resInfo.ModulesList;
- p.nbnodes = resInfo.DataForSort._nbOfNodes;
- p.nbprocpernode = resInfo.DataForSort._nbOfProcPerNode;
- if( resInfo.mpi == indif )
- p.mpiImpl = "indif";
- else if( resInfo.mpi == lam )
- p.mpiImpl = "lam";
- else if( resInfo.mpi == mpich1 )
- p.mpiImpl = "mpich1";
- else if( resInfo.mpi == mpich2 )
- p.mpiImpl = "mpich2";
- else if( resInfo.mpi == openmpi )
- p.mpiImpl = "openmpi";
- else
- throw SALOME_Exception("Unknown mpi implementation");
-
- switch( resInfo.Batch ){
- case pbs:
- return new BatchLight::BatchManager_PBS(p);
- case slurm:
- return new BatchLight::BatchManager_SLURM(p);
- default:
- MESSAGE("BATCH = " << resInfo.Batch);
- throw SALOME_Exception("no batchmanager for that cluster");
- }
-}
-
-//=============================================================================
-/*! CORBA Method:
- * query a batch job on a cluster and returns the status of the job
- * \param jobId : identification of Salome job
- * \param params : Constraints for the choice of the batch cluster
- */
-//=============================================================================
-string SALOME_ResourcesManager::querySalomeJob( const CORBA::Long jobId, const Engines::MachineParameters& params) throw(SALOME_Exception)
-{
- string status;
-
- // find a cluster matching params structure
- Engines::CompoList aCompoList ;
- vector<string> aMachineList = GetFittingResources( params , aCompoList ) ;
- const ParserResourcesType& resInfo = _resourcesList[aMachineList[0]];
- string clustername = resInfo.Alias;
-
- // search batch manager for that cluster in map
- std::map < string, BatchLight::BatchManager * >::const_iterator it = _batchmap.find(clustername);
- if(it == _batchmap.end())
- throw SALOME_Exception("no batchmanager for that cluster");
-
- status = _batchmap[clustername]->queryJob(jobId);
- return(status);
-}
-
-
-//=============================================================================
-/*! CORBA Method:
- * delete a batch job on a cluster
- * \param jobId : identification of Salome job
- * \param params : Constraints for the choice of the batch cluster
- */
-//=============================================================================
-void SALOME_ResourcesManager::deleteSalomeJob( const CORBA::Long jobId, const Engines::MachineParameters& params) throw(SALOME_Exception)
-{
- // find a cluster matching params structure
- Engines::CompoList aCompoList ;
- vector<string> aMachineList = GetFittingResources( params , aCompoList ) ;
- const ParserResourcesType& resInfo = _resourcesList[aMachineList[0]];
- string clustername = resInfo.Alias;
-
- // search batch manager for that cluster in map
- std::map < string, BatchLight::BatchManager * >::const_iterator it = _batchmap.find(clustername);
- if(it == _batchmap.end())
- throw SALOME_Exception("no batchmanager for that cluster");
-
- _batchmap[clustername]->deleteJob(jobId);
-}
-
-//=============================================================================
-/*! CORBA Method:
- * delete a batch job on a cluster
- * \param jobId : identification of Salome job
- * \param params : Constraints for the choice of the batch cluster
- */
-//=============================================================================
-void SALOME_ResourcesManager::getResultSalomeJob( const char *directory,
- const CORBA::Long jobId,
- const Engines::MachineParameters& params) throw(SALOME_Exception)
-{
- // find a cluster matching params structure
- Engines::CompoList aCompoList ;
- vector<string> aMachineList = GetFittingResources( params , aCompoList ) ;
- const ParserResourcesType& resInfo = _resourcesList[aMachineList[0]];
- string clustername = resInfo.Alias;
-
- // search batch manager for that cluster in map
- std::map < string, BatchLight::BatchManager * >::const_iterator it = _batchmap.find(clustername);
- if(it == _batchmap.end())
- throw SALOME_Exception("no batchmanager for that cluster");
-
- _batchmap[clustername]->importOutputFiles( directory, jobId );
-}
-
//=============================================================================
/*!
* builds the command to be launched.
Engines::MachineParameters *p_ptr = new Engines::MachineParameters;
p_ptr->container_name = CORBA::string_dup("");
p_ptr->hostname = CORBA::string_dup("hostname");
+ p_ptr->alias = CORBA::string_dup(resource.Alias.c_str());
+ if( resource.Protocol == rsh )
+ p_ptr->protocol = "rsh";
+ else if( resource.Protocol == ssh )
+ p_ptr->protocol = "ssh";
+ p_ptr->username = CORBA::string_dup(resource.UserName.c_str());
+ p_ptr->applipath = CORBA::string_dup(resource.AppliPath.c_str());
+ p_ptr->modList.length(resource.ModulesList.size());
+ for(int i=0;i<resource.ModulesList.size();i++)
+ p_ptr->modList[i] = CORBA::string_dup(resource.ModulesList[i].c_str());
p_ptr->OS = CORBA::string_dup(resource.OS.c_str());
p_ptr->mem_mb = resource.DataForSort._memInMB;
p_ptr->cpu_clock = resource.DataForSort._CPUFreqMHz;
p_ptr->nb_proc_per_node = resource.DataForSort._nbOfProcPerNode;
p_ptr->nb_node = resource.DataForSort._nbOfNodes;
+ if( resource.mpi == indif )
+ p_ptr->mpiImpl = "indif";
+ else if( resource.mpi == lam )
+ p_ptr->mpiImpl = "lam";
+ else if( resource.mpi == mpich1 )
+ p_ptr->mpiImpl = "mpich1";
+ else if( resource.mpi == mpich2 )
+ p_ptr->mpiImpl = "mpich2";
+ else if( resource.mpi == openmpi )
+ p_ptr->mpiImpl = "openmpi";
+ if( resource.Batch == pbs )
+ p_ptr->batch = "pbs";
+ else if( resource.Batch == lsf )
+ p_ptr->batch = "lsf";
+ else if( resource.Batch == slurm )
+ p_ptr->batch = "slurm";
return p_ptr;
}
#include "Utils_SALOME_Exception.hxx"
#include "utilities.h"
#include <SALOMEconfig.h>
-#include "BatchLight_BatchManager.hxx"
#include "SALOME_ResourcesCatalog_Handler.hxx"
#include "SALOME_LoadRateManager.hxx"
#include "SALOME_NamingService.hxx"
// Only one thread should use the SALOME_ResourcesManager class in a SALOME
// session.
-class RESOURCESMANAGER_EXPORT SALOME_ResourcesManager
+class RESOURCESMANAGER_EXPORT SALOME_ResourcesManager:
+ public POA_Engines::ResourcesManager,
+ public PortableServer::RefCountServantBase
{
public:
- SALOME_ResourcesManager(CORBA::ORB_ptr orb, const char *xmlFilePath);
- SALOME_ResourcesManager(CORBA::ORB_ptr orb);
+ SALOME_ResourcesManager(CORBA::ORB_ptr orb, PortableServer::POA_var poa, SALOME_NamingService *ns, const char *xmlFilePath);
+ SALOME_ResourcesManager(CORBA::ORB_ptr orb, PortableServer::POA_var poa, SALOME_NamingService *ns);
~SALOME_ResourcesManager();
- std::vector<std::string>
+ Engines::MachineList *
GetFittingResources(const Engines::MachineParameters& params,
const Engines::CompoList& componentList)
throw(SALOME_Exception);
- std::string FindFirst(const Engines::MachineList& listOfMachines);
+ char* FindFirst(const Engines::MachineList& listOfMachines);
std::string FindNext(const Engines::MachineList& listOfMachines);
std::string FindBest(const Engines::MachineList& listOfMachines);
(const std::string& machine,
const Engines::MachineParameters& params, const long id);
- CORBA::Long submitSalomeJob(const char * fileToExecute ,
- const Engines::FilesList& filesToExport ,
- const Engines::FilesList& filesToImport ,
- const CORBA::Long NumberOfProcessors ,
- const Engines::MachineParameters& params) throw(SALOME_Exception);
-
- std::string querySalomeJob( const CORBA::Long jobId, const Engines::MachineParameters& params) throw(SALOME_Exception);
- void deleteSalomeJob( const CORBA::Long jobId, const Engines::MachineParameters& params) throw(SALOME_Exception);
- void getResultSalomeJob( const char *directory,
- const CORBA::Long jobId,
- const Engines::MachineParameters& params) throw(SALOME_Exception);
-
std::string BuildCommandToLaunchLocalContainer
(const Engines::MachineParameters& params, const long id);
Engines::MachineParameters* GetMachineParameters(const char *hostname);
+ void Shutdown();
+
+ static const char *_ResourcesManagerNameInNS;
+
protected:
SALOME_NamingService *_NS;
- std::map <std::string,BatchLight::BatchManager*> _batchmap;
+ CORBA::ORB_var _orb;
+ PortableServer::POA_var _poa;
std::string BuildTempFileToLaunchRemoteContainer
(const std::string& machine,
std::string BuildTemporaryFileName() const;
- BatchLight::BatchManager *FactoryBatchManager( const ParserResourcesType& resInfo ) throw(SALOME_Exception);
-
//! will contain the path to the ressources catalog
QString _path_resources;
# launch container manager server
-myCmServer = runSalome.ContainerManagerServer(args)
+myCmServer = runSalome.LauncherServer(args)
myCmServer.setpath(modules_list,modules_root_dir)
myCmServer.run()
-clt.waitNS("/ContainerManager")
+clt.waitNS("/SalomeLauncher")
# execute Unit Test
# kill containers created by the Container Manager
import Engines
-containerManager = clt.waitNS("/ContainerManager",Engines.ContainerManager)
-containerManager.Shutdown()
+launcher = clt.waitNS("/SalomeLauncher",Engines.SalomeLauncher)
+launcher.Shutdown()
# kill Test process