if [ -z "$aRes" ]; then
echo ${NSPORT} - Ok
local myhost=`hostname`
- export OMNIORB_CONFIG=${HOME}/$APPLI//.omniORB_${myhost}_${NSPORT}.cfg
+ export OMNIORB_CONFIG=${HOME}/${APPLI}/.omniORB_${myhost}_${NSPORT}.cfg
export NSPORT
local initref="NameService=corbaname::"`hostname`":$NSPORT"
echo "ORBInitRef $initref" > $OMNIORB_CONFIG
+ LAST_RUNNING_CONFIG=${HOME}/${APPLI}/.omniORB_${myhost}_last.cfg
+ rm ${LAST_RUNNING_CONFIG}
+ ln -s ${OMNIORB_CONFIG} ${LAST_RUNNING_CONFIG}
break
fi
echo -n "${NSPORT} "
else
${KERNEL_ROOT_DIR}/bin/salome/envSalome.py python ${KERNEL_ROOT_DIR}/bin/salome/runSalome.py
fi
+
+rm ${OMNIORB_CONFIG}
. ${HOME}/${APPLI}/envd ${HOME}/${APPLI}
+myhost=`hostname`
+export OMNIORB_CONFIG=${HOME}/${APPLI}/.omniORB_${myhost}_last.cfg
+
# --- invoque shell with or without args
if [ $# -ne 0 ] ; then
module Engines
{
/*!
- A byte stream which is used for binary data transfer between different components
-
+ A byte stream which is used for binary data transfer between different
+ components
*/
typedef sequence<octet> TMPFile;
/*!
Creates a new servant instance of a component.
Component library must be loaded.
- \param comoponentName Name of the component which will be registered
- in Registry and Name Service,
+ \param componentName Name of the component which will be registered
+ in Registry and Name Service,
(instance number suffix added to the registered name)
\param studyId 0 if instance is not associated to a study,
>0 otherwise (== study id)
/*!
This method is used by the %SUPERVISOR component. It sets the names of
the graph and of the node.
- \param aGraphName
- Name of graph
- \param aNodeName Name of node
+ \param aGraphName Name of graph
+ \param aNodeName Name of node
*/
void Names( in string aGraphName , in string aNodeName ) ;
long CpuUsed_impl() ;
/*!
- Returns a python script, which is being played back reproduces the data model of component
+ Returns a python script, which is being played back reproduces
+ the data model of component
*/
- TMPFile DumpPython(in Object theStudy, in boolean isPublished, out boolean isValidScript);
+ TMPFile DumpPython(in Object theStudy,
+ in boolean isPublished,
+ out boolean isValidScript);
} ;
} ;
#ifndef _SALOME_CONTAINERMANAGER_IDL_
#define _SALOME_CONTAINERMANAGER_IDL_
+#include "SALOME_Exception.idl"
#include "SALOME_Component.idl"
module Engines
*/
typedef sequence<string> MachineList;
+/*!
+ exception thrown if a computer is not found in the catalog
+*/
+ exception NotFound {};
+
+
/*! \brief Interface of the %containerManager
- This interface is used for interaction with the unique instance of ContainerManager
+ This interface is used for interaction with the unique instance
+ of ContainerManager
*/
interface ContainerManager
{
- Container FindOrStartContainer( in MachineParameters params, in MachineList possibleComputers);
+ Container FindOrStartContainer( in MachineParameters params,
+ in MachineList possibleComputers);
+
string FindBest(in MachineList possibleComputers);
MachineList GetFittingResources( in MachineParameters params,
- in string componentName );
+ in string componentName )
+ raises (SALOME::SALOME_Exception);
+
void Shutdown();
+
void ShutdownContainers();
} ;
};
Engines::Container_ptr Engines_Component_i::GetContainerRef()
{
+ MESSAGE("Engines_Component_i::GetContainerRef");
CORBA::Object_ptr o = _poa->id_to_reference(*_contId) ;
return Engines::Container::_narrow(o);
}
-Engines_Container_i *Engines_Component_i::GetContainerPtr()
-{
- return dynamic_cast<Engines_Container_i*>(_poa->id_to_servant(*_contId)) ;
-}
+//=============================================================================
+/*!
+ * CORBA method:
+ * Gives a sequence of (key=string,value=any) to the component.
+ * Base class component stores the sequence in a map.
+ * The map is cleared before.
+ * This map is for use by derived classes.
+ * \param dico sequence of (key=string,value=any)
+ */
+//=============================================================================
void Engines_Component_i::setProperties(const Engines::FieldsDict& dico)
{
return cpu ;
}
+
+//=============================================================================
+/*!
+ * C++ method: return Container Servant
+ */
+//=============================================================================
+
+Engines_Container_i *Engines_Component_i::GetContainerPtr()
+{
+ return dynamic_cast<Engines_Container_i*>(_poa->id_to_servant(*_contId)) ;
+}
+
//=============================================================================
/*!
* C++ method: set study Id
* \param studyId 0 if instance is not associated to a study,
* >0 otherwise (== study id)
* \return true if the set of study Id is OK
- * must be set once by Container, and cannot be changed after.
+ * must be set once by Container, at instance creation,
+ * and cannot be changed after.
*/
//=============================================================================
{
ASSERT( studyId >= 0);
CORBA::Boolean ret = false;
- if (_studyId < 0)
+ if (_studyId < 0) // --- not yet initialized
{
_studyId = studyId;
ret = true;
//=============================================================================
/*!
- * C++ method:
+ * C++ method: return standard library name built on component name
*/
//=============================================================================
isValidScript = true;
return aStreamFile._retn();
}
-
Engines::Container_var pCont
= Engines::Container::_narrow(obj);
- _containerName = _NS->BuildContainerNameForNS(containerName,hostname.c_str());
+ _containerName = _NS->BuildContainerNameForNS(containerName,
+ hostname.c_str());
SCRUTE(_containerName);
_NS->Register(pCont, _containerName.c_str());
+ MESSAGE("Engines_Container_i::Engines_Container_i : Container name "
+ << _containerName);
// Python:
// import SALOME_Container
{
Py_ACQUIRE_NEW_THREAD;
#ifdef WNT
-Sleep(2000); // mpv: this is temporary solution: there is a unregular crash if not
- PyRun_SimpleString("import sys\n"); // first element is the path to Registry.dll, but it's wrong
+ // mpv: this is temporary solution: there is a unregular crash if not
+ Sleep(2000);
+ PyRun_SimpleString("import sys\n");
+ // first element is the path to Registry.dll, but it's wrong
PyRun_SimpleString("sys.path = sys.path[1:]\n");
#endif
PyRun_SimpleString("import SALOME_Container\n");
SigIntAct.sa_flags = SA_SIGINFO ;
#endif
-// DEBUG 03.02.2005 : the first parameter of sigaction is not a mask of signals (SIGINT | SIGUSR1) :
-// it must be only one signal ===> one call for SIGINT and an other one for SIGUSR1
+// DEBUG 03.02.2005 : the first parameter of sigaction is not a mask of signals
+// (SIGINT | SIGUSR1) :
+// it must be only one signal ===> one call for SIGINT
+// and an other one for SIGUSR1
#ifndef WNT
if ( sigaction( SIGINT , &SigIntAct, NULL ) ) {
perror("SALOME_Container main ") ;
SALOME_ContainerManager.cxx \
Container_init_python.cxx
-LIB_SERVER_IDL = SALOME_Registry.idl SALOME_Component.idl SALOME_ContainerManager.idl
+LIB_SERVER_IDL = SALOME_Registry.idl SALOME_Component.idl SALOME_ContainerManager.idl SALOME_Exception.idl
LIB_CLIENT_IDL =
# Executables targets
#-------------------------------------------------------------------------
def __init__ (self, orb, poa, contID, containerName,
- instanceName, interfaceName, notif):
+ instanceName, interfaceName, notif=0):
# Notif for notification services
# NOT YET IMPLEMENTED
MESSAGE( "SALOME_ComponentPy_i::__init__" + " " + str (containerName) + " " + str(instanceName) + " " + str(interfaceName) )
naming_service = SALOME_NamingServicePy_i(self._orb)
myMachine=getShortHostName()
- Component_path = "/Containers/" + myMachine + "/" + self._containerName + "/" + self._interfaceName
+ Component_path = self._containerName + "/" + self._instanceName
MESSAGE( 'SALOME_ComponentPy_i Register' + str( Component_path ) )
naming_service.Register(self._this(), Component_path)
#endif
#endif
-class CONTAINER_EXPORT Engines_Component_i: public virtual POA_Engines::Component,
- public virtual PortableServer::RefCountServantBase
+class CONTAINER_EXPORT Engines_Component_i:
+ public virtual POA_Engines::Component,
+ public virtual PortableServer::RefCountServantBase
{
public:
Engines_Component_i();
virtual ~Engines_Component_i();
+ // --- CORBA methods
+
char* instanceName();
char* interfaceName();
- void destroy();
void ping();
+ void destroy();
+ CORBA::Long getStudyId();
Engines::Container_ptr GetContainerRef();
- Engines_Container_i *GetContainerPtr();
- PortableServer::ObjectId * getId();
void setProperties(const Engines::FieldsDict& dico);
Engines::FieldsDict* getProperties();
- void beginService(const char *serviceName);
- void endService(const char *serviceName);
- void sendMessage(const char *event_type, const char *message);
-
void Names( const char * graphName , const char * nodeName ) ;
- char * graphName() ;
- char * nodeName() ;
- bool Killer( pthread_t ThreadId , int signum );
bool Kill_impl();
bool Stop_impl();
bool Suspend_impl();
bool Resume_impl();
- void SetCurCpu() ;
- long CpuUsed() ;
CORBA::Long CpuUsed_impl() ;
- CORBA::Long getStudyId();
- virtual Engines::TMPFile* DumpPython(CORBA::Object_ptr theStudy, CORBA::Boolean isPublished, CORBA::Boolean& isValidScript);
+ virtual Engines::TMPFile* DumpPython(CORBA::Object_ptr theStudy,
+ CORBA::Boolean isPublished,
+ CORBA::Boolean& isValidScript);
+
+
+ // --- local C++ methods
+
+ PortableServer::ObjectId * getId();
+ Engines_Container_i *GetContainerPtr();
bool setStudyId(CORBA::Long studyId);
static bool isMultiStudy();
static bool isMultiInstance();
static std::string GetDynLibraryName(const char *componentName);
+
+ void beginService(const char *serviceName);
+ void endService(const char *serviceName);
+ void sendMessage(const char *event_type, const char *message);
+ char * graphName() ;
+ char * nodeName() ;
+ bool Killer( pthread_t ThreadId , int signum );
+ void SetCurCpu() ;
+ long CpuUsed() ;
+
protected:
+ int _studyId; // -1: not initialised; 0: multiStudy; >0: study
static bool _isMultiStudy;
static bool _isMultiInstance;
+
std::string _instanceName ;
std::string _interfaceName ;
- std::string _serviceName ;
- std::string _graphName ;
- std::string _nodeName ;
- int _studyId; // -1: not initialised; 0: multiStudy; >0: study
+
CORBA::ORB_ptr _orb;
PortableServer::POA_ptr _poa;
PortableServer::ObjectId * _id;
NOTIFICATION_Supplier* _notifSupplier;
std::map<std::string,CORBA::Any>_fieldsDict;
+ std::string _serviceName ;
+ std::string _graphName ;
+ std::string _nodeName ;
+
private:
#ifndef WNT
pthread_t _ThreadId ;
};
#endif
-
self._orb = CORBA.ORB_init(sys.argv, CORBA.ORB_ID)
self._poa = self._orb.resolve_initial_references("RootPOA")
self._containerName = containerName
+ print "SALOME_Container.SALOME_Container_i : _containerName ",self._containerName
#self._naming_service = SALOME_NamingServicePy_i(self._orb)
self._container = self._orb.string_to_object(containerIORStr)
#include <unistd.h>
#endif
#include <vector>
+#include "Utils_CorbaException.hxx"
#define TIME_OUT_TO_LAUNCH_CONT 21
using namespace std;
-const char *SALOME_ContainerManager::_ContainerManagerNameInNS="/ContainerManager";
+const char *SALOME_ContainerManager::_ContainerManagerNameInNS =
+ "/ContainerManager";
SALOME_ContainerManager::SALOME_ContainerManager(CORBA::ORB_ptr orb)
{
MESSAGE("constructor");
- _NS=new SALOME_NamingService(orb);
- _ResManager=new SALOME_ResourcesManager(orb);
- PortableServer::POA_var root_poa=PortableServer::POA::_the_root_poa();
+ _NS = new SALOME_NamingService(orb);
+ _ResManager = new SALOME_ResourcesManager(orb);
+ PortableServer::POA_var root_poa = PortableServer::POA::_the_root_poa();
PortableServer::POAManager_var pman = root_poa->the_POAManager();
PortableServer::POA_var my_poa;
+
CORBA::PolicyList policies;
policies.length(1);
- PortableServer::ThreadPolicy_var threadPol=root_poa->create_thread_policy(PortableServer::SINGLE_THREAD_MODEL);
- policies[0]=PortableServer::ThreadPolicy::_duplicate(threadPol);
- my_poa=root_poa->create_POA("SThreadPOA",pman,policies);
+ PortableServer::ThreadPolicy_var threadPol =
+ root_poa->create_thread_policy(PortableServer::SINGLE_THREAD_MODEL);
+ policies[0] = PortableServer::ThreadPolicy::_duplicate(threadPol);
+
+ my_poa =
+ root_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);
- Engines::ContainerManager_var refContMan = Engines::ContainerManager::_narrow(obj);
+ PortableServer::ObjectId_var id = my_poa->activate_object(this);
+ CORBA::Object_var obj = my_poa->id_to_reference(id);
+ Engines::ContainerManager_var refContMan =
+ Engines::ContainerManager::_narrow(obj);
+
_NS->Register(refContMan,_ContainerManagerNameInNS);
MESSAGE("constructor end");
}
{
MESSAGE("ShutdownContainers");
_NS->Change_Directory("/Containers");
- vector<string> vec=_NS->list_directory_recurs();
- for(vector<string>::iterator iter=vec.begin();iter!=vec.end();iter++)
+ vector<string> vec = _NS->list_directory_recurs();
+ for(vector<string>::iterator iter = vec.begin();iter!=vec.end();iter++)
{
SCRUTE((*iter));
CORBA::Object_var obj=_NS->Resolve((*iter).c_str());
}
}
-Engines::Container_ptr SALOME_ContainerManager::FindOrStartContainer(const Engines::MachineParameters& params, const Engines::MachineList& possibleComputers)
+Engines::Container_ptr
+SALOME_ContainerManager::
+FindOrStartContainer(const Engines::MachineParameters& params,
+ const Engines::MachineList& possibleComputers)
{
- Engines::Container_ptr ret=FindContainer(params,possibleComputers);
+ Engines::Container_ptr ret = FindContainer(params,possibleComputers);
if(!CORBA::is_nil(ret))
return ret;
MESSAGE("Container doesn't exist try to launch it ...");
- vector<string> vector;
+ MESSAGE("SALOME_ContainerManager::FindOrStartContainer " <<
+ possibleComputers.length());
+ //vector<string> vector;
string theMachine=_ResManager->FindBest(possibleComputers);
+ MESSAGE("try to launch it on " << theMachine);
+
string command;
- if(theMachine==GetHostname())
- command=_ResManager->BuildCommandToLaunchLocalContainer(params);
+ if(theMachine=="")
+ {
+ MESSAGE("SALOME_ContainerManager::FindOrStartContainer : " <<
+ "no possible computer");
+ return Engines::Container::_nil();
+ }
+ else if(theMachine==GetHostname())
+ {
+ command=_ResManager->BuildCommandToLaunchLocalContainer(params);
+ }
else
- command=_ResManager->BuildTempFileToLaunchRemoteContainer(theMachine,params);
+ command =
+ _ResManager->BuildTempFileToLaunchRemoteContainer(theMachine,params);
+
_ResManager->RmTmpFile();
int status=system(command.c_str());
- if (status == -1) {
- MESSAGE("SALOME_LifeCycleCORBA::StartOrFindContainer rsh failed (system command status -1)");
- return Engines::Container::_nil();
- }
- else if (status == 217) {
- MESSAGE("SALOME_LifeCycleCORBA::StartOrFindContainer rsh failed (system command status 217)");
- return Engines::Container::_nil();
- }
- else {
- int count=TIME_OUT_TO_LAUNCH_CONT;
- while ( CORBA::is_nil(ret) && count ) {
+ if (status == -1)
+ {
+ MESSAGE("SALOME_LifeCycleCORBA::StartOrFindContainer rsh failed " <<
+ "(system command status -1)");
+ return Engines::Container::_nil();
+ }
+ else if (status == 217)
+ {
+ MESSAGE("SALOME_LifeCycleCORBA::StartOrFindContainer rsh failed " <<
+ "(system command status 217)");
+ return Engines::Container::_nil();
+ }
+ else
+ {
+ int count=TIME_OUT_TO_LAUNCH_CONT;
+ while ( CORBA::is_nil(ret) && count )
+ {
#ifndef WNT
- sleep( 1 ) ;
+ sleep( 1 ) ;
#else
Sleep(1000);
#endif
- count-- ;
- if ( count != 10 )
- MESSAGE( count << ". Waiting for FactoryServer on " << theMachine);
- string containerNameInNS=_NS->BuildContainerNameForNS(params,theMachine.c_str());
- SCRUTE(containerNameInNS);
- CORBA::Object_var obj = _NS->Resolve(containerNameInNS.c_str());
- ret=Engines::Container::_narrow(obj);
- }
- if ( CORBA::is_nil(ret) ) {
- MESSAGE("SALOME_LifeCycleCORBA::StartOrFindContainer rsh failed");
+ count-- ;
+ if ( count != 10 )
+ MESSAGE( count << ". Waiting for FactoryServer on " << theMachine);
+ string containerNameInNS =
+ _NS->BuildContainerNameForNS(params,theMachine.c_str());
+ SCRUTE(containerNameInNS);
+ CORBA::Object_var obj = _NS->Resolve(containerNameInNS.c_str());
+ ret=Engines::Container::_narrow(obj);
+ }
+ if ( CORBA::is_nil(ret) )
+ {
+ MESSAGE("SALOME_LifeCycleCORBA::StartOrFindContainer rsh failed");
+ }
+ return ret;
}
- return ret;
- }
}
-Engines::MachineList *SALOME_ContainerManager::GetFittingResources(const Engines::MachineParameters& params, const char *componentName)
+Engines::MachineList *
+SALOME_ContainerManager::
+GetFittingResources(const Engines::MachineParameters& params,
+ const char *componentName)
{
- vector<string> vec=_ResManager->GetFittingResources(params,componentName);
+ MESSAGE("SALOME_ContainerManager::GetFittingResources");
Engines::MachineList *ret=new Engines::MachineList;
+ vector<string> vec;
+ try
+ {
+ vec = _ResManager->GetFittingResources(params,componentName);
+ }
+ catch(const SALOME_Exception &ex)
+ {
+ INFOS("Caught exception.");
+ cerr << ex.what() <<endl;
+ 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++)
return ret;
}
-char* SALOME_ContainerManager::FindBest(const Engines::MachineList& possibleComputers)
- {
- string theMachine=_ResManager->FindBest(possibleComputers);
- return CORBA::string_dup(theMachine.c_str());
- }
+char*
+SALOME_ContainerManager::
+FindBest(const Engines::MachineList& possibleComputers)
+{
+ string theMachine=_ResManager->FindBest(possibleComputers);
+ return CORBA::string_dup(theMachine.c_str());
+}
-Engines::Container_ptr SALOME_ContainerManager::FindContainer(const Engines::MachineParameters& params,const char *theMachine)
+Engines::Container_ptr
+SALOME_ContainerManager::
+FindContainer(const Engines::MachineParameters& params,
+ const char *theMachine)
{
string containerNameInNS(_NS->BuildContainerNameForNS(params,theMachine));
CORBA::Object_var obj = _NS->Resolve(containerNameInNS.c_str());
return Engines::Container::_nil();
}
-Engines::Container_ptr SALOME_ContainerManager::FindContainer(const Engines::MachineParameters& params,const Engines::MachineList& possibleComputers)
+Engines::Container_ptr
+SALOME_ContainerManager::
+FindContainer(const Engines::MachineParameters& params,
+ const Engines::MachineList& possibleComputers)
{
MESSAGE("FindContainer "<<possibleComputers.length());
for(unsigned int i=0;i<possibleComputers.length();i++)
{
- Engines::Container_ptr cont=FindContainer(params,possibleComputers[i]);
+ MESSAGE("FindContainer possible " << possibleComputers[i]);
+ Engines::Container_ptr cont = FindContainer(params,possibleComputers[i]);
if( !CORBA::is_nil(cont) )
return cont;
}
+ MESSAGE("FindContainer: not found");
return Engines::Container::_nil();
}
#endif
#endif
-class CONTAINER_EXPORT SALOME_ContainerManager: public POA_Engines::ContainerManager,
- public PortableServer::RefCountServantBase {
-private:
- SALOME_ResourcesManager *_ResManager;
- SALOME_NamingService *_NS;
+class CONTAINER_EXPORT SALOME_ContainerManager:
+ public POA_Engines::ContainerManager,
+ public PortableServer::RefCountServantBase
+{
public:
SALOME_ContainerManager(CORBA::ORB_ptr orb);
~SALOME_ContainerManager();
- Engines::Container_ptr FindOrStartContainer(const Engines::MachineParameters& params, const Engines::MachineList& possibleComputer);
- Engines::MachineList *GetFittingResources(const Engines::MachineParameters& params, const char *componentName);
+
+ Engines::Container_ptr
+ FindOrStartContainer(const Engines::MachineParameters& params,
+ const Engines::MachineList& possibleComputer);
+ Engines::MachineList *
+ GetFittingResources(const Engines::MachineParameters& params,
+ const char *componentName);
+
char* FindBest(const Engines::MachineList& possibleComputers);
+
void Shutdown();
void ShutdownContainers();
static const char *_ContainerManagerNameInNS;
+
private:
- Engines::Container_ptr FindContainer(const Engines::MachineParameters& params,const Engines::MachineList& possibleComputers);
- Engines::Container_ptr FindContainer(const Engines::MachineParameters& params,const char *theMachine);
+ Engines::Container_ptr
+ FindContainer(const Engines::MachineParameters& params,
+ const Engines::MachineList& possibleComputers);
+
+ Engines::Container_ptr
+ FindContainer(const Engines::MachineParameters& params,
+ const char *theMachine);
+
+ SALOME_ResourcesManager *_ResManager;
+ SALOME_NamingService *_NS;
};
#endif
MESSAGE( "SALOME_ContainerPy_i::__init__" )
self._orb = orb
self._poa = poa
- self._containerName = containerName
-
myMachine=getShortHostName()
+ Container_path = "/Containers/" + myMachine + "/" + containerName
+ #self._containerName = containerName
+ self._containerName = Container_path
+ print "container name ",self._containerName
+
naming_service = SALOME_NamingServicePy_i(self._orb)
self._naming_service = naming_service
- Container_path = "/Containers/" + myMachine + "/" + self._containerName
MESSAGE( str(Container_path) )
naming_service.Register(self._this(), Container_path)
ret = 0
instanceName = componentName + "_inst_" + `self._numInstance`
interfaceName = componentName
- the_command = "import " + componentName + "\n"
- the_command = the_command + "comp_i = " + componentName + "." + componentName
- the_command = the_command + "(self._orb, self._poa, self._this(), self._containerName, instanceName, interfaceName)\n"
- MESSAGE( "SALOME_ContainerPy_i::load_component_Library :" + str (the_command) )
- exec the_command
- comp_o = comp_i._this()
- if comp_o is not None:
- ret = 1
- else:
+ #the_command = "import " + componentName + "\n"
+ #the_command = the_command + "comp_i = " + componentName + "." + componentName
+ #the_command = the_command + "(self._orb, self._poa, self._this(), self._containerName, instanceName, interfaceName)\n"
+ #MESSAGE( "SALOME_ContainerPy_i::load_component_Library :" + str (the_command) )
+ #exec the_command
+ #comp_o = comp_i._this()
+ #if comp_o is not None:
+ # ret = 1
+ #else:
# --- try to import Python component
- retImpl = self.import_component(componentName)
- if retImpl == 1:
+ # retImpl = self.import_component(componentName)
+ # if retImpl == 1:
#import is possible
- ret = 1
- else:
+ # ret = 1
+ # else:
#import isn't possible
- ret = 0
- return ret
+ # ret = 0
+ #return ret
+ return self.import_component(componentName)
#-------------------------------------------------------------------------
#endif
#endif
-class CONTAINER_EXPORT Engines_Container_i: public virtual POA_Engines::Container,
- public virtual PortableServer::RefCountServantBase
+class CONTAINER_EXPORT Engines_Container_i:
+ public virtual POA_Engines::Container,
+ public virtual PortableServer::RefCountServantBase
{
public:
Engines_Container_i();
void remove_impl(Engines::Component_ptr component_i);
void finalize_removal();
- char* getHostName();
- CORBA::Long getPID();
- char* name();
- char* machineName();
virtual void ping();
+ char* name();
virtual void Shutdown();
+ char* getHostName();
+ CORBA::Long getPID();
//! Kill current container
bool Kill_impl() ;
static bool isPythonContainer(const char* ContainerName);
static void decInstanceCnt(std::string genericRegisterName);
+ //??? char* machineName();
protected:
- int getArgc() { return _argc; }
- char **getArgv() { return _argv; }
+ //??? int getArgc() { return _argc; }
+ //??? char **getArgv() { return _argv; }
static std::map<std::string, int> _cntInstances_map;
static std::map<std::string, void *> _library_map; // library names, loaded
bool _isSupervContainer;
- SALOME_NamingService *_NS ;
+ SALOME_NamingService *_NS ;
std::string _library_path;
std::string _containerName;
CORBA::ORB_var _orb;
#endif
-
# in fact client is a test ! So it may go away BIN !
BIN = SALOME_DataTypeCatalog_Server SALOME_DataTypeCatalog_Client
BIN_SRC =
-BIN_SERVER_IDL = SALOME_DataTypeCatalog.idl
+BIN_SERVER_IDL = SALOME_DataTypeCatalog.idl SALOME_Exception.idl
CPPFLAGS+= $(QT_MT_INCLUDES)
CXXFLAGS+=
LIB = libSalomeLifeCycleCORBA.la
LIB_SRC = SALOME_LifeCycleCORBA.cxx Launchers.cxx
LIB_CLIENT_IDL = SALOME_Component.idl SALOME_TestComponent.idl \
- SALOME_ModuleCatalog.idl SALOME_ContainerManager.idl
+ SALOME_ModuleCatalog.idl SALOME_ContainerManager.idl SALOME_Exception.idl
# Executables targets
BIN = TestLifeCycleCORBA
//
// 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
#include "SALOME_NamingService.hxx"
using namespace std;
-IncompatibleComponent::IncompatibleComponent( void ): SALOME_Exception( "IncompatibleComponent" )
+IncompatibleComponent::IncompatibleComponent( void ):
+ SALOME_Exception( "IncompatibleComponent" )
{
- ;
}
-IncompatibleComponent::IncompatibleComponent( const IncompatibleComponent &ex ): SALOME_Exception( ex )
+
+IncompatibleComponent::IncompatibleComponent(const IncompatibleComponent &ex):
+ SALOME_Exception( ex )
{
- ;
}
//=============================================================================
{
}
+//=============================================================================
+/*! Public -
+ * Find and aready existing and registered component instance.
+ * \param params machine parameters like type or name...
+ * \param componentName the name of component class
+ * \param studyId default = 0 : multistudy instance
+ * \return a CORBA reference of the component instance, or _nil if not found
+ */
+//=============================================================================
+
Engines::Component_ptr
-SALOME_LifeCycleCORBA::FindOrLoad_Component(const Engines::MachineParameters& params,
- const char *componentName,
- int studyId)
+SALOME_LifeCycleCORBA::FindComponent(const Engines::MachineParameters& params,
+ const char *componentName,
+ int studyId)
{
- if (! isKnownComponentClass(componentName)) return Engines::Component::_nil();
+ if (! isKnownComponentClass(componentName))
+ return Engines::Component::_nil();
- Engines::MachineList_var listOfMachine=_ContManager->GetFittingResources(params,componentName);
- Engines::Component_ptr ret=FindComponent(params,componentName,listOfMachine);
- if(CORBA::is_nil(ret))
- return LoadComponent(params,componentName,listOfMachine);
- else
- return ret;
+ Engines::MachineList_var listOfMachines =
+ _ContManager->GetFittingResources(params, componentName);
+
+ Engines::Component_var compo = _FindComponent(params,
+ componentName,
+ studyId,
+ listOfMachines);
+
+ return compo._retn();
+}
+
+//=============================================================================
+/*! Public -
+ * Load a component instance on a container defined by machine parameters
+ * \param params machine parameters like type or name...
+ * \param componentName the name of component class
+ * \param studyId default = 0 : multistudy instance
+ * \return a CORBA reference of the component instance, or _nil if problem
+ */
+//=============================================================================
+
+Engines::Component_ptr
+SALOME_LifeCycleCORBA::LoadComponent(const Engines::MachineParameters& params,
+ const char *componentName,
+ int studyId)
+{
+ // --- Check if Component Name is known in ModuleCatalog
+
+ if (! isKnownComponentClass(componentName))
+ return Engines::Component::_nil();
+
+ Engines::MachineList_var listOfMachines =
+ _ContManager->GetFittingResources(params, componentName);
+
+ Engines::Component_var compo = _LoadComponent(params,
+ componentName,
+ studyId,
+ listOfMachines);
+
+ return compo._retn();
+}
+
+//=============================================================================
+/*! Public -
+ * Find and aready existing and registered component instance or load a new
+ * component instance on a container defined by machine parameters.
+ * \param params machine parameters like type or name...
+ * \param componentName the name of component class
+ * \param studyId default = 0 : multistudy instance
+ * \return a CORBA reference of the component instance, or _nil if problem
+ */
+//=============================================================================
+
+Engines::Component_ptr
+SALOME_LifeCycleCORBA::
+FindOrLoad_Component(const Engines::MachineParameters& params,
+ const char *componentName,
+ int studyId)
+{
+ // --- Check if Component Name is known in ModuleCatalog
+
+ if (! isKnownComponentClass(componentName))
+ return Engines::Component::_nil();
+
+ Engines::MachineList_var listOfMachines =
+ _ContManager->GetFittingResources(params,componentName);
+
+ Engines::Component_var compo = _FindComponent(params,
+ componentName,
+ studyId,
+ listOfMachines);
+
+ if(CORBA::is_nil(compo))
+ compo = _LoadComponent(params,
+ componentName,
+ studyId,
+ listOfMachines);
+
+ return compo._retn();
}
//=============================================================================
* Find and aready existing and registered component instance or load a new
* component instance on a container defined by name
* \param containerName the name of container, under one of the forms
- * - 1 localhost/aContainer
- * - 2 aContainer
- * - 3 /machine/aContainer
- * (not the same rules as FindContainer() method based on protected method
- * ContainerName() -- MUST BE CORRECTED --)
+ * - 1 aContainer (local container)
+ * - 2 /machine/aContainer (container on hostnme = machine)
* \param componentName the name of component class
* \return a CORBA reference of the component instance, or _nil if problem
*/
SALOME_LifeCycleCORBA::FindOrLoad_Component(const char *containerName,
const char *componentName)
{
- // Check if Component Name is known
- if (! isKnownComponentClass(componentName)) return Engines::Component::_nil();
+ // --- Check if Component Name is known in ModuleCatalog
+
+ if (! isKnownComponentClass(componentName))
+ return Engines::Component::_nil();
+
+ // --- Check if containerName contains machine name (if yes: rg>0)
- // Chack if containerName contains machine name (if yes: rg>0)
char *stContainer=strdup(containerName);
string st2Container(stContainer);
int rg=st2Container.find("/");
Engines::MachineParameters_var params=new Engines::MachineParameters;
- if(rg<0) {
- params->container_name=CORBA::string_dup(stContainer);
- params->hostname=CORBA::string_dup(GetHostname().c_str());
- }
- else {
- stContainer[rg]='\0';
- params->container_name=CORBA::string_dup(stContainer+rg+1);
- params->hostname=CORBA::string_dup(stContainer);
- }
+ if (rg<0)
+ {
+ //containerName doesn't contain "/" => Local container
+ params->container_name=CORBA::string_dup(stContainer);
+ params->hostname=CORBA::string_dup(GetHostname().c_str());
+ }
+ else
+ {
+ stContainer[rg]='\0';
+ params->container_name=CORBA::string_dup(stContainer+rg+1);
+ params->hostname=CORBA::string_dup(stContainer);
+ }
params->isMPI = false;
+ SCRUTE(params->container_name);
+ SCRUTE(params->hostname);
+ SCRUTE(params->OS);
+ SCRUTE(params->mem_mb);
+ SCRUTE(params->cpu_clock);
+ SCRUTE(params->nb_proc_per_node);
+ SCRUTE(params->nb_node);
+ SCRUTE(params->isMPI);
free(stContainer);
return FindOrLoad_Component(params,componentName);
return false;
}
-bool SALOME_LifeCycleCORBA::isMpiContainer(const Engines::MachineParameters& params) throw(IncompatibleComponent)
+//=============================================================================
+/*! Public -
+ * Not so complex... useful ?
+ */
+//=============================================================================
+
+bool
+SALOME_LifeCycleCORBA::isMpiContainer(const Engines::MachineParameters& params)
+ throw(IncompatibleComponent)
{
-// MESSAGE(params.container_name)
-// if( strstr(params.container_name,"MPI") ){
-// if( !params.isMPI ){
-// cerr << "IncompatibleComponent" << endl;
-// throw IncompatibleComponent();
-// }
-// return true;
-// }
-// else{
-// if( params.isMPI ){
-// cerr << "IncompatibleComponent" << endl;
-// throw IncompatibleComponent();
-// }
-// return false;
-// }
if( params.isMPI )
return true;
else
return false;
}
+//=============================================================================
+/*! Public -
+ * \return a number of processors not 0, only for MPI containers
+ */
+//=============================================================================
+
int SALOME_LifeCycleCORBA::NbProc(const Engines::MachineParameters& params)
{
if( !isMpiContainer(params) )
return params.nb_node * params.nb_proc_per_node;
}
+//=============================================================================
+/*! Protected -
+ * Find and aready existing and registered component instance.
+ * \param params machine parameters like type or name...
+ * \param componentName the name of component class
+ * \param studyId default = 0 : multistudy instance
+ * \param listOfMachines list of machine address
+ * \return a CORBA reference of the component instance, or _nil if not found
+ * - build a list of machines on which an instance of the component is running,
+ * - find the best machine among the list
+ */
+//=============================================================================
+
Engines::Component_ptr
-SALOME_LifeCycleCORBA::FindComponent(const Engines::MachineParameters& params,
- const char *componentName,
- const Engines::MachineList& listOfMachines)
+SALOME_LifeCycleCORBA::
+_FindComponent(const Engines::MachineParameters& params,
+ const char *componentName,
+ int studyId,
+ const Engines::MachineList& listOfMachines)
{
+ // --- build the list of machines on which the component is already running
+
const char *containerName = params.container_name;
int nbproc = NbProc(params);
+ MESSAGE("_FindComponent, required " << containerName <<
+ " " << componentName << " " << nbproc);
- if (! isKnownComponentClass(componentName)) return Engines::Component::_nil();
+ Engines::MachineList_var machinesOK = new Engines::MachineList;
- // find list of machines which have component
- Engines::MachineList_var machinesOK=new Engines::MachineList;
- unsigned int lghtOfmachinesOK=0;
+ unsigned int lghtOfmachinesOK = 0;
machinesOK->length(listOfMachines.length());
- for(unsigned int i=0;i<listOfMachines.length();i++) {
- const char *currentMachine=listOfMachines[i];
-
- CORBA::Object_var obj = _NS->ResolveComponent(currentMachine,containerName,componentName,nbproc);
- if(!CORBA::is_nil(obj))
- machinesOK[lghtOfmachinesOK++]=CORBA::string_dup(currentMachine);
- }
-
- // find the best machine among the list which have component
- if(lghtOfmachinesOK!=0) {
- machinesOK->length(lghtOfmachinesOK);
- CORBA::String_var bestMachine=_ContManager->FindBest(machinesOK);
- CORBA::Object_var obj = _NS->ResolveComponent(bestMachine,containerName,componentName,nbproc);
- return Engines::Component::_narrow(obj);
- }
+
+ for(unsigned int i=0; i<listOfMachines.length(); i++)
+ {
+ const char *currentMachine=listOfMachines[i];
+ MESSAGE("_FindComponent, look at " << currentMachine);
+ CORBA::Object_var obj = _NS->ResolveComponent(currentMachine,
+ containerName,
+ componentName,
+ nbproc);
+ if (!CORBA::is_nil(obj))
+ machinesOK[lghtOfmachinesOK++] = CORBA::string_dup(currentMachine);
+ }
+
+ // --- find the best machine among the list
+
+ if(lghtOfmachinesOK != 0)
+ {
+ machinesOK->length(lghtOfmachinesOK);
+ CORBA::String_var bestMachine = _ContManager->FindBest(machinesOK);
+ CORBA::Object_var obj = _NS->ResolveComponent(bestMachine,
+ containerName,
+ componentName,
+ nbproc);
+ return Engines::Component::_narrow(obj);
+ }
else
return Engines::Component::_nil();
}
+//=============================================================================
+/*! Protected -
+ * Load a component instance.
+ * \param params machine parameters like type or name...
+ * \param componentName the name of component class
+ * \param studyId default = 0 : multistudy instance
+ * \param listOfMachines list of machine address
+ * \return a CORBA reference of the component instance, or _nil if problem
+ * - Finds a container in the list of machine or start one.
+ * - Try to load the component library in the container,
+ * - then create an instance of the component.
+ */
+//=============================================================================
+
Engines::Component_ptr
-SALOME_LifeCycleCORBA::LoadComponent(const Engines::MachineParameters& params,
- const char *componentName,
- const Engines::MachineList& listOfMachines)
+SALOME_LifeCycleCORBA::
+_LoadComponent(const Engines::MachineParameters& params,
+ const char *componentName,
+ int studyId,
+ const Engines::MachineList& listOfMachines)
{
- Engines::Container_var cont=_ContManager->FindOrStartContainer(params,listOfMachines);
+ const char *containerName = params.container_name;
+ int nbproc = NbProc(params);
+
+ MESSAGE("_LoadComponent, required " << containerName <<
+ " " << componentName << " " << nbproc);
+
+ Engines::Container_var cont =
+ _ContManager->FindOrStartContainer(params,
+ listOfMachines);
if (CORBA::is_nil(cont)) return Engines::Component::_nil();
bool isLoadable = cont->load_component_Library(componentName);
if (!isLoadable) return Engines::Component::_nil();
Engines::Component_var myInstance =
- cont->create_component_instance(componentName, 0);
+ cont->create_component_instance(componentName, studyId);
return myInstance._retn();
}
class LIFECYCLECORBA_EXPORT IncompatibleComponent : public SALOME_Exception
{
public :
- IncompatibleComponent( void );
- IncompatibleComponent( const IncompatibleComponent &ex );
-} ;
+ IncompatibleComponent(void);
+ IncompatibleComponent(const IncompatibleComponent &ex);
+};
class LIFECYCLECORBA_EXPORT SALOME_LifeCycleCORBA
{
Engines::Component_ptr
FindComponent(const Engines::MachineParameters& params,
- const char *componentName,
- const Engines::MachineList& listOfMachines);
+ const char *componentName,
+ int studyId=0);
- Engines::Component_ptr
- LoadComponent(const Engines::MachineParameters& params,
- const char *componentName,
- const Engines::MachineList& listOfMachines);
+ Engines::Component_ptr
+ LoadComponent(const Engines::MachineParameters& params,
+ const char *componentName,
+ int studyId=0);
Engines::Component_ptr
FindOrLoad_Component(const Engines::MachineParameters& params,
const char *componentName); // for compatibility
bool isKnownComponentClass(const char *componentName);
- bool isMpiContainer(const Engines::MachineParameters& params) throw(IncompatibleComponent);
+
+ bool isMpiContainer(const Engines::MachineParameters& params)
+ throw(IncompatibleComponent);
+
int NbProc(const Engines::MachineParameters& params);
- //! Establish if a component called "componentName" in a container called "containerName" exists among the list of resources
- //! in "listOfMachines". This method uses Naming Service to find the component.
protected:
* exists among the list of resources in "listOfMachines".
* This method uses Naming Service to find the component.
*/
-
Engines::Component_ptr
- _FindComponent(const char *containerName,
+ _FindComponent(const Engines::MachineParameters& params,
const char *componentName,
+ int studyId,
const Engines::MachineList& listOfMachines);
Engines::Component_ptr
- _LoadComponent(const char *containerName,
+ _LoadComponent(const Engines::MachineParameters& params,
const char *componentName,
+ int studyId,
const Engines::MachineList& listOfMachines);
SALOME_NamingService *_NS;
} ;
#endif
-
LIB = libSALOME_LifeCycleCORBAcmodule.la
LIB_SRC =
-LIB_CLIENT_IDL = SALOME_Component.idl SALOME_ContainerManager.idl
+LIB_CLIENT_IDL = SALOME_Component.idl SALOME_ContainerManager.idl SALOME_Exception.idl
SWIG_DEF = libSALOME_LifeCycleCORBA.i
#comp.Coucou(1)
param={}
-param['hostname']='cli76ce'
+param['hostname']='cli76cc'
param['container_name']='myContainer'
-smesh=lcc.FindOrLoad_Component(param,'SMESH')
+smesh=lcc.FindOrLoad_Component(param,'PYHELLO')
container=lcc.FindContainer('myContainer')
-engine=lcc.FindComponent(param,'SMESH')
+engine=lcc.FindComponent(param,'HELLO')
geom=lcc.LoadComponent(param,'GEOM')
# in fact client is a test ! So it may go away BIN !
BIN = SALOME_ModuleCatalog_Server SALOME_ModuleCatalog_Client
BIN_SRC =
-BIN_SERVER_IDL = SALOME_ModuleCatalog.idl
+BIN_SERVER_IDL = SALOME_ModuleCatalog.idl SALOME_Exception.idl
CPPFLAGS+= $(QT_MT_INCLUDES)
LDFLAGS+= $(QT_MT_LIBS) -lSalomeNS -lSALOMELocalTrace -lSALOMETraceCollector -lOpUtil
SALOME_NamingService.cxx \
ServiceUnreachable.cxx \
NamingService_WaitForServerReadiness.cxx
+LIB_SERVER_IDL = SALOME_Exception.idl
LDFLAGS+= -lOpUtil
CORBA::Object_ptr SALOME_NamingService::ResolveComponent(const char* hostname, const char* containerName, const char* componentName, const int nbproc)
{
+ MESSAGE("ResolveComponent");
+ Utils_Locker lock(&_myMutex);
string name="/Containers/";
name += hostname;
LIB_SRC = \
RegistryConnexion.cxx \
RegistryService.cxx
-LIB_CLIENT_IDL = SALOME_Registry.idl
+LIB_CLIENT_IDL = SALOME_Registry.idl SALOME_Exception.idl
# Executables targets
BIN = SALOME_Registry_Server
# in fact client is a test ! So it may go away BIN !
#BIN = test_rc2
#SALOME_RessourcesCatalog_Server SALOME_RessourcesCatalog_Client test
-LIB_CLIENT_IDL = SALOME_ContainerManager.idl SALOME_Component.idl
+LIB_CLIENT_IDL = SALOME_ContainerManager.idl SALOME_Component.idl SALOME_Exception.idl
BIN_SRC =
BIN_SERVER_IDL = SALOME_ContainerManager.idl
#include "SALOME_LoadRateManager.hxx"
+#include <iostream>
using namespace std;
string SALOME_LoadRateManager::FindBest(const Engines::MachineList& hosts)
{
// for the moment then "maui" will be used for dynamic selection ...
+ cout << "SALOME_LoadRateManager::FindBest" << endl;
+ if(hosts.length() == 0)return string("");
return string(hosts[0]);
}
//To be sure that we search in a correct list.
ParseXmlFile();
const char *hostname=(const char *)params.hostname;
+ MESSAGE("ResourcesManager::GetFittingResources" << hostname << GetHostname().c_str());
if(hostname[0]!='\0')
{
- if( strcmp(hostname,"localhost") == 0 || strcmp(hostname,GetHostname().c_str()) == 0 )
+ MESSAGE("ResourcesManager::GetFittingResources : hostname specified" );
+ cout << "hostname specified" << endl;
+ if( strcmp(hostname,"localhost") == 0 || strcmp(hostname,GetHostname().c_str()) == 0 ){
+ MESSAGE("ResourcesManager::GetFittingResources : localhost" );
ret.push_back(GetHostname().c_str());
- else if(_resourcesList.find(hostname)!=_resourcesList.end())
+ MESSAGE("ResourcesManager::GetFittingResources : " << ret.size());
+ }
+ else if(_resourcesList.find(hostname)!=_resourcesList.end()){
// params.hostame is in the list of resources so return it.
ret.push_back(hostname);
- else
+ } else{
//user specified an unknown hostame so notify to him.
+ MESSAGE("ResourcesManager::GetFittingResources : SALOME_Exception");
throw SALOME_Exception("unknown host");
+ }
}
else
// Search for available resources sorted by priority
for(list<ResourceDataToSort>::iterator iter2=li.begin();iter2!=li.end();iter2++)
ret[i++]=(*iter2)._hostName;
}
+ MESSAGE("ResourcesManager::GetFittingResources : return" << ret.size());
return ret;
}
void SALOME_ResourcesManager::AddOmninamesParams(string& command) const
{
- string omniORBcfg( getenv( "OMNIORB_CONFIG" ) ) ;
- ifstream omniORBfile( omniORBcfg.c_str() ) ;
- char ORBInitRef[11] ;
- char egal[3] ;
- char nameservice[132] ;
- omniORBfile >> ORBInitRef ;
- command += "ORBInitRef " ;
- omniORBfile >> egal ;
- omniORBfile >> nameservice ;
- omniORBfile.close() ;
- char * bsn = strchr( nameservice , '\n' ) ;
- if ( bsn ) {
- bsn[ 0 ] = '\0' ;
- }
- command += nameservice ;
+ // If env variable OMNIORB_CONFIG is not defined or the file is more complex than one line
+ // does not work
+ // Even if we use it we have to check if env variable exists
+ //string omniORBcfg( getenv( "OMNIORB_CONFIG" ) ) ;
+ //ifstream omniORBfile( omniORBcfg.c_str() ) ;
+ //char ORBInitRef[11] ;
+ //char egal[3] ;
+ //char nameservice[132] ;
+ //omniORBfile >> ORBInitRef ;
+ //command += "ORBInitRef " ;
+ //omniORBfile >> egal ;
+ //omniORBfile >> nameservice ;
+ //omniORBfile.close() ;
+ //char * bsn = strchr( nameservice , '\n' ) ;
+ //if ( bsn ) {
+ //bsn[ 0 ] = '\0' ;
+ //}
+ //command += nameservice ;
+
+ char *iorstr = _NS->getIORaddr();
+ command += "ORBInitRef NameService=";
+ command += iorstr;
}
void SALOME_ResourcesManager::AddOmninamesParams(ofstream& fileStream) const
# in fact client is a test ! So it may go away BIN !
BIN = SALOME_RessourcesCatalog_Server SALOME_RessourcesCatalog_Client
BIN_SRC =
-BIN_SERVER_IDL = SALOME_RessourcesCatalog.idl
+BIN_SERVER_IDL = SALOME_RessourcesCatalog.idl SALOME_Exception.idl
CPPFLAGS+= $(QT_MT_INCLUDES)
CXXFLAGS+=
LIB = libSalomeTestComponentEngine.la
LIB_SRC = SALOME_TestComponent_i.cxx
-LIB_CLIENT_IDL = SALOME_Component.idl SALOME_TestComponent.idl
+LIB_CLIENT_IDL = SALOME_Component.idl SALOME_TestComponent.idl SALOME_Exception.idl
# Executables targets
BIN = TestContainer TestLogger