+++ /dev/null
-# SALOME ResourcesManager
-#
-# 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 : Jean Rahuel
-# Module : SALOME
-# $Header:
-
-top_srcdir=@top_srcdir@
-top_builddir=../..
-srcdir=@srcdir@
-VPATH=.:@srcdir@:@top_srcdir@/idl
-
-
-@COMMENCE@
-
-# Libraries targets
-LIB = libResourcesManager.la
-LIB_SRC = ResourcesManager_Handler.cxx \
- ResourcesComputer_Impl.cxx \
- ResourcesManager_Impl.cxx
-LIB_SERVER_IDL = ResourcesManager.idl
-
-# Executables targets
-BIN = ResourcesManager_Server
-BIN_SRC =
-BIN_SERVER_IDL = ContainersManager.idl SALOME_Component.idl ResourcesManager.idl
-
-CPPFLAGS+= $(QT_MT_INCLUDES)
-CXXFLAGS+=
-LDFLAGS+= $(QT_MT_LIBS) $(OGL_LIBS) -lSalomeNS -lOpUtil -lSALOMELocalTrace
-
-@CONCLUDE@
-
-
+++ /dev/null
-// ResourcesComputer_Impl
-//
-// 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 : ResourcesComputer_Impl.cxx
-// Author : Jean Rahuel
-// Module : SALOME
-
-#include "OpUtil.hxx"
-
-#include "ResourcesComputer_Impl.hxx"
-#include <fstream>
-
-using namespace std;
-
-Computer_Impl::Computer_Impl() {
-}
-
-Computer_Impl::Computer_Impl( CORBA::ORB_ptr orb ,
- PortableServer::POA_ptr poa ,
- Resources::ComputerParameters * aComputerParameters ,
- Resources::ComputerEnvironment * aComputerEnvironment ) {
- _Orb = CORBA::ORB::_duplicate( orb ) ;
- _Poa = PortableServer::POA::_duplicate( poa ) ;
- _Id = _Poa->activate_object( this ) ;
- _ComputerParameters = new Resources::ComputerParameters() ;
- _ComputerParameters->FullName = CORBA::string_dup( aComputerParameters->FullName ) ;
- _ComputerParameters->Alias = CORBA::string_dup( aComputerParameters->Alias ) ;
- _ComputerParameters->SshAccess = aComputerParameters->SshAccess ;
- _ComputerParameters->Interactive = aComputerParameters->Interactive ;
- _ComputerParameters->Batch = aComputerParameters->Batch ;
- _ComputerParameters->UserName = CORBA::string_dup( aComputerParameters->UserName ) ;
- _ComputerParameters->Os = aComputerParameters->Os ;
- _ComputerParameters->Memory = aComputerParameters->Memory ;
- _ComputerParameters->Swap = aComputerParameters->Swap ;
- _ComputerParameters->CpuClock = aComputerParameters->CpuClock ;
- _ComputerParameters->NbProc = aComputerParameters->NbProc ;
- _ComputerParameters->NbNode = aComputerParameters->NbNode ;
- _ComputerEnvironment = new Resources::ComputerEnvironment() ;
-// _ComputerEnvironment->Path = CORBA::string_dup( aComputerEnvironment->Path ) ;
-// _ComputerEnvironment->Ld_Library_Path = CORBA::string_dup( aComputerEnvironment->Ld_Library_Path ) ;
-// _ComputerEnvironment->PythonPath = CORBA::string_dup( aComputerEnvironment->PythonPath ) ;
-// _ComputerEnvironment->CasRoot = CORBA::string_dup( aComputerEnvironment->CasRoot ) ;
- int size = aComputerEnvironment->Module_Root_Dir_Names.length() ;
- _ComputerEnvironment->Module_Root_Dir_Names.length( size ) ;
- _ComputerEnvironment->Module_Root_Dir_Values.length( size ) ;
- int i ;
- for ( i = 0 ; i < size ; i++ ) {
- _ComputerEnvironment->Module_Root_Dir_Names[ i ] = CORBA::string_dup( aComputerEnvironment->Module_Root_Dir_Names[ i ] ) ;
- _ComputerEnvironment->Module_Root_Dir_Values[ i ] = CORBA::string_dup( aComputerEnvironment->Module_Root_Dir_Values[ i ] ) ;
- }
-#if 0
- cout << "Computer_Impl::Computer_Impl FullName " << _ComputerParameters->FullName << endl ;
- cout << "Computer_Impl::Computer_Impl Alias " << _ComputerParameters->Alias << endl ;
- cout << "Computer_Impl::Computer_Impl SshAccess " << _ComputerParameters->SshAccess << endl ;
- cout << "Computer_Impl::Computer_Impl Interactive " << _ComputerParameters->Interactive << endl ;
- cout << "Computer_Impl::Computer_Impl Batch " << _ComputerParameters->Batch << endl ;
- cout << "Computer_Impl::Computer_Impl UserName " << _ComputerParameters->UserName << endl ;
- cout << "Computer_Impl::Computer_Impl Os " << _ComputerParameters->Os << endl ;
- cout << "Computer_Impl::Computer_Impl Memory " << _ComputerParameters->Memory << endl ;
- cout << "Computer_Impl::Computer_Impl Swap " << _ComputerParameters->Swap << endl ;
- cout << "Computer_Impl::Computer_Impl CpuClock " << _ComputerParameters->CpuClock << endl ;
- cout << "Computer_Impl::Computer_Impl NbProc " << _ComputerParameters->NbProc << endl ;
- cout << "Computer_Impl::Computer_Impl NbNode " << _ComputerParameters->NbNode << endl ;
- for ( i = 0 ; i < size ; i++ ) {
- cout << "Computer_Impl::Computer_Impl Module_Root_Dir_Names[" << i << " ] " << _ComputerEnvironment->Module_Root_Dir_Names[ i ] << endl ;
- cout << "Computer_Impl::Computer_Impl Module_Root_Dir_Values[" << i << " ] " << _ComputerEnvironment->Module_Root_Dir_Values[ i ] << endl ;
- }
-// cout << "Computer_Impl::Computer_Impl Path " << _ComputerEnvironment->Path << endl ;
-// cout << "Computer_Impl::Computer_Impl Ld_Library_Path " << _ComputerEnvironment->Ld_Library_Path << endl ;
-// cout << "Computer_Impl::Computer_Impl PythonPath " << _ComputerEnvironment->PythonPath << endl ;
-// cout << "Computer_Impl::Computer_Impl CasRoot " << _ComputerEnvironment->CasRoot << endl ;
-#endif
-}
-
-Computer_Impl::~Computer_Impl() {
-}
-
-PortableServer::ObjectId * Computer_Impl::getId() {
- return _Id ;
-}
-
-bool Computer_Impl::ping() {
- MESSAGE("Computer_Impl::ping()") ;
- return true ;
-}
-
-char * Computer_Impl::FullName() {
-// MESSAGE("Computer_Impl::FullName()") ;
- return CORBA::string_dup( _ComputerParameters->FullName ) ;
-}
-
-char * Computer_Impl::Alias() {
-// MESSAGE("Computer_Impl::Alias()") ;
- return CORBA::string_dup( _ComputerParameters->Alias ) ;
-}
-
-bool Computer_Impl::IsAlive() {
-// MESSAGE("Computer_Impl::IsAlive()") ;
- bool IsAlive = true ;
- string ping( "ping -c 1 -t 2 -q " ) ;
- if ( strcmp( Alias() , GetHostname().c_str() ) ) {
-//CCRT string ping( "ping -c 1 -w 2 -q " ) ;
- ping += Alias() ;
- int status = system( ping.c_str() ) ;
- if ( status != 0 ) {
- IsAlive = false ;
- }
- }
-// MESSAGE("Computer_Impl::IsAlive() " << ping << " IsAlive " << IsAlive ) ;
- return IsAlive ;
-}
-
-bool Computer_Impl::SshAccess() {
-// MESSAGE("Computer_Impl::SshAccess()") ;
- return _ComputerParameters->SshAccess ;
-}
-
-bool Computer_Impl::RshAccess() {
-// MESSAGE("Computer_Impl::RshAccess()") ;
- return !_ComputerParameters->SshAccess ;
-}
-
-bool Computer_Impl::Interactive() {
-// MESSAGE("Computer_Impl::Interactive()") ;
- return _ComputerParameters->Interactive ;
-}
-
-bool Computer_Impl::Batch() {
-// MESSAGE("Computer_Impl::Batch()") ;
- return _ComputerParameters->Batch ;
-}
-
-char * Computer_Impl::UserName() {
-// MESSAGE("Computer_Impl::UserName()") ;
- return CORBA::string_dup( _ComputerParameters->UserName ) ;
-}
-
-Containers::System Computer_Impl::Os() {
-// MESSAGE("Computer_Impl::Os()") ;
- return _ComputerParameters->Os ;
-}
-
-CORBA::Long Computer_Impl::Memory() {
-// MESSAGE("Computer_Impl::Memory()") ;
- return _ComputerParameters->Memory ;
-}
-
-CORBA::Long Computer_Impl::Swap() {
-// MESSAGE("Computer_Impl::Swap()") ;
- return _ComputerParameters->Swap ;
-}
-
-CORBA::Long Computer_Impl::CpuClock() {
-// MESSAGE("Computer_Impl::CpuClock()") ;
- return _ComputerParameters->CpuClock ;
-}
-
-CORBA::Long Computer_Impl::NbProc() {
-// MESSAGE("Computer_Impl::NbProc()") ;
- return _ComputerParameters->NbProc ;
-}
-
-CORBA::Long Computer_Impl::NbNode() {
-// MESSAGE("Computer_Impl::NbNode()") ;
- return _ComputerParameters->NbNode ;
-}
-
-Resources::ComputerParameters * Computer_Impl::Parameters() {
- Resources::ComputerParameters_var aComputerParameters = new Resources::ComputerParameters() ;
- aComputerParameters->FullName = CORBA::string_dup( _ComputerParameters->FullName ) ;
- aComputerParameters->Alias = CORBA::string_dup( _ComputerParameters->Alias ) ;
- aComputerParameters->SshAccess = _ComputerParameters->SshAccess ;
- aComputerParameters->Interactive = _ComputerParameters->Interactive ;
- aComputerParameters->Batch = _ComputerParameters->Batch ;
- aComputerParameters->UserName = CORBA::string_dup( _ComputerParameters->UserName ) ;
- aComputerParameters->Os = _ComputerParameters->Os ;
- aComputerParameters->Memory = _ComputerParameters->Memory ;
- aComputerParameters->Swap = _ComputerParameters->Swap ;
- aComputerParameters->CpuClock = _ComputerParameters->CpuClock ;
- aComputerParameters->NbProc = _ComputerParameters->NbProc ;
- aComputerParameters->NbNode = _ComputerParameters->NbNode ;
- return aComputerParameters._retn() ;
-}
-
-Resources::ComputerEnvironment * Computer_Impl::Environment() {
- Resources::ComputerEnvironment_var aComputerEnvironment = new Resources::ComputerEnvironment() ;
-// aComputerEnvironment->Path = CORBA::string_dup( _ComputerEnvironment->Path ) ;
-// aComputerEnvironment->Ld_Library_Path = CORBA::string_dup( _ComputerEnvironment->Ld_Library_Path ) ;
-// aComputerEnvironment->PythonPath = CORBA::string_dup( _ComputerEnvironment->PythonPath ) ;
-// aComputerEnvironment->CasRoot = CORBA::string_dup( _ComputerEnvironment->CasRoot ) ;
- int size = _ComputerEnvironment->Module_Root_Dir_Names.length() ;
- aComputerEnvironment->Module_Root_Dir_Names.length( size ) ;
- aComputerEnvironment->Module_Root_Dir_Values.length( size ) ;
- int i ;
- for ( i = 0 ; i < size ; i++ ) {
- aComputerEnvironment->Module_Root_Dir_Names[ i ] = CORBA::string_dup( _ComputerEnvironment->Module_Root_Dir_Names[ i ] ) ;
- aComputerEnvironment->Module_Root_Dir_Values[ i ] = CORBA::string_dup( _ComputerEnvironment->Module_Root_Dir_Values[ i ] ) ;
- }
- return aComputerEnvironment._retn() ;
-}
-
+++ /dev/null
-// SALOME ResourcesComputer_Impl
-//
-// 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 : ResourcesComputer_Impl.hxx
-// Author : Jean Rahuel
-// Module : SALOME
-// $Header:
-
-#ifndef RESOURCESCOMPUTER_IMPL_HXX
-#define RESOURCESCOMPUTER_IMPL_HXX
-
-#include "utilities.h"
-#include <SALOMEconfig.h>
-#include CORBA_SERVER_HEADER( ResourcesManager )
-
-class Computer_Impl : public POA_Resources::Computer ,
- public PortableServer::RefCountServantBase {
- private:
-
- CORBA::ORB_ptr _Orb ;
- PortableServer::POA_ptr _Poa ;
- PortableServer::ObjectId * _Id ;
-
- Resources::ComputerParameters * _ComputerParameters ;
- Resources::ComputerEnvironment * _ComputerEnvironment ;
-
- public:
-
- Computer_Impl() ;
-
- Computer_Impl( CORBA::ORB_ptr orb ,
- PortableServer::POA_ptr poa ,
- Resources::ComputerParameters * aComputerParameters ,
- Resources::ComputerEnvironment * aComputerEnvironment ) ;
-
- ~Computer_Impl() ;
-
- PortableServer::ObjectId * getId() ;
-
- virtual bool ping() ;
-
- virtual char * FullName() ;
-
- virtual char * Alias() ;
-
- virtual bool IsAlive() ;
-
- virtual bool SshAccess() ;
-
- virtual bool RshAccess() ;
-
- virtual bool Interactive() ;
-
- virtual bool Batch() ;
-
- virtual char * UserName() ;
-
- virtual Containers::System Os() ;
-
- virtual CORBA::Long Memory() ;
-
- virtual CORBA::Long Swap() ;
-
- virtual CORBA::Long CpuClock() ;
-
- virtual CORBA::Long NbProc() ;
-
- virtual CORBA::Long NbNode() ;
-
- virtual Resources::ComputerParameters * Parameters() ;
-
- virtual Resources::ComputerEnvironment * Environment() ;
-
-} ;
-
-#endif
+++ /dev/null
-// SALOME ResourcesManager_Handler
-//
-// 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 : ResourcesManager_Handler.cxx
-// Author : Jean Rahuel
-// Module : SALOME
-//$Header:
-
-#define TRACE 0
-
-#include "ResourcesManager_Handler.hxx"
-
-using namespace std;
-
-ResourcesManager_Handler::ResourcesManager_Handler( CORBA::ORB_ptr orb ,
- PortableServer::POA_ptr poa ) {
- MESSAGE("ResourcesManager_Handler creation") ;
- _Orb = CORBA::ORB::_duplicate( orb ) ;
- _Poa = PortableServer::POA::_duplicate( poa ) ;
- ResetParameters() ;
-}
-
-ResourcesManager_Handler::~ResourcesManager_Handler() {
- MESSAGE("~ResourcesManager_Handler");
-}
-
-//Resources::ListOfComputers * ResourcesManager_Handler::ListOfComputers() {
-// MESSAGE("ResourcesManager_Handler::ListOfComputers() " << _ComputersList->length() << " computers" ) ;
-// return _ComputersList._retn() ;
-//}
-
-vector< Computer_Impl * > ResourcesManager_Handler::ComputersVector() {
- MESSAGE("ResourcesManager_Handler::ComputersVector() " << _ComputersVector.size() << " computers" ) ;
- return _ComputersVector;
-}
-
-void ResourcesManager_Handler::ResetParameters() {
- _ComputerParameters.FullName = CORBA::string_dup( "" ) ;
- _ComputerParameters.Alias = CORBA::string_dup( "" ) ;
- _ComputerParameters.SshAccess = 0 ;
- _ComputerParameters.Interactive = 0 ;
- _ComputerParameters.Batch = 0 ;
- _ComputerParameters.UserName = CORBA::string_dup( "" ) ;
- _ComputerParameters.Os = Containers::Unknown ;
- _ComputerParameters.Memory = 0 ;
- _ComputerParameters.Swap = 0 ;
- _ComputerParameters.CpuClock = 0 ;
- _ComputerParameters.NbProc = 0 ;
- _ComputerParameters.NbNode = 0 ;
-// _ComputerEnvironment.Path = CORBA::string_dup( "" ) ;
-// _ComputerEnvironment.Ld_Library_Path = CORBA::string_dup( "" ) ;
-// _ComputerEnvironment.PythonPath = CORBA::string_dup( "" ) ;
-// _ComputerEnvironment.CasRoot = CORBA::string_dup( "" ) ;
- _ComputerEnvironment.Module_Root_Dir_Names.length( 0 ) ;
- _ComputerEnvironment.Module_Root_Dir_Values.length( 0 ) ;
-}
-
-Containers::System ResourcesManager_Handler::OsEnumValue( const string anOsName ) {
- if ( anOsName == "Linux" ) {
- return Containers::Linux ;
- }
- return Containers::Unknown ;
-}
-
-bool ResourcesManager_Handler::startDocument() {
- MESSAGE("Begin parse document");
- return true;
-}
-
-bool ResourcesManager_Handler::startElement( const QString&,
- const QString&,
- const QString& qName,
- const QXmlAttributes& atts) {
- return true;
-}
-
-bool ResourcesManager_Handler::endElement( const QString& , const QString& ,
- const QString& qName ) {
- if ( qName.compare( QString( "fullname" ) ) == 0 ) {
-#if TRACE
- cout << "fullname " << content.c_str() << endl ;
-#endif
- _ComputerParameters.FullName = CORBA::string_dup( content.c_str() ) ;
- }
- else if ( qName.compare(QString( "alias" ) ) == 0 ) {
-#if TRACE
- cout << "alias " << content.c_str() << endl ;
-#endif
- _ComputerParameters.Alias = CORBA::string_dup( content.c_str() ) ;
- }
- else if ( qName.compare(QString( "sshaccess" ) ) == 0 ) {
-#if TRACE
- cout << "sshaccess " << content.c_str() << endl ;
-#endif
- _ComputerParameters.SshAccess = atol( content.c_str() ) ;
- }
- else if ( qName.compare(QString( "interactive" ) ) == 0 ) {
-#if TRACE
- cout << "interactive " << content.c_str() << endl ;
-#endif
- _ComputerParameters.Interactive = atol( content.c_str() ) ;
- }
- else if ( qName.compare(QString( "batch" ) ) == 0 ) {
-#if TRACE
- cout << "batch " << content.c_str() << endl ;
-#endif
- _ComputerParameters.Batch = atol( content.c_str() ) ;
- }
- else if ( qName.compare(QString( "username" ) ) == 0 ) {
-#if TRACE
- cout << "username " << content.c_str() << " length " << content.length() << endl ;
-#endif
- if ( content[0] != '\n' ) {
- _ComputerParameters.UserName = CORBA::string_dup( content.c_str() ) ;
- }
- else {
- _ComputerParameters.UserName = CORBA::string_dup( "" ) ;
- }
- }
- else if ( qName.compare(QString( "os" ) ) == 0 ) {
-#if TRACE
- cout << "os " << content.c_str() << endl ;
-#endif
- _ComputerParameters.Os = OsEnumValue( content ) ;
- }
- else if ( qName.compare(QString( "memory" ) ) == 0 ) {
-#if TRACE
- cout << "memory " << content.c_str() << endl ;
-#endif
- _ComputerParameters.Memory = atol( content.c_str() ) ;
- }
- else if ( qName.compare(QString( "swap" ) ) == 0 ) {
-#if TRACE
- cout << "swap " << content.c_str() << endl ;
-#endif
- _ComputerParameters.Swap = atol( content.c_str() ) ;
- }
- else if ( qName.compare(QString( "cpuclock" ) ) == 0 ) {
-#if TRACE
- cout << "cpuclock " << content.c_str() << endl ;
-#endif
- _ComputerParameters.CpuClock = atol( content.c_str() ) ;
- }
- else if ( qName.compare(QString( "nbproc" ) ) == 0 ) {
-#if TRACE
- cout << "nbproc " << content.c_str() << endl ;
-#endif
- _ComputerParameters.NbProc = atol( content.c_str() ) ;
- }
- else if ( qName.compare(QString( "nbnode" ) ) == 0 ) {
-#if TRACE
- cout << "nbnode " << content.c_str() << endl ;
-#endif
- _ComputerParameters.NbNode = atol( content.c_str() ) ;
- }
-
-// else if ( qName.compare(QString("path") ) == 0 ) {
-//#if TRACE
-// cout << "path " << content.c_str() << endl ;
-//#endif
-// _ComputerEnvironment.Path = CORBA::string_dup( content.c_str() ) ;
-// }
-// else if ( qName.compare(QString("ld_library_path") ) == 0 ) {
-//#if TRACE
-// cout << "ld_library_path " << content.c_str() << endl ;
-//#endif
-// _ComputerEnvironment.Ld_Library_Path = CORBA::string_dup( content.c_str() ) ;
-// }
-// else if ( qName.compare(QString("pythonpath") ) == 0 ) {
-//#if TRACE
-// cout << "pythonpath " << content.c_str() << endl ;
-//#endif
-// _ComputerEnvironment.PythonPath = CORBA::string_dup( content.c_str() ) ;
-// }
-// else if ( qName.compare(QString("casroot") ) == 0 ) {
-//#if TRACE
-// cout << "casroot " << content.c_str() << endl ;
-//#endif
-// _ComputerEnvironment.CasRoot = CORBA::string_dup( content.c_str() ) ;
-// }
- else if ( qName.compare(QString("modules_root_dir") ) == 0 ) {
-#if TRACE
- cout << "modules_root_dir " << content.c_str() << endl ;
-#endif
- int size = _ComputerEnvironment.Module_Root_Dir_Names.length() ;
- _ComputerEnvironment.Module_Root_Dir_Names.length( size + 1 ) ;
- _ComputerEnvironment.Module_Root_Dir_Names[ size ] = CORBA::string_dup( content.c_str() ) ;
- }
- else if ( qName.compare(QString("modules_root_path") ) == 0 ) {
-#if TRACE
- cout << "modules_root_path " << content.c_str() << endl ;
-#endif
- int size = _ComputerEnvironment.Module_Root_Dir_Values.length() ;
- _ComputerEnvironment.Module_Root_Dir_Values.length( size + 1 ) ;
- _ComputerEnvironment.Module_Root_Dir_Values[ size ] = CORBA::string_dup( content.c_str() ) ;
- }
-
- else if ( qName.compare(QString("computer") ) == 0 ) {
- Computer_Impl * aComputer = new Computer_Impl( _Orb , _Poa ,
- &_ComputerParameters , &_ComputerEnvironment ) ;
- int size = _ComputersVector.size() ;
- _ComputersVector.resize( size + 1 ) ;
- _ComputersVector[ size ] = aComputer ;
- ResetParameters() ;
-#if TRACE
- cout << size+1 << " computers" << endl ;
-#endif
- }
-
- return true;
-}
-
-bool ResourcesManager_Handler::characters(const QString& chars) {
- content = (const char *)chars ;
- return true;
-}
-
-bool ResourcesManager_Handler::endDocument() {
- MESSAGE("End parse document");
- return true;
-}
-
-QString ResourcesManager_Handler::errorProtocol() {
- return errorProt;
-}
-
-bool ResourcesManager_Handler::fatalError(const QXmlParseException& exception) {
- 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 );
-}
-
+++ /dev/null
-// SALOME ResourcesManager_Handler
-//
-// 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 : ResourcesManager_Handler.hxx
-// Author : Jean Rahuel
-// Module : SALOME
-//$Header:
-
-#ifndef RESSOURCESMANAGER_HANDLER_HXX
-#define RESSOURCESMANAGER_HANDLER_HXX
-
-#include <SALOMEconfig.h>
-#include CORBA_SERVER_HEADER( ResourcesManager )
-#include CORBA_SERVER_HEADER( ContainersManager )
-
-#include "utilities.h"
-#include "ResourcesManager_Parser.hxx"
-#include "ResourcesComputer_Impl.hxx"
-#include <qxml.h>
-#include <string>
-#include <vector>
-
-class ResourcesManager_Handler : public QXmlDefaultHandler {
-
- private :
-
- CORBA::ORB_ptr _Orb ;
- PortableServer::POA_ptr _Poa ;
-
-// Resources::ListOfComputers_var _ComputersList ;
- vector< Computer_Impl * > _ComputersVector ;
- Resources::ComputerParameters _ComputerParameters ;
- Resources::ComputerEnvironment _ComputerEnvironment ;
-
- QString errorProt ;
-
- string content ;
-
- void ResetParameters() ;
-
- Containers::System OsEnumValue( const string anOsName ) ;
-
- public :
-
- ResourcesManager_Handler( CORBA::ORB_ptr orb ,
- PortableServer::POA_ptr poa ) ;
-
- virtual ~ResourcesManager_Handler() ;
-
-// virtual Resources::ListOfComputers * ListOfComputers() ;
- vector< Computer_Impl * > ComputersVector() ;
-
- virtual bool startDocument() ;
-
- virtual bool startElement( const QString& , const QString& ,
- const QString& qName , const QXmlAttributes& atts ) ;
-
- virtual bool endElement( const QString& , const QString& ,
- const QString& qName) ;
-
- virtual bool characters( const QString & chars) ;
-
- virtual bool endDocument() ;
-
- virtual QString errorProtocol() ;
-
- virtual bool fatalError( const QXmlParseException& exception ) ;
-
-} ;
-
-#endif
+++ /dev/null
-// ResourcesManager_Impl
-//
-// 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 : ResourcesManager_Impl.cxx
-// Author : Jean Rahuel
-// Module : SALOME
-
-#include <stdlib.h>
-#include <unistd.h>
-#include <string>
-
-#include <fstream>
-
-#include "OpUtil.hxx"
-
-#include "ResourcesManager_Impl.hxx"
-
-using namespace std;
-
-Manager_Impl::Manager_Impl( CORBA::ORB_ptr orb ,
- PortableServer::POA_ptr poa ,
- SALOME_NamingService * NamingService ,
- int argc ,
- char ** argv ) {
-
- _Orb = CORBA::ORB::_duplicate( orb ) ;
- _Poa = PortableServer::POA::_duplicate( poa ) ;
- _Id = _Poa->activate_object( this ) ;
- _NamingService = NamingService ;
-
- _ComputersList = new Resources::ListOfComputers() ;
-
- if ( !ParseArguments( argc , argv , &_CatalogPath ) ) {
- MESSAGE( "Error while argument parsing" ) ;
- }
- else if ( _CatalogPath == NULL ) {
- MESSAGE( "Error the resources catalog should be indicated" ) ;
- }
- else {
- MESSAGE("Parse resources catalog");
- ParseXmlFile( _CatalogPath ) ;
- }
- int i ;
- MESSAGE(_ComputersVector.size() << " computers") ;
- int size = _ComputersVector.size() ;
- _ComputersList->length( size ) ;
- for ( i = 0 ; i < size ; i++ ) {
- Computer_Impl * aComputer = _ComputersVector[ i ] ;
- PortableServer::ObjectId * id = aComputer->getId() ;
- CORBA::Object_var obj = _Poa->id_to_reference( *id ) ;
- Resources::Computer_var iobject = Resources::Computer::_narrow( obj ) ;
- _ComputersList[ i ] = Resources::Computer::_duplicate( iobject ) ;
- Resources::ComputerParameters * aComputerParameters = aComputer->Parameters() ;
- const char * anAlias = aComputerParameters->Alias ;
- if ( _MapOfAliasComputers[ anAlias ] > 0 ) {
- MESSAGE("Duplicate computer " << aComputerParameters->FullName << " " << anAlias ) ;
- }
- else {
- MESSAGE("Computer " << aComputerParameters->FullName << " " << anAlias ) ;
- _MapOfAliasComputers[ anAlias ] = i + 1 ;
- }
- const char * aFullName = aComputerParameters->FullName ;
- if ( _MapOfFullNameComputers[ aFullName ] > 0 ) {
- MESSAGE("Duplicate computer " << aComputerParameters->FullName << " " << aFullName ) ;
- }
- else {
- MESSAGE("Computer " << aComputerParameters->FullName << " " << aFullName ) ;
- _MapOfFullNameComputers[ aFullName ] = i + 1 ;
- }
- }
- MESSAGE(_ComputersList->length() << " computers") ;
-}
-
-Manager_Impl::~Manager_Impl() {
- MESSAGE("~Manager_Impl()") ;
-}
-
-bool Manager_Impl::ping() {
- MESSAGE("Manager_Impl::ping()") ;
- return true ;
-}
-
-bool Manager_Impl::SshAccess( const char * aComputerName ) {
- if ( !CORBA::is_nil( SearchComputer( aComputerName ) ) ) {
- return SearchComputer( aComputerName )->Parameters()->SshAccess ;
- }
- return false ;
-}
-
-char * Manager_Impl::UserName( const char * aComputerName ) {
- if ( !CORBA::is_nil( SearchComputer( aComputerName ) ) ) {
- return CORBA::string_dup( SearchComputer( aComputerName )->Parameters()->UserName ) ;
- }
- return CORBA::string_dup( "" ) ;
-}
-
-Resources::ListOfComputers * Manager_Impl::AllComputers() {
- MESSAGE("Manager_Impl::AllComputers()") ;
- Resources::ListOfComputers_var aListOfComputers = new Resources::ListOfComputers() ;
- aListOfComputers->length( _ComputersList->length() ) ;
- int i ;
- for ( i = 0 ; i < _ComputersList->length() ; i++ ) {
- Resources::Computer_var aComputer = _ComputersList[ i ] ;
- aListOfComputers[ i ] = Resources::Computer::_duplicate( aComputer ) ;
- }
- return aListOfComputers._retn() ;
-}
-
-Resources::ListOfComputers * Manager_Impl::GetComputers( const Containers::MachineParameters & aMachineParameters ) {
-// MESSAGE(endl << "Manager_Impl::GetComputers() search in list of "
-// << _ComputersList->length() << " computers for '" << aMachineParameters.HostName << "'" ) ;
- Resources::ListOfComputers_var aListOfComputers = new Resources::ListOfComputers() ;
- int i ;
- if ( strlen( (char * ) ((CORBA::String_member ) aMachineParameters.HostName) ) ) {
- for ( i = 0 ; i < _ComputersList->length() ; i++ ) {
- Resources::Computer_var aComputer = _ComputersList[ i ] ;
- if ( strcmp( aComputer->Parameters()->FullName , aMachineParameters.HostName ) == 0 ||
- strcmp( aComputer->Parameters()->Alias , aMachineParameters.HostName ) == 0 ) {
- aListOfComputers->length( 1 ) ;
- aListOfComputers[ 0 ] = Resources::Computer::_duplicate( aComputer ) ;
-// MESSAGE("Manager_Impl::GetComputers() " << aComputer->Parameters()->FullName << " "
-// << aComputer->Parameters()->Alias << " selected" ) ;
- break ;
- }
- else {
-// MESSAGE("Manager_Impl::GetComputers() " << aComputer->Parameters()->FullName << " "
-// << strcmp( aComputer->Parameters()->FullName , aMachineParameters.HostName ) << " "
-// << aComputer->Parameters()->Alias << " "
-// << strcmp( aComputer->Parameters()->Alias , aMachineParameters.HostName ) <<// " skipped" ) ;
- }
- }
- }
- else {
- for ( i = 0 ; i < _ComputersList->length() ; i++ ) {
- Resources::Computer_var aComputer = _ComputersList[ i ] ;
- if ( ( aMachineParameters.Os == Containers::Unknown ||
- ( aComputer->Parameters()->Os == aMachineParameters.Os ) ) &&
- aComputer->Parameters()->Memory >= aMachineParameters.Memory &&
- aComputer->Parameters()->CpuClock >= aMachineParameters.CpuClock &&
- aComputer->Parameters()->NbProc >= aMachineParameters.NbProc &&
- aComputer->Parameters()->NbNode >= aMachineParameters.NbNode ) {
- int size = aListOfComputers->length() ;
- aListOfComputers->length( size + 1 ) ;
- aListOfComputers[ size ] = Resources::Computer::_duplicate( aComputer ) ;
-// MESSAGE("Manager_Impl::GetComputers() " << aComputer->FullName() << " selected" ) ;
- }
- }
- }
-// MESSAGE("Manager_Impl::GetComputers() " << aListOfComputers->length() << " found" << endl ) ;
- return aListOfComputers._retn() ;
-}
-
-Resources::Computer_ptr Manager_Impl::SelectComputer( const Containers::MachineParameters & aMachineParameters ) {
- MESSAGE("Manager_Impl::SelectComputer()") ;
- Resources::ListOfComputers_var aListOfComputers = GetComputers( aMachineParameters ) ;
- MESSAGE("Manager_Impl::SelectComputer()") ;
- return GetComputer( aListOfComputers ) ;
-}
-
-Resources::Computer_ptr Manager_Impl::GetComputer( const Resources::ListOfComputers & aListOfComputers ) {
- MESSAGE("Manager_Impl::GetComputer()") ;
- Resources::Computer_var aComputer = Resources::Computer::_nil() ;
- int i ;
- for ( i = 0 ; i < aListOfComputers.length() ; i++ ) {
- if ( aListOfComputers[ i ]->IsAlive() &&
- !strcmp( aListOfComputers[ i ]->Alias() , GetHostname().c_str() ) ) {
- aComputer = aListOfComputers[ i ] ;
- break ;
- }
- }
- if ( CORBA::is_nil( aComputer ) ) {
- for ( i = 0 ; i < aListOfComputers.length() ; i++ ) {
- if ( aListOfComputers[ i ]->IsAlive() ) {
- aComputer = aListOfComputers[ i ] ;
- break ;
- }
- }
- }
- if ( CORBA::is_nil( aComputer ) ) {
- MESSAGE("Manager_Impl::GetComputer() : nil_objref_Computer") ;
- }
- else {
- MESSAGE("Manager_Impl::GetComputer() : " << aComputer->Alias() ) ;
- }
- return Resources::Computer::_duplicate( aComputer ) ;
-}
-
-Resources::Computer_ptr Manager_Impl::SearchComputer( const char * aComputerName ) {
- MESSAGE("Manager_Impl::SearchComputer()") ;
- Resources::Computer_var aComputer = Resources::Computer::_nil() ;
- int i = _MapOfAliasComputers[ aComputerName ] ;
- if ( i ) {
- aComputer = _ComputersList[ i - 1 ] ;
- MESSAGE("Manager_Impl::SearchComputer " << aComputerName << " found in MapOfAliasComputers") ;
- }
- else {
- MESSAGE("Manager_Impl::SearchComputer " << aComputerName << " NOT found in MapOfAliasComputers") ;
- }
- i = _MapOfFullNameComputers[ aComputerName ] ;
- if ( i ) {
- aComputer = _ComputersList[ i - 1 ] ;
- MESSAGE("Manager_Impl::SearchComputer " << aComputerName << " found in MapOfFullNameComputers") ;
- }
- else {
- MESSAGE("Manager_Impl::SearchComputer " << aComputerName << " NOT found in MapOfFullNameComputers") ;
- }
- return Resources::Computer::_duplicate( aComputer ) ;
-}
-
-//Resources::ListOfComputers_var Manager_Impl::ParseXmlFile( const char * xmlfile ) {
-void Manager_Impl::ParseXmlFile( const char * xmlfile ) {
- ResourcesManager_Handler * MyHandler = new ResourcesManager_Handler( _Orb , _Poa );
- QFile xmlFile( xmlfile ) ;
- QXmlInputSource source( xmlFile ) ;
- QXmlSimpleReader reader ;
- reader.setContentHandler( MyHandler ) ;
- reader.setErrorHandler( MyHandler ) ;
- reader.parse( source ) ;
-// Resources::ListOfComputers_var aListOfComputers = MyHandler->ListOfComputers() ;
- _ComputersVector = MyHandler->ComputersVector() ;
- xmlFile.close() ;
- MESSAGE("Manager_Impl::ParseXmlFile()" << _ComputersVector.size() << " computers" ) ;
-// return aListOfComputers ;
-}
-
-bool Manager_Impl::ParseArguments( int argc , char ** argv , char ** path) {
- bool RetVal = true;
- *path = NULL;
- for ( int ind = 0 ; ind < argc ; ind++ ) {
- if ( strcmp( argv[ind] , "-help" ) == 0 ) {
- INFOS( "Usage: " << argv[0] << " -common 'path to ressources catalog' -ORBInitRef NameService=corbaname::localhost");
- RetVal = false ;
- }
- if ( strcmp( argv[ind] ,"-common" ) == 0 ) {
- if ( ind + 1 <= argc ) {
- *path = argv[ind + 1] ;
- ifstream path_file(*path);
- if ( !path_file ) {
- MESSAGE( "Sorry the file " << *path << " can't be open" )
- *path = NULL ;
- RetVal = false;
- }
- }
- }
- }
- return RetVal ;
-}
-
+++ /dev/null
-// SALOME ResourcesManager_Impl
-//
-// 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 : ResourcesManager_Impl.hxx
-// Author : Jean Rahuel
-// Module : SALOME
-// $Header:
-
-#ifndef RESOURCESMANAGER_IMPL_HXX
-#define RESOURCESMANAGER_IMPL_HXX
-
-//CCRT
-//#include <vector.h>
-#include <vector>
-//#include <map.h>
-#include <map>
-
-#include <ServiceUnreachable.hxx>
-
-#include "SALOME_NamingService.hxx"
-
-#include "utilities.h"
-#include "ResourcesManager_Handler.hxx"
-
-#include <SALOMEconfig.h>
-#include CORBA_SERVER_HEADER( ResourcesManager )
-#include CORBA_SERVER_HEADER( ContainersManager )
-
-class Manager_Impl : public POA_Resources::Manager ,
- public PortableServer::RefCountServantBase {
-
- private:
-
- CORBA::ORB_ptr _Orb ;
- PortableServer::POA_ptr _Poa ;
- SALOME_NamingService * _NamingService ;
- PortableServer::ObjectId * _Id ;
-
- char * _CatalogPath ;
-
- vector< Computer_Impl * > _ComputersVector ;
- Resources::ListOfComputers_var _ComputersList ;
-
- map< string , int > _MapOfFullNameComputers ;
- map< string , int > _MapOfAliasComputers ;
-
-// virtual Resources::ListOfComputers_var ParseXmlFile( const char * xmlfile ) ;
- virtual void ParseXmlFile( const char * xmlfile ) ;
-
- virtual bool ParseArguments( int argc , char ** argv , char ** path ) ;
-
- public:
-
- Manager_Impl( CORBA::ORB_ptr orb ,
- PortableServer::POA_ptr poa ,
- SALOME_NamingService * NamingService ,
- int argc ,
- char** argv ) ;
-
- virtual ~Manager_Impl();
-
- virtual bool ping() ;
-
- virtual bool SshAccess( const char * aComputerName ) ;
-
- virtual char * UserName( const char * aComputerName ) ;
-
- virtual Resources::ListOfComputers * AllComputers() ;
-
- virtual Resources::ListOfComputers * GetComputers( const Containers::MachineParameters & aMachineParameters ) ;
-
- virtual Resources::Computer_ptr SelectComputer( const Containers::MachineParameters & aMachineParameters ) ;
-
- virtual Resources::Computer_ptr GetComputer( const Resources::ListOfComputers & aListOfComputers ) ;
-
- virtual Resources::Computer_ptr SearchComputer( const char * aComputerName ) ;
-
-} ;
-
-#endif
+++ /dev/null
-// SALOME ResourcesManager_Parser
-//
-// 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 : ResourcesManager_Parser.hxx
-// Author : Jean Rahuel
-// Module : SALOME
-//$Header:
-
-#ifndef RESOURCESMANAGER_PARSER
-#define RESOURCESMANAGER_PARSER
-
-#include <string>
-#include <vector>
-
-struct ParserProc{
- long Parsernumber;
- string Parsermodel_name;
- float Parsercpu_mhz;
- float Parsercache_size;
-};
-
-typedef vector<ParserProc> ListOfParserProc;
-
-enum Parsercontainertype {Cpp, python, NP};
-typedef vector<Parsercontainertype> ListOfParserContainerType;
-
-struct Parserressources{
- string Parsername;
- string ParserOS;
- string ParserOS_version;
- ListOfParserProc Parserprocs;
- ListOfParserContainerType Parsercontainertype;
-};
-
-typedef vector<Parserressources> ListOfParserressources;
-
-#ifdef WRITE_RESSOURCES_TYPE
-ListOfParserressources _ressources_list;
-#else
-extern ListOfParserressources _ressources_list;
-#endif
-
-#endif
+++ /dev/null
-// SALOME ResourcesManager_Server
-//
-// 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 : ResourcesManager_Server.cxx
-// Author : Jean Rahuel
-// Module : SALOME
-// $Header:
-
-#define WITH_SINGLETON 1
-
-#include <iostream.h>
-#include "SALOME_NamingService.hxx"
-#include "Utils_ORB_INIT.hxx"
-#include "Utils_SINGLETON.hxx"
-
-#include "ResourcesManager_Impl.hxx"
-
-using namespace std;
-
-int main(int argc,char **argv) {
- try {
-
-// initialize the ORB
-#if WITH_SINGLETON
- ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance() ;
- ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting()) ;
- CORBA::ORB_var &orb = init( argc , argv ) ;
-#else
- CORBA::ORB_var orb = CORBA::ORB_init(argc, argv) ;
-#endif
-
- long TIMESleep = 250000000 ;
- int NumberOfTries = 40 ;
- int a ;
- int i ;
- int j ;
- timespec ts_req ;
- ts_req.tv_nsec=TIMESleep ;
- ts_req.tv_sec=0 ;
- timespec ts_rem ;
- ts_rem.tv_nsec=0 ;
- ts_rem.tv_sec=0 ;
-
-// initialize POA
- CosNaming::NamingContext_var inc ;
- PortableServer::POA_var poa ;
- CORBA::Object_var theObj = CORBA::Object::_nil() ;
- CORBA::Object_var obj = CORBA::Object::_nil() ;
- CORBA::Object_var object = CORBA::Object::_nil() ;
-#if WITH_SINGLETON
- SALOME_NamingService &naming = *SINGLETON_<SALOME_NamingService>::Instance() ;
-#else
- theObj = orb->resolve_initial_references("NameService");
- inc = CosNaming::NamingContext::_narrow(theObj);
-#endif
- int CONTAINERS_MANAGER = 0 ;
- const char * Env = getenv("USE_LOGGER") ;
- int EnvL =0;
- if ( ( Env != NULL ) && ( strlen(Env ) ) ) {
- EnvL=1 ;
- }
- CosNaming::Name name ;
- name.length( 1 ) ;
- name[0].id = CORBA::string_dup("Logger") ;
- PortableServer::POAManager_var mgr ;
- for ( i = 1 ; i <= NumberOfTries ; i++ ) {
- if ( i != 1 ) {
- a=nanosleep( &ts_req , &ts_rem ) ;
- }
- try {
- obj = orb->resolve_initial_references( "RootPOA" ) ;
- if ( !CORBA::is_nil( obj ) ) {
- poa = PortableServer::POA::_narrow( obj ) ;
- }
- if ( !CORBA::is_nil( poa ) ) {
- mgr = poa->the_POAManager() ;
- }
- if ( !CORBA::is_nil( orb ) ) {
- theObj = orb->resolve_initial_references( "NameService" ) ;
- }
- if ( !CORBA::is_nil( theObj ) ) {
- inc = CosNaming::NamingContext::_narrow(theObj) ;
- }
- }
- catch ( CORBA::COMM_FAILURE& ) {
- MESSAGE( "ContainersManager : CORBA::COMM_FAILURE: Unable to contact the Naming Service" ) ;
- }
- if ( !CORBA::is_nil( inc ) ) {
- MESSAGE( "ContainersManager : Naming Service was found" ) ;
- if ( EnvL == 1 ) {
- for ( j = 1 ; j <= NumberOfTries ; j++ ) {
- if ( j !=1 ) {
- a=nanosleep( &ts_req , &ts_rem ) ;
- }
- try {
- object = inc->resolve( name ) ;
- }
- catch ( CosNaming::NamingContext::NotFound ) {
- MESSAGE( "ContainersManager : Logger Server wasn't found" ) ;
- }
- catch (...) {
- MESSAGE( "ContainersManager : Unknown exception" ) ;
- }
- if ( !CORBA::is_nil( object ) ) {
- MESSAGE( "ContainersManager : Loger Server was found" ) ;
- CONTAINERS_MANAGER = 1 ;
- break;
- }
- }
- }
- }
- if ( ( CONTAINERS_MANAGER == 1 ) || ( (EnvL ==0 ) && ( !CORBA::is_nil( inc ) ) ) ) {
- break;
- }
- }
-
-#if 0
- // define policy objects
- PortableServer::ImplicitActivationPolicy_var implicitActivation =
- poa->create_implicit_activation_policy(PortableServer::NO_IMPLICIT_ACTIVATION) ;
-
- // default = NO_IMPLICIT_ACTIVATION
- PortableServer::ThreadPolicy_var threadPolicy =
- poa->create_thread_policy(PortableServer::ORB_CTRL_MODEL) ;
- // default = ORB_CTRL_MODEL, other choice SINGLE_THREAD_MODEL
-
- // create policy list
- CORBA::PolicyList policyList;
- policyList.length(2);
- policyList[0] = PortableServer::ImplicitActivationPolicy::_duplicate(implicitActivation) ;
- policyList[1] = PortableServer::ThreadPolicy::_duplicate(threadPolicy) ;
-
- // create the child POA
- PortableServer::POAManager_var nil_mgr = PortableServer::POAManager::_nil() ;
- PortableServer::POA_var factory_poa =
- poa->create_POA("factory_poa", mgr, policyList) ;
- //with nil_mgr instead of mgr, a new POA manager is created with the new POA
-
- // destroy policy objects
- implicitActivation->destroy() ;
- threadPolicy->destroy() ;
-
-#endif
-
-// initialise Naming Service
- SALOME_NamingService *_NS ;
- _NS = new SALOME_NamingService( orb ) ;
-
-// Active ResourcesManager
- Manager_Impl * MyResourcesManager = new Manager_Impl( orb , poa , _NS , argc , argv ) ;
-// Manager_Impl * MyResourcesManager = new Manager_Impl( orb , factory_poa , _NS , argc , argv ) ;
-// poa->activate_object ( MyResourcesManager ) ;
- mgr->activate() ;
- CORBA::Object_ptr TheResourcesManager = MyResourcesManager->_this() ;
-
-
-// register ResourcesManager in Naming Service
- _NS->Register( TheResourcesManager , "/Kernel/ResourcesManager" ) ;
-
- MESSAGE("Running ResourcesManager Server.") ;
-
- orb->run();
-
- poa->destroy( 1 , 1 ) ;
-
- orb->destroy();
-
- }
- catch ( CORBA::SystemException& ) {
- INFOS("Caught CORBA::SystemException.") ;
- }
- catch ( CORBA::Exception& ) {
- INFOS("Caught CORBA::Exception.") ;
- }
-
- return 0 ;
-}