]> SALOME platform Git repositories - modules/kernel.git/commitdiff
Salome HOME
- Fix warning for SALOME_Registry
authorribes <ribes>
Mon, 24 Sep 2007 13:52:40 +0000 (13:52 +0000)
committerribes <ribes>
Mon, 24 Sep 2007 13:52:40 +0000 (13:52 +0000)
- Parallel_Salome_file ok, needs some more tests

idl/SALOME_Component.xml
src/ParallelContainer/Parallel_Salome_file_i.cxx
src/ParallelContainer/Parallel_Salome_file_i.hxx
src/ParallelContainer/SALOME_ParallelComponent_i.cxx
src/ParallelContainer/SALOME_ParallelContainerNodeDummy.cxx
src/Registry/SALOME_Registry.hxx

index 189f18638059592a9592a9713a782f335ef57a8b..850f18a07ea2b2dbecd4023db9911a4d7ee3c3b8 100644 (file)
    <Name>setInputServiceSalome_file</Name>
    <Type>distributed</Type>
   </Method>
+  <Method>
+   <Name>setOutputServiceSalome_file</Name>
+   <Type>distributed</Type>
+  </Method>
  </Interface>
  <Interface>
   <Name>Parallel_Component</Name>
  </Interface>
  <Interface>
   <Name>Salome_file</Name>
-  <Method>
-   <Name>recvFiles</Name>
-   <Type>distributed</Type>
-  </Method>
  </Interface>
  <Interface>
   <Name>Parallel_Salome_file</Name>
index 440a0b455ab95738a6b906b7b9b5b5754e799140..19cecbb251be584e1a0f343c19de392490a20ae2 100644 (file)
@@ -26,7 +26,7 @@
 #include "Parallel_Salome_file_i.hxx"
 #include "utilities.h"
 
-Parallel_Salome_file_i::Parallel_Salome_file_i(CORBA::ORB_ptr orb, char * ior) :
+Parallel_Salome_file_i::Parallel_Salome_file_i(CORBA::ORB_ptr orb, const char * ior) :
   InterfaceParallel_impl(orb,ior), 
   Engines::Salome_file_serv(orb,ior),
   Engines::fileTransfer_serv(orb,ior),
@@ -120,7 +120,7 @@ Parallel_Salome_file_i::recvFiles() {
   int total = getTotalNode();
   for (int i =0; i<total; i++) {
     try {
-      parallel_file->recvFiles_node(i);
+     parallel_file->recvFiles_node(i);
     }
     catch (SALOME::SALOME_Exception & ex) {
       files_not_ok = files_not_ok + std::string(ex.details.text.in());
@@ -200,6 +200,7 @@ Parallel_Salome_file_i::getParallelDistributedFile(std::string file_name) {
   int fileId;
   FILE* fp;
   std::string comp_file_name(_fileManaged[file_name].path.in());
+  comp_file_name.append("/");
   comp_file_name.append(_fileManaged[file_name].file_name.in());
 
   // Test if the process can write on disk
@@ -320,6 +321,24 @@ Parallel_Salome_file_i::getFileNode(const char* file_name) {
   
   // Test if this file is managed
   std::string fname(file_name);
+  if (fname == "") {
+    // We enter in the simple case where the user
+    // has not used setDistributedSourceFile.
+    // In this case we try to see if the Salome_file
+    if (_fileManaged.size() == 1) 
+    {
+      // only one file managed 
+      _t_fileManaged::iterator it = _fileManaged.begin();
+      fname = it->first;
+    }
+    else
+    {
+      SALOME::ExceptionStruct es;
+      es.type = SALOME::INTERNAL_ERROR;
+      es.text = "Error : there is more than one file that is managed";
+      throw SALOME::SALOME_Exception(es);
+    }
+  }
   _t_fileManaged::iterator it = _fileManaged.find(fname);
   if (it == _fileManaged.end()) 
   {
index f2847b82481ac54a1e03c2cc44eb03ec12fd2751..c3814a5c4124861413678c3e8fa736b22ea0aec0 100644 (file)
@@ -39,7 +39,7 @@ class CONTAINER_EXPORT Parallel_Salome_file_i:
   public virtual Engines::Parallel_Salome_file_serv
 {
   public:
-    Parallel_Salome_file_i(CORBA::ORB_ptr orb, char * ior);
+    Parallel_Salome_file_i(CORBA::ORB_ptr orb, const char * ior);
     virtual ~Parallel_Salome_file_i();
 
     virtual void setFileNode(const char* file_name, CORBA::Long node);
index 3a6002cb7f9ef87dcca4a5178b937c044141e00f..245a6f791b2b4b054aa83c248a980868ef339901 100644 (file)
@@ -771,10 +771,10 @@ string Engines_Parallel_Component_i::GetDynLibraryName(const char *componentName
 //=============================================================================
 
 Engines::TMPFile* Engines_Parallel_Component_i::DumpPython(CORBA::Object_ptr theStudy, 
-                                                 CORBA::Boolean isPublished, 
-                                                 CORBA::Boolean& isValidScript)
+                                                          CORBA::Boolean isPublished, 
+                                                          CORBA::Boolean& isValidScript)
 {
-  char* aScript = "def RebuildData(theStudy): pass";
+  const char* aScript = "def RebuildData(theStudy): pass";
   char* aBuffer = new char[strlen(aScript)+1];
   strcpy(aBuffer, aScript);
   CORBA::Octet* anOctetBuf =  (CORBA::Octet*)aBuffer;
@@ -784,38 +784,10 @@ Engines::TMPFile* Engines_Parallel_Component_i::DumpPython(CORBA::Object_ptr the
   return aStreamFile._retn(); 
 }
 
-// This is a parallel method
-Engines::Salome_file_ptr 
-Engines_Parallel_Component_i::getInputServiceSalome_file(const char* service_name, 
-                                               const char* Salome_file_name) 
-{
-  // Try to find the service, if it doesn't exist, we throw an exception.
-  _Proxy_Service_file_map_it = _Proxy_Input_Service_file_map.find(service_name);
-  if (_Proxy_Service_file_map_it ==  _Proxy_Input_Service_file_map.end()) {
-    SALOME::ExceptionStruct es;
-    es.type = SALOME::INTERNAL_ERROR;
-    es.text = "service doesn't have salome files";
-    throw SALOME::SALOME_Exception(es);
-  }
-  _t_Proxy_Salome_file_map * _map = _Proxy_Input_Service_file_map[service_name];
-
-  // Try to find the Salome_file ...
-  _Proxy_Salome_file_map_it = _map->find(Salome_file_name);
-  if (_Proxy_Salome_file_map_it ==  _map->end()) {
-    SALOME::ExceptionStruct es;
-    es.type = SALOME::INTERNAL_ERROR;
-    es.text = "service doesn't have this Salome_file";
-    throw SALOME::SALOME_Exception(es);
-  }
-
-  // Client get the proxy object
-  Engines::Parallel_Salome_file_proxy_impl * Sfile = (*_map)[Salome_file_name];
-  return Sfile->_this();
-}
 
 Engines::Salome_file_ptr 
 Engines_Parallel_Component_i::setInputFileToService(const char* service_name, 
-                                          const char* Salome_file_name) 
+                                                   const char* Salome_file_name) 
 {
   // Try to find the service, if it doesn't exist, we add it.
   _Service_file_map_it = _Input_Service_file_map.find(service_name);
@@ -828,7 +800,7 @@ Engines_Parallel_Component_i::setInputFileToService(const char* service_name,
   _t_Salome_file_map * _map = _Input_Service_file_map[service_name];
   _t_Proxy_Salome_file_map * _proxy_map = _Proxy_Input_Service_file_map[service_name];
   
-  char * proxy_ior;
+  std::string proxy_ior;
 
   // Try to find the Salome_file ...
   _Salome_file_map_it = _map->find(Salome_file_name);
@@ -855,9 +827,9 @@ Engines_Parallel_Component_i::setInputFileToService(const char* service_name,
       proxy->setTopo(serveur_topo);
 
       // We initialize the object with the context of the Parallel component
-      PaCO_operation * compo_global_ptr =  this->getContext("global_paco_context");
-      compo_global_ptr->init_context(proxy_global_ptr);
-
+      PaCO_operation * compo_global_ptr =  getContext("global_paco_context");
+      //compo_global_ptr->init_context(proxy_global_ptr);
+      proxy_global_ptr->init_context(compo_global_ptr);
       // We register the CORBA objet into the POA
       CORBA::Object_ptr proxy_ref = proxy->_this();
 
@@ -880,12 +852,13 @@ Engines_Parallel_Component_i::setInputFileToService(const char* service_name,
     for (int i = 0; i < getTotalNode(); i++) {
       if (i ==  getMyRank()) {
        Parallel_Salome_file_i * servant = 
-         new Parallel_Salome_file_i(CORBA::ORB::_duplicate(_orb), proxy_ior);
+         new Parallel_Salome_file_i(CORBA::ORB::_duplicate(_orb), proxy_ior.c_str());
        PaCO_operation * servant_global_ptr = servant->getContext("global_paco_context");
        
        // We initialize the object with the context of the Parallel component
        PaCO_operation * compo_global_ptr =  this->getContext("global_paco_context");
-       compo_global_ptr->init_context(servant_global_ptr);
+//     compo_global_ptr->init_context(servant_global_ptr);
+       servant_global_ptr->init_context(compo_global_ptr);
        
        // We register the CORBA objet into the POA
        servant->POA_PaCO::InterfaceParallel::_this();
@@ -900,6 +873,7 @@ Engines_Parallel_Component_i::setInputFileToService(const char* service_name,
       PaCO_operation * compo_global_ptr =  this->getContext("global_paco_context");
       compo_global_ptr->my_com->paco_barrier();
     }
+
     // Parallel_Salome_file is created and deployed
     delete _proxy;
     _proxy = NULL;
@@ -914,102 +888,203 @@ Engines_Parallel_Component_i::setInputFileToService(const char* service_name,
     throw SALOME::SALOME_Exception(es);
   }
 
-  CORBA::Object_ptr obj = _orb->string_to_object(proxy_ior);
+  CORBA::Object_ptr obj = _orb->string_to_object(proxy_ior.c_str());
   return Engines::Salome_file::_narrow(obj);
 }
 
-void 
-Engines_Parallel_Component_i::checkInputServiceFiles(const char* service_name) 
+Engines::Salome_file_ptr 
+Engines_Parallel_Component_i::setOutputFileToService(const char* service_name, 
+                                                    const char* Salome_file_name) 
 {
-  // Try to find the service, if it doesn't exist, nothing to do.
-  _Proxy_Service_file_map_it = _Proxy_Input_Service_file_map.find(service_name);
-  if (_Proxy_Service_file_map_it !=  _Proxy_Input_Service_file_map.end()) {
-    _t_Proxy_Salome_file_map * _proxy_map = _Proxy_Input_Service_file_map[service_name];
-    _t_Proxy_Salome_file_map::iterator begin = _proxy_map->begin();
-    _t_Proxy_Salome_file_map::iterator end = _proxy_map->end();
+  // Try to find the service, if it doesn't exist, we add it.
+  _Service_file_map_it = _Output_Service_file_map.find(service_name);
+  if (_Service_file_map_it ==  _Output_Service_file_map.end()) {
+    _t_Salome_file_map * _map = new _t_Salome_file_map();
+    _Output_Service_file_map[service_name] = _map;
+    _t_Proxy_Salome_file_map * _proxy_map = new _t_Proxy_Salome_file_map();
+    _Proxy_Output_Service_file_map[service_name] = _proxy_map;
+  }
+  _t_Salome_file_map * _map = _Output_Service_file_map[service_name];
+  _t_Proxy_Salome_file_map * _proxy_map = _Proxy_Output_Service_file_map[service_name];
+  
+  std::string proxy_ior;
 
-    for(;begin!=end;begin++) {
-      Engines::Parallel_Salome_file_proxy_impl * file = begin->second;
-      file->recvFiles();
+  // Try to find the Salome_file ...
+  _Salome_file_map_it = _map->find(Salome_file_name);
+  if (_Salome_file_map_it ==  _map->end()) {
+
+    // We create a new PaCO++ object.
+    // He has the same configuration than
+    // his component
+
+    pthread_mutex_lock(deploy_mutex);
+    // Firstly, we have to create the proxy object
+    // of the Salome_file and transmit his
+    // reference to the other nodes.
+    if (getMyRank() == 0) {
+      Engines::Parallel_Salome_file_proxy_impl * proxy = 
+       new Engines::Parallel_Salome_file_proxy_impl(CORBA::ORB::_duplicate(_orb));
+      PaCO_operation * proxy_global_ptr =  proxy->getContext("global_paco_context");
+      proxy_global_ptr->setTypeClient(true);
+      PaCO::PacoTopology_t client_topo;
+      client_topo.total = 1;
+      proxy_global_ptr->setClientTopo(client_topo);
+      PaCO::PacoTopology_t serveur_topo;
+      serveur_topo.total = getTotalNode();
+      proxy->setTopo(serveur_topo);
+
+      // We initialize the object with the context of the Parallel component
+      PaCO_operation * compo_global_ptr =  getContext("global_paco_context");
+      //compo_global_ptr->init_context(proxy_global_ptr);
+      proxy_global_ptr->init_context(compo_global_ptr);
+      // We register the CORBA objet into the POA
+      CORBA::Object_ptr proxy_ref = proxy->_this();
+
+      // We send the reference to all the nodes...
+      CORBA::Object_ptr comp_proxy = _orb->string_to_object(_ior.c_str());
+      Engines::Parallel_Component_var component_proxy = Engines::Parallel_Component::_narrow(comp_proxy);
+      component_proxy->send_parallel_proxy_object(proxy_ref);
+
+      // Adding proxy into the map
+      (*_proxy_map)[Salome_file_name] = proxy;
     }
+    else {
+      this->wait_parallel_object_proxy();
+    }
+
+    proxy_ior = this->get_parallel_proxy_object();
+
+    // We register each node of the parallel Salome_file object
+    // into the proxy.
+    for (int i = 0; i < getTotalNode(); i++) {
+      if (i ==  getMyRank()) {
+       Parallel_Salome_file_i * servant = 
+         new Parallel_Salome_file_i(CORBA::ORB::_duplicate(_orb), proxy_ior.c_str());
+       PaCO_operation * servant_global_ptr = servant->getContext("global_paco_context");
+       
+       // We initialize the object with the context of the Parallel component
+       PaCO_operation * compo_global_ptr =  this->getContext("global_paco_context");
+//     compo_global_ptr->init_context(servant_global_ptr);
+       servant_global_ptr->init_context(compo_global_ptr);
+       
+       // We register the CORBA objet into the POA
+       servant->POA_PaCO::InterfaceParallel::_this();
+
+       // Register the servant
+       servant->deploy(getMyRank());
+
+       // Adding servant to the map
+       (*_map)[Salome_file_name] = servant;
+      }
+
+      PaCO_operation * compo_global_ptr =  this->getContext("global_paco_context");
+      compo_global_ptr->my_com->paco_barrier();
+    }
+
+    // Parallel_Salome_file is created and deployed
+    delete _proxy;
+    _proxy = NULL;
+    pthread_mutex_unlock(deploy_mutex);
   }
+  else {
+    // Salome_file_name already added into the service
+    // throw Exception
+    SALOME::ExceptionStruct es;
+    es.type = SALOME::INTERNAL_ERROR;
+    es.text = "Salome_file_name already added";
+    throw SALOME::SALOME_Exception(es);
+  }
+
+  CORBA::Object_ptr obj = _orb->string_to_object(proxy_ior.c_str());
+  return Engines::Salome_file::_narrow(obj);
 }
 
 Engines::Salome_file_ptr 
-Engines_Parallel_Component_i::getOutputServiceSalome_file(const char* service_name, 
+Engines_Parallel_Component_i::getInputServiceSalome_file(const char* service_name, 
                                                const char* Salome_file_name) 
 {
   // Try to find the service, if it doesn't exist, we throw an exception.
-  _Service_file_map_it = _Output_Service_file_map.find(service_name);
-  if (_Service_file_map_it ==  _Output_Service_file_map.end()) {
+  _Proxy_Service_file_map_it = _Proxy_Input_Service_file_map.find(service_name);
+  if (_Proxy_Service_file_map_it ==  _Proxy_Input_Service_file_map.end()) {
     SALOME::ExceptionStruct es;
     es.type = SALOME::INTERNAL_ERROR;
     es.text = "service doesn't have salome files";
     throw SALOME::SALOME_Exception(es);
   }
-  _t_Salome_file_map * _map = _Output_Service_file_map[service_name];
+  _t_Proxy_Salome_file_map * _map = _Proxy_Input_Service_file_map[service_name];
 
   // Try to find the Salome_file ...
-  _Salome_file_map_it = _map->find(Salome_file_name);
-  if (_Salome_file_map_it ==  _map->end()) {
+  _Proxy_Salome_file_map_it = _map->find(Salome_file_name);
+  if (_Proxy_Salome_file_map_it ==  _map->end()) {
     SALOME::ExceptionStruct es;
     es.type = SALOME::INTERNAL_ERROR;
     es.text = "service doesn't have this Salome_file";
     throw SALOME::SALOME_Exception(es);
   }
-  Salome_file_i * Sfile = (*_map)[Salome_file_name];
 
+  // Client get the proxy object
+  Engines::Parallel_Salome_file_proxy_impl * Sfile = (*_map)[Salome_file_name];
   return Sfile->_this();
 }
 
 Engines::Salome_file_ptr 
-Engines_Parallel_Component_i::setOutputFileToService(const char* service_name, 
-                                          const char* Salome_file_name) 
+Engines_Parallel_Component_i::getOutputServiceSalome_file(const char* service_name, 
+                                               const char* Salome_file_name) 
 {
-  // Try to find the service, if it doesn't exist, we add it.
-  _Service_file_map_it = _Output_Service_file_map.find(service_name);
-  if (_Service_file_map_it ==  _Output_Service_file_map.end()) {
-    _t_Salome_file_map * _map = new _t_Salome_file_map();
-    _Output_Service_file_map[service_name] = _map;
+  // Try to find the service, if it doesn't exist, we throw an exception.
+  _Proxy_Service_file_map_it = _Proxy_Output_Service_file_map.find(service_name);
+  if (_Proxy_Service_file_map_it ==  _Proxy_Output_Service_file_map.end()) {
+    SALOME::ExceptionStruct es;
+    es.type = SALOME::INTERNAL_ERROR;
+    es.text = "service doesn't have salome files";
+    throw SALOME::SALOME_Exception(es);
   }
-  _t_Salome_file_map * _map = _Output_Service_file_map[service_name];
-  
+  _t_Proxy_Salome_file_map * _map = _Proxy_Output_Service_file_map[service_name];
+
   // Try to find the Salome_file ...
-  _Salome_file_map_it = _map->find(Salome_file_name);
-  if (_Salome_file_map_it ==  _map->end()) {
-//    Salome_file_i * Sfile = new Salome_file_i();
-//    (*_map)[Salome_file_name] = Sfile;
-//
-//
-//
-//   TODO
-//
-  }
-  else {
-    // Salome_file_name already added into the service
-    // throw Exception
+  _Proxy_Salome_file_map_it = _map->find(Salome_file_name);
+  if (_Proxy_Salome_file_map_it ==  _map->end()) {
     SALOME::ExceptionStruct es;
     es.type = SALOME::INTERNAL_ERROR;
-    es.text = "Salome_file_name already added";
+    es.text = "service doesn't have this Salome_file";
     throw SALOME::SALOME_Exception(es);
   }
-  Salome_file_i * Sfile = (*_map)[Salome_file_name];
 
+  // Client get the proxy object
+  Engines::Parallel_Salome_file_proxy_impl * Sfile = (*_map)[Salome_file_name];
   return Sfile->_this();
 }
 
+
+void 
+Engines_Parallel_Component_i::checkInputServiceFiles(const char* service_name) 
+{
+  // Try to find the service, if it doesn't exist, nothing to do.
+  _Proxy_Service_file_map_it = _Proxy_Input_Service_file_map.find(service_name);
+  if (_Proxy_Service_file_map_it !=  _Proxy_Input_Service_file_map.end()) {
+    _t_Proxy_Salome_file_map * _proxy_map = _Proxy_Input_Service_file_map[service_name];
+    _t_Proxy_Salome_file_map::iterator begin = _proxy_map->begin();
+    _t_Proxy_Salome_file_map::iterator end = _proxy_map->end();
+
+    for(;begin!=end;begin++) {
+      Engines::Parallel_Salome_file_proxy_impl * file = begin->second;
+      file->recvFiles();
+    }
+  }
+}
+
 void 
 Engines_Parallel_Component_i::checkOutputServiceFiles(const char* service_name) 
 {
   // Try to find the service, if it doesn't exist, nothing to do.
-  _Service_file_map_it = _Output_Service_file_map.find(service_name);
-  if (_Service_file_map_it !=  _Output_Service_file_map.end()) {
-    _t_Salome_file_map * _map = _Output_Service_file_map[service_name];
-    _t_Salome_file_map::iterator begin = _map->begin();
-    _t_Salome_file_map::iterator end = _map->end();
+  _Proxy_Service_file_map_it = _Proxy_Output_Service_file_map.find(service_name);
+  if (_Proxy_Service_file_map_it !=  _Proxy_Output_Service_file_map.end()) {
+    _t_Proxy_Salome_file_map * _map = _Proxy_Output_Service_file_map[service_name];
+    _t_Proxy_Salome_file_map::iterator begin = _map->begin();
+    _t_Proxy_Salome_file_map::iterator end = _map->end();
 
     for(;begin!=end;begin++) {
-      Salome_file_i * file = begin->second;
+      Engines::Parallel_Salome_file_proxy_impl * file = begin->second;
       file->recvFiles();
     }
   }
index f08a384c75ae2c44428838d43b49aa169caa5dfe..4f5d0d2749de547ab403ba68f7ce09dc5dd357aa 100644 (file)
@@ -63,13 +63,63 @@ void handler(int t) {
 }
 #endif
 
+typedef void (*sighandler_t)(int);
+sighandler_t setsig(int sig, sighandler_t handler)
+{
+  struct sigaction context, ocontext;
+  context.sa_handler = handler;
+  sigemptyset(&context.sa_mask);
+  context.sa_flags = 0;
+  if (sigaction(sig, &context, &ocontext) == -1)
+    return SIG_ERR;
+  return ocontext.sa_handler;
+}
+
+void AttachDebugger()
+{
+  if(getenv ("DEBUGGER"))
+    {
+      std::stringstream exec;
+      exec << "$DEBUGGER SALOME_ParallelContainerNodeDummy " << getpid() << "&";
+      std::cerr << exec.str() << std::endl;
+      system(exec.str().c_str());
+      while(1);
+    }
+}
+
+void Handler(int theSigId)
+{
+  std::cerr << "SIGSEGV: "  << std::endl;
+  AttachDebugger();
+  //to exit or not to exit
+  exit(1);
+}
+
+void terminateHandler(void)
+{
+  std::cerr << "Terminate: not managed exception !"  << std::endl;
+  AttachDebugger();
+}
+
+void unexpectedHandler(void)
+{
+  std::cerr << "Unexpected: unexpected exception !"  << std::endl;
+  AttachDebugger();
+}
+
 int main(int argc, char* argv[])
 {
        INFOS("Launching a parallel container node");
 
 #ifdef _DEBUG_
-       signal(SIGSEGV, handler);
+//     signal(SIGSEGV, handler);
 #endif
+  if(getenv ("DEBUGGER"))
+    {
+      setsig(SIGSEGV,&Handler);
+      set_terminate(&terminateHandler);
+      set_unexpected(&unexpectedHandler);
+    }
 
        // Initialise the ORB.
        ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance();
index 899bc55861dcbd189b8eee62851d670885a84068..4ca01a2c74c87c2c064b5b18556ffd0c4a9da0f7 100755 (executable)
@@ -44,4 +44,5 @@
  #define REGISTRY_EXPORT
 #endif
 
-#endif
\ No newline at end of file
+#endif
+