list = []
pass
- print "source=",source
+ #print "source=",source
result = {}
i = 0
try:
opts = options_parser(sys.argv[1:])
- print "opts=",opts
+ #print "opts=",opts
kernel_root_dir=os.environ["KERNEL_ROOT_DIR"]
except:
opts["h"] = 1
args[gui_nam] = 0
pass
-print "args=",args
+#print "args=",args
os.environ["SALOMEPATH"]=":".join(modules_root_dir_list)
- # special path for logger lib if needeed
+ # set trace environment variable
- os.environ["SALOME_trace"]="local"
+ if not os.environ.has_key("SALOME_trace"):
+ os.environ["SALOME_trace"]="local"
if args['file']:
os.environ["SALOME_trace"]="file:"+args['file'][0]
if args['logger']:
os.environ["SALOME_trace"]="with_logger"
- locdir=os.environ['PWD']
- libtracedir=os.path.join(locdir,"libSalomeTrace")
- libtrace = os.path.join(modules_root_dir["KERNEL"],"lib",
- salome_subdir,
- "libSALOMELoggerClient.so.0.0.0")
- libtraceln = os.path.join(libtracedir,"libSALOMELocalTrace.so")
- aCommand = 'rm -rf ' + libtracedir + "; "
- aCommand += 'mkdir ' + libtracedir + "; "
- aCommand += 'ln -s ' + libtrace + " " + libtraceln + "; "
- aCommand += 'ln -s ' + libtrace + " " + libtraceln + ".0; "
- aCommand += 'ln -s ' + libtrace + " " + libtraceln + ".0.0.0; "
- os.system(aCommand)
- add_path(libtracedir, "LD_LIBRARY_PATH")
# set environment for SMESH plugins
os.environ["ENABLE_MACRO_NODE"]="1"
+ os.environ["CSF_PluginDefaults"] \
+ = os.path.join(modules_root_dir["KERNEL"],"share",
+ salome_subdir,"resources")
+ os.environ["CSF_SALOMEDS_ResourcesDefaults"] \
+ = os.path.join(modules_root_dir["KERNEL"],"share",
+ salome_subdir,"resources")
+
+ if "GEOM" in modules_list:
+ print "GEOM OCAF Resources"
+ os.environ["CSF_GEOMDS_ResourcesDefaults"] \
+ = os.path.join(modules_root_dir["GEOM"],"share",
+ salome_subdir,"resources")
+ print "GEOM Shape Healing Resources"
+ os.environ["CSF_ShHealingDefaults"] \
+ = os.path.join(modules_root_dir["GEOM"],"share",
+ salome_subdir,"resources")
+
# -----------------------------------------------------------------------------
from killSalome import killAllPorts
def run(self):
global process_id
command = self.CMD
- print "command = ", command
+ #print "command = ", command
pid = os.spawnvp(os.P_NOWAIT, command[0], command)
process_id[pid]=self.CMD
for module in ["KERNEL", "GUI"] + list_modules:
module_root_dir=modules_root_dir[module]
module_cata=module+"Catalog.xml"
- print " ", module_cata
+ #print " ", module_cata
cata_path.extend(
glob.glob(os.path.join(module_root_dir,
"share",salome_subdir,
# ---
-# class SessionLoader(Server):
-# def __init__(self,args):
-# self.args=args
-# self.initArgs()
-# self.CMD=['SALOME_Session_Loader']
-# if "cppContainer" in self.args['standalone'] \
-# or "cppContainer" in self.args['embedded']:
-# self.CMD=self.CMD+['CPP']
-# if "pyContainer" in self.args['standalone'] \
-# or "pyContainer" in self.args['embedded']:
-# self.CMD=self.CMD+['PY']
-# if "supervContainer" in self.args['containers'] \
-# or "supervContainer" in self.args['standalone']:
-# self.CMD=self.CMD+['SUPERV']
-# if self.args['gui']:
-# self.CMD=self.CMD+['GUI']
-# print self.CMD
-
-# ---
-
class SessionServer(Server):
def __init__(self,args):
self.args=args
for module in ["KERNEL", "GUI"] + list_modules:
module_root_dir=modules_root_dir[module]
module_cata=module+"Catalog.xml"
- print " ", module_cata
+ #print " ", module_cata
cata_path.extend(
glob.glob(os.path.join(module_root_dir,"share",
salome_subdir,"resources",
for module in ["KERNEL", "GUI"] + list_modules:
module_root_dir=modules_root_dir[module]
module_cata=module+"Catalog.xml"
- print " ", module_cata
+ #print " ", module_cata
cata_path.extend(
glob.glob(os.path.join(module_root_dir,"share",
self.args['appname'],"resources",
# attente de la disponibilite du SalomeDS dans le Naming Service
#
- os.environ["CSF_PluginDefaults"] \
- = os.path.join(modules_root_dir["KERNEL"],"share",
- salome_subdir,"resources")
- os.environ["CSF_SALOMEDS_ResourcesDefaults"] \
- = os.path.join(modules_root_dir["KERNEL"],"share",
- salome_subdir,"resources")
-
- if "GEOM" in modules_list:
- print "GEOM OCAF Resources"
- os.environ["CSF_GEOMDS_ResourcesDefaults"] \
- = os.path.join(modules_root_dir["GEOM"],"share",
- salome_subdir,"resources")
- print "GEOM Shape Healing Resources"
- os.environ["CSF_ShHealingDefaults"] \
- = os.path.join(modules_root_dir["GEOM"],"share",
- salome_subdir,"resources")
-
- print "ARGS = ",args
+ #print "ARGS = ",args
if 'study' not in args['embedded']:
print "RunStudy"
myServer=SalomeDSServer(args)
catch(const SALOME_Exception &ex)
{
INFOS("Caught exception.");
- cerr << ex.what() <<endl;
THROW_SALOME_CORBA_EXCEPTION(ex.what(),SALOME::BAD_PARAM);
//return ret;
}
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);
SALOME_ModuleCatalog.idl SALOME_ContainerManager.idl SALOME_Exception.idl
# Executables targets
-BIN = TestLifeCycleCORBA
+BIN = Test_LifeCycleCORBA
BIN_SRC =
BIN_CLIENT_IDL = SALOME_Component.idl SALOME_TestComponent.idl \
SALOME_ModuleCatalog.idl SALOME_ContainerManager.idl
* 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 hostnme = machine)
+ * - 2 machine/aContainer (container on hostname = machine)
* \param componentName the name of component class
* \return a CORBA reference of the component instance, or _nil if problem
*/
int rg=st2Container.find("/");
Engines::MachineParameters_var params=new Engines::MachineParameters;
+ preSet(params);
if (rg<0)
{
- //containerName doesn't contain "/" => Local container
+ // containerName doesn't contain "/" => Local container
params->container_name=CORBA::string_dup(stContainer);
params->hostname=CORBA::string_dup(GetHostname().c_str());
}
CORBA::Object_var obj = _NS->Resolve("/Kernel/ModulCatalog");
SALOME_ModuleCatalog::ModuleCatalog_var Catalog =
SALOME_ModuleCatalog::ModuleCatalog::_narrow(obj) ;
+ ASSERT(! CORBA::is_nil(Catalog));
SALOME_ModuleCatalog::Acomponent_ptr compoInfo =
Catalog->GetComponent(componentName);
if (CORBA::is_nil (compoInfo))
return false;
}
+
+//=============================================================================
+/*! Public -
+ * Pre initialisation of a given Engines::MachineParameters with default
+ * values.
+ * - container_name = "" : not relevant
+ * - hostname = "" : not relevant
+ * - OS = "" : not relevant
+ * - mem_mb = 0 : not relevant
+ * - cpu_clock = 0 : not relevant
+ * - nb_proc_per_node = 0 : not relevant
+ * - nb_node = 0 : not relevant
+ * - isMPI = false : standard components
+ */
+//=============================================================================
+
+void SALOME_LifeCycleCORBA::preSet( Engines::MachineParameters& params)
+{
+ params.container_name = "";
+ params.hostname = "";
+ params.OS = "";
+ params.mem_mb = 0;
+ params.cpu_clock = 0;
+ params.nb_proc_per_node = 0;
+ params.nb_node = 0;
+ params.isMPI = false;
+}
+
//=============================================================================
/*! Public -
* \return a number of processors not 0, only for MPI containers
int NbProc(const Engines::MachineParameters& params);
+ void preSet(Engines::MachineParameters& params);
+
protected:
/*! Establish if a component called "componentName" in a container called
--- /dev/null
+
+#include "LifeCycleCORBATest.hxx"
+#include "SALOME_LifeCycleCORBA.hxx"
+#include "Utils_ORB_INIT.hxx"
+#include "Utils_SINGLETON.hxx"
+#include "OpUtil.hxx"
+
+#include <iostream>
+#include <fstream>
+#include <string>
+#include <cstdlib>
+
+using namespace std;
+
+// --- uncomment to have some traces on standard error
+// (useful only when adding new tests...)
+//#define _DEVDEBUG_
+
+#ifdef _DEVDEBUG_
+#define MYDEVTRACE {std::cerr << __FILE__ << " [" << __LINE__ << "] : ";}
+#define DEVTRACE(msg) {MYDEVTRACE; std::cerr<<msg<<std::endl<<std::flush;}
+#else
+#define MYDEVTRACE
+#define DEVTRACE(msg)
+#endif
+
+#define TRACEFILE "/tmp/traceUnitTest.log"
+
+// ============================================================================
+/*!
+ * Set Trace mecanism
+ * - delete preexisting trace classes if any
+ * - set trace on file
+ * Get or initialize the orb
+ * Create a SALOME_NamingService instance
+ */
+// ============================================================================
+
+void
+LifeCycleCORBATest::setUp()
+{
+ LocalTraceBufferPool* bp1 = LocalTraceBufferPool::instance();
+ CPPUNIT_ASSERT(bp1);
+ bp1->deleteInstance(bp1);
+
+ // --- trace on file
+ char *theFileName = TRACEFILE;
+
+ string s = "file:";
+ s += theFileName;
+ //s="local";
+ CPPUNIT_ASSERT(! setenv("SALOME_trace",s.c_str(),1)); // 1: overwrite
+
+ ofstream traceFile;
+ // traceFile.open(theFileName, ios::out | ios::trunc);
+ traceFile.open(theFileName, ios::out | ios::app);
+ CPPUNIT_ASSERT(traceFile); // file created empty, then closed
+ traceFile.close();
+
+ bp1 = LocalTraceBufferPool::instance();
+ CPPUNIT_ASSERT(bp1);
+
+ // --- Get or initialize the orb
+
+ int _argc = 1;
+ char* _argv[] = {""};
+ ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance() ;
+ ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting());
+ _orb = init(_argc , _argv ) ;
+
+ // --- Create a SALOME_NamingService instance
+
+ _NS.init_orb(_orb) ;
+}
+
+// ============================================================================
+/*!
+ * - delete trace classes
+ */
+// ============================================================================
+
+void
+LifeCycleCORBATest::tearDown()
+{
+
+ LocalTraceBufferPool* bp1 = LocalTraceBufferPool::instance();
+ CPPUNIT_ASSERT(bp1);
+ bp1->deleteInstance(bp1);
+}
+
+// ============================================================================
+/*!
+ * Check FindOrLoad_Component.
+ * - get a local container (no hostname given),
+ * load an engine, check that the CORBA object is not null.
+ * - check narrow
+ */
+// ============================================================================
+
+void
+LifeCycleCORBATest::testFindOrLoad_Component_LaunchContainer()
+{
+ SALOME_LifeCycleCORBA _LCC(&_NS);
+
+ // --- get a local container,
+ // load an engine, check that the CORBA object is not null
+
+ string containerName = "myContainer";
+ Engines::Component_var mycompo =
+ _LCC.FindOrLoad_Component(containerName.c_str(),"SalomeTestComponent");
+ CPPUNIT_ASSERT(!CORBA::is_nil(mycompo));
+
+ // --- check narrow
+
+ Engines::TestComponent_var m1;
+ m1 = Engines::TestComponent::_narrow(mycompo);
+ CPPUNIT_ASSERT(!CORBA::is_nil(m1));
+}
+
+// ============================================================================
+/*!
+ * Check FindOrLoad_Component.
+ * - Call 2 times FindOrLoad_Component with the same parameters
+ * - check if we get the same engine
+ */
+// ============================================================================
+
+void
+LifeCycleCORBATest::testFindOrLoad_Component_SameInstance()
+{
+ SALOME_LifeCycleCORBA _LCC(&_NS);
+
+ // --- get a local container,
+ // load an engine, check that the CORBA object is not null
+
+ string containerName = "myContainer";
+
+ Engines::Component_var mycompo1 =
+ _LCC.FindOrLoad_Component(containerName.c_str(),"SalomeTestComponent");
+ CPPUNIT_ASSERT(!CORBA::is_nil(mycompo1));
+
+ Engines::Component_var mycompo2 =
+ _LCC.FindOrLoad_Component(containerName.c_str(),"SalomeTestComponent");
+ CPPUNIT_ASSERT(!CORBA::is_nil(mycompo2));
+
+ // --- check narrow
+
+ Engines::TestComponent_var m1;
+ m1 = Engines::TestComponent::_narrow(mycompo1);
+ CPPUNIT_ASSERT(!CORBA::is_nil(m1));
+
+ Engines::TestComponent_var m2;
+ m2 = Engines::TestComponent::_narrow(mycompo2);
+ CPPUNIT_ASSERT(!CORBA::is_nil(m2));
+
+ // --- check equality of instance names
+
+ string name1 = m1->instanceName();
+ string name2 = m2->instanceName();
+ CPPUNIT_ASSERT_EQUAL(name1, name2);
+}
+
+// ============================================================================
+/*!
+ * Check FindOrLoad_Component with Python Component on C++ Container
+ * load an engine, check that the CORBA object is not null.
+ * - check narrow
+ */
+// ============================================================================
+
+void
+LifeCycleCORBATest::testFindOrLoad_Component_PythonInCppContainer()
+{
+ SALOME_LifeCycleCORBA _LCC(&_NS);
+
+ // --- get a local container,
+ // load an engine, check that the CORBA object is not null
+
+ string containerName = "myContainer";
+
+ Engines::Component_var mycompo1 =
+ _LCC.FindOrLoad_Component(containerName.c_str(),"SALOME_TestComponentPy");
+ CPPUNIT_ASSERT(!CORBA::is_nil(mycompo1));
+
+ // --- check narrow
+
+ Engines::TestComponent_var m1;
+ m1 = Engines::TestComponent::_narrow(mycompo1);
+ CPPUNIT_ASSERT(!CORBA::is_nil(m1));
+}
+
+// ============================================================================
+/*!
+ * Check FindOrLoad_Component with Python Component on C++ Container
+ * - Call 2 times FindOrLoad_Component with the same parameters
+ * - check if we get the same engine
+ */
+// ============================================================================
+
+void
+LifeCycleCORBATest::testFindOrLoad_Component_PythonSameInstance()
+{
+ SALOME_LifeCycleCORBA _LCC(&_NS);
+
+ // --- get a local container (with a name based on local hostname),
+ // load an engine, check that the CORBA object is not null
+
+ string containerName = "myContainer";
+
+ Engines::Component_var mycompo1 =
+ _LCC.FindOrLoad_Component(containerName.c_str(),"SALOME_TestComponentPy");
+ CPPUNIT_ASSERT(!CORBA::is_nil(mycompo1));
+
+ Engines::Component_var mycompo2 =
+ _LCC.FindOrLoad_Component(containerName.c_str(),"SALOME_TestComponentPy");
+ CPPUNIT_ASSERT(!CORBA::is_nil(mycompo2));
+
+ // --- check narrow
+
+ Engines::TestComponent_var m1;
+ m1 = Engines::TestComponent::_narrow(mycompo1);
+ CPPUNIT_ASSERT(!CORBA::is_nil(m1));
+
+ Engines::TestComponent_var m2;
+ m2 = Engines::TestComponent::_narrow(mycompo2);
+ CPPUNIT_ASSERT(!CORBA::is_nil(m2));
+
+ // --- check equality of instance names
+
+ string name1 = m1->instanceName();
+ string name2 = m2->instanceName();
+ CPPUNIT_ASSERT_EQUAL(name1, name2);
+}
+
+// ============================================================================
+/*!
+ * Check FindOrLoad_Component with a component name not in catalog.
+ * See list of catalog given to module catalog server.
+ * Here, we work with KERNEL_SRC/resources/KERNELCatalog.xml that contains
+ * only KERNEL, SalomeTestComponent and SALOME_TestComponentPy
+ */
+// ============================================================================
+
+void
+LifeCycleCORBATest::testFindOrLoad_Component_UnknownInCatalog()
+{
+ SALOME_LifeCycleCORBA _LCC(&_NS);
+
+ // --- get a local container (with a name based on local hostname),
+ // load an engine, check that the CORBA object is not null
+
+ string containerName = "myContainer";
+
+ Engines::Component_var mycompo1 =
+ _LCC.FindOrLoad_Component(containerName.c_str(),"MyNewComponent");
+ CPPUNIT_ASSERT(CORBA::is_nil(mycompo1));
+}
+
+// ============================================================================
+/*!
+ * Check FindOrLoad_Component with hostname given
+ * - get a local container : getHostName()/componentName,
+ * load an engine, check that the CORBA object is not null.
+ * - check narrow
+ */
+// ============================================================================
+
+void
+LifeCycleCORBATest::testFindOrLoad_Component_LaunchContainerHostname()
+{
+ SALOME_LifeCycleCORBA _LCC(&_NS);
+
+ // --- get a local container (with a name based on local hostname),
+ // load an engine, check that the CORBA object is not null
+
+ string containerName = GetHostname();
+ containerName += "/theContainer";
+ DEVTRACE("containerName = " << containerName);
+ Engines::Component_var mycompo =
+ _LCC.FindOrLoad_Component(containerName.c_str(),"SalomeTestComponent");
+ CPPUNIT_ASSERT(!CORBA::is_nil(mycompo));
+
+ // --- check narrow
+
+ Engines::TestComponent_var m1;
+ m1 = Engines::TestComponent::_narrow(mycompo);
+ CPPUNIT_ASSERT(!CORBA::is_nil(m1));
+}
+
+// ============================================================================
+/*!
+ * Check FindOrLoad_Component with and without local hostname given.
+ * We must get the same container, the same instance of component
+ */
+// ============================================================================
+
+void
+LifeCycleCORBATest::testFindOrLoad_Component_SameContainer()
+{
+ SALOME_LifeCycleCORBA _LCC(&_NS);
+
+ // --- get a local container (with a name based on local hostname),
+ // load an engine, check that the CORBA object is not null
+
+ string containerName = "aContainer";
+
+ Engines::Component_var mycompo1 =
+ _LCC.FindOrLoad_Component(containerName.c_str(),"SalomeTestComponent");
+ CPPUNIT_ASSERT(!CORBA::is_nil(mycompo1));
+
+ containerName = GetHostname();
+ containerName += "/aContainer";
+ DEVTRACE("containerName = " << containerName);
+ Engines::Component_var mycompo2 =
+ _LCC.FindOrLoad_Component(containerName.c_str(),"SalomeTestComponent");
+ CPPUNIT_ASSERT(!CORBA::is_nil(mycompo2));
+
+ // --- check narrow
+
+ Engines::TestComponent_var m1;
+ m1 = Engines::TestComponent::_narrow(mycompo1);
+ CPPUNIT_ASSERT(!CORBA::is_nil(m1));
+
+ Engines::TestComponent_var m2;
+ m2 = Engines::TestComponent::_narrow(mycompo2);
+ CPPUNIT_ASSERT(!CORBA::is_nil(m2));
+
+ // --- check equality of instance names
+
+ string name1 = m1->instanceName();
+ string name2 = m2->instanceName();
+ CPPUNIT_ASSERT_EQUAL(name1, name2);
+
+ // --- check containers are the same servant (same container name+hostname)
+
+ Engines::Container_var c1 = m1->GetContainerRef();
+ CPPUNIT_ASSERT(!CORBA::is_nil(c1));
+ Engines::Container_var c2 = m2->GetContainerRef();
+ CPPUNIT_ASSERT(!CORBA::is_nil(c1));
+ string cname1 = c1->name();
+ string cname2 = c2->name();
+ CPPUNIT_ASSERT_EQUAL(cname1, cname2);
+ string hostname1 = c1->getHostName();
+ string hostname2 = c2->getHostName();
+ CPPUNIT_ASSERT_EQUAL(hostname1, hostname2);
+ CORBA::Long pidc1 = c1->getPID();
+ CORBA::Long pidc2 = c2->getPID();
+ CPPUNIT_ASSERT_EQUAL(pidc1, pidc2);
+}
+
+// ============================================================================
+/*!
+ * Check FindOrLoad_Component: check behaviour when ask for an unknown computer
+ * We must catch a Salome Exception with "unknown host" message
+ */
+// ============================================================================
+
+void
+LifeCycleCORBATest::testFindOrLoad_Component_UnknownMachine()
+{
+ SALOME_LifeCycleCORBA _LCC(&_NS);
+
+ // --- try to get a distant container on an unknown machine (not existing)
+ // check that the CORBA object is null
+
+ string containerName = "aFarAwayComputer";
+ containerName += "/theContainer";
+// CPPUNIT_ASSERT_THROW(Engines::Component_var mycompo =
+// _LCC.FindOrLoad_Component(containerName.c_str(),"SalomeTestComponent");,SALOME::SALOME_Exception);
+ try
+ {
+ Engines::Component_var mycompo =
+ _LCC.FindOrLoad_Component(containerName.c_str(),"SalomeTestComponent");
+ }
+ catch(const SALOME::SALOME_Exception &ex)
+ {
+ CPPUNIT_ASSERT(true);
+// string expectedMessage = "BAD PARAM";
+// std::ostream os;
+// os << ex;
+// string actualMessage = os.str();
+// DEVTRACE("actual Exception Message = " << actualMessage);
+// CPPUNIT_ASSERT(actualMessage.find(expectedMessage) != string::npos);
+ }
+}
+
+// ============================================================================
+/*!
+ * Check FindOrLoad_Component, empty params must give an instance
+ */
+// ============================================================================
+
+void
+LifeCycleCORBATest::testFindOrLoad_Component_ParamsEmpty()
+{
+ SALOME_LifeCycleCORBA _LCC(&_NS);
+
+ Engines::MachineParameters params;
+ _LCC.preSet(params);
+ Engines::Component_var mycompo =
+ _LCC.FindOrLoad_Component(params,"SalomeTestComponent");
+ CPPUNIT_ASSERT(!CORBA::is_nil(mycompo));
+
+ // --- check narrow
+
+ Engines::TestComponent_var m1;
+ m1 = Engines::TestComponent::_narrow(mycompo);
+}
+
+// ============================================================================
+/*!
+ * Check FindOrLoad_Component params = local container
+ */
+// ============================================================================
+
+void
+LifeCycleCORBATest::testFindOrLoad_Component_ParamsLocalContainer()
+{
+ SALOME_LifeCycleCORBA _LCC(&_NS);
+
+ Engines::MachineParameters params;
+ _LCC.preSet(params);
+ string hostname=GetHostname();
+ params.hostname=hostname.c_str();
+ Engines::Component_var mycompo =
+ _LCC.FindOrLoad_Component(params,"SalomeTestComponent");
+ CPPUNIT_ASSERT(!CORBA::is_nil(mycompo));
+
+ // --- check narrow
+
+ Engines::TestComponent_var m1;
+ m1 = Engines::TestComponent::_narrow(mycompo);
+
+ // --- check container is on local computer
+
+ CPPUNIT_ASSERT(!CORBA::is_nil(m1));
+ Engines::Container_var c1 = m1->GetContainerRef();
+ CPPUNIT_ASSERT(!CORBA::is_nil(c1));
+ string hostname1 = c1->getHostName();
+ CPPUNIT_ASSERT_EQUAL(hostname1, GetHostname());
+}
+
+
+// ============================================================================
+/*!
+ * Check FindOrLoad_Component params = containerName
+ */
+// ============================================================================
+
+void
+LifeCycleCORBATest::testFindOrLoad_Component_ParamsContainerName()
+{
+ SALOME_LifeCycleCORBA _LCC(&_NS);
+
+ Engines::MachineParameters params;
+ _LCC.preSet(params);
+ string containerName = "myContainer";
+ params.container_name = containerName.c_str();
+ Engines::Component_var mycompo =
+ _LCC.FindOrLoad_Component(params,"SalomeTestComponent");
+ CPPUNIT_ASSERT(!CORBA::is_nil(mycompo));
+
+ // --- check narrow
+
+ Engines::TestComponent_var m1;
+ m1 = Engines::TestComponent::_narrow(mycompo);
+
+ // --- check container has good name
+
+ CPPUNIT_ASSERT(!CORBA::is_nil(m1));
+ Engines::Container_var c1 = m1->GetContainerRef();
+ CPPUNIT_ASSERT(!CORBA::is_nil(c1));
+ string hostname1 = c1->getHostName();
+ CPPUNIT_ASSERT_EQUAL(hostname1, GetHostname());
+ string cname1 = c1->name();
+ CPPUNIT_ASSERT(cname1.find(containerName) != string::npos);
+}
+
+
+// ============================================================================
+/*!
+ * Check FindOrLoad_Component params = containerName
+ */
+// ============================================================================
+
+// void
+// LifeCycleCORBATest::testFindOrLoad_Component_()
+// {
+// }
+
--- /dev/null
+
+#ifndef _LIFECYCLECORBATEST_HXX_
+#define _LIFECYCLECORBATEST_HXX_
+
+#include <cppunit/extensions/HelperMacros.h>
+
+#include <SALOMEconfig.h>
+#include CORBA_CLIENT_HEADER(SALOME_Component)
+#include CORBA_CLIENT_HEADER(SALOME_TestComponent)
+#include "SALOME_NamingService.hxx"
+
+class LifeCycleCORBATest : public CppUnit::TestFixture
+{
+ CPPUNIT_TEST_SUITE( LifeCycleCORBATest );
+ CPPUNIT_TEST( testFindOrLoad_Component_LaunchContainer );
+ CPPUNIT_TEST( testFindOrLoad_Component_SameInstance );
+ CPPUNIT_TEST( testFindOrLoad_Component_PythonInCppContainer );
+ CPPUNIT_TEST( testFindOrLoad_Component_PythonSameInstance );
+ CPPUNIT_TEST( testFindOrLoad_Component_UnknownInCatalog );
+ CPPUNIT_TEST( testFindOrLoad_Component_LaunchContainerHostname );
+ CPPUNIT_TEST( testFindOrLoad_Component_SameContainer );
+ CPPUNIT_TEST( testFindOrLoad_Component_UnknownMachine );
+ CPPUNIT_TEST( testFindOrLoad_Component_ParamsEmpty );
+ CPPUNIT_TEST( testFindOrLoad_Component_ParamsLocalContainer );
+ CPPUNIT_TEST( testFindOrLoad_Component_ParamsContainerName );
+// CPPUNIT_TEST( testFindOrLoad_Component_ );
+// CPPUNIT_TEST( );
+// CPPUNIT_TEST( );
+ CPPUNIT_TEST_SUITE_END();
+
+public:
+
+ void setUp();
+ void tearDown();
+
+ void testFindOrLoad_Component_LaunchContainer();
+ void testFindOrLoad_Component_SameInstance();
+ void testFindOrLoad_Component_PythonInCppContainer();
+ void testFindOrLoad_Component_PythonSameInstance();
+ void testFindOrLoad_Component_UnknownInCatalog();
+ void testFindOrLoad_Component_LaunchContainerHostname();
+ void testFindOrLoad_Component_SameContainer();
+ void testFindOrLoad_Component_UnknownMachine();
+ void testFindOrLoad_Component_ParamsEmpty();
+ void testFindOrLoad_Component_ParamsLocalContainer();
+ void testFindOrLoad_Component_ParamsContainerName();
+// void testFindOrLoad_Component_();
+
+protected:
+ CORBA::ORB_var _orb;
+ SALOME_NamingService _NS;
+};
+
+#endif
--- /dev/null
+# SALOMELocalTrace : log on local machine
+#
+# 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+#
+#
+#
+# File : Makefile.in
+# Author : Paul RASCLE (EDF)
+# Module : SALOME
+# $Header$
+
+top_srcdir=@top_srcdir@
+top_builddir=../../..
+srcdir=@srcdir@
+VPATH=.:@srcdir@:@top_srcdir@/idl
+
+
+@COMMENCE@
+
+# header files
+EXPORT_HEADERS= LifeCycleCORBATest.hxx
+
+EXPORT_PYSCRIPTS = TestLifeCycleCORBA.py
+
+# Libraries targets
+
+LIB = libLifeCycleCORBATest.la
+LIB_SRC = LifeCycleCORBATest.cxx
+LIB_CLIENT_IDL = SALOME_Component.idl SALOME_TestComponent.idl \
+ SALOME_Exception.idl
+
+# Executables targets
+
+BIN = TestLifeCycleCORBA
+BIN_SRC =
+
+LIBS= @LIBS@
+LDFLAGS+=
+
+LDFLAGSFORBIN+= \
+ -lSALOMELocalTraceTest -lSALOMELocalTrace -lSALOMEBasics \
+ -lSALOMETraceCollectorTest \
+ -lUtilsTest -lOpUtil \
+ -lSalomeNS -lSalomeContainer -lSalomeResourcesManager \
+ -lRegistry -lSalomeNotification \
+ -lLifeCycleCORBATest -lSalomeLifeCycleCORBA \
+ -lcppunit
+
+@CONCLUDE@
--- /dev/null
+
+// --- include all Unit Test from basics until the present directory
+
+#include "SALOMELocalTraceTest.hxx"
+#include "SALOMETraceCollectorTest.hxx"
+#include "UtilsTest.hxx"
+#include "LifeCycleCORBATest.hxx"
+
+// --- Registers the fixture into the 'registry'
+
+CPPUNIT_TEST_SUITE_REGISTRATION( SALOMELocalTraceTest );
+CPPUNIT_TEST_SUITE_REGISTRATION( SALOMETraceCollectorTest );
+CPPUNIT_TEST_SUITE_REGISTRATION( UtilsTest );
+CPPUNIT_TEST_SUITE_REGISTRATION( LifeCycleCORBATest );
+
+// --- generic Main program from Basic/Test
+
+#include "BasicMainTest.hxx"
--- /dev/null
+
+import sys, os,signal,string,commands
+import runSalome
+import orbmodule
+import TestKiller
+
+# get SALOME environment :
+
+args, modules_list, modules_root_dir = runSalome.get_config()
+runSalome.set_env(args, modules_list, modules_root_dir)
+
+# set environment for trace in logger
+# (with file, servers may be killed before the write to the file...)
+
+#os.environ["SALOME_trace"] = "file:/tmp/traceUnitTest.log"
+#os.environ["SALOME_trace"] = "local"
+os.environ["SALOME_trace"] = "with_logger"
+
+# launch CORBA naming server
+
+clt=orbmodule.client()
+
+# launch CORBA logger server
+
+myServer=runSalome.LoggerServer(args)
+myServer.run()
+clt.waitLogger("Logger")
+
+# launch notify server
+
+myServer=runSalome.NotifyServer(args,modules_root_dir)
+myServer.run()
+
+# launch registry server
+
+myServer=runSalome.RegistryServer(args)
+myServer.run()
+clt.waitNS("/Registry")
+
+# launch module catalog server
+
+cataServer=runSalome.CatalogServer(args)
+cataServer.setpath(modules_list,modules_root_dir)
+cataServer.run()
+clt.waitNS("/Kernel/ModulCatalog")
+
+# launch container manager server
+
+myCmServer = runSalome.ContainerManagerServer(args)
+myCmServer.setpath(modules_list,modules_root_dir)
+myCmServer.run()
+clt.waitNS("/ContainerManager")
+
+# execute Unit Test
+
+command = ['TestLifeCycleCORBA']
+ret = os.spawnvp(os.P_WAIT, command[0], command)
+
+# kill containers created by the Container Manager
+
+import Engines
+containerManager = clt.waitNS("/ContainerManager",Engines.ContainerManager)
+containerManager.Shutdown()
+
+# kill Test process
+
+TestKiller.killProcess(runSalome.process_id)
+++ /dev/null
-// SALOME LifeCycleCORBA : implementation of containers and engines life cycle both in Python and C++
-//
-// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
-//
-//
-//
-// File : TestLifeCycleCORBA.cxx
-// Author : Paul RASCLE, EDF - MARC TAJCHMAN, CEA
-// Module : SALOME
-// $Header$
-
-#include <iostream>
-#ifndef WNT
-#include <unistd.h>
-#endif
-#include <SALOMEconfig.h>
-#ifndef WNT
-#include CORBA_CLIENT_HEADER(SALOME_Component)
-#include CORBA_CLIENT_HEADER(SALOME_TestComponent)
-#else
-#include <SALOME_Component.hh>
-#include <SALOME_TestComponent.hh>
-#endif
-#include "SALOME_NamingService.hxx"
-#include "SALOME_LifeCycleCORBA.hxx"
-#include "utilities.h"
-#include "SALOMETraceCollector.hxx"
-#include <OpUtil.hxx>
-
-using namespace std;
-
-int main (int argc, char * argv[])
-{
-
- try
- {
- // Initializing omniORB
- CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);
- // LocalTraceCollector *myThreadTrace = SALOMETraceCollector::instance(orb);
-
- // Obtain a reference to the root POA
- CORBA::Object_var obj = orb->resolve_initial_references("RootPOA") ;
- PortableServer::POA_var poa = PortableServer::POA::_narrow(obj) ;
-
- SALOME_NamingService _NS(orb) ;
-
- SALOME_LifeCycleCORBA _LCC(&_NS) ;
-
- // get a local container (with a name based on local hostname),
- // load an engine, and invoque methods on that engine
-
- string containerName = GetHostname();
-
- cout << containerName << endl;
- cout << "FindOrLoadComponent " + containerName + "/" + "SalomeTestComponent" << endl;
- MESSAGE("FindOrLoadComponent " + containerName + "/" + "SalomeTestComponent" );
-
- Engines::Component_var mycompo =
- _LCC.FindOrLoad_Component(containerName.c_str(),"SalomeTestComponent");
-
- ASSERT(!CORBA::is_nil(mycompo));
-
- Engines::TestComponent_var m1;
- m1 = Engines::TestComponent::_narrow(mycompo);
-
- ASSERT(!CORBA::is_nil(m1));
-
- SCRUTE(m1->instanceName());
- MESSAGE("Coucou " << m1->Coucou(1L));
-
- // get another container (with a fixed name),
- // load an engine, and invoque methods on that engine
-
- string containerName2 = "FactoryServerPy";
-
- Engines::Component_var mycompo2 =
- _LCC.FindOrLoad_Component(containerName2.c_str(),"SALOME_TestComponentPy");
-
- ASSERT(!CORBA::is_nil(mycompo2));
-
- Engines::TestComponent_var m2;
- m2 = Engines::TestComponent::_narrow(mycompo2);
-
- ASSERT(!CORBA::is_nil(m2));
-
- SCRUTE(m2->instanceName());
- cout << m2->instanceName() << endl;
- MESSAGE("Coucou " << m2->Coucou(1L));
-
- Engines::Component_var mycompo3 = _LCC.FindOrLoad_Component("totoPy","SALOME_TestComponentPy");
- ASSERT(!CORBA::is_nil(mycompo3));
- Engines::TestComponent_var m3 = Engines::TestComponent::_narrow(mycompo3);
- ASSERT(!CORBA::is_nil(m3));
- cout << m3->instanceName() << endl;
-
- string containerName4 = containerName + "/titiPy";
- Engines::Component_var mycompo4 = _LCC.FindOrLoad_Component(containerName4.c_str(),"SALOME_TestComponentPy");
- ASSERT(!CORBA::is_nil(mycompo4));
- Engines::TestComponent_var m4 = Engines::TestComponent::_narrow(mycompo4);
- ASSERT(!CORBA::is_nil(m4));
- cout << m4->instanceName() << endl;
-
- }
- catch(CORBA::SystemException& ex)
- {
- INFOS("Caught system exception COMM_FAILURE -- unable to contact the object.");
- }
-#ifndef WNT
- catch(CORBA::SystemException&)
- {
- INFOS("Caught a CORBA::SystemException.");
- }
-#endif
- catch(CORBA::Exception&)
- {
- INFOS("Caught CORBA::Exception.");
- }
- catch(...)
- {
- INFOS("Caught unknown exception.");
- }
-
- return 0;
-}
-
--- /dev/null
+// SALOME LifeCycleCORBA : implementation of containers and engines life cycle both in Python and C++
+//
+// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : TestLifeCycleCORBA.cxx
+// Author : Paul RASCLE, EDF - MARC TAJCHMAN, CEA
+// Module : SALOME
+// $Header$
+
+#include <iostream>
+#ifndef WNT
+#include <unistd.h>
+#endif
+#include <SALOMEconfig.h>
+#ifndef WNT
+#include CORBA_CLIENT_HEADER(SALOME_Component)
+#include CORBA_CLIENT_HEADER(SALOME_TestComponent)
+#else
+#include <SALOME_Component.hh>
+#include <SALOME_TestComponent.hh>
+#endif
+#include "SALOME_NamingService.hxx"
+#include "SALOME_LifeCycleCORBA.hxx"
+#include "utilities.h"
+#include "SALOMETraceCollector.hxx"
+#include <OpUtil.hxx>
+
+using namespace std;
+
+int main (int argc, char * argv[])
+{
+
+ try
+ {
+ // Initializing omniORB
+ CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);
+ // LocalTraceCollector *myThreadTrace = SALOMETraceCollector::instance(orb);
+
+ // Obtain a reference to the root POA
+ CORBA::Object_var obj = orb->resolve_initial_references("RootPOA") ;
+ PortableServer::POA_var poa = PortableServer::POA::_narrow(obj) ;
+
+ SALOME_NamingService _NS(orb) ;
+
+ SALOME_LifeCycleCORBA _LCC(&_NS) ;
+
+ // get a local container (with a name based on local hostname),
+ // load an engine, and invoque methods on that engine
+
+ string containerName = GetHostname();
+
+ cout << containerName << endl;
+ cout << "FindOrLoadComponent " + containerName + "/" + "SalomeTestComponent" << endl;
+ MESSAGE("FindOrLoadComponent " + containerName + "/" + "SalomeTestComponent" );
+
+ Engines::Component_var mycompo =
+ _LCC.FindOrLoad_Component(containerName.c_str(),"SalomeTestComponent");
+
+ ASSERT(!CORBA::is_nil(mycompo));
+
+ Engines::TestComponent_var m1;
+ m1 = Engines::TestComponent::_narrow(mycompo);
+
+ ASSERT(!CORBA::is_nil(m1));
+
+ SCRUTE(m1->instanceName());
+ MESSAGE("Coucou " << m1->Coucou(1L));
+
+ // get another container (with a fixed name),
+ // load an engine, and invoque methods on that engine
+
+ string containerName2 = "FactoryServerPy";
+
+ Engines::Component_var mycompo2 =
+ _LCC.FindOrLoad_Component(containerName2.c_str(),"SALOME_TestComponentPy");
+
+ ASSERT(!CORBA::is_nil(mycompo2));
+
+ Engines::TestComponent_var m2;
+ m2 = Engines::TestComponent::_narrow(mycompo2);
+
+ ASSERT(!CORBA::is_nil(m2));
+
+ SCRUTE(m2->instanceName());
+ cout << m2->instanceName() << endl;
+ MESSAGE("Coucou " << m2->Coucou(1L));
+
+ Engines::Component_var mycompo3 = _LCC.FindOrLoad_Component("totoPy","SALOME_TestComponentPy");
+ ASSERT(!CORBA::is_nil(mycompo3));
+ Engines::TestComponent_var m3 = Engines::TestComponent::_narrow(mycompo3);
+ ASSERT(!CORBA::is_nil(m3));
+ cout << m3->instanceName() << endl;
+
+ string containerName4 = containerName + "/titiPy";
+ Engines::Component_var mycompo4 = _LCC.FindOrLoad_Component(containerName4.c_str(),"SALOME_TestComponentPy");
+ ASSERT(!CORBA::is_nil(mycompo4));
+ Engines::TestComponent_var m4 = Engines::TestComponent::_narrow(mycompo4);
+ ASSERT(!CORBA::is_nil(m4));
+ cout << m4->instanceName() << endl;
+
+ }
+ catch(CORBA::SystemException& ex)
+ {
+ INFOS("Caught system exception COMM_FAILURE -- unable to contact the object.");
+ }
+#ifndef WNT
+ catch(CORBA::SystemException&)
+ {
+ INFOS("Caught a CORBA::SystemException.");
+ }
+#endif
+ catch(CORBA::Exception&)
+ {
+ INFOS("Caught CORBA::Exception.");
+ }
+ catch(...)
+ {
+ INFOS("Caught unknown exception.");
+ }
+
+ return 0;
+}
+
"""
kills omniORB4 Naming Service on local machine.
Selects process corresponding to the port used in $OMNIORB_CONFIG file.
- works only with a single line $OMNIORB_CONFIG like
+ Works only with a single line $OMNIORB_CONFIG like
InitRef = NameService=corbaname::<hostname>:<port>
"""
fic=os.environ['OMNIORB_CONFIG']
except:
print " ---- process %s : %s inexistant"% (pid, cmd[0])
pass
+ del process_id[pid]
pass
killNamingService()
Logger/Test \
SALOMETraceCollector/Test \
Utils/Test \
+ LifeCycleCORBA/Test \
UnitTests
ifeq (@mpi_ok@,yes)
SALOME_ModuleCatalog_impl.cxx \
SALOME_ModuleCatalog_Acomponent_impl.cxx
+LIB_SERVER_IDL = SALOME_ModuleCatalog.idl SALOME_Exception.idl
+
CXXFLAGS+=-ftemplate-depth-32
# Executables targets
# trouble we have client and serveur and build don't known about this with rule
# 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 SALOME_Exception.idl
CPPFLAGS+= $(QT_MT_INCLUDES)
-LDFLAGS+= $(QT_MT_LIBS) -lSalomeNS -lSALOMELocalTrace -lOpUtil
+LDFLAGS+= $(QT_MT_LIBS) -lSalomeNS -lSALOMELocalTrace -lOpUtil -lSALOMEBasics
+
LDFLAGSFORBIN+= -lSalomeNS -lSALOMELocalTrace -lOpUtil -lSALOMEBasics
#include <qfileinfo.h>
using namespace std;
+#include "utilities.h"
+
#ifdef _DEBUG_
-static int MYDEBUG = 0;
+static int MYDEBUG = 1;
#else
-static int MYDEBUG = 0;
+static int MYDEBUG = 1;
#endif
static const char* SEPARATOR = ":";
ParserComponent *C_parser = NULL;
ParserPathPrefixes *pp = NULL;
- SALOME_ModuleCatalog::Acomponent_ptr compo = NULL;
-
+ SALOME_ModuleCatalog::Acomponent_ptr compo
+ = SALOME_ModuleCatalog::Acomponent::_nil();
C_parser = findComponent(s);
if (C_parser) {
-// DebugParserComponent(*C_parser);
+ // DebugParserComponent(*C_parser);
SALOME_ModuleCatalog::Component C_corba;
duplicate(C_corba, *C_parser);
// return NULL object
if(MYDEBUG) MESSAGE("Component with name " << name
<< " not found in catalog");
- compo = NULL;
}
return compo;
if (!C_parser)
for (unsigned int ind=0; ind < _personal_module_list.size();ind++)
- if (name.compare(_personal_module_list[ind].name) == 0)
- {
- if(MYDEBUG) MESSAGE("Component named " << name
- << " found in the personal catalog");
- C_parser = &(_personal_module_list[ind]);
- break;
- }
+ {
+ if (name.compare(_personal_module_list[ind].name) == 0)
+ {
+ if(MYDEBUG) MESSAGE("Component named " << name
+ << " found in the personal catalog");
+ C_parser = &(_personal_module_list[ind]);
+ break;
+ }
+ }
if (!C_parser)
for (unsigned int ind=0; ind < _general_module_list.size();ind++)
#ifndef MODULECATALOG_IMPL_H
#define MODULECATALOG_IMPL_H
-#include "utilities.h"
#include <string>
#include <map>
#include "SALOME_LoadRateManager.hxx"
+#include "utilities.h"
#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("");
+ MESSAGE("SALOME_LoadRateManager::FindBest " << hosts.length());
+
+ if (hosts.length() == 0)
+ return string("");
+
return string(hosts[0]);
}
#endif
class RESOURCESMANAGER_EXPORT SALOME_LoadRateManager
-{
-public:
- std::string FindBest(const Engines::MachineList& hosts);
-};
+ {
+
+ public:
+ std::string FindBest(const Engines::MachineList& hosts);
+ };
#endif
// SALOME ResourcesCatalog : implementation of catalog resources parsing (SALOME_ModuleCatalog.idl)
//
// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
//Function : SALOME_ResourcesCatalog_Handler
//Purpose: Constructor
//----------------------------------------------------------------------
-SALOME_ResourcesCatalog_Handler::SALOME_ResourcesCatalog_Handler(MapOfParserResourcesType& listOfResources):_resources_list(listOfResources)
+SALOME_ResourcesCatalog_Handler::
+SALOME_ResourcesCatalog_Handler(MapOfParserResourcesType& listOfResources):
+ _resources_list(listOfResources)
{
MESSAGE("SALOME_ResourcesCatalog_Handler creation");
//XML tags initialisation
- test_machine="machine";
- test_resources="resources";
-
- test_hostname="hostname";
- test_alias="alias";
- test_protocol="protocol";
- test_mode="mode";
- test_user_name="userName";
- test_modules="modules";
- test_module_name="moduleName";
- test_module_path="modulePath";
- test_pre_req_file_path="preReqFilePath";
- test_os="OS";
- test_mem_in_mb="memInMB";
- test_cpu_freq_mhz="CPUFreqMHz";
- test_nb_of_nodes="nbOfNodes";
- test_nb_of_proc_per_node="nbOfProcPerNode";
+ test_machine = "machine";
+ test_resources = "resources";
+
+ test_hostname = "hostname";
+ test_alias = "alias";
+ test_protocol = "protocol";
+ test_mode = "mode";
+ test_user_name = "userName";
+ test_modules = "modules";
+ test_module_name = "moduleName";
+ test_module_path = "modulePath";
+ test_pre_req_file_path = "preReqFilePath";
+ test_os = "OS";
+ test_mem_in_mb = "memInMB";
+ test_cpu_freq_mhz = "CPUFreqMHz";
+ test_nb_of_nodes = "nbOfNodes";
+ test_nb_of_proc_per_node = "nbOfProcPerNode";
}
//----------------------------------------------------------------------
//Function : GetResourcesAfterParsing
//Purpose: Retrieves DS after the file parse.
//----------------------------------------------------------------------
-const MapOfParserResourcesType& SALOME_ResourcesCatalog_Handler::GetResourcesAfterParsing() const
-{
- return _resources_list;
-}
+const MapOfParserResourcesType&
+SALOME_ResourcesCatalog_Handler::GetResourcesAfterParsing() const
+ {
+ return _resources_list;
+ }
//----------------------------------------------------------------------
//Function : startDocument
-//Purpose: overload handler function
+//Purpose: overload handler function
//----------------------------------------------------------------------
bool SALOME_ResourcesCatalog_Handler::startDocument()
{
//----------------------------------------------------------------------
//Function : startElement
-//Purpose: overload handler function
+//Purpose: overload handler function
//----------------------------------------------------------------------
-bool SALOME_ResourcesCatalog_Handler::startElement(const QString&,
- const QString&,
- const QString& name,
- const QXmlAttributes& attrs)
+bool
+SALOME_ResourcesCatalog_Handler::
+startElement( const QString&,
+ const QString&,
+ const QString& name,
+ const QXmlAttributes& attrs )
{
- for(int i=0;i<attrs.count();i++)
+ for (int i = 0;i < attrs.count();i++)
{
QString qName(attrs.localName(i));
std::string content(attrs.value(i).latin1());
- if((qName.compare(QString(test_hostname))==0))
- _resource.DataForSort._hostName = content;
- if((qName.compare(QString(test_alias))==0))
- _resource.Alias = content;
- if((qName.compare(QString(test_protocol))==0)){
- switch(content[0]) {
- case 'r':
- _resource.Protocol = rsh;
- break;
- case 's':
- _resource.Protocol = ssh;
- break;
- default:
- // If it'not in all theses cases, the protocol is affected to rsh
- _resource.Protocol = rsh;
- break;
- }
- }
- if((qName.compare(QString(test_mode))==0))
- {
- switch(content[0]) {
- case 'i':
- _resource.Mode = interactive;
- break;
- case 'b':
- _resource.Mode = batch;
- break;
- default:
- // If it'not in all theses cases, the mode is affected to interactive
- _resource.Mode = interactive;
- break;
- }
- }
- if((qName.compare(QString(test_user_name))==0))
- _resource.UserName = content;
- if((qName.compare(QString(test_module_name))==0))
- previous_module_name = content;
- if((qName.compare(QString(test_module_path))==0))
- previous_module_path = content;
- if((qName.compare(QString(test_pre_req_file_path))==0))
- _resource.PreReqFilePath = content;
- if((qName.compare(QString(test_os))==0))
- _resource.OS = content;
- if((qName.compare(QString(test_mem_in_mb))==0))
- _resource.DataForSort._memInMB = atoi(content.c_str());
- if((qName.compare(QString(test_cpu_freq_mhz))==0))
- _resource.DataForSort._CPUFreqMHz = atoi(content.c_str());
- if((qName.compare(QString(test_nb_of_nodes))==0))
- _resource.DataForSort._nbOfNodes = atoi(content.c_str());
- if((qName.compare(QString(test_nb_of_proc_per_node))==0))
- _resource.DataForSort._nbOfProcPerNode = atoi(content.c_str());
+
+ if ((qName.compare(QString(test_hostname)) == 0))
+ _resource.DataForSort._hostName = content;
+
+ if ((qName.compare(QString(test_alias)) == 0))
+ _resource.Alias = content;
+
+ if ((qName.compare(QString(test_protocol)) == 0))
+ {
+ switch (content[0])
+ {
+
+ case 'r':
+ _resource.Protocol = rsh;
+ break;
+
+ case 's':
+ _resource.Protocol = ssh;
+ break;
+
+ default:
+ // If it'not in all theses cases, the protocol is affected to rsh
+ _resource.Protocol = rsh;
+ break;
+ }
+ }
+
+ if ((qName.compare(QString(test_mode)) == 0))
+ {
+ switch (content[0])
+ {
+
+ case 'i':
+ _resource.Mode = interactive;
+ break;
+
+ case 'b':
+ _resource.Mode = batch;
+ break;
+
+ default:
+ // If it'not in all theses cases, the mode is affected to interactive
+ _resource.Mode = interactive;
+ break;
+ }
+ }
+
+ if ((qName.compare(QString(test_user_name)) == 0))
+ _resource.UserName = content;
+
+ if ((qName.compare(QString(test_module_name)) == 0))
+ previous_module_name = content;
+
+ if ((qName.compare(QString(test_module_path)) == 0))
+ previous_module_path = content;
+
+ if ((qName.compare(QString(test_pre_req_file_path)) == 0))
+ _resource.PreReqFilePath = content;
+
+ if ((qName.compare(QString(test_os)) == 0))
+ _resource.OS = content;
+
+ if ((qName.compare(QString(test_mem_in_mb)) == 0))
+ _resource.DataForSort._memInMB = atoi(content.c_str());
+
+ if ((qName.compare(QString(test_cpu_freq_mhz)) == 0))
+ _resource.DataForSort._CPUFreqMHz = atoi(content.c_str());
+
+ if ((qName.compare(QString(test_nb_of_nodes)) == 0))
+ _resource.DataForSort._nbOfNodes = atoi(content.c_str());
+
+ if ((qName.compare(QString(test_nb_of_proc_per_node)) == 0))
+ _resource.DataForSort._nbOfProcPerNode = atoi(content.c_str());
}
+
return true;
}
//----------------------------------------------------------------------
//Function : endElement
-//Purpose: overload handler function
+//Purpose: overload handler function
//----------------------------------------------------------------------
-bool SALOME_ResourcesCatalog_Handler::endElement(const QString&, const QString&,
- const QString& qName)
+bool SALOME_ResourcesCatalog_Handler::
+endElement(const QString&,
+ const QString&,
+ const QString& qName)
{
- if((qName.compare(QString(test_modules))==0))
+ if ((qName.compare(QString(test_modules)) == 0))
_resource.ModulesPath[previous_module_name] = previous_module_path;
- if((qName.compare(QString(test_machine))==0))
- _resources_list[_resource.DataForSort._hostName]=_resource;
+
+ if ((qName.compare(QString(test_machine)) == 0))
+ _resources_list[_resource.DataForSort._hostName] = _resource;
+
return true;
}
//----------------------------------------------------------------------
//Function : endDocument
-//Purpose: overload handler function
+//Purpose: overload handler function
//----------------------------------------------------------------------
bool SALOME_ResourcesCatalog_Handler::endDocument()
{
//_resources_list
-// for (unsigned int ind = 0; ind < _resources_list.size(); ind++)
-// {
-// MESSAGE("Resources name :"<<_resources_list[ind].Parsername);
-// MESSAGE("OS :"<<_resources_list[ind].ParserOS);
-// MESSAGE("OS version :"<<_resources_list[ind].ParserOS_version);
-// for (unsigned int i = 0; i < _resources_list[ind].Parserprocs.size(); i++)
-// {
-// MESSAGE("Proc number :" << _resources_list[ind].Parserprocs[i].Parsernumber);
-// MESSAGE("Model name :" << _resources_list[ind].Parserprocs[i].Parsermodel_name);
-// MESSAGE("CPU(MHz) :" << _resources_list[ind].Parserprocs[i].Parsercpu_mhz);
-// MESSAGE("Cache :" << _resources_list[ind].Parserprocs[i].Parsercache_size);
-// }
-// for (unsigned int j = 0; j < _resources_list[ind].Parsercontainertype.size(); j++)
-// MESSAGE("Container Type :" << _resources_list[ind].Parsercontainertype[j]);
-// }
- cout << "This is the end of document" << endl;
+ // for (unsigned int ind = 0; ind < _resources_list.size(); ind++)
+ // {
+ // MESSAGE("Resources name :"<<_resources_list[ind].Parsername);
+ // MESSAGE("OS :"<<_resources_list[ind].ParserOS);
+ // MESSAGE("OS version :"<<_resources_list[ind].ParserOS_version);
+ // for (unsigned int i = 0; i < _resources_list[ind].Parserprocs.size(); i++)
+ // {
+ // MESSAGE("Proc number :" << _resources_list[ind].Parserprocs[i].Parsernumber);
+ // MESSAGE("Model name :" << _resources_list[ind].Parserprocs[i].Parsermodel_name);
+ // MESSAGE("CPU(MHz) :" << _resources_list[ind].Parserprocs[i].Parsercpu_mhz);
+ // MESSAGE("Cache :" << _resources_list[ind].Parserprocs[i].Parsercache_size);
+ // }
+ // for (unsigned int j = 0; j < _resources_list[ind].Parsercontainertype.size(); j++)
+ // MESSAGE("Container Type :" << _resources_list[ind].Parsercontainertype[j]);
+ // }
+ MESSAGE("This is the end of document");
return true;
}
//----------------------------------------------------------------------
QString SALOME_ResourcesCatalog_Handler::errorProtocol()
{
- cout << "error prot !!!!!!!!!!!!!!!!!" << endl;
+ INFOS(" ------------- error protocole !");
return errorProt;
}
//Function : fatalError
//Purpose: overload handler function
//----------------------------------------------------------------------
-bool
-SALOME_ResourcesCatalog_Handler::fatalError(const QXmlParseException& exception)
+bool
+SALOME_ResourcesCatalog_Handler::fatalError
+(const QXmlParseException& exception)
{
- cout << "fatal error !!!!!!!!!!!!!!!!!" << endl;
- errorProt += QString( "fatal parsing error: %1 in line %2, column %3\n" )
- .arg( exception.message() )
- .arg( exception.lineNumber() )
- .arg( exception.columnNumber() );
+ INFOS(" ------------- fatal error !");
+ errorProt += QString( "fatal parsing error: %1 in line %2, column %3\n" )
+ .arg( exception.message() )
+ .arg( exception.lineNumber() )
+ .arg( exception.columnNumber() );
return QXmlDefaultHandler::fatalError( exception );
}
{
QDomElement root = doc.createElement("resources");
doc.appendChild(root);
- for(map<string, ParserResourcesType>::iterator iter=_resources_list.begin();iter!=_resources_list.end();iter++)
+
+ for (map<string, ParserResourcesType>::iterator iter =
+ _resources_list.begin();
+ iter != _resources_list.end();
+ iter++)
{
QDomElement eltRoot = doc.createElement(test_machine);
root.appendChild( eltRoot );
- eltRoot.setAttribute((char *)test_hostname,(*iter).first.c_str());
- eltRoot.setAttribute((char *)test_alias,(*iter).second.Alias.c_str());
- switch((*iter).second.Protocol)
- {
- case rsh:
- eltRoot.setAttribute((char *)test_protocol,"rsh");
- break;
- case ssh:
- eltRoot.setAttribute((char *)test_protocol,"ssh");
- break;
- default:
- eltRoot.setAttribute((char *)test_protocol,"rsh");
- }
- switch((*iter).second.Mode)
- {
- case interactive:
- eltRoot.setAttribute((char *)test_mode,"interactive");
- break;
- case batch:
- eltRoot.setAttribute((char *)test_mode,"batch");
- break;
- default:
- eltRoot.setAttribute((char *)test_mode,"interactive");
- }
- eltRoot.setAttribute((char *)test_user_name,(*iter).second.UserName.c_str());
- for(map<string, string>::const_iterator iter2=(*iter).second.ModulesPath.begin();iter2!=(*iter).second.ModulesPath.end();iter2++)
- {
- QDomElement rootForModulesPaths=doc.createElement(test_modules);
- rootForModulesPaths.setAttribute(test_module_name,(*iter2).first.c_str());
- rootForModulesPaths.setAttribute(test_module_path,(*iter2).second.c_str());
- eltRoot.appendChild(rootForModulesPaths);
- }
- eltRoot.setAttribute(test_pre_req_file_path,(*iter).second.PreReqFilePath.c_str());
- eltRoot.setAttribute(test_os,(*iter).second.OS.c_str());
- eltRoot.setAttribute(test_mem_in_mb,(*iter).second.DataForSort._memInMB);
- eltRoot.setAttribute(test_cpu_freq_mhz,(*iter).second.DataForSort._CPUFreqMHz);
- eltRoot.setAttribute(test_nb_of_nodes,(*iter).second.DataForSort._nbOfNodes);
- eltRoot.setAttribute(test_nb_of_proc_per_node,(*iter).second.DataForSort._nbOfProcPerNode);
+ eltRoot.setAttribute((char *)test_hostname, (*iter).first.c_str());
+ eltRoot.setAttribute((char *)test_alias, (*iter).second.Alias.c_str());
+
+ switch ((*iter).second.Protocol)
+ {
+
+ case rsh:
+ eltRoot.setAttribute((char *)test_protocol, "rsh");
+ break;
+
+ case ssh:
+ eltRoot.setAttribute((char *)test_protocol, "ssh");
+ break;
+
+ default:
+ eltRoot.setAttribute((char *)test_protocol, "rsh");
+ }
+
+ switch ((*iter).second.Mode)
+ {
+
+ case interactive:
+ eltRoot.setAttribute((char *)test_mode, "interactive");
+ break;
+
+ case batch:
+ eltRoot.setAttribute((char *)test_mode, "batch");
+ break;
+
+ default:
+ eltRoot.setAttribute((char *)test_mode, "interactive");
+ }
+
+ eltRoot.setAttribute((char *)test_user_name,
+ (*iter).second.UserName.c_str());
+
+ for (map<string, string>::const_iterator iter2 =
+ (*iter).second.ModulesPath.begin();
+ iter2 != (*iter).second.ModulesPath.end();
+ iter2++)
+ {
+ QDomElement rootForModulesPaths = doc.createElement(test_modules);
+ rootForModulesPaths.setAttribute(test_module_name,
+ (*iter2).first.c_str());
+ rootForModulesPaths.setAttribute(test_module_path,
+ (*iter2).second.c_str());
+ eltRoot.appendChild(rootForModulesPaths);
+ }
+
+ eltRoot.setAttribute(test_pre_req_file_path,
+ (*iter).second.PreReqFilePath.c_str());
+ eltRoot.setAttribute(test_os, (*iter).second.OS.c_str());
+ eltRoot.setAttribute(test_mem_in_mb,
+ (*iter).second.DataForSort._memInMB);
+ eltRoot.setAttribute(test_cpu_freq_mhz,
+ (*iter).second.DataForSort._CPUFreqMHz);
+ eltRoot.setAttribute(test_nb_of_nodes,
+ (*iter).second.DataForSort._nbOfNodes);
+ eltRoot.setAttribute(test_nb_of_proc_per_node,
+ (*iter).second.DataForSort._nbOfProcPerNode);
}
}
// SALOME ResourcesCatalog : implementation of catalog resources parsing (SALOME_ModuleCatalog.idl)
//
// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
#include <vector>
class QDomElement;
+
class QDomDocument;
class SALOME_ResourcesCatalog_Handler : public QXmlDefaultHandler
-{
-public :
- //! standard constructor
- SALOME_ResourcesCatalog_Handler(MapOfParserResourcesType& listOfResources);
-
- const MapOfParserResourcesType& GetResourcesAfterParsing() const;
-
- //! standard destructor
- virtual ~SALOME_ResourcesCatalog_Handler();
-
- //! method to overload handler function startDocument
- /*! is called before a xml file is parsed
- \return true if no error was detected
- */
- virtual bool startDocument();
-
- //! method to overload handler function startElement
- /*!
- \param QString argument by value
- \param QString argument by value
- \param QString qName argument by value
- \param QXmlAttributes atts argument by value
- \return true if no error was detected
- */
- virtual bool startElement(const QString& , const QString& ,
- const QString& name, const QXmlAttributes& attrs);
-
- //! method to overload handler function endElement
- /*!
- \param QString argument by value
- \param QString argument by value
- \param QString qName argument by value
- \return true if no error was detected
- */
- virtual bool endElement(const QString&, const QString&,
- const QString& qName);
-
- //! method to overload handler function characters
- /*!
- \param QString chars argument by value
- \return true if no error was detected
- */
- virtual bool characters(const QString& chars);
-
- //! method to overload handler function endDocument
- /*! is called at the end of the parsing
- \return true if no error was detected
- */
- virtual bool endDocument();
-
- //! method to overload handler function errorProtocol
- /*!
- \return the error message
- */
- virtual QString errorProtocol();
-
-//! method to overload handler function fatalError
- /*!
- \param QXmlParseException exception argument by value
- \return true if no error was detected
- */
- virtual bool fatalError(const QXmlParseException& exception);
-
-//! method to fill the document to be writen in a file
- void PrepareDocToXmlFile(QDomDocument& doc);
-
-private :
- QString errorProt;
- std::string content;
- std::string previous_module_name;
- std::string previous_module_path;
-
- ParserResourcesType _resource;
- MapOfParserResourcesType& _resources_list;
-
- const char *test_machine;
- const char *test_resources;
-
- const char *test_hostname;
- const char *test_alias;
- const char *test_protocol;
- const char *test_mode;
- const char *test_user_name;
- const char *test_modules;
- const char *test_module_name;
- const char *test_module_path;
- const char *test_pre_req_file_path;
- const char *test_os;
- const char *test_mem_in_mb;
- const char *test_cpu_freq_mhz;
- const char *test_nb_of_nodes;
- const char *test_nb_of_proc_per_node;
-
-};
+ {
+
+ public :
+ //! standard constructor
+ SALOME_ResourcesCatalog_Handler(MapOfParserResourcesType& listOfResources);
+
+ const MapOfParserResourcesType& GetResourcesAfterParsing() const;
+
+ //! standard destructor
+ virtual ~SALOME_ResourcesCatalog_Handler();
+
+ //! method to overload handler function startDocument
+ /*! is called before a xml file is parsed
+ \return true if no error was detected
+ */
+ virtual bool startDocument();
+
+ //! method to overload handler function startElement
+ /*!
+ \param QString argument by value
+ \param QString argument by value
+ \param QString qName argument by value
+ \param QXmlAttributes atts argument by value
+ \return true if no error was detected
+ */
+ virtual bool startElement(const QString& , const QString& ,
+ const QString& name,
+ const QXmlAttributes& attrs);
+
+ //! method to overload handler function endElement
+ /*!
+ \param QString argument by value
+ \param QString argument by value
+ \param QString qName argument by value
+ \return true if no error was detected
+ */
+ virtual bool endElement(const QString&, const QString&,
+ const QString& qName);
+
+ //! method to overload handler function characters
+ /*!
+ \param QString chars argument by value
+ \return true if no error was detected
+ */
+ virtual bool characters(const QString& chars);
+
+ //! method to overload handler function endDocument
+ /*! is called at the end of the parsing
+ \return true if no error was detected
+ */
+ virtual bool endDocument();
+
+ //! method to overload handler function errorProtocol
+ /*!
+ \return the error message
+ */
+ virtual QString errorProtocol();
+
+ //! method to overload handler function fatalError
+ /*!
+ \param QXmlParseException exception argument by value
+ \return true if no error was detected
+ */
+ virtual bool fatalError(const QXmlParseException& exception);
+
+ //! method to fill the document to be writen in a file
+ void PrepareDocToXmlFile(QDomDocument& doc);
+
+ private :
+ QString errorProt;
+ std::string content;
+ std::string previous_module_name;
+ std::string previous_module_path;
+
+ ParserResourcesType _resource;
+ MapOfParserResourcesType& _resources_list;
+
+ const char *test_machine;
+ const char *test_resources;
+
+ const char *test_hostname;
+ const char *test_alias;
+ const char *test_protocol;
+ const char *test_mode;
+ const char *test_user_name;
+ const char *test_modules;
+ const char *test_module_name;
+ const char *test_module_path;
+ const char *test_pre_req_file_path;
+ const char *test_os;
+ const char *test_mem_in_mb;
+ const char *test_cpu_freq_mhz;
+ const char *test_nb_of_nodes;
+ const char *test_nb_of_proc_per_node;
+
+ };
#endif // SALOME_RESOURCES_CATALOG_HANDLER
#include "SALOME_ResourcesCatalog_Parser.hxx"
+#include "utilities.h"
#include <iostream>
#define NULL_VALUE 0
using namespace std;
-unsigned int ResourceDataToSort::_nbOfNodesWanted=NULL_VALUE;
-unsigned int ResourceDataToSort::_nbOfProcPerNodeWanted=NULL_VALUE;
-unsigned int ResourceDataToSort::_CPUFreqMHzWanted=NULL_VALUE;
-unsigned int ResourceDataToSort::_memInMBWanted=NULL_VALUE;
+unsigned int ResourceDataToSort::_nbOfNodesWanted = NULL_VALUE;
+unsigned int ResourceDataToSort::_nbOfProcPerNodeWanted = NULL_VALUE;
+unsigned int ResourceDataToSort::_CPUFreqMHzWanted = NULL_VALUE;
+unsigned int ResourceDataToSort::_memInMBWanted = NULL_VALUE;
ResourceDataToSort::ResourceDataToSort()
-{
-}
+{}
-ResourceDataToSort::ResourceDataToSort(const string& hostname,unsigned int nbOfNodes,unsigned int nbOfProcPerNode,unsigned int CPUFreqMHz,unsigned int memInMB):_hostName(hostname),_nbOfNodes(nbOfNodes),_nbOfProcPerNode(nbOfProcPerNode),_CPUFreqMHz(CPUFreqMHz),_memInMB(memInMB)
-{
-}
+ResourceDataToSort::ResourceDataToSort(const string& hostname,
+ unsigned int nbOfNodes,
+ unsigned int nbOfProcPerNode,
+ unsigned int CPUFreqMHz,
+ unsigned int memInMB):
+ _hostName(hostname),
+ _nbOfNodes(nbOfNodes),
+ _nbOfProcPerNode(nbOfProcPerNode),
+ _CPUFreqMHz(CPUFreqMHz),
+ _memInMB(memInMB)
+{}
//! Method used by list::sort to sort the resources used in SALOME_ResourcesManager::GetResourcesFitting
bool ResourceDataToSort::operator< (const ResourceDataToSort& other) const
-{
- unsigned int nbPts=GetNumberOfPoints();
- return nbPts<other.GetNumberOfPoints();
-}
+ {
+ unsigned int nbPts = GetNumberOfPoints();
+ return nbPts < other.GetNumberOfPoints();
+ }
unsigned int ResourceDataToSort::GetNumberOfPoints() const
-{
- unsigned int ret=0;
- //priority 1 : Nb of nodes
- if(_nbOfNodesWanted!=NULL_VALUE)
- {
- if(_nbOfNodes==_nbOfNodesWanted)
- ret+=3000;
- else if(_nbOfNodes>_nbOfNodesWanted)
- ret+=2000;
- else
- ret+=1000;
- }
- //priority 2 : Nb of proc by node
- if(_nbOfProcPerNodeWanted!=NULL_VALUE)
- {
- if(_nbOfProcPerNode==_nbOfProcPerNodeWanted)
- ret+=300;
- else if(_nbOfProcPerNode > _nbOfProcPerNodeWanted)
- ret+=200;
- else
- ret+=100;
- }
- //priority 3 : Cpu freq
- if(_CPUFreqMHzWanted!=NULL_VALUE)
- {
- if(_CPUFreqMHz==_CPUFreqMHzWanted)
- ret+=30;
- else if(_CPUFreqMHz > _CPUFreqMHzWanted)
- ret+=20;
- else
- ret+=10;
- }
- //priority 4 : memory
- if(_memInMBWanted!=NULL_VALUE)
- {
- if(_memInMB==_memInMBWanted)
- ret+=3;
- else if(_memInMB > _memInMBWanted)
- ret+=2;
- else
- ret+=1;
- }
- return ret;
-}
+ {
+ unsigned int ret = 0;
+ //priority 1 : Nb of nodes
+
+ if (_nbOfNodesWanted != NULL_VALUE)
+ {
+ if (_nbOfNodes == _nbOfNodesWanted)
+ ret += 3000;
+ else if (_nbOfNodes > _nbOfNodesWanted)
+ ret += 2000;
+ else
+ ret += 1000;
+ }
+
+ //priority 2 : Nb of proc by node
+ if (_nbOfProcPerNodeWanted != NULL_VALUE)
+ {
+ if (_nbOfProcPerNode == _nbOfProcPerNodeWanted)
+ ret += 300;
+ else if (_nbOfProcPerNode > _nbOfProcPerNodeWanted)
+ ret += 200;
+ else
+ ret += 100;
+ }
+
+ //priority 3 : Cpu freq
+ if (_CPUFreqMHzWanted != NULL_VALUE)
+ {
+ if (_CPUFreqMHz == _CPUFreqMHzWanted)
+ ret += 30;
+ else if (_CPUFreqMHz > _CPUFreqMHzWanted)
+ ret += 20;
+ else
+ ret += 10;
+ }
+
+ //priority 4 : memory
+ if (_memInMBWanted != NULL_VALUE)
+ {
+ if (_memInMB == _memInMBWanted)
+ ret += 3;
+ else if (_memInMB > _memInMBWanted)
+ ret += 2;
+ else
+ ret += 1;
+ }
+
+ return ret;
+ }
//! Method used for debug
void ResourceDataToSort::Print() const
+ {
+ SCRUTE(_nbOfNodes);
+ SCRUTE(_nbOfProcPerNode);
+ SCRUTE(_CPUFreqMHz);
+ SCRUTE(_memInMB);
+ }
+
+void ParserResourcesType::Print()
{
- cout << "Nb of nodes : " << _nbOfNodes << endl;
- cout << "Nb of proc per node : " << _nbOfProcPerNode << endl;
- cout << "CPU : " << _CPUFreqMHz << endl;
- cout << "Mem : " << _memInMB << endl;
-}
+ MESSAGE("##############*****");
+ MESSAGE("HostName : " << DataForSort._hostName);
+ MESSAGE("Alias : " << Alias);
+ MESSAGE("Protocol : " << Protocol);
+ MESSAGE("Mode : " << Mode);
+ MESSAGE("UserName : " << UserName);
+ MESSAGE("Modules : ");
+ int i = 1;
+
+ for (std::map<std::string, std::string>::iterator iter = ModulesPath.begin();
+ iter != ModulesPath.end();
+ iter++)
+ {
+ MESSAGE("Module " << i++ << " called : " << (*iter).first
+ << " with path : " << (*iter).second);
+ }
+ MESSAGE("PreReqFilePath : " << PreReqFilePath);
+ MESSAGE("OS : " << OS);
+ DataForSort.Print();
+}
// SALOME ResourcesCatalog : implementation of catalog resources parsing (SALOME_ModuleCatalog.idl)
//
// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
enum AccessModeType {interactive, batch};
-class ResourceDataToSort {
-public:
- std::string _hostName;
- unsigned int _nbOfNodes;
- unsigned int _nbOfProcPerNode;
- unsigned int _CPUFreqMHz;
- unsigned int _memInMB;
- static unsigned int _nbOfNodesWanted;
- static unsigned int _nbOfProcPerNodeWanted;
- static unsigned int _CPUFreqMHzWanted;
- static unsigned int _memInMBWanted;
-public:
- ResourceDataToSort();
- ResourceDataToSort(const std::string& hostname,unsigned int nbOfNodes,unsigned int nbOfProcPerNode,unsigned int CPUFreqMHz,unsigned int memInMB);
- bool operator< (const ResourceDataToSort& other) const;
- void Print() const;
-private:
- unsigned int GetNumberOfPoints() const;
-// friend class SALOME_ResourcesCatalog_Handler;
-// friend class SALOME_ResourcesManager;
-// friend struct ParserResourcesType;
-};
+class ResourceDataToSort
+ {
+
+ public:
+ std::string _hostName;
+ unsigned int _nbOfNodes;
+ unsigned int _nbOfProcPerNode;
+ unsigned int _CPUFreqMHz;
+ unsigned int _memInMB;
+ static unsigned int _nbOfNodesWanted;
+ static unsigned int _nbOfProcPerNodeWanted;
+ static unsigned int _CPUFreqMHzWanted;
+ static unsigned int _memInMBWanted;
+
+ public:
+ ResourceDataToSort();
+ ResourceDataToSort(const std::string& hostname,
+ unsigned int nbOfNodes,
+ unsigned int nbOfProcPerNode,
+ unsigned int CPUFreqMHz,
+ unsigned int memInMB);
+ bool operator< (const ResourceDataToSort& other) const;
+ void Print() const;
+
+ private:
+ unsigned int GetNumberOfPoints() const;
+ };
-struct ParserResourcesType {
- ResourceDataToSort DataForSort;
- std::string Alias;
- AccessProtocolType Protocol;
- AccessModeType Mode;
- std::string UserName;
- MapOfModulesPath ModulesPath;
- std::string PreReqFilePath;
- std::string OS;
+struct ParserResourcesType
+ {
+ ResourceDataToSort DataForSort;
+ std::string Alias;
+ AccessProtocolType Protocol;
+ AccessModeType Mode;
+ std::string UserName;
+ MapOfModulesPath ModulesPath;
+ std::string PreReqFilePath;
+ std::string OS;
- void Print(){
- std::cout << "##############*****" << std::endl;
- std::cout << "HostName : " << DataForSort._hostName << std::endl;
- std::cout << "Alias : " << Alias << std::endl;
- std::cout << "Protocol : " << Protocol << std::endl;
- std::cout << "Mode : " << Mode << std::endl;
- std::cout << "UserName : " << UserName << std::endl;
- std::cout << "Modules : " << std::endl;
- int i=1;
- for(std::map<std::string, std::string>::iterator iter=ModulesPath.begin();iter!=ModulesPath.end();iter++)
- {
- std::cout << " Module " << i++ << " called : " << (*iter).first << " with path : " << (*iter).second << std::endl;
- }
- std::cout << "PreReqFilePath : " << PreReqFilePath << std::endl;
- std::cout << "OS : " << OS << std::endl;
- DataForSort.Print();
- }
-};
+ void Print();
+ };
typedef std::map<std::string, ParserResourcesType> MapOfParserResourcesType;
-#include "SALOME_ResourcesManager.hxx"
+#include "SALOME_ResourcesManager.hxx"
//#include "SALOME_Container_i.hxx"
#include "Utils_ExceptHandlers.hxx"
#include "OpUtil.hxx"
using namespace std;
-//just for test
-SALOME_ResourcesManager::SALOME_ResourcesManager(CORBA::ORB_ptr orb,const char *xmlFilePath):_path_resources(xmlFilePath)
+//=============================================================================
+/*!
+ * just for test
+ */
+//=============================================================================
+
+SALOME_ResourcesManager::
+SALOME_ResourcesManager(CORBA::ORB_ptr orb,
+ const char *xmlFilePath) :
+ _path_resources(xmlFilePath)
{
- _NS=new SALOME_NamingService(orb);
+ _NS = new SALOME_NamingService(orb);
}
+//=============================================================================
+/*!
+ * Standard constructor, parse resource file.
+ * - if ${APPLI} exists in environment,
+ * look for ${HOME}/*{APPLI}/CatalogResources.xml
+ * - else look for default:
+ * ${KERNEL_ROOT_DIR}/share/salome/resources/CatalogResources.xml
+ * - parse XML resource file.
+ */
+//=============================================================================
+
SALOME_ResourcesManager::SALOME_ResourcesManager(CORBA::ORB_ptr orb)
{
- _NS=new SALOME_NamingService(orb);
-// _path_resources=getenv("KERNEL_ROOT_DIR");
-// _path_resources+="/share/salome/resources/CatalogResources.xml";
- _path_resources=getenv("HOME");
- _path_resources+="/";
- _path_resources+=getenv("APPLI");
- _path_resources+="/CatalogResources.xml";
+ _NS = new SALOME_NamingService(orb);
+ // _path_resources=getenv("KERNEL_ROOT_DIR");
+ // _path_resources+="/share/salome/resources/CatalogResources.xml";
+ _path_resources = getenv("HOME");
+ _path_resources += "/";
+ _path_resources += getenv("APPLI");
+ _path_resources += "/CatalogResources.xml";
ParseXmlFile();
}
+//=============================================================================
+/*!
+ * Standard Destructor
+ */
+//=============================================================================
+
SALOME_ResourcesManager::~SALOME_ResourcesManager()
{
delete _NS;
}
-vector<string> SALOME_ResourcesManager::GetFittingResources(const Engines::MachineParameters& params,const char *moduleName) throw(SALOME_Exception)
+//=============================================================================
+/*!
+ * get the list of name of ressources fitting for the specified module.
+ * If hostname specified, check it is local or known in resources catalog.
+ *
+ * Else
+ * - select first machines with corresponding OS (all machines if
+ * parameter OS empty),
+ * - then select the sublist of machines on witch the module is known
+ * (if the result is empty, that probably means that the inventory of
+ * modules is probably not done, so give complete list from previous step)
+ *
+ */
+//=============================================================================
+
+vector<string>
+SALOME_ResourcesManager::
+GetFittingResources(const Engines::MachineParameters& params,
+ const char *moduleName)
+throw(SALOME_Exception)
{
MESSAGE("ResourcesManager::GetFittingResources");
vector <std::string> ret;
- //To be sure that we search in a correct list.
+
+ // --- To be sure that we search in a correct list.
ParseXmlFile();
- const char *hostname=(const char *)params.hostname;
- MESSAGE("GetFittingResources " << hostname << "" << GetHostname().c_str());
- if(hostname[0]!='\0')
+
+ const char *hostname = (const char *)params.hostname;
+ MESSAGE("GetFittingResources " << hostname << " " << GetHostname().c_str());
+
+ 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.hostame is in the list of resources so return it.
- ret.push_back(hostname);
- } else{
- //user specified an unknown hostame so notify to him.
- MESSAGE("ResourcesManager::GetFittingResources : SALOME_Exception");
- throw SALOME_Exception("unknown host");
- }
+ 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.hostame is in the list of resources so return it.
+ ret.push_back(hostname);
+ }
+
+ else
+ {
+ // --- 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
+ // --- Search for available resources sorted by priority
{
- SelectOnlyResourcesWithOS(ret,params.OS);
- KeepOnlyResourcesWithModule(ret,moduleName);
- //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
+ SelectOnlyResourcesWithOS(ret, params.OS);
+
+ KeepOnlyResourcesWithModule(ret, moduleName);
+ 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);
+
+ 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;
+
+ unsigned int i = 0;
+
+ for (list<ResourceDataToSort>::iterator iter2 = li.begin();
+ iter2 != li.end();
+ iter2++)
+ ret[i++] = (*iter2)._hostName;
}
+
MESSAGE("ResourcesManager::GetFittingResources : return" << ret.size());
return ret;
}
-int SALOME_ResourcesManager::AddResourceInCatalog(const Engines::MachineParameters& paramsOfNewResources, const map<string,string>& modulesOnNewResources,
- const char *environPathOfPrerequired,
- const char *alias, const char *userName, AccessModeType mode, AccessProtocolType prot) throw(SALOME_Exception)
+//=============================================================================
+/*!
+ * add an entry in the ressources catalog xml file.
+ * Return 1 if OK.
+ * Return 0 if the ressource with the same hostname already exists.
+ *
+ */
+//=============================================================================
+
+int
+SALOME_ResourcesManager::
+AddResourceInCatalog(const Engines::MachineParameters& paramsOfNewResources,
+ const map<string, string>& modulesOnNewResources,
+ const char *environPathOfPrerequired,
+ const char *alias,
+ const char *userName,
+ AccessModeType mode,
+ AccessProtocolType prot)
+throw(SALOME_Exception)
{
- map<string,string>::const_iterator iter=modulesOnNewResources.find("KERNEL");
- if(iter!=modulesOnNewResources.end())
+ map<string, string>::const_iterator iter =
+ modulesOnNewResources.find("KERNEL");
+
+ if (iter != modulesOnNewResources.end())
{
ParserResourcesType newElt;
- newElt.DataForSort._hostName=paramsOfNewResources.hostname;
- newElt.Alias=alias;
- newElt.Protocol=prot;
- newElt.Mode=mode;
- newElt.UserName=userName;
- newElt.ModulesPath=modulesOnNewResources;
- newElt.PreReqFilePath=environPathOfPrerequired;
- newElt.OS=paramsOfNewResources.OS;
- newElt.DataForSort._memInMB=paramsOfNewResources.mem_mb;
- newElt.DataForSort._CPUFreqMHz=paramsOfNewResources.cpu_clock;
- newElt.DataForSort._nbOfNodes=paramsOfNewResources.nb_node;
- newElt.DataForSort._nbOfProcPerNode=paramsOfNewResources.nb_proc_per_node;
- _resourcesList[newElt.DataForSort._hostName]=newElt;
+ newElt.DataForSort._hostName = paramsOfNewResources.hostname;
+ newElt.Alias = alias;
+ newElt.Protocol = prot;
+ newElt.Mode = mode;
+ newElt.UserName = userName;
+ newElt.ModulesPath = modulesOnNewResources;
+ newElt.PreReqFilePath = environPathOfPrerequired;
+ newElt.OS = paramsOfNewResources.OS;
+ newElt.DataForSort._memInMB = paramsOfNewResources.mem_mb;
+ newElt.DataForSort._CPUFreqMHz = paramsOfNewResources.cpu_clock;
+ newElt.DataForSort._nbOfNodes = paramsOfNewResources.nb_node;
+ newElt.DataForSort._nbOfProcPerNode =
+ paramsOfNewResources.nb_proc_per_node;
+ _resourcesList[newElt.DataForSort._hostName] = newElt;
return 0;
}
+
else
throw SALOME_Exception("KERNEL is not present in this resource");
}
+
+//=============================================================================
+/*!
+ * Deletes a resource from the catalog
+ */
+//=============================================================================
+
void SALOME_ResourcesManager::DeleteResourceInCatalog(const char *hostname)
{
_resourcesList.erase(hostname);
}
+
+//=============================================================================
+/*!
+ * write the current data in memory in file.
+ */
+//=============================================================================
+
void SALOME_ResourcesManager::WriteInXmlFile()
{
QDomDocument doc("ResourcesCatalog");
- SALOME_ResourcesCatalog_Handler* handler = new SALOME_ResourcesCatalog_Handler(_resourcesList);
+ SALOME_ResourcesCatalog_Handler* handler =
+ new SALOME_ResourcesCatalog_Handler(_resourcesList);
handler->PrepareDocToXmlFile(doc);
delete handler;
QFile file( _path_resources );
- if( !file.open( IO_WriteOnly ) )
+
+ if ( !file.open( IO_WriteOnly ) )
cout << "WRITING ERROR !!!" << endl;
QTextStream ts( &file );
+
ts << doc.toString();
file.close();
+
cout << "WRITING DONE!!!" << endl;
}
-const MapOfParserResourcesType& SALOME_ResourcesManager::ParseXmlFile()
+
+//=============================================================================
+/*!
+ * parse the data type catalog
+ */
+//=============================================================================
+
+const MapOfParserResourcesType& SALOME_ResourcesManager::ParseXmlFile()
{
- SALOME_ResourcesCatalog_Handler* handler = new SALOME_ResourcesCatalog_Handler(_resourcesList);
+ SALOME_ResourcesCatalog_Handler* handler =
+ new SALOME_ResourcesCatalog_Handler(_resourcesList);
QFile xmlFile(_path_resources);
QXmlInputSource source(xmlFile);
return _resourcesList;
}
-bool SALOME_ResourcesManager::_verify_resources(MapOfParserResourcesType resourceslist)
+//=============================================================================
+/*!
+ * verify ressources catalog content - return true if verfication is OK
+ */
+//=============================================================================
+
+
+bool
+SALOME_ResourcesManager::_verify_resources
+(MapOfParserResourcesType resourceslist)
{
-// bool _return_value = true;
-// bool _bool = false ;
-// vector<string> _machine_list;
-// _machine_list.resize(0);
-
-// // Fill a list of all computers indicated in the resources list
-// for (unsigned int ind = 0; ind < resourceslist.size(); ind++)
-// _machine_list.push_back(resourceslist[ind].HostName);
-
-// // Parse if a computer name is twice in the list of computers
-// for (unsigned int ind = 0; ind < _machine_list.size(); ind++)
-// {
-// for (unsigned int ind1 = ind+1 ; ind1 < _machine_list.size(); ind1++)
-// {
-// if(_machine_list[ind].compare(_machine_list[ind1]) == 0)
-// {
-// MESSAGE("The computer " << _machine_list[ind] << " is indicated more than once in the resources list")
-// _return_value = false;
-// }
-// }
-// }
-
-// return _return_value;
+ // bool _return_value = true;
+ // bool _bool = false ;
+ // vector<string> _machine_list;
+ // _machine_list.resize(0);
+
+ // // Fill a list of all computers indicated in the resources list
+ // for (unsigned int ind = 0; ind < resourceslist.size(); ind++)
+ // _machine_list.push_back(resourceslist[ind].HostName);
+
+ // // Parse if a computer name is twice in the list of computers
+ // for (unsigned int ind = 0; ind < _machine_list.size(); ind++)
+ // {
+ // for (unsigned int ind1 = ind+1 ; ind1 < _machine_list.size(); ind1++)
+ // {
+ // if(_machine_list[ind].compare(_machine_list[ind1]) == 0)
+ // {
+ // MESSAGE("The computer " << _machine_list[ind] << " is indicated more than once in the resources list")
+ // _return_value = false;
+ // }
+ // }
+ // }
+
+ // return _return_value;
return true;
}
+
+//=============================================================================
+/*!
+ * consult the content of the list
+ */
+//=============================================================================
+
const MapOfParserResourcesType& SALOME_ResourcesManager::GetList() const
-{
- return _resourcesList;
-}
+ {
+ return _resourcesList;
+ }
+
-string SALOME_ResourcesManager::FindBest(const Engines::MachineList& listOfMachines)
+//=============================================================================
+/*!
+ * dynamically obtains the best machines
+ */
+//=============================================================================
+
+string
+SALOME_ResourcesManager::FindBest(const Engines::MachineList& listOfMachines)
{
return _dynamicResourcesSelecter.FindBest(listOfMachines);
}
+
+//=============================================================================
+/*!
+ * This is no longer valid (C++ container are also python containers)
+ */
+//=============================================================================
+
bool isPythonContainer(const char* ContainerName)
{
- bool ret=false;
- int len=strlen(ContainerName);
- if(len>=2)
- if(strcmp(ContainerName+len-2,"Py")==0)
- ret=true;
+ bool ret = false;
+ int len = strlen(ContainerName);
+
+ if (len >= 2)
+ if (strcmp(ContainerName + len - 2, "Py") == 0)
+ ret = true;
+
return ret;
}
-string SALOME_ResourcesManager::BuildTempFileToLaunchRemoteContainer(const string& machine,const Engines::MachineParameters& params)
+
+//=============================================================================
+/*!
+ * builds in a temporary file the script to be launched
+ */
+//=============================================================================
+
+string
+SALOME_ResourcesManager::BuildTempFileToLaunchRemoteContainer
+(const string& machine,
+ const Engines::MachineParameters& params)
{
-// _TmpFileName=BuildTemporaryFileName();
-// ofstream tempOutputFile;
-// tempOutputFile.open(_TmpFileName.c_str(),ofstream::out );
+ // _TmpFileName=BuildTemporaryFileName();
+ // ofstream tempOutputFile;
+ // tempOutputFile.open(_TmpFileName.c_str(),ofstream::out );
+
const ParserResourcesType& resInfo=_resourcesList[machine];
-// tempOutputFile << "#! /bin/sh" << endl;
-// //set env vars
-// for(map<string,string>::const_iterator iter=resInfo.ModulesPath.begin();iter!=resInfo.ModulesPath.end();iter++)
-// {
-// string curModulePath((*iter).second);
-// tempOutputFile << (*iter).first << "_ROOT_DIR="<< curModulePath << endl;
-// tempOutputFile << "export " << (*iter).first << "_ROOT_DIR" << endl;
-// tempOutputFile << "LD_LIBRARY_PATH=" << curModulePath << "/lib/salome" << ":${LD_LIBRARY_PATH}" << endl;
-// tempOutputFile << "PYTHONPATH=" << curModulePath << "/bin/salome:" << curModulePath << "/lib/salome:" << curModulePath << "/lib/python2.2/site-packages/salome:";
-// tempOutputFile << curModulePath << "/lib/python2.2/site-packages/salome/shared_modules:${PYTHONPATH}" << endl;
-// }
-// tempOutputFile << "export LD_LIBRARY_PATH" << endl;
-// tempOutputFile << "export PYTHONPATH" << endl;
-// tempOutputFile << "source " << resInfo.PreReqFilePath << endl;
-// // ! env vars
- if(params.isMPI){
-// tempOutputFile << "mpirun -np ";
- int nbproc;
- if( (params.nb_node <= 0) && (params.nb_proc_per_node <= 0) )
- nbproc = 1;
- else if( params.nb_node == 0 )
- nbproc = params.nb_proc_per_node;
- else if( params.nb_proc_per_node == 0 )
- nbproc = params.nb_node;
- else
- nbproc = params.nb_node * params.nb_proc_per_node;
-// std::ostringstream o;
-// tempOutputFile << nbproc << " ";
- }
-// tempOutputFile << (*(resInfo.ModulesPath.find("KERNEL"))).second << "/bin/salome/";
-// if(params.isMPI){
-// if(isPythonContainer(params.container_name))
-// tempOutputFile << "pyMPI SALOME_ContainerPy.py ";
-// else
-// tempOutputFile << "SALOME_MPIContainer ";
-// }
-// else{
-// if(isPythonContainer(params.container_name))
-// tempOutputFile << "SALOME_ContainerPy.py ";
-// else
-// tempOutputFile << "SALOME_Container ";
-// }
-// tempOutputFile << _NS->ContainerName(params) << " -";
-// AddOmninamesParams(tempOutputFile);
-// tempOutputFile << " &" << endl;
-// tempOutputFile.flush();
-// tempOutputFile.close();
-// chmod(_TmpFileName.c_str(),0x1ED);
+
+ // tempOutputFile << "#! /bin/sh" << endl;
+ // //set env vars
+ // for(map<string,string>::const_iterator iter =
+ // resInfo.ModulesPath.begin();iter!=resInfo.ModulesPath.end();iter++)
+ // {
+ // string curModulePath((*iter).second);
+ // tempOutputFile << (*iter).first << "_ROOT_DIR="<< curModulePath << endl;
+ // tempOutputFile << "export " << (*iter).first << "_ROOT_DIR" << endl;
+ // tempOutputFile << "LD_LIBRARY_PATH=" << curModulePath << "/lib/salome" << ":${LD_LIBRARY_PATH}" << endl;
+ // tempOutputFile << "PYTHONPATH=" << curModulePath << "/bin/salome:" << curModulePath << "/lib/salome:" << curModulePath << "/lib/python2.2/site-packages/salome:";
+ // tempOutputFile << curModulePath << "/lib/python2.2/site-packages/salome/shared_modules:${PYTHONPATH}" << endl;
+ // }
+ // tempOutputFile << "export LD_LIBRARY_PATH" << endl;
+ // tempOutputFile << "export PYTHONPATH" << endl;
+ // tempOutputFile << "source " << resInfo.PreReqFilePath << endl;
+ // // ! env vars
+
+ if (params.isMPI)
+ {
+ // tempOutputFile << "mpirun -np ";
+ int nbproc;
+
+ if ( (params.nb_node <= 0) && (params.nb_proc_per_node <= 0) )
+ nbproc = 1;
+ else if ( params.nb_node == 0 )
+ nbproc = params.nb_proc_per_node;
+ else if ( params.nb_proc_per_node == 0 )
+ nbproc = params.nb_node;
+ else
+ nbproc = params.nb_node * params.nb_proc_per_node;
+
+ // std::ostringstream o;
+ // tempOutputFile << nbproc << " ";
+ }
+
+ // tempOutputFile << (*(resInfo.ModulesPath.find("KERNEL"))).second << "/bin/salome/";
+ // if(params.isMPI){
+ // if(isPythonContainer(params.container_name))
+ // tempOutputFile << "pyMPI SALOME_ContainerPy.py ";
+ // else
+ // tempOutputFile << "SALOME_MPIContainer ";
+ // }
+ // else{
+ // if(isPythonContainer(params.container_name))
+ // tempOutputFile << "SALOME_ContainerPy.py ";
+ // else
+ // tempOutputFile << "SALOME_Container ";
+ // }
+ // tempOutputFile << _NS->ContainerName(params) << " -";
+ // AddOmninamesParams(tempOutputFile);
+ // tempOutputFile << " &" << endl;
+ // tempOutputFile.flush();
+ // tempOutputFile.close();
+ // chmod(_TmpFileName.c_str(),0x1ED);
//Build command
string command;
- if(resInfo.Protocol==rsh)
+
+ if (resInfo.Protocol == rsh)
{
command = "rsh ";
-// string commandRcp="rcp ";
-// commandRcp+=_TmpFileName;
-// commandRcp+=" ";
-// commandRcp+=machine;
-// commandRcp+=":";
-// commandRcp+=_TmpFileName;
-// system(commandRcp.c_str());
+ // string commandRcp="rcp ";
+ // commandRcp+=_TmpFileName;
+ // commandRcp+=" ";
+ // commandRcp+=machine;
+ // commandRcp+=":";
+ // commandRcp+=_TmpFileName;
+ // system(commandRcp.c_str());
}
- else if(resInfo.Protocol==ssh)
+
+ else if (resInfo.Protocol == ssh)
command = "ssh ";
else
throw SALOME_Exception("Unknown protocol");
-
-// command+=machine;
-// _CommandForRemAccess=command;
-// command+=" ";
-// command+=_TmpFileName;
-// command += " > ";
-// command += "/tmp/";
-// command += _NS->ContainerName(params);
-// command += "_";
-// command += machine;
-// command += ".log 2>&1 &";
-// cout << "Command is ... " << command << endl;
+
+ // command+=machine;
+ // _CommandForRemAccess=command;
+ // command+=" ";
+ // command+=_TmpFileName;
+ // command += " > ";
+ // command += "/tmp/";
+ // command += _NS->ContainerName(params);
+ // command += "_";
+ // command += machine;
+ // command += ".log 2>&1 &";
+ // cout << "Command is ... " << command << endl;
command += machine; // on suppose le même user par defaut
+
command += " ";
+
command += getenv("APPLI"); // chemin relatif a $HOME
+
command += "/runRemote.sh ";
+
command += GetHostname(); // ********** A CHANGER, le naming service n'est pas obligatoirement ici
+
command += " ";
+
command += getenv("NSPORT");
+
command += " SALOME_Container ";
+
command += _NS->ContainerName(params);
+
command += "&";
+
MESSAGE("command =" << command);
+
return command;
}
-string SALOME_ResourcesManager::BuildCommandToLaunchLocalContainer(const Engines::MachineParameters& params)
+
+//=============================================================================
+/*!
+ * builds the command to be launched.
+ */
+//=============================================================================
+
+string
+SALOME_ResourcesManager::BuildCommandToLaunchLocalContainer
+(const Engines::MachineParameters& params)
{
- _TmpFileName="";
+ _TmpFileName = "";
string command;
- int nbproc=0;
- if(params.isMPI){
- command="mpirun -np ";
- if( (params.nb_node <= 0) && (params.nb_proc_per_node <= 0) )
- nbproc = 1;
- else if( params.nb_node == 0 )
- nbproc = params.nb_proc_per_node;
- else if( params.nb_proc_per_node == 0 )
- nbproc = params.nb_node;
- else
- nbproc = params.nb_node * params.nb_proc_per_node;
- std::ostringstream o;
- o << nbproc << " ";
- command += o.str();
- if(isPythonContainer(params.container_name))
- command+="pyMPI SALOME_ContainerPy.py ";
- else
- command+="SALOME_MPIContainer ";
- }
- else{
- if(isPythonContainer(params.container_name))
- command="SALOME_ContainerPy.py ";
- else
- command="SALOME_Container ";
- }
- command+=_NS->ContainerName(params);
- command+=" -";
+ int nbproc = 0;
+
+ if (params.isMPI)
+ {
+ command = "mpirun -np ";
+
+ if ( (params.nb_node <= 0) && (params.nb_proc_per_node <= 0) )
+ nbproc = 1;
+ else if ( params.nb_node == 0 )
+ nbproc = params.nb_proc_per_node;
+ else if ( params.nb_proc_per_node == 0 )
+ nbproc = params.nb_node;
+ else
+ nbproc = params.nb_node * params.nb_proc_per_node;
+
+ std::ostringstream o;
+
+ o << nbproc << " ";
+
+ command += o.str();
+
+ if (isPythonContainer(params.container_name))
+ command += "pyMPI SALOME_ContainerPy.py ";
+ else
+ command += "SALOME_MPIContainer ";
+ }
+
+ else
+ {
+ if (isPythonContainer(params.container_name))
+ command = "SALOME_ContainerPy.py ";
+ else
+ command = "SALOME_Container ";
+ }
+
+ command += _NS->ContainerName(params);
+ command += " -";
AddOmninamesParams(command);
- command+=" > /tmp/";
- command+=_NS->ContainerName(params);
+ command += " > /tmp/";
+ command += _NS->ContainerName(params);
command += "_";
command += GetHostname();
command += "_";
command += getenv( "USER" ) ;
command += ".log 2>&1 &" ;
- cout << "Command is ... " << command << endl << flush;
+ MESSAGE("Command is ... " << command);
return command;
}
+
+//=============================================================================
+/*!
+ * removes the generated temporary file in case of a remote launch.
+ */
+//=============================================================================
+
void SALOME_ResourcesManager::RmTmpFile()
{
- if(_TmpFileName!="")
+ if (_TmpFileName != "")
{
- string command="rm ";
- command+=_TmpFileName;
- char *temp=strdup(command.c_str());
- int lgthTemp=strlen(temp);
- temp[lgthTemp-3]='*';
- temp[lgthTemp-2]='\0';
+ string command = "rm ";
+ command += _TmpFileName;
+ char *temp = strdup(command.c_str());
+ int lgthTemp = strlen(temp);
+ temp[lgthTemp - 3] = '*';
+ temp[lgthTemp - 2] = '\0';
system(temp);
free(temp);
}
}
-string SALOME_ResourcesManager::BuildCommand(const string& machine,const char *containerName)
+
+//=============================================================================
+/*!
+ * builds the script to be launched
+ */
+//=============================================================================
+
+string
+SALOME_ResourcesManager::BuildCommand
+(const string& machine,
+ const char *containerName)
{
-// rsh -n ikkyo /export/home/rahuel/SALOME_ROOT/bin/runSession SALOME_Container -ORBInitRef NameService=corbaname::dm2s0017:1515 &
- const ParserResourcesType& resInfo=_resourcesList[machine];
- bool pyCont=isPythonContainer(containerName);
+ // rsh -n ikkyo /export/home/rahuel/SALOME_ROOT/bin/runSession SALOME_Container -ORBInitRef NameService=corbaname::dm2s0017:1515 &
+ const ParserResourcesType& resInfo = _resourcesList[machine];
+ bool pyCont = isPythonContainer(containerName);
string command;
- if(resInfo.Protocol==rsh)
+
+ if (resInfo.Protocol == rsh)
command = "rsh -n " ;
- else if(resInfo.Protocol==ssh)
+ else if (resInfo.Protocol == ssh)
command = "ssh -f -n ";
else
throw SALOME_Exception("Not implemented yet...");
- command += machine;
+
+ command += machine;
command += " ";
string path = (*(resInfo.ModulesPath.find("KERNEL"))).second;
- command +=path;
+ command += path;
command += "/bin/salome/";
+
if ( pyCont )
command += "SALOME_ContainerPy.py ";
else
command += "SALOME_Container ";
+
command += containerName;
command += " -";
AddOmninamesParams(command);
command += "_";
command += machine;
command += ".log 2>&1 &" ;
+
SCRUTE( command );
return command;
}
+//=============================================================================
+/*!
+ * Gives a sublist of machines with matching OS.
+ * If parameter OS is empty, gives the complete list of machines
+ */
+//=============================================================================
+
// Warning need an updated parsed list : _resourcesList
-void SALOME_ResourcesManager::SelectOnlyResourcesWithOS(vector<string>& hosts,const char *OS) const throw(SALOME_Exception)
+void
+SALOME_ResourcesManager::SelectOnlyResourcesWithOS
+( vector<string>& hosts,
+ const char *OS) const
+throw(SALOME_Exception)
{
string base(OS);
- for(map<string, ParserResourcesType>::const_iterator iter=_resourcesList.begin();iter!=_resourcesList.end();iter++)
+
+ for (map<string, ParserResourcesType>::const_iterator iter =
+ _resourcesList.begin();
+ iter != _resourcesList.end();
+ iter++)
{
- if((*iter).second.OS==base)
- hosts.push_back((*iter).first);
+ if ( (*iter).second.OS == base || base.size() == 0)
+ hosts.push_back((*iter).first);
}
}
+
+//=============================================================================
+/*!
+ * Gives a sublist of machines on which the module is known.
+ */
+//=============================================================================
+
//Warning need an updated parsed list : _resourcesList
-void SALOME_ResourcesManager::KeepOnlyResourcesWithModule(vector<string>& hosts,const char *moduleName) const throw(SALOME_Exception)
+void
+SALOME_ResourcesManager::KeepOnlyResourcesWithModule
+( vector<string>& hosts,
+ const char *moduleName) const
+throw(SALOME_Exception)
{
- for(vector<string>::iterator iter=hosts.begin();iter!=hosts.end();)
- {
- MapOfParserResourcesType::const_iterator it=_resourcesList.find(*iter);
- const map<string,string>& mapOfModulesOfCurrentHost=(((*it).second).ModulesPath);
- if(mapOfModulesOfCurrentHost.find(moduleName)==mapOfModulesOfCurrentHost.end())
- hosts.erase(iter);
- else
- iter++;
- }
+ for (vector<string>::iterator iter = hosts.begin(); iter != hosts.end();)
+ {
+ MapOfParserResourcesType::const_iterator it = _resourcesList.find(*iter);
+ const map<string, string>& mapOfModulesOfCurrentHost =
+ (((*it).second).ModulesPath);
+
+ if (mapOfModulesOfCurrentHost.find(moduleName) ==
+ mapOfModulesOfCurrentHost.end())
+ hosts.erase(iter);
+ else
+ iter++;
+ }
}
+
+//=============================================================================
+/*!
+ * add to command all options relative to naming service.
+ */
+//=============================================================================
+
void SALOME_ResourcesManager::AddOmninamesParams(string& command) const
-{
- // 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 ) {
+ {
+ // 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 ;
+ //}
+ //command += nameservice ;
- char *iorstr = _NS->getIORaddr();
- command += "ORBInitRef NameService=";
- command += iorstr;
-}
+ char *iorstr = _NS->getIORaddr();
+ command += "ORBInitRef NameService=";
+ command += iorstr;
+ }
+
+
+//=============================================================================
+/*!
+ * add to command all options relative to naming service.
+ */
+//=============================================================================
void SALOME_ResourcesManager::AddOmninamesParams(ofstream& fileStream) const
-{
- string omniORBcfg( getenv( "OMNIORB_CONFIG" ) ) ;
- ifstream omniORBfile( omniORBcfg.c_str() ) ;
- char ORBInitRef[11] ;
- char egal[3] ;
- char nameservice[132] ;
- omniORBfile >> ORBInitRef ;
- fileStream << "ORBInitRef ";
- omniORBfile >> egal ;
- omniORBfile >> nameservice ;
- omniORBfile.close() ;
- char * bsn = strchr( nameservice , '\n' ) ;
- if ( bsn ) {
- bsn[ 0 ] = '\0' ;
+ {
+ string omniORBcfg( getenv( "OMNIORB_CONFIG" ) ) ;
+ ifstream omniORBfile( omniORBcfg.c_str() ) ;
+ char ORBInitRef[11] ;
+ char egal[3] ;
+ char nameservice[132] ;
+ omniORBfile >> ORBInitRef ;
+ fileStream << "ORBInitRef ";
+ omniORBfile >> egal ;
+ omniORBfile >> nameservice ;
+ omniORBfile.close() ;
+ char * bsn = strchr( nameservice , '\n' ) ;
+
+ if ( bsn )
+ {
+ bsn[ 0 ] = '\0' ;
+ }
+
+ fileStream << nameservice;
}
- fileStream << nameservice;
-}
+
+
+//=============================================================================
+/*!
+ * generate a file name in /tmp directory
+ */
+//=============================================================================
string SALOME_ResourcesManager::BuildTemporaryFileName() const
-{
- //build more complex file name to support multiple salome session
- char *temp=new char[19];
- strcpy(temp,"/tmp/command");
- strcat(temp,"XXXXXX");
+ {
+ //build more complex file name to support multiple salome session
+ char *temp = new char[19];
+ strcpy(temp, "/tmp/command");
+ strcat(temp, "XXXXXX");
#ifndef WNT
- mkstemp(temp);
+
+ mkstemp(temp);
#else
- char aPID[80];
- itoa(getpid(), aPID, 10);
- strcat(temp,aPID);
+
+ char aPID[80];
+ itoa(getpid(), aPID, 10);
+ strcat(temp, aPID);
#endif
- string command(temp);
- delete [] temp;
- command += ".sh";
- return command;
-}
+
+ string command(temp);
+ delete [] temp;
+ command += ".sh";
+ return command;
+ }
#endif
#endif
-//WARNING the call of BuildTempFileToLaunchRemoteContainer and RmTmpFile must be done in a critical section to be sure to be clean.
-//Only one thread should use the SALOME_ResourcesManager class in a SALOME session.
+// --- WARNING ---
+// The call of BuildTempFileToLaunchRemoteContainer and RmTmpFile must be done
+// in a critical section to be sure to be clean.
+// Only one thread should use the SALOME_ResourcesManager class in a SALOME
+// session.
class RESOURCESMANAGER_EXPORT SALOME_ResourcesManager
-{
-public:
- //! standard constructor
- SALOME_ResourcesManager(CORBA::ORB_ptr orb);
+ {
- //!just for test
- SALOME_ResourcesManager(CORBA::ORB_ptr orb,const char *xmlFilePath);
-
- //! standard destructor
- ~SALOME_ResourcesManager();
+ public:
- //! method to get the list of name of ressources fitting for the specified module.
- std::vector<std::string> GetFittingResources(const Engines::MachineParameters& params,const char *moduleName) throw(SALOME_Exception);
+ SALOME_ResourcesManager(CORBA::ORB_ptr orb, const char *xmlFilePath);
+ SALOME_ResourcesManager(CORBA::ORB_ptr orb);
- //! method to dynamically obtain the best machines
- std::string FindBest(const Engines::MachineList& listOfMachines);
+ ~SALOME_ResourcesManager();
- //! method that builds in a temporary file the script to be launched
- std::string BuildTempFileToLaunchRemoteContainer(const std::string& machine,const Engines::MachineParameters& params);
+ std::vector<std::string>
+ GetFittingResources(const Engines::MachineParameters& params,
+ const char *moduleName)
+ throw(SALOME_Exception);
- //! method that builds the command to be launched.
- std::string BuildCommandToLaunchLocalContainer(const Engines::MachineParameters& params);
+ std::string FindBest(const Engines::MachineList& listOfMachines);
- //! method that remove the generated temporary file in case of a remote launch.
- void RmTmpFile();
+ std::string BuildTempFileToLaunchRemoteContainer
+ (const std::string& machine,
+ const Engines::MachineParameters& params);
- //! method that builds the script to be launched
- std::string BuildCommand(const std::string& machine,const char *containerName);
+ std::string BuildCommandToLaunchLocalContainer
+ (const Engines::MachineParameters& params);
- //! add an entry in the ressources catalog xml file. Return 1 if OK. Return 0 if the ressource with the same hostname already exists.
- int AddResourceInCatalog(const Engines::MachineParameters& paramsOfNewResources, const std::map<std::string,std::string>& modulesOnNewResources,
- const char *environPathOfPrerequired,
- const char *alias, const char *userName, AccessModeType mode, AccessProtocolType prot) throw(SALOME_Exception);
-
- //! delete a ressource from the Catalog.
- void DeleteResourceInCatalog(const char *hostname);
+ void RmTmpFile();
- //! write the current data in memory in file.
- void WriteInXmlFile();
+ std::string BuildCommand(const std::string& machine,
+ const char *containerName);
- //! method to parse the data type catalog
- const MapOfParserResourcesType& ParseXmlFile();
+ int AddResourceInCatalog
+ (const Engines::MachineParameters& paramsOfNewResources,
+ const std::map<std::string, std::string>& modulesOnNewResources,
+ const char *environPathOfPrerequired,
+ const char *alias,
+ const char *userName,
+ AccessModeType mode,
+ AccessProtocolType prot)
+ throw(SALOME_Exception);
- //! to consult the content of the list
- const MapOfParserResourcesType& GetList() const;
+ void DeleteResourceInCatalog(const char *hostname);
-private:
- SALOME_NamingService *_NS;
+ void WriteInXmlFile();
- //! method to verify ressources catalog content - return true if verfication is OK
- bool _verify_resources(MapOfParserResourcesType resourceslist);
+ const MapOfParserResourcesType& ParseXmlFile();
- //! method that fill hosts with only resources in xml files that are on the specified OS
- void SelectOnlyResourcesWithOS(std::vector<std::string>& hosts,const char *OS) const throw(SALOME_Exception);
+ const MapOfParserResourcesType& GetList() const;
- //! method that keep from hosts only those having component of name moduleName.
- void KeepOnlyResourcesWithModule(std::vector<std::string>& hosts,const char *moduleName) const throw(SALOME_Exception);
+ private:
+ SALOME_NamingService *_NS;
- //! methode that add to command all options relative to naming service.
- void AddOmninamesParams(std::string& command) const;
+ bool _verify_resources(MapOfParserResourcesType resourceslist);
- //! method that add to command all options relative to naming service.
- void AddOmninamesParams(std::ofstream& fileStream) const;
+ void SelectOnlyResourcesWithOS(std::vector<std::string>& hosts,
+ const char *OS) const
+ throw(SALOME_Exception);
- //! method that generate a file name in /tmp directory
- std::string BuildTemporaryFileName() const;
+ void KeepOnlyResourcesWithModule(std::vector<std::string>& hosts,
+ const char *moduleName) const
+ throw(SALOME_Exception);
- // will contain the path to the ressources catalog
- QString _path_resources;
+ void AddOmninamesParams(std::string& command) const;
- //! attribute that contains current tmp files generated
- std::string _TmpFileName;
+ void AddOmninamesParams(std::ofstream& fileStream) const;
- //! attribute that contains the rsh or ssh command to access directly to machine. Only used by this->RmTmpFile in case of a remote launch.
- std::string _CommandForRemAccess;
-
- //will contain the informations on the data type catalog(after parsing)
- MapOfParserResourcesType _resourcesList;
+ std::string BuildTemporaryFileName() const;
- SALOME_LoadRateManager _dynamicResourcesSelecter;
-};
+
+ //! will contain the path to the ressources catalog
+ QString _path_resources;
+
+ //! attribute that contains current tmp files generated
+ std::string _TmpFileName;
+
+ //! contains the rsh or ssh command to access directly to machine.
+ // Only used by this->RmTmpFile in case of a remote launch.
+ std::string _CommandForRemAccess;
+
+ //! will contain the informations on the data type catalog(after parsing)
+ MapOfParserResourcesType _resourcesList;
+
+ SALOME_LoadRateManager _dynamicResourcesSelecter;
+ };
#endif // RESSOURCESCATALOG_IMPL_H
using namespace std;
-// --- Registers the fixture into the 'registry'
-
-CPPUNIT_TEST_SUITE_REGISTRATION( SALOMELocalTraceTest );
// ============================================================================
/*!
CPPUNIT_ASSERT(! setenv("SALOME_trace",s.c_str(),1)); // 1: overwrite
ofstream traceFile;
- traceFile.open(theFileName, ios::out | ios::trunc);
+ traceFile.open(theFileName, ios::out | ios::app);
CPPUNIT_ASSERT(traceFile); // file created empty, then closed
traceFile.close();
CPPUNIT_TEST( testSingletonBufferPool );
CPPUNIT_TEST( testLoadBufferPoolLocal );
CPPUNIT_TEST( testLoadBufferPoolFile );
- CPPUNIT_TEST( testLoadBufferPoolFile );
CPPUNIT_TEST_SUITE_END();
public:
#include "SALOMELocalTraceTest.hxx"
+// --- Registers the fixture into the 'registry'
+
+CPPUNIT_TEST_SUITE_REGISTRATION( SALOMELocalTraceTest );
+
// --- generic Main program from Basic/Test
#include "BasicMainTest.hxx"
using namespace std;
-// --- Registers the fixture into the 'registry'
-
-CPPUNIT_TEST_SUITE_REGISTRATION( SALOMETraceCollectorTest );
-
// ============================================================================
/*!
*
#include "SALOMELocalTraceTest.hxx"
#include "SALOMETraceCollectorTest.hxx"
+// --- Registers the fixture into the 'registry'
+
+CPPUNIT_TEST_SUITE_REGISTRATION( SALOMELocalTraceTest );
+CPPUNIT_TEST_SUITE_REGISTRATION( SALOMETraceCollectorTest );
+
// --- generic Main program from Basic/Test
#include "BasicMainTest.hxx"
BIN = UnitTests
BIN_SRC =
+BIN_CLIENT_IDL = SALOME_Component.idl SALOME_TestComponent.idl \
+ SALOME_Exception.idl
LIBS= @LIBS@
-lSALOMELocalTraceTest -lSALOMELocalTrace -lSALOMEBasics \
-lSALOMETraceCollectorTest \
-lUtilsTest -lOpUtil \
+ -lSalomeNS -lSalomeContainer -lSalomeResourcesManager \
+ -lRegistry -lSalomeNotification \
+ -lLifeCycleCORBATest -lSalomeLifeCycleCORBA \
-lcppunit
-# -lefence
@CONCLUDE@
#include "SALOMELocalTraceTest.hxx"
#include "SALOMETraceCollectorTest.hxx"
#include "UtilsTest.hxx"
+#include "LifeCycleCORBATest.hxx"
+
+// --- Registers the fixture into the 'registry'
+
+CPPUNIT_TEST_SUITE_REGISTRATION( SALOMELocalTraceTest );
+CPPUNIT_TEST_SUITE_REGISTRATION( SALOMETraceCollectorTest );
+CPPUNIT_TEST_SUITE_REGISTRATION( UtilsTest );
+CPPUNIT_TEST_SUITE_REGISTRATION( LifeCycleCORBATest );
// --- generic Main program from Basic/Test
args, modules_list, modules_root_dir = runSalome.get_config()
runSalome.set_env(args, modules_list, modules_root_dir)
+# set environment for trace in logger
+# (with file, servers may be killed before the write to the file...)
+
+#os.environ["SALOME_trace"] = "file:/tmp/traceUnitTest.log"
+#os.environ["SALOME_trace"] = "local"
+os.environ["SALOME_trace"] = "with_logger"
+
# launch CORBA naming server
clt=orbmodule.client()
myServer.run()
clt.waitLogger("Logger")
+# launch notify server
+
+myServer=runSalome.NotifyServer(args,modules_root_dir)
+myServer.run()
+
+# launch registry server
+
+myServer=runSalome.RegistryServer(args)
+myServer.run()
+clt.waitNS("/Registry")
+
+# launch module catalog server
+
+cataServer=runSalome.CatalogServer(args)
+cataServer.setpath(modules_list,modules_root_dir)
+cataServer.run()
+clt.waitNS("/Kernel/ModulCatalog")
+
+# launch container manager server
+
+myCmServer = runSalome.ContainerManagerServer(args)
+myCmServer.setpath(modules_list,modules_root_dir)
+myCmServer.run()
+clt.waitNS("/ContainerManager")
+
# execute Unit Test
command = ['UnitTests']
ret = os.spawnvp(os.P_WAIT, command[0], command)
+# kill containers created by the Container Manager
+
+import Engines
+containerManager = clt.waitNS("/ContainerManager",Engines.ContainerManager)
+containerManager.Shutdown()
+
# kill Test process
TestKiller.killProcess(runSalome.process_id)
#include "SALOMETraceCollectorTest.hxx"
#include "UtilsTest.hxx"
+// --- Registers the fixture into the 'registry'
+
+CPPUNIT_TEST_SUITE_REGISTRATION( SALOMELocalTraceTest );
+CPPUNIT_TEST_SUITE_REGISTRATION( SALOMETraceCollectorTest );
+CPPUNIT_TEST_SUITE_REGISTRATION( UtilsTest );
+
// --- generic Main program from Basic/Test
#include "BasicMainTest.hxx"
using namespace std;
-// --- Registers the fixture into the 'registry'
-
-CPPUNIT_TEST_SUITE_REGISTRATION( UtilsTest );
-
#define TRACEFILE "/tmp/traceUnitTest.log"
// ============================================================================
CPPUNIT_ASSERT(! setenv("SALOME_trace",s.c_str(),1)); // 1: overwrite
ofstream traceFile;
- traceFile.open(theFileName, ios::out | ios::trunc);
+ traceFile.open(theFileName, ios::out | ios::app);
CPPUNIT_ASSERT(traceFile); // file created empty, then closed
traceFile.close();
if ( Make_ATEXIT && !ATEXIT_Done ) {
//CCRT
assert (DESTRUCTEUR_GENERIQUE_::Destructeurs==0);
- cerr << "ATEXIT_::ATEXIT_ Construction ATEXIT" << endl;// message necessaire pour utiliser logger dans Nettoyage (cf.BUG KERNEL4561)
+ //cerr << "ATEXIT_::ATEXIT_ Construction ATEXIT" << endl;// message necessaire pour utiliser logger dans Nettoyage (cf.BUG KERNEL4561)
DESTRUCTEUR_GENERIQUE_::Destructeurs =
new std::list<DESTRUCTEUR_GENERIQUE_*> ; // Destructeur alloue dynamiquement (cf. ci-dessous) ,
// il est utilise puis detruit par la fonction Nettoyage
~ATEXIT_( )
{
- cerr << "ATEXIT_::~ATEXIT_ Destruction ATEXIT" << endl;
+ //cerr << "ATEXIT_::~ATEXIT_ Destruction ATEXIT" << endl;
}
};
void Nettoyage( void )
{
- cerr << "Nettoyage()" << endl;
+ //cerr << "Nettoyage()" << endl;
//if(MYDEBUG) BEGIN_OF("Nettoyage( void )") ;
assert(DESTRUCTEUR_GENERIQUE_::Destructeurs) ;
//if(MYDEBUG) SCRUTE( DESTRUCTEUR_GENERIQUE_::Destructeurs->size() ) ;
typedef PortableServer::ServantBase TServant;
if(_PtrObjet){
if(TServant* aServant = dynamic_cast<TServant*>(_PtrObjet)){
- cerr << "DESTRUCTEUR_GENERIQUE_::operator() deleting ServantBase's _PtrObjet" << endl;
+ //cerr << "DESTRUCTEUR_GENERIQUE_::operator() deleting ServantBase's _PtrObjet" << endl;
PortableServer::POA_var aPOA = aServant->_default_POA();
PortableServer::ObjectId_var anObjectId = aPOA->servant_to_id(aServant);
aPOA->deactivate_object(anObjectId.in());
aServant->_remove_ref();
}else{
- cerr << "DESTRUCTEUR_GENERIQUE_::operator() deleting _PtrObjet" << endl;
+ //cerr << "DESTRUCTEUR_GENERIQUE_::operator() deleting _PtrObjet" << endl;
TYPE* aPtr = static_cast<TYPE*>(_PtrObjet);
delete aPtr;
}
{
if ( ! CORBA::is_nil( _orb ) )
{
- std::cerr << "appel _orb->destroy()" << std::endl;
+ //std::cerr << "appel _orb->destroy()" << std::endl;
_orb->destroy() ;
- std::cerr << "retour _orb->destroy()" << std::endl;
+ //std::cerr << "retour _orb->destroy()" << std::endl;
}
}