module Engines
{
typedef sequence<octet> IORType;
+ typedef sequence<string> NSListOfStrings;
interface EmbeddedNamingService
{
void Destroy_Name(in string Path);
IORType Resolve(in string Path);
IORType ResolveFirst(in string Path);
+ NSListOfStrings keys();
};
};
type(logm).DumpInFile = LogManagerDumpInFile
type(logm).LaunchMonitoringDumpFile = LogManagerLaunchMonitoringDumpFile
type(logm).GetLatestMonitoringDumpFile = LogManagerGetLatestMonitoringDumpFile
+ type(logm).DumpIORInFile = LogManagerDumpIORInFile
#
import KernelLogger
naming_service.Register(KernelLogger.myLogger(),"/Logger")
pid = KernelBasis.LaunchMonitoring( tempPyFile )
return SALOME_PyNode.MonitoringInfo(pyFileName,None,pid)
+def LogManagerDumpIORInFile(self, iorFileName):
+ global logm
+ with open(iorFileName,"w") as f:
+ f.write( orb.object_to_string( logm ) )
+
def LogManagerLoadFromFile(fileName):
from SALOME_ContainerHelper import unserializeLogManager
with open(fileName,"rb") as f:
#include <sstream>
static Engines::LogManager_var LogManagerInstanceSingleton;
+static SALOME::ExternalServerLauncher_var ExternalServerLauncherSingleton;
std::string RetrieveInternalInstanceOfLocalCppResourcesManager()
{
std::string GetExternalServerInstance()
{
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_ExternalServerLauncher *esm(new SALOME_ExternalServerLauncher(cPyh,orb,safePOA,ns));
- esm->_remove_ref();
- //
- CORBA::Object_var esmPtr = safePOA->servant_to_reference(esm);
- SALOME::ExternalServerLauncher_var esmCPtr = SALOME::ExternalServerLauncher::_narrow(esmPtr);
+ if( CORBA::is_nil(ExternalServerLauncherSingleton) )
+ {
+ 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_ExternalServerLauncher *esm(new SALOME_ExternalServerLauncher(cPyh,orb,safePOA,ns));
+ esm->_remove_ref();
+ //
+ CORBA::Object_var esmPtr = safePOA->servant_to_reference(esm);
+ ExternalServerLauncherSingleton = SALOME::ExternalServerLauncher::_narrow(esmPtr);
+ }
//
- CORBA::String_var ior = orb->object_to_string(esmCPtr);
+ CORBA::String_var ior = orb->object_to_string(ExternalServerLauncherSingleton);
return std::string(ior.in());
}
return ret, fileNamesProxyOut
class testPerfLogManager1(unittest.TestCase):
- def testPerfLogManager0(self):
+ def tessPerfLogManager0(self):
"""
[EDF29150] : This test checks measure performance methods
"""
monitoringFile = os.path.join( str( tmpdirnameMonitoring ), "zeHtop.pckl" )
monitoringFileTwo = os.path.join( str( tmpdirnameMonitoring ), "zeHtopTwo.pckl" )
iorLogm = os.path.join( str( tmpdirnameMonitoring ), "logm.ior" )
+ with open(iorLogm,"w") as f:
+ f.write( salome.orb.object_to_string(salome.logm) )
logging.debug("Monitoring file : {}".format(monitoringFile))
with tempfile.TemporaryDirectory() as tmpdirname:
with salome.LogManagerLaunchMonitoringFileCtxMgr(250,monitoringFile) as monitoringParams:
logging.debug( logManagerInst0[0][1][0].get()._input_hdd_mem._data[1]._data[0]._data[0]._hdd_mem ) # important
logManagerInst = salome.logm.Fetch(True)
logManagerInst2 = salome.logm.Fetch(True)
+ logging.debug( salome.LogManagerLoadFromIORFile( iorLogm )[0][1][0].get() )
salome.logm.putStructInFileAtomic(False,monitoringFileTwo)
logging.debug( salome.LogManagerLoadFromFile(monitoringFileTwo)[0][1][0].get() )
logging.debug( logManagerInst[0][1][0].get()._input_hdd_mem._data[1]._data[0]._data[0]._hdd_mem ) # important
self.assertFalse( os.path.exists(pyFileContainingCodeOfMonitoring) )
cont.Shutdown()
+ def testEasyNamingService(self):
+ """
+ [EDF29150] : This test checks measure performance methods
+ """
+ hostname = "localhost"
+ cp = pylauncher.GetRequestForGiveContainer(hostname,"container_test_two")
+ PROXY_THRES = "1"
+ with tempfile.TemporaryDirectory() as tmpdirname:
+ ior_ns_file = os.path.join(tmpdirname,"ns.ior")
+ val_for_big_obj = str( tmpdirname )
+ salome.cm.SetOverrideEnvForContainersSimple(env = [("SALOME_FILE_BIG_OBJ_DIR",val_for_big_obj),("SALOME_BIG_OBJ_ON_DISK_THRES",PROXY_THRES)])
+ salome.cm.SetDeltaTimeBetweenCPUMemMeasureInMilliSecond( 250 )
+ salome.naming_service.DumpIORInFile( ior_ns_file )
+ cont = salome.cm.GiveContainer(cp)
+ script_st = """
+from SALOME_Embedded_NamingService_ClientPy import SALOME_Embedded_NamingService_ClientPy
+ior_ns_file = "{ior_ns_file}"
+ns = SALOME_Embedded_NamingService_ClientPy.BuildFromIORFile( ior_ns_file )
+ret = ns.repr()
+""".format(**locals())
+ cont = salome.cm.GiveContainer(cp)
+ pyscript2 = cont.createPyScriptNode("testScript3",script_st)
+ retCoarse = pickle.loads( pyscript2.execute( ["ret"], pickle.dumps( ([],{} ) ) ) )
+ ret = retCoarse[0]
+ self.assertTrue( isinstance(ret,list) and isinstance(ret[0],str) )
+ cont.Shutdown()
+ pass
+
if __name__ == '__main__':
from salome_utils import positionVerbosityOfLoggerRegardingState,setVerboseLevel,setVerbose
salome.standalone()
orb=CORBA.ORB_init([''])
return orb.string_to_object(ret)
NamingService.RefOfNS = classmethod(NamingService_RefOfNS)
+def NamingService_DumpIORInFile(cls,iorFileName):
+ with open( iorFileName, "w" ) as f:
+ f.write( cls.IOROfNS() )
+NamingService.DumpIORInFile = classmethod(NamingService_DumpIORInFile)
def NamingService_KillContainersInFile(cls,logFileName):
import Engines
import CORBA
CORBA::Object_var obj = ns.ResolveFirst(Path);
return ObjectToIOR(obj);
}
+
+Engines::NSListOfStrings *SALOME_Embedded_NamingService::keys()
+{
+ SALOME_Fake_NamingService ns;
+ std::vector<std::string> ks = ns.repr();
+ Engines::NSListOfStrings *ret = new Engines::NSListOfStrings;
+ std::size_t sz(ks.size());
+ ret->length( sz );
+ for(std::size_t i = 0 ; i < sz ; ++i)
+ (*ret)[i] = CORBA::string_dup( ks[i].c_str() );
+ return ret;
+}
void Destroy_Name(const char *Path) override;
Engines::IORType *Resolve(const char *Path) override;
Engines::IORType *ResolveFirst(const char *Path) override;
+ Engines::NSListOfStrings *keys() override;
};
#-------------------------------------------------------------------------
def __init__(self, serv):
- self._orb=CORBA.ORB_init([''], CORBA.ORB_ID)
+ self._orb = CORBA.ORB_init([''], CORBA.ORB_ID)
self._obj = serv
#-------------------------------------------------------------------------
def Resolve(self, Path):
ret = self._obj.Resolve(Path)
return self._orb.string_to_object(ret.decode())
+
+ def keys(self):
+ return self._obj.keys()
+
+ def repr(self):
+ return self.keys()
+
+def SALOME_Embedded_NamingService_ClientPy_BuildFromIORFile(cls, iorNSFile):
+ import Engines
+ orb = CORBA.ORB_init([''], CORBA.ORB_ID)
+ with open(iorNSFile,"r") as f:
+ ior = f.read()
+ serv = orb.string_to_object( ior )
+ return SALOME_Embedded_NamingService_ClientPy(serv)
+
+SALOME_Embedded_NamingService_ClientPy.BuildFromIORFile = classmethod(SALOME_Embedded_NamingService_ClientPy_BuildFromIORFile)