#include "SALOME_ContainerManager.hxx"
#include "SALOME_Component_i.hxx"
#include "SALOME_NamingService.hxx"
+#include "SALOME_FileTransferCORBA.hxx"
using namespace std;
{
}
+/*! \class SALOME_LifeCycleCORBA
+ \brief A class to manage life cycle of SALOME components.
+
+*/
+
//=============================================================================
/*!
* Constructor
char **argv = &xargv;
CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);
// LocalTraceCollector *myThreadTrace = SALOMETraceCollector::instance(orb);
+ _NSnew=0;
if (!ns)
{
_NS = new SALOME_NamingService(orb);
+ _NSnew=_NS;
}
else _NS = ns;
//add try catch
SALOME_LifeCycleCORBA::~SALOME_LifeCycleCORBA()
{
+ if(_NSnew)delete _NSnew;
}
//=============================================================================
-/*! Public -
- * Find and aready existing and registered component instance.
+/*! \brief Find an already 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::FindComponent(const Engines::MachineParameters& params,
const char *componentName,
if (! isKnownComponentClass(componentName))
return Engines::Component::_nil();
- Engines::CompoList clist;
- clist.length(1);
- clist[0] = componentName;
- Engines::MachineList_var listOfMachines =
- _ResManager->GetFittingResources(params, clist);
+ Engines::MachineParameters parms(params);
+ parms.componentList.length(1);
+ parms.componentList[0] = componentName;
+ Engines::MachineList_var listOfMachines = _ResManager->GetFittingResources(parms);
- Engines::Component_var compo = _FindComponent(params,
+ Engines::Component_var compo = _FindComponent(parms,
componentName,
studyId,
listOfMachines);
}
//=============================================================================
-/*! Public -
- * Load a component instance on a container defined by machine parameters
+/*! \brief 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
if (! isKnownComponentClass(componentName))
return Engines::Component::_nil();
- Engines::CompoList clist;
- clist.length(1);
- clist[0] = componentName;
- Engines::MachineList_var listOfMachines =
- _ResManager->GetFittingResources(params, clist);
+ Engines::MachineParameters parms(params);
+ parms.componentList.length(1);
+ parms.componentList[0] = componentName;
+
+ Engines::MachineList_var listOfMachines = _ResManager->GetFittingResources(parms);
+ parms.computerList=listOfMachines;
- Engines::Component_var compo = _LoadComponent(params,
+ Engines::Component_var compo = _LoadComponent(parms,
componentName,
- studyId,
- listOfMachines);
+ studyId);
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.
+/*! \brief Find an already 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
if (! isKnownComponentClass(componentName))
return Engines::Component::_nil();
- Engines::CompoList clist;
- clist.length(1);
- clist[0] = componentName;
- Engines::MachineList_var listOfMachines =
- _ResManager->GetFittingResources(params,clist);
+ Engines::MachineParameters parms(params);
+ parms.componentList.length(1);
+ parms.componentList[0] = componentName;
+ Engines::MachineList_var listOfMachines = _ResManager->GetFittingResources(parms);
- Engines::Component_var compo = _FindComponent(params,
+ Engines::Component_var compo = _FindComponent(parms,
componentName,
studyId,
listOfMachines);
if(CORBA::is_nil(compo))
- compo = _LoadComponent(params,
+ {
+ parms.computerList=listOfMachines;
+ compo = _LoadComponent(parms,
componentName,
- studyId,
- listOfMachines);
+ studyId);
+ }
return compo._retn();
}
//=============================================================================
-/*! Public -
- * Find and aready existing and registered component instance or load a new
- * component instance on a container defined by name
+/*! \brief Find an already 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 aContainer (local container)
* - 2 machine/aContainer (container on hostname = machine)
{
// containerName doesn't contain "/" => Local container
params->container_name=CORBA::string_dup(stContainer);
- params->hostname=CORBA::string_dup(Kernel_Utils::GetHostname().c_str());
+ params->hostname="";
}
else
{
}
//=============================================================================
-/*! Public -
- * Check if the component class is known in module catalog
+/*! \brief Check if the component class is known in module catalog
+ *
* \param componentName the name of component class
* \return true if found, false otherwise
*/
}
//=============================================================================
-/*! Public -
+/*!
* Not so complex... useful ?
*/
//=============================================================================
//=============================================================================
-/*! Public -
- * Pre initialisation of a given Engines::MachineParameters with default
- * values.
+/*! \brief Initialisation of a given Engines::MachineParameters with default values.
+ *
* - container_name = "" : not relevant
* - hostname = "" : not relevant
* - OS = "" : not relevant
{
params.container_name = "";
params.hostname = "";
+ //param.componentList = 0;
+ //param.computerList = 0;
params.OS = "";
params.mem_mb = 0;
params.cpu_clock = 0;
params.nb_proc_per_node = 0;
params.nb_node = 0;
params.isMPI = false;
-
+ params.workingdir = "";
+ params.mode = "";
+ params.policy = "";
params.parallelLib = "";
params.nb_component_nodes = 0;
}
//=============================================================================
-/*! Public -
+/*!
* \return a number of processors not 0, only for MPI containers
*/
//=============================================================================
}
//=============================================================================
-/*! Public -
+/*! \brief Get the container manager
+ *
* \return the container Manager
*/
//=============================================================================
}
//=============================================================================
-/*! Public -
+/*! \brief Get the resources manager
+ *
* \return the container Manager
*/
//=============================================================================
}
//=============================================================================
-/*! Public -
- * shutdown all the SALOME servers except SALOME_Session_Server, omniNames and notifd
+/*! \brief shutdown all the SALOME servers except SALOME_Session_Server, omniNames and notifd
*/
//=============================================================================
}
//=============================================================================
-/*! Public -
- * shutdown omniNames and notifd
+/*! \brief shutdown omniNames and notifd
*/
//=============================================================================
string portNumber (::getenv ("NSPORT") );
if ( !portNumber.empty() )
{
+#ifdef WNT
+#else
string cmd ;
cmd = string( "ps -eo pid,command | grep -v grep | grep -E \"omniNames.*")
+ portNumber
}
catch ( ... ) {
}
+#endif
}
// NPAL 18309 (Kill Notifd)
}
//=============================================================================
-/*! Protected -
- * Find and aready existing and registered component instance.
+/*! \brief Find an already existing and registered component instance.
+ *
+ * - build a list of machines on which an instance of the component is running,
+ * - find the best machine among the list
+ *
* \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
*/
//=============================================================================
}
//=============================================================================
-/*! Protected -
- * Load a component instance.
+/*! \brief Load a component instance.
+ *
+ * - 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.
+ *
* \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.
*/
//=============================================================================
SALOME_LifeCycleCORBA::
_LoadComponent(const Engines::MachineParameters& params,
const char *componentName,
- int studyId,
- const Engines::MachineList& listOfMachines)
+ int studyId)
{
MESSAGE("_LoadComponent, required " << params.container_name <<
" " << componentName << " " << NbProc(params));
- Engines::Container_var cont =
- _ContManager->FindOrStartContainer(params,
- listOfMachines);
+ Engines::Container_var cont = _ContManager->FindOrStartContainer(params);
if (CORBA::is_nil(cont)) return Engines::Component::_nil();
bool isLoadable = cont->load_component_Library(componentName);
return myInstance._retn();
}
+//=============================================================================
+/*! \brief Load a parallel 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 parallel component instance, or _nil if problem
+ */
+//=============================================================================
Engines::Component_ptr
SALOME_LifeCycleCORBA::Load_ParallelComponent(const Engines::MachineParameters& params,
const char *componentName,
MESSAGE("Number of component nodes : " << params.nb_component_nodes);
MESSAGE("Component Name : " << componentName);*/
- Engines::CompoList clist;
- clist.length(1);
- clist[0] = componentName;
- MESSAGE("Building a list of machines");
- Engines::MachineList_var listOfMachines = _ResManager->GetFittingResources(params, clist);
- if (listOfMachines->length() == 0)
- {
- INFOS("No matching machines founded !");
- return Engines::Component::_nil();
- }
+ Engines::MachineParameters parms(params);
+ parms.componentList.length(1);
+ parms.componentList[0] = componentName;
MESSAGE("Starting Parallel Container");
- Engines::Container_var cont = _ContManager->FindOrStartParallelContainer(params, listOfMachines);
+ Engines::Container_var cont = _ContManager->StartParallelContainer(parms);
if (CORBA::is_nil(cont)) {
INFOS("FindOrStartParallelContainer() returns a NULL container !");
return Engines::Component::_nil();
MESSAGE("Creating component instance");
// @PARALLEL@ permits to identify that the component requested
// is a parallel component.
- string name = string(componentName) + string("@PARALLEL@");
+ string name = string(componentName);
Engines::Component_var myInstance = cont->create_component_instance(name.c_str(), studyId);
if (CORBA::is_nil(myInstance))
INFOS("create_component_instance returns a NULL component !");
return myInstance._retn();
}
+/*! \brief copy a file from a source host to a destination host
+ * \param hostSrc the source host
+ * \param fileSrc the file to copy from the source host to the destination host
+ * \param hostDest the destination host
+ * \param fileDest the destination file
+ */
+void SALOME_LifeCycleCORBA::copyFile(const char* hostSrc, const char* fileSrc, const char* hostDest, const char* fileDest)
+{
+ if(strcmp(hostDest,"localhost") == 0)
+ {
+ //if localhost use a shortcut
+ SALOME_FileTransferCORBA transfer(hostSrc,fileSrc);
+ transfer.getLocalFile(fileDest);
+ return;
+ }
+
+ Engines::ContainerManager_var contManager = getContainerManager();
+
+ Engines::MachineParameters params;
+ preSet(params);
+
+ params.hostname = hostDest;
+ Engines::Container_var containerDest = contManager->FindOrStartContainer(params);
+
+ params.hostname = hostSrc;
+ Engines::Container_var containerSrc = contManager->FindOrStartContainer(params);
+
+ containerDest->copyFile(containerSrc,fileSrc,fileDest);
+}
+
+/*! \brief get the naming service used by the life cycle
+ *
+ * \return the naming service
+ */
+SALOME_NamingService * SALOME_LifeCycleCORBA::namingService()
+{
+ return _NS;
+}
+
+/*! \brief get the orb used by the life cycle
+ *
+ * \return the orb
+ */
+CORBA::ORB_ptr SALOME_LifeCycleCORBA::orb()
+{
+ return _NS->orb();
+}
+