From 6099480a40371089a149ccd59d1dcca6081af7e7 Mon Sep 17 00:00:00 2001 From: Anthony Geay Date: Wed, 3 Jan 2024 09:10:47 +0100 Subject: [PATCH] [EDF29150] : Start of implementation of centralization of log performance accross Containers. --- idl/CMakeLists.txt | 1 + idl/SALOME_LogManager.idl | 63 +++++++++++ src/Container/Container_i.cxx | 17 ++- src/Container/SALOME_Container.py | 32 ++++-- src/Container/SALOME_PyNode.py | 5 +- src/KERNEL_PY/__init__.py | 12 ++- src/Launcher/CMakeLists.txt | 3 +- src/Launcher/KernelLauncher.cxx | 21 ++++ src/Launcher/KernelLauncher.hxx | 1 + src/Launcher/KernelLauncher.i | 7 ++ src/Launcher/SALOME_LogManager.cxx | 162 +++++++++++++++++++++++++++++ src/Launcher/SALOME_LogManager.hxx | 101 ++++++++++++++++++ 12 files changed, 408 insertions(+), 17 deletions(-) create mode 100644 idl/SALOME_LogManager.idl create mode 100644 src/Launcher/SALOME_LogManager.cxx create mode 100644 src/Launcher/SALOME_LogManager.hxx diff --git a/idl/CMakeLists.txt b/idl/CMakeLists.txt index 43cd37e9a..ea026e5fd 100644 --- a/idl/CMakeLists.txt +++ b/idl/CMakeLists.txt @@ -55,6 +55,7 @@ SET(SalomeIDLKernel_IDLSOURCES SALOME_TestModuleCatalog.idl SALOME_CommonTypes.idl SALOME_ExternalServerLauncher.idl + SALOME_LogManager.idl SALOME_Embedded_NamingService.idl ${CMAKE_CURRENT_BINARY_DIR}/Calcium_Ports.idl ) diff --git a/idl/SALOME_LogManager.idl b/idl/SALOME_LogManager.idl new file mode 100644 index 000000000..9ef2fab96 --- /dev/null +++ b/idl/SALOME_LogManager.idl @@ -0,0 +1,63 @@ +// Copyright (C) 2024 CEA, EDF +// +// 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, or (at your option) any later version. +// +// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#ifndef __SALOME_LOGMANAGER_IDL__ +#define __SALOME_LOGMANAGER_IDL__ + +#include "SALOME_Exception.idl" +#include "SALOME_Comm.idl" + +module Engines +{ + interface ContainerScriptExecPerfLog + { + void assign(in SALOME::vectorOfByte value); + }; + + typedef sequence ListOfContainerScriptExecPerfLog; + + interface ContainerScriptPerfLog + { + string getCode(); + string getName(); + ContainerScriptExecPerfLog addExecutionSession(); + ListOfContainerScriptExecPerfLog listOfExecs(); + }; + + typedef sequence ListOfContainerScriptPerfLog; + + interface ContainerPerfLog + { + string getLogFile(); + string getContainerEntryInNS(); + ContainerScriptPerfLog addScript(in string name, in string code); + ListOfContainerScriptPerfLog listOfScripts(); + }; + + typedef sequence ListOfContainerPerfLog; + + interface LogManager + { + ContainerPerfLog declareContainer(in string contInNS, in string logfile); + ListOfContainerPerfLog listOfContainerLogs(); + SALOME::vectorOfByte getAllInfo(); + }; +}; + +#endif diff --git a/src/Container/Container_i.cxx b/src/Container/Container_i.cxx index b7e084ac7..d83a20529 100644 --- a/src/Container/Container_i.cxx +++ b/src/Container/Container_i.cxx @@ -204,9 +204,6 @@ Abstract_Engines_Container_i::Abstract_Engines_Container_i (CORBA::ORB_ptr orb, _remove_ref(); _containerName = SALOME_NamingService_Abstract::BuildContainerNameForNS(containerName, hostname.c_str()); - SCRUTE(_containerName); - _NS->Register(pCont, _containerName.c_str()); - MESSAGE("Engines_Container_i::Engines_Container_i : Container name " << _containerName); // Python: // import SALOME_Container @@ -248,7 +245,11 @@ Abstract_Engines_Container_i::Abstract_Engines_Container_i (CORBA::ORB_ptr orb, //PyThreadState_Swap(NULL); //PyEval_ReleaseLock(); } - + {// register to NS after python initialization to be sure that client invoke after py constructor execution + SCRUTE(_containerName); + _NS->Register(pCont, _containerName.c_str()); + MESSAGE("Engines_Container_i::Engines_Container_i : Container name " << _containerName); + } fileTransfer_i* aFileTransfer = new fileTransfer_i(); CORBA::Object_var obref=aFileTransfer->_this(); _fileTransfer = Engines::fileTransfer::_narrow(obref); @@ -323,7 +324,15 @@ char *Abstract_Engines_Container_i::locallogfilename() void Abstract_Engines_Container_i::locallogfilename(const char *name) { + AutoGIL gstate; _localfilename = name; + PyObject *result = PyObject_CallMethod(_pyCont,(char*)"setLogFileName","s",name,nullptr); + if (PyErr_Occurred()) + { + std::string error("can not set logfilename"); + PyErr_Print(); + THROW_SALOME_CORBA_EXCEPTION(error.c_str(),SALOME::INTERNAL_ERROR); + } } CORBA::Long Abstract_Engines_Container_i::monitoringtimeresms() diff --git a/src/Container/SALOME_Container.py b/src/Container/SALOME_Container.py index 61ed8bff4..1f4fa66e3 100644 --- a/src/Container/SALOME_Container.py +++ b/src/Container/SALOME_Container.py @@ -41,10 +41,11 @@ import Engines, Engines__POA from SALOME_NamingServicePy import * from SALOME_ComponentPy import * import SALOME_PyNode +import logging from SALOME_utilities import * from Utils_Identity import getShortHostName -from launchConfigureParser import verbose +from salome_utils import verbose from KernelBasis import VerbosityActivated from SALOME_ContainerHelper import ScriptInfo @@ -72,20 +73,32 @@ class SALOME_Container_i: self._orb = CORBA.ORB_init(argv, CORBA.ORB_ID) self._poa = self._orb.resolve_initial_references("RootPOA") self._containerName = containerName + self._logFileName = None self._dbg_info = [] self._timeIntervalInMs = dftTimeIntervalInMs + self._logm = None + self._log = None + # let verbose here because SALOME_Container_i is instanciated before the container process verbosity mecanism is initialized if verbose(): print("SALOME_Container.SALOME_Container_i : _containerName ",self._containerName) self._container = self._orb.string_to_object(containerIORStr) + @property + def logm(self): + import salome + if self._logm is None: + salome.salome_init() + self._logm = salome.logm + return self._logm + #------------------------------------------------------------------------- def import_component(self, componentName): MESSAGE( "SALOME_Container_i::import_component" ) ret="" try: - if verbose(): print("try import ",componentName) + logging.debug("try import ",componentName) importlib.import_module(componentName) - if verbose(): print("import ",componentName," successful") + logging.debug("import ",componentName," successful") except ImportError: #can't import python module componentName #try to find it in python path @@ -99,14 +112,13 @@ class SALOME_Container_i: except ImportError as ee: ret="ImplementationNotFound" except Exception: - if verbose():print("error when calling find_module") + print("error when calling find_module") ret="ImplementationNotFound" except Exception: ret="Component "+componentName+": Python implementation found but it can't be loaded\n" ret=ret+traceback.format_exc(10) - if verbose(): - traceback.print_exc() - print("import ",componentName," not possible") + traceback.print_exc() + print("import ",componentName," not possible") return ret #------------------------------------------------------------------------- @@ -150,7 +162,8 @@ class SALOME_Container_i: def create_pyscriptnode(self,nodeName,code): try: self._dbg_info.append( ScriptInfo(nodeName) ) - node=SALOME_PyNode.PyScriptNode_i(nodeName,code,self._poa,self) + logscript = self._log.addScript(nodeName,code) + node=SALOME_PyNode.PyScriptNode_i(nodeName,code,self._poa,self, logscript) node.setIDInContainer(len(self._dbg_info)-1) self.addInfoOnLevel1(node.getIDInContainer(),"code",code) id_o = self._poa.activate_object(node) @@ -185,5 +198,8 @@ class SALOME_Container_i: def monitoringtimeresms(self): return self._timeIntervalInMs + def setLogFileName(self, logFileName): + self._log = self.logm.declareContainer( self._containerName, logFileName ) + def SetMonitoringtimeresms(self , value): self._timeIntervalInMs = value diff --git a/src/Container/SALOME_PyNode.py b/src/Container/SALOME_PyNode.py index 0baa785c0..52f3d5d98 100644 --- a/src/Container/SALOME_PyNode.py +++ b/src/Container/SALOME_PyNode.py @@ -489,7 +489,7 @@ class SeqByteReceiver: class PyScriptNode_i (Engines__POA.PyScriptNode,Generic): """The implementation of the PyScriptNode CORBA IDL that executes a script""" - def __init__(self, nodeName,code,poa,my_container): + def __init__(self, nodeName,code,poa,my_container,logscript): """Initialize the node : compilation in the local context""" Generic.__init__(self,poa) self.nodeName=nodeName @@ -502,6 +502,8 @@ class PyScriptNode_i (Engines__POA.PyScriptNode,Generic): self.context[MY_CONTAINER_ENTRY_IN_GLBS] = self.my_container self._pos = None self._current_exec = 0 + self._log_script = logscript + self._current_execution_session = None sys.stdout.flush() ; sys.stderr.flush() # flush to correctly capture log per execution session #start of non remote callable methods @@ -586,6 +588,7 @@ class PyScriptNode_i (Engines__POA.PyScriptNode,Generic): """ Same than first part of self.execute to reduce memory peak.""" try: #self.my_container_py.addInfoOnLevel2(self.getIDInContainer(),self._current_exec,"tracePosStart",) + self._current_execution_session = self._log_script.addExecutionSession() data = None self.my_container_py.addTimeInfoOnLevel2(self.getIDInContainer(),self._current_exec,"startInputTime") if True: # to force call of SeqByteReceiver's destructor diff --git a/src/KERNEL_PY/__init__.py b/src/KERNEL_PY/__init__.py index ee39881d4..7c052ae65 100644 --- a/src/KERNEL_PY/__init__.py +++ b/src/KERNEL_PY/__init__.py @@ -161,7 +161,7 @@ if not flags: # sys.setdlopenflags(flags) # pass -orb, lcc, naming_service, cm, sg, esm, dsm, modulcat, rm = None,None,None,None,None,None,None,None,None +orb, lcc, naming_service, cm, sg, esm, dsm, logm, modulcat, rm = None,None,None,None,None,None,None,None,None,None myStudy, myStudyName = None,None salome_initial=True @@ -245,7 +245,7 @@ def salome_init_without_session(path=None, embedded=False, iorfakensfile=None): A Fake NamingService is created storing reference of all servants in the current process. """ salome_init_without_session_common(path,embedded) - global lcc,cm,dsm,esm,rm + global lcc,cm,dsm,esm,rm,logm import KernelLauncher cm = KernelLauncher.myContainerManager() type(cm).SetOverrideEnvForContainersSimple = ContainerManagerSetOverrideEnvForContainersSimple @@ -266,6 +266,8 @@ def salome_init_without_session(path=None, embedded=False, iorfakensfile=None): # esm inherits from SALOME_CPythonHelper singleton already initialized by GetDSMInstance # esm inherits also from SALOME_ResourcesManager creation/initialization (concerning SingleThreadPOA POA) when KernelLauncher.GetContainerManager() has been called esm = KernelLauncher.GetExternalServer() + # idem for logm + logm = KernelLauncher.myLogManager() # import KernelLogger naming_service.Register(KernelLogger.myLogger(),"/Logger") @@ -282,7 +284,7 @@ def salome_init_without_session_attached(path=None, embedded=False): lcc is pointing to the FakeNamingService above. """ salome_init_without_session_common(path,embedded) - global lcc,cm,dsm,esm,rm + global lcc,cm,dsm,esm,rm,logm import CORBA orb=CORBA.ORB_init(['']) import Engines @@ -306,6 +308,10 @@ def salome_init_without_session_attached(path=None, embedded=False): ESM_NAME_IN_NS = "/ExternalServers" esm = orb.string_to_object( nsAbroad.Resolve(ESM_NAME_IN_NS).decode() ) naming_service.Register(esm,ESM_NAME_IN_NS) + # + LOGM_NAME_IN_NS = "/LogManager" + logm = orb.string_to_object( nsAbroad.Resolve(LOGM_NAME_IN_NS).decode() ) + naming_service.Register(logm,LOGM_NAME_IN_NS) def salome_init_with_session(path=None, embedded=False): """ diff --git a/src/Launcher/CMakeLists.txt b/src/Launcher/CMakeLists.txt index 79d482119..0a11fa419 100644 --- a/src/Launcher/CMakeLists.txt +++ b/src/Launcher/CMakeLists.txt @@ -103,7 +103,7 @@ ADD_EXECUTABLE(TestLauncher TestLauncher.cxx) TARGET_LINK_LIBRARIES(TestLauncher ${TestLauncher_LIBS}) INSTALL(TARGETS TestLauncher DESTINATION ${SALOME_INSTALL_BINS}) -ADD_LIBRARY(SalomeLauncher BatchTest.cxx SALOME_Launcher.cxx SALOME_ExternalServerLauncher.cxx SALOME_LauncherException.cxx SALOME_ExternalServerHandler.cxx) +ADD_LIBRARY(SalomeLauncher BatchTest.cxx SALOME_Launcher.cxx SALOME_ExternalServerLauncher.cxx SALOME_LauncherException.cxx SALOME_ExternalServerHandler.cxx SALOME_LogManager.cxx) TARGET_LINK_LIBRARIES(SalomeLauncher Launcher ${COMMON_LIBS}) INSTALL(TARGETS SalomeLauncher EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_LIBS}) @@ -133,6 +133,7 @@ SET(COMMON_HEADERS_HXX Launcher_Job_SALOME.hxx Launcher_Job_YACSFile.hxx Launcher_Utils.hxx + SALOME_LogManager.hxx SALOME_Launcher.hxx SALOME_Launcher_Parser.hxx SALOME_Launcher_defs.hxx diff --git a/src/Launcher/KernelLauncher.cxx b/src/Launcher/KernelLauncher.cxx index 5ed46f83c..c04805d21 100644 --- a/src/Launcher/KernelLauncher.cxx +++ b/src/Launcher/KernelLauncher.cxx @@ -25,6 +25,7 @@ #include "SALOME_KernelServices.hxx" #include "SALOME_ResourcesManager.hxx" #include "SALOME_ExternalServerLauncher.hxx" +#include "SALOME_LogManager.hxx" #include "SALOME_CPythonHelper.hxx" #include @@ -82,3 +83,23 @@ std::string GetExternalServerInstance() CORBA::String_var ior = orb->object_to_string(esmCPtr); return std::string(ior.in()); } + +std::string GetLogManagerInstance() +{ + CORBA::ORB_ptr orb = KERNEL::getORB(); + CORBA::Object_var obj = orb->resolve_initial_references("RootPOA"); + PortableServer::POA_var root_poa = PortableServer::POA::_narrow(obj); + // + PortableServer::POA_var safePOA = root_poa->find_POA("SingleThreadPOA",true); + // + SALOME_CPythonHelper *cPyh(SALOME_CPythonHelper::Singleton()); + SALOME_Fake_NamingService *ns = new SALOME_Fake_NamingService; + SALOME_LogManager *esm(new SALOME_LogManager(cPyh,orb,safePOA,ns)); + esm->_remove_ref(); + // + CORBA::Object_var esmPtr = safePOA->servant_to_reference(esm); + Engines::LogManager_var esmCPtr = Engines::LogManager::_narrow(esmPtr); + // + CORBA::String_var ior = orb->object_to_string(esmCPtr); + return std::string(ior.in()); +} diff --git a/src/Launcher/KernelLauncher.hxx b/src/Launcher/KernelLauncher.hxx index d7f8c880e..30dadfcf8 100644 --- a/src/Launcher/KernelLauncher.hxx +++ b/src/Launcher/KernelLauncher.hxx @@ -25,3 +25,4 @@ std::string RetrieveInternalInstanceOfLocalCppResourcesManager(); std::string GetContainerManagerInstance(); std::string GetResourcesManagerInstance(); std::string GetExternalServerInstance(); +std::string GetLogManagerInstance(); \ No newline at end of file diff --git a/src/Launcher/KernelLauncher.i b/src/Launcher/KernelLauncher.i index 7a97e9a11..5348795b2 100644 --- a/src/Launcher/KernelLauncher.i +++ b/src/Launcher/KernelLauncher.i @@ -31,6 +31,7 @@ std::string GetContainerManagerInstance(); std::string GetResourcesManagerInstance(); std::string GetExternalServerInstance(); + std::string GetLogManagerInstance(); } %pythoncode %{ @@ -51,4 +52,10 @@ def GetExternalServer(): import CORBA orb=CORBA.ORB_init(['']) return orb.string_to_object(GetExternalServerInstance()) + +def myLogManager(): + import Engines + import CORBA + orb=CORBA.ORB_init(['']) + return orb.string_to_object(GetLogManagerInstance()) %} diff --git a/src/Launcher/SALOME_LogManager.cxx b/src/Launcher/SALOME_LogManager.cxx new file mode 100644 index 000000000..1aea17de8 --- /dev/null +++ b/src/Launcher/SALOME_LogManager.cxx @@ -0,0 +1,162 @@ +// Copyright (C) 2024 CEA, EDF +// +// 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, or (at your option) any later version. +// +// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// Author : Anthony GEAY (EDF R&D) + +#include "SALOME_LogManager.hxx" +#include "SALOME_Fake_NamingService.hxx" +#include "SALOME_ContainerManager.hxx" +#include "SALOME_CPythonHelper.hxx" + +#ifndef WIN32 +#include +#else +#include +#include +#endif + +#include +#include +#include +#include +#include + +const char SALOME_LogManager::NAME_IN_NS[]="/LogManager"; + +PortableServer::POA_var SALOME_ContainerScriptExecPerfLog::getPOA() +{ + return father()->getPOA(); +} + +void SALOME_ContainerScriptExecPerfLog::assign(const SALOME::vectorOfByte& value) +{ + +} + +///// + +PortableServer::POA_var SALOME_ContainerScriptPerfLog::getPOA() +{ + return father()->getPOA(); +} + +char *SALOME_ContainerScriptPerfLog::getCode() +{ + return CORBA::string_dup( _code.c_str() ); +} + +char *SALOME_ContainerScriptPerfLog::getName() +{ + return CORBA::string_dup( _name.c_str() ); +} + +Engines::ContainerScriptExecPerfLog_ptr SALOME_ContainerScriptPerfLog::addExecutionSession() +{ + SALOME_ContainerScriptExecPerfLog *execution = new SALOME_ContainerScriptExecPerfLog(this); + PortableServer::ObjectId_var id(getPOA()->activate_object(execution)); + execution->_remove_ref(); + CORBA::Object_var executionPtr(getPOA()->id_to_reference(id)); + Engines::ContainerScriptExecPerfLog_var executionPtr2 = Engines::ContainerScriptExecPerfLog::_narrow(executionPtr); + _sessions.push_back( executionPtr2 ); + return executionPtr2; +} + +Engines::ListOfContainerScriptExecPerfLog *SALOME_ContainerScriptPerfLog::listOfExecs() +{ + +} + +///// + +PortableServer::POA_var SALOME_ContainerPerfLog::getPOA() +{ + return father()->getPOA(); + } + +Engines::ContainerScriptPerfLog_ptr SALOME_ContainerPerfLog::addScript(const char *name, const char *code) +{ + SALOME_ContainerScriptPerfLog *script = new SALOME_ContainerScriptPerfLog(this,name,code); + PortableServer::ObjectId_var id(getPOA()->activate_object(script)); + script->_remove_ref(); + CORBA::Object_var scriptPtr(getPOA()->id_to_reference(id)); + Engines::ContainerScriptPerfLog_var scriptPtr2 = Engines::ContainerScriptPerfLog::_narrow(scriptPtr); + _scripts.push_back( scriptPtr2 ); + return scriptPtr2; +} + +Engines::ListOfContainerScriptPerfLog *SALOME_ContainerPerfLog::listOfScripts() +{ + Engines::ListOfContainerScriptPerfLog_var ret = new Engines::ListOfContainerScriptPerfLog; + std::size_t len( this->_scripts.size() ); + ret->length( len ); + for(std::size_t i = 0 ; i < len ; ++i) + ret[i] = this->_scripts[i]; + return ret._retn(); +} + +char *SALOME_ContainerPerfLog::getLogFile() +{ + return CORBA::string_dup( this->_log_file.c_str() ); +} + +char *SALOME_ContainerPerfLog::getContainerEntryInNS() +{ + return CORBA::string_dup( this->_name_in_ns.c_str() ); +} + +///// + +SALOME_LogManager::SALOME_LogManager(const SALOME_CPythonHelper *pyHelper, CORBA::ORB_ptr orb, PortableServer::POA_var poa,SALOME_NamingService_Abstract *ns):_pyHelper(pyHelper),_poa(poa) +{ + _NS.reset(ns); + PortableServer::ObjectId_var id(_poa->activate_object(this)); + CORBA::Object_var obj(_poa->id_to_reference(id)); + Engines::LogManager_var refPtr(Engines::LogManager::_narrow(obj)); + _NS->Register(refPtr,NAME_IN_NS); +} + +SALOME::vectorOfByte *SALOME_LogManager::getAllInfo() +{ + auto length = 2; + SALOME::vectorOfByte *ret = new SALOME::vectorOfByte; + ret->length(length); + for(auto i = 0 ; i < length ; ++i) + (*ret)[i] = 1; + return ret; +} + +Engines::ContainerPerfLog_ptr SALOME_LogManager::declareContainer(const char *contInNS, const char *logfile) +{ + SALOME_ContainerPerfLog *cont = new SALOME_ContainerPerfLog(this,contInNS,logfile); + PortableServer::ObjectId_var id(_poa->activate_object(cont)); + CORBA::Object_var contPtr(_poa->id_to_reference(id)); + cont->_remove_ref(); + Engines::ContainerPerfLog_var contPtr2 = Engines::ContainerPerfLog::_narrow(contPtr); + _containers.push_back( contPtr2 ); + return contPtr2; +} + +Engines::ListOfContainerPerfLog *SALOME_LogManager::listOfContainerLogs() +{ + Engines::ListOfContainerPerfLog_var ret = new Engines::ListOfContainerPerfLog; + std::size_t len( this->_containers.size() ); + ret->length( len ); + for(std::size_t i = 0 ; i < len ; ++i) + ret[i] = this->_containers[i]; + return ret._retn(); +} diff --git a/src/Launcher/SALOME_LogManager.hxx b/src/Launcher/SALOME_LogManager.hxx new file mode 100644 index 000000000..373924659 --- /dev/null +++ b/src/Launcher/SALOME_LogManager.hxx @@ -0,0 +1,101 @@ +// Copyright (C) 2024 CEA, EDF +// +// 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, or (at your option) any later version. +// +// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#pragma once + +#include "SALOME_Launcher_defs.hxx" + +#include + +#include CORBA_SERVER_HEADER(SALOME_LogManager) + +#include +#include +#include + +class SALOME_NamingService_Abstract; +class SALOME_CPythonHelper; +class SALOME_LogManager; +class SALOME_ContainerPerfLog; +class SALOME_ContainerScriptPerfLog; + +class SALOMELAUNCHER_EXPORT SALOME_ContainerScriptExecPerfLog : public POA_Engines::ContainerScriptExecPerfLog +{ +public: + SALOME_ContainerScriptExecPerfLog(SALOME_ContainerScriptPerfLog *father):_father(father) { } + SALOME_ContainerScriptPerfLog *father() const { return _father; } + PortableServer::POA_var getPOA(); + void assign(const SALOME::vectorOfByte& value) override; +private: + SALOME_ContainerScriptPerfLog *_father = nullptr; +}; + +class SALOMELAUNCHER_EXPORT SALOME_ContainerScriptPerfLog : public POA_Engines::ContainerScriptPerfLog +{ +public: + SALOME_ContainerScriptPerfLog(SALOME_ContainerPerfLog *father, const std::string& name, const std::string& code):_father(father),_name(name),_code(code) { } + SALOME_ContainerPerfLog *father() const { return _father; } + PortableServer::POA_var getPOA(); + Engines::ContainerScriptExecPerfLog_ptr addExecutionSession() override; + Engines::ListOfContainerScriptExecPerfLog *listOfExecs() override; + char *getCode() override; + char *getName() override; +private: + SALOME_ContainerPerfLog *_father = nullptr; + std::string _name; + std::string _code; + std::vector< Engines::ContainerScriptExecPerfLog_var > _sessions; +}; + +class SALOMELAUNCHER_EXPORT SALOME_ContainerPerfLog : public POA_Engines::ContainerPerfLog +{ +public: + SALOME_ContainerPerfLog(SALOME_LogManager *father, const std::string& nameInNS, const std::string& logFile):_father(father),_name_in_ns(nameInNS),_log_file(logFile) { } + SALOME_LogManager *father() const { return _father; } + PortableServer::POA_var getPOA(); + char *getLogFile() override; + char *getContainerEntryInNS() override; + Engines::ContainerScriptPerfLog_ptr addScript(const char *name, const char *code) override; + Engines::ListOfContainerScriptPerfLog *listOfScripts() override; +private: + SALOME_LogManager *_father = nullptr; + std::string _name_in_ns; + std::string _log_file; + std::vector< Engines::ContainerScriptPerfLog_var > _scripts; +}; + +class SALOMELAUNCHER_EXPORT SALOME_LogManager : public POA_Engines::LogManager +{ + public: + SALOME_LogManager(const SALOME_CPythonHelper *pyHelper, CORBA::ORB_ptr orb, PortableServer::POA_var poa, SALOME_NamingService_Abstract *ns = nullptr); + PortableServer::POA_var getPOA() { return _poa; } + virtual ~SALOME_LogManager() = default; + SALOME::vectorOfByte *getAllInfo() override; + Engines::ContainerPerfLog_ptr declareContainer(const char *contInNS, const char *logfile) override; + Engines::ListOfContainerPerfLog *listOfContainerLogs() override; + public: + const SALOME_CPythonHelper *getPyHelper() const { return _pyHelper; } + private: + const SALOME_CPythonHelper *_pyHelper = nullptr; + std::unique_ptr _NS; + PortableServer::POA_var _poa; + std::vector _containers; + public: + static const char NAME_IN_NS[]; +}; -- 2.39.2