From 6f473f7aa7e8de91538d95beadb552022663342e Mon Sep 17 00:00:00 2001 From: =?utf8?q?C=C3=A9dric=20Aguerre?= Date: Mon, 18 Jan 2016 14:10:52 +0100 Subject: [PATCH] PortManager is not an option anymore --- CMakeLists.txt | 8 +-- SalomeKERNELConfig.cmake.in | 7 +-- bin/PortManager.py | 7 ++- bin/salomeContext.py | 3 +- bin/searchFreePort.py | 64 +------------------- doc/salome/salome_command.dox | 5 +- src/LifeCycleCORBA/SALOME_LifeCycleCORBA.cxx | 4 +- 7 files changed, 13 insertions(+), 85 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 384d9882a..cc9fe1274 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2015 CEA/DEN, EDF R&D, OPEN CASCADE +# Copyright (C) 2012-2016 CEA/DEN, EDF R&D, OPEN CASCADE # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -60,12 +60,11 @@ OPTION(SALOME_LIGHT_ONLY "Build SALOME Light only (no CORBA)" OFF) OPTION(SALOME_USE_LIBBATCH "Use LibBatch in KERNEL" OFF) CMAKE_DEPENDENT_OPTION(SALOME_PACO_PARALLEL "Build with PACO (implies SALOME_USE_MPI)" OFF "NOT SALOME_LIGHT_ONLY" OFF) -OPTION(SALOME_USE_PORTMANAGER "Add PortManager support" ON) CMAKE_DEPENDENT_OPTION(SALOME_USE_MPI "Use MPI containers" OFF "NOT SALOME_PACO_PARALLEL" ON) CMAKE_DEPENDENT_OPTION(SALOME_USE_MPI "Use MPI containers" ${SALOME_USE_MPI} "NOT SALOME_LIGHT_ONLY" OFF) -MARK_AS_ADVANCED(SALOME_LIGHT_ONLY SALOME_USE_LIBBATCH SALOME_PACO_PARALLEL SALOME_USE_PORTMANAGER) +MARK_AS_ADVANCED(SALOME_LIGHT_ONLY SALOME_USE_LIBBATCH SALOME_PACO_PARALLEL) # Required prerequisites # Find "big" prerequisites first - they reference themselves many others @@ -102,9 +101,6 @@ ENDIF() IF(SALOME_PACO_PARALLEL) FIND_PACKAGE(SalomePaco REQUIRED) ENDIF() -IF(SALOME_USE_PORTMANAGER) - ADD_DEFINITIONS(-DWITH_PORTMANAGER) -ENDIF() IF(SALOME_BUILD_TESTS) ENABLE_TESTING() FIND_PACKAGE(SalomeCppUnit) diff --git a/SalomeKERNELConfig.cmake.in b/SalomeKERNELConfig.cmake.in index c9c4cfa88..463578ff9 100644 --- a/SalomeKERNELConfig.cmake.in +++ b/SalomeKERNELConfig.cmake.in @@ -10,7 +10,7 @@ # SALOME_LIGHT_ONLY - ON if SALOME is built in Light mode (no CORBA) ############################################################### -# Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE +# Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE # # Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS @@ -67,11 +67,6 @@ SET(SALOME_KERNEL_BUILD_TESTS @SALOME_BUILD_TESTS@) SET(SALOME_KERNEL_LIGHT_ONLY @SALOME_LIGHT_ONLY@) SET(SALOME_USE_LIBBATCH @SALOME_USE_LIBBATCH@) -SET(SALOME_USE_PORTMANAGER @SALOME_USE_PORTMANAGER@) -IF(SALOME_USE_PORTMANAGER) - LIST(APPEND KERNEL_DEFINITIONS "-DWITH_PORTMANAGER") -ENDIF() - # Prerequisites: IF(SALOME_KERNEL_BUILD_TESTS) SET_AND_CHECK(CPPUNIT_ROOT_DIR_EXP "@PACKAGE_CPPUNIT_ROOT_DIR@") diff --git a/bin/PortManager.py b/bin/PortManager.py index f1641bdb6..653258713 100644 --- a/bin/PortManager.py +++ b/bin/PortManager.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -*- coding: iso-8859-1 -*- -# Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE +# Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE # # Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS @@ -44,7 +44,7 @@ def createLogger(): logger = createLogger() #------------------------------------ -# A file locker (Linux only) +# A file locker def __acquire_lock(lock): if sys.platform == "win32": import msvcrt @@ -62,6 +62,7 @@ def __release_lock(lock): import fcntl fcntl.flock(lock, fcntl.LOCK_UN) # +#------------------------------------ def _getConfigurationFilename(): omniorbUserPath = os.getenv("OMNIORB_USER_PATH") @@ -200,7 +201,7 @@ def releasePort(port): __release_lock(lock) logger.debug("released port port: %s"%str(port)) - + os.umask(oldmask) # diff --git a/bin/salomeContext.py b/bin/salomeContext.py index 7a89e9666..2132c0613 100644 --- a/bin/salomeContext.py +++ b/bin/salomeContext.py @@ -1,4 +1,4 @@ -# Copyright (C) 2013-2015 CEA/DEN, EDF R&D, OPEN CASCADE +# Copyright (C) 2013-2016 CEA/DEN, EDF R&D, OPEN CASCADE # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -425,6 +425,7 @@ class SalomeContext: p.start() p.join() except ImportError: + # :TODO: should be declared obsolete from killSalome import killAllPorts killAllPorts() pass diff --git a/bin/searchFreePort.py b/bin/searchFreePort.py index 3240663b4..cdf304eba 100755 --- a/bin/searchFreePort.py +++ b/bin/searchFreePort.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -*- coding: iso-8859-1 -*- -# Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE +# Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE # # Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS @@ -64,65 +64,6 @@ def __setup_config(nsport, args, save_config): # # -def searchFreePort_withoutPortManager(args={}, save_config=1, use_port=None): - # :NOTE: Under windows: - # netstat options -l and -t are unavailable - # grep command is unavailable - from subprocess import Popen, PIPE - (stdout, stderr) = Popen(['netstat','-an'], stdout=PIPE).communicate() - import StringIO - buf = StringIO.StringIO(stdout) - ports = buf.readlines() - - # - def portIsUsed(port, data): - import re - regObj = re.compile( ".*tcp.*:([0-9]+).*:.*listen", re.IGNORECASE ); - for item in data: - try: - p = int(regObj.match(item).group(1)) - if p == port: return True - pass - except: - pass - pass - return False - # - - if use_port: - print "Check if port can be used: %d" % use_port, - if not portIsUsed(use_port, ports): - print "- OK" - __setup_config(use_port, args, save_config) - return - else: - print "- KO: port is busy" - pass - # - - print "Searching for a free port for naming service:", - # - - NSPORT=2810 - limit=NSPORT+100 - # - - while 1: - if not portIsUsed(NSPORT, ports): - print "%s - OK"%(NSPORT) - __setup_config(NSPORT, args, save_config) - break - print "%s"%(NSPORT), - if NSPORT == limit: - msg = "\n" - msg += "Can't find a free port to launch omniNames\n" - msg += "Try to kill the running servers and then launch SALOME again.\n" - raise RuntimeError, msg - NSPORT=NSPORT+1 - pass - # -# - def searchFreePort_withPortManager(queue, args={}, save_config=1, use_port=None): from PortManager import getPort port = getPort(use_port) @@ -186,6 +127,5 @@ def searchFreePort(args={}, save_config=1, use_port=None): p.join() # this blocks until the process terminates except ImportError: - searchFreePort_withoutPortManager(args, save_config, use_port) - __savePortToFile(args) + raise Exception('PortManager module not found') # diff --git a/doc/salome/salome_command.dox b/doc/salome/salome_command.dox index 2d2387417..1bb3a45e8 100644 --- a/doc/salome/salome_command.dox +++ b/doc/salome/salome_command.dox @@ -89,11 +89,8 @@ For example: \section handling_concurrency Handling concurrent starts A SALOME instance uses a dedicated TCP port number on which the CORBA name server of each SALOME application will connect. This refers to a technical solution that allows multiple software components belonging to the same application to communicate with each other. This approach is a standard used when multiple applications are running at the same time (components should not interfere with each other), and when application components can be distributed across multiple machines. -Each SALOME application owns a specific port number. This port is determined automatically when application starts. When multiple applications are started at the same time, assigning a number to each port could be conflicting, and the same port could be assigned to several applications. To prevent from such a situation, a Python object named \c Portmanager has been implemented (Linux only). In SALOME 7, this object is available when activating a specific compilation flag of KERNEL module: -- For gcc: -DWITH_PORTMANAGER -- With CMake: SALOME_USE_PORTMANAGER=ON +Each SALOME application owns a specific port number. This port is determined automatically when application starts. When multiple applications are started at the same time, assigning a number to each port could be conflicting, and the same port could be assigned to several applications. To prevent from such a situation, a Python object named \c Portmanager has been implemented. This object has been introduced in SALOME 7 as an optional tool, then evaluated on Linux and Windows. In SALOME 8, this object becomes the standard. -Since SALOME 7.5.0 this flag is switched ON by default. Several instances can be safely started concurrently. For example in an automated process, calling several times the following commands (WORK_DIR variable changes at each call): \code salome start -t --ns-port-log=${WORK_DIR}/session.log diff --git a/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.cxx b/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.cxx index 966ab07d6..754fffa22 100644 --- a/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.cxx +++ b/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE // // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS @@ -623,7 +623,6 @@ void SALOME_LifeCycleCORBA::killOmniNames() system( cmd.c_str() ); } -#ifdef WITH_PORTMANAGER // shutdown portmanager if ( !portNumber.empty() ) { @@ -635,7 +634,6 @@ void SALOME_LifeCycleCORBA::killOmniNames() MESSAGE(cmd); system( cmd.c_str() ); } -#endif } //============================================================================= -- 2.39.2