Ignore:
Timestamp:
01/11/17 15:14:22 (7 years ago)
Author:
mhnguyen
Message:

Merging working version of coupler

+) Add some changes of domain and axis: Retransfer the atttributes in a generic ways for each level of client (or server)
+) Remove some spoiled files from the previous commits

Test
+) No test

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XIOS/dev/dev_olga/src/node/context.cpp

    r1021 r1025  
    2929      , idServer_(), client(0), server(0) 
    3030//        , clientPrimServer(0), serverPrimServer(0) 
     31      , allProcessed(false) 
    3132   { /* Ne rien faire de plus */ } 
    3233 
     
    3738      , idServer_(), client(0), server(0) 
    3839//        , clientPrimServer(0), serverPrimServer(0) 
     40      , allProcessed(false) 
    3941   { /* Ne rien faire de plus */ } 
    4042 
     
    475477   } 
    476478 
     479 
     480   void CContext::postProcessingGlobalAttributes() 
     481   { 
     482     if (allProcessed) return; 
     483      
     484     if (hasClient) 
     485     { 
     486       // After xml is parsed, there are some more works with post processing 
     487       postProcessing(); 
     488     } 
     489 
     490     setClientServerBuffer(); 
     491 
     492     if (hasClient) 
     493     { 
     494      // Send all attributes of current context to server 
     495      this->sendAllAttributesToServer(); 
     496 
     497      // Send all attributes of current calendar 
     498      CCalendarWrapper::get(CCalendarWrapper::GetDefName())->sendAllAttributesToServer(); 
     499 
     500      // We have enough information to send to server 
     501      // First of all, send all enabled files 
     502      sendEnabledFiles(); 
     503 
     504      // Then, send all enabled fields 
     505      sendEnabledFields(); 
     506 
     507      // At last, we have all info of domain and axis, then send them 
     508       sendRefDomainsAxis(); 
     509 
     510       // After that, send all grid (if any) 
     511       sendRefGrid(); 
     512 
     513       // We have a xml tree on the server side and now, it should be also processed 
     514       sendPostProcessing(); 
     515     } 
     516     allProcessed = true; 
     517   } 
     518 
     519   void CContext::sendPostProcessingGlobalAttributes() 
     520   { 
     521         // Use correct context client to send message 
     522     CContextClient* contextClientTmp = (0 != clientPrimServer) ? clientPrimServer : client; 
     523     CEventClient event(getType(),EVENT_ID_POST_PROCESS_GLOBAL_ATTRIBUTES); 
     524 
     525     if (contextClientTmp->isServerLeader()) 
     526     { 
     527       CMessage msg; 
     528       msg<<this->getIdServer(); 
     529       const std::list<int>& ranks = contextClientTmp->getRanksServerLeader(); 
     530       for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 
     531         event.push(*itRank,1,msg); 
     532       contextClientTmp->sendEvent(event); 
     533     } 
     534     else contextClientTmp->sendEvent(event); 
     535   } 
     536 
     537   void CContext::recvPostProcessingGlobalAttributes(CEventServer& event) 
     538   { 
     539      CBufferIn* buffer=event.subEvents.begin()->buffer; 
     540      string id; 
     541      *buffer>>id; 
     542      // get(id)->recvPostProcessingGlobalAttributes(*buffer); 
     543   } 
     544 
     545   void CContext::recvPostProcessingGlobalAttributes(CBufferIn& buffer) 
     546   { 
     547      // CCalendarWrapper::get(CCalendarWrapper::GetDefName())->createCalendar(); 
     548      postProcessingGlobalAttributes(); 
     549   } 
     550 
    477551   /*! 
    478552   \brief Close all the context defintion and do processing data 
     
    487561   { 
    488562     // There is nothing client need to send to server 
    489      if (hasClient) 
    490      { 
    491        // After xml is parsed, there are some more works with post processing 
    492        postProcessing(); 
    493      } 
    494  
    495      setClientServerBuffer(); 
    496  
    497      if (hasClient) 
    498      { 
    499       // Send all attributes of current context to server 
    500       this->sendAllAttributesToServer(); 
    501  
    502       // Send all attributes of current calendar 
    503       CCalendarWrapper::get(CCalendarWrapper::GetDefName())->sendAllAttributesToServer(); 
    504  
    505       // We have enough information to send to server 
    506       // First of all, send all enabled files 
    507       sendEnabledFiles(); 
    508  
    509       // Then, send all enabled fields 
    510       sendEnabledFields(); 
    511  
    512       // At last, we have all info of domain and axis, then send them 
    513        sendRefDomainsAxis(); 
    514  
    515        // After that, send all grid (if any) 
    516        sendRefGrid(); 
    517  
    518        // We have a xml tree on the server side and now, it should be also processed 
    519        sendPostProcessing(); 
    520      } 
     563//      if (hasClient) 
     564//     if (hasClient && !hasServer) 
     565//      if (hasClient) 
     566//      { 
     567//        // After xml is parsed, there are some more works with post processing 
     568//        postProcessing(); 
     569//      } 
     570 
     571//      setClientServerBuffer(); 
     572 
     573// //     if (hasClient && !hasServer) 
     574//      if (hasClient) 
     575//      { 
     576//       // Send all attributes of current context to server 
     577//       this->sendAllAttributesToServer(); 
     578 
     579//       // Send all attributes of current calendar 
     580//       CCalendarWrapper::get(CCalendarWrapper::GetDefName())->sendAllAttributesToServer(); 
     581 
     582//       // We have enough information to send to server 
     583//       // First of all, send all enabled files 
     584//        sendEnabledFiles(); 
     585 
     586//       // Then, send all enabled fields 
     587//        sendEnabledFields(); 
     588 
     589//       // At last, we have all info of domain and axis, then send them 
     590//        sendRefDomainsAxis(); 
     591 
     592//       // After that, send all grid (if any) 
     593//        sendRefGrid(); 
     594 
     595//        // // We have a xml tree on the server side and now, it should be also processed 
     596//        sendPostProcessing(); 
     597//      } 
    521598 
    522599 
    523600     // Now tell server that it can process all messages from client 
    524      if (hasClient) this->sendCloseDefinition(); 
     601     // if (hasClient) this->sendCloseDefinition(); 
     602    postProcessingGlobalAttributes(); 
     603 
     604    if (hasClient) sendPostProcessingGlobalAttributes(); 
    525605 
    526606    // There are some processings that should be done after all of above. For example: check mask or index 
     607    this->buildFilterGraphOfEnabledFields(); 
     608     
    527609     if (hasClient && !hasServer) 
    528610    { 
    529       this->buildFilterGraphOfEnabledFields();  // references are resolved here (access xml file) 
     611      // this->buildFilterGraphOfEnabledFields();  // references are resolved here (access xml file) 
    530612      buildFilterGraphOfFieldsWithReadAccess(); 
    531       this->solveAllRefOfEnabledFields(true); 
     613      // this->solveAllRefOfEnabledFields(true); 
    532614    } 
    533615 
     616    // if (hasClient) this->solveAllRefOfEnabledFields(true); 
     617    this->processGridEnabledFields(); 
     618    if (hasClient) this->sendProcessingGridOfEnabledFields(); 
     619    // if (hasClient)        // We have a xml tree on the server side and now, it should be also processed 
     620    //    sendPostProcessing(); 
    534621//    // Now tell server that it can process all messages from client 
    535622////    if (hasClient && !hasServer) this->sendCloseDefinition(); 
    536 //    if (hasClient) this->sendCloseDefinition(); 
     623   if (hasClient) this->sendCloseDefinition(); 
    537624 
    538625    // Nettoyage de l'arborescence 
     
    564651        (void)this->enabledReadModeFiles[i]->readAttributesOfEnabledFieldsInReadMode(); 
    565652   } 
     653 
     654   void CContext::solveAllEnabledFields() 
     655   { 
     656     int size = this->enabledFiles.size(); 
     657     for (int i = 0; i < size; ++i) 
     658     { 
     659       this->enabledFiles[i]->solveOnlyRefOfEnabledFields(false); 
     660     } 
     661 
     662     for (int i = 0; i < size; ++i) 
     663     { 
     664       this->enabledFiles[i]->generateNewTransformationGridDest(); 
     665     } 
     666   } 
     667 
     668   void CContext::processGridEnabledFields() 
     669   { 
     670     int size = this->enabledFiles.size(); 
     671     for (int i = 0; i < size; ++i) 
     672     { 
     673       this->enabledFiles[i]->checkGridOfEnabledFields(); 
     674       this->enabledFiles[i]->sendGridOfEnabledFields(); 
     675     } 
     676   } 
     677 
     678 
    566679 
    567680   void CContext::solveOnlyRefOfEnabledFields(bool sendToServer) 
     
    754867             recvRegistry(event); 
    755868             return true; 
    756             break; 
    757  
     869             break; 
     870            case EVENT_ID_POST_PROCESS_GLOBAL_ATTRIBUTES: 
     871             recvPostProcessingGlobalAttributes(event); 
     872             return true; 
     873             break; 
     874            case EVENT_ID_PROCESS_GRID_ENABLED_FIELDS: 
     875             recvProcessingGridOfEnabledFields(event); 
     876             return true; 
     877             break; 
    758878           default : 
    759879             ERROR("bool CContext::dispatchEvent(CEventServer& event)", 
     
    802922      *buffer>>id; 
    803923      get(id)->closeDefinition(); 
    804       if (get(id)->hasClient && get(id)->hasServer) 
    805       {         
    806         get(id)->sendCloseDefinition(); 
    807       } 
     924      // if (get(id)->hasClient && get(id)->hasServer) 
     925      // {         
     926      //   get(id)->sendCloseDefinition(); 
     927      // } 
    808928   } 
    809929 
     
    833953         else contextClientTmp->sendEvent(event); 
    834954     } 
    835  
    836      // if (!hasServer) 
    837      // { 
    838      //   if (client->isServerLeader()) 
    839      //   { 
    840      //     CMessage msg; 
    841      //     msg<<this->getIdServer()<<step; 
    842      //     const std::list<int>& ranks = client->getRanksServerLeader(); 
    843      //     for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 
    844      //       event.push(*itRank,1,msg); 
    845      //     client->sendEvent(event); 
    846      //   } 
    847      //   else client->sendEvent(event); 
    848      // } 
    849      // else 
    850      // { 
    851      //   if (clientPrimServer->isServerLeader()) 
    852      //   { 
    853      //     CMessage msg; 
    854      //     msg<<this->getIdServer()<<step; 
    855      //     const std::list<int>& ranks = clientPrimServer->getRanksServerLeader(); 
    856      //     for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 
    857      //       event.push(*itRank,1,msg); 
    858      //     clientPrimServer->sendEvent(event); 
    859      //   } 
    860      //   else clientPrimServer->sendEvent(event); 
    861      // } 
    862955   } 
    863956 
     
    9071000       else contextClientTmp->sendEvent(event); 
    9081001     } 
    909      // if (!hasServer) 
    910      // { 
    911      //   if (client->isServerLeader()) 
    912      //   { 
    913      //     CMessage msg; 
    914      //     msg<<this->getIdServer(); 
    915      //     const std::list<int>& ranks = client->getRanksServerLeader(); 
    916      //     for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 
    917      //       event.push(*itRank,1,msg) ; 
    918      //     client->sendEvent(event); 
    919      //   } 
    920      //   else client->sendEvent(event); 
    921      // } 
    922      // else 
    923      // { 
    924      //   if (clientPrimServer->isServerLeader()) 
    925      //   { 
    926      //     CMessage msg; 
    927      //     msg<<this->getIdServer(); 
    928      //     const std::list<int>& ranks = clientPrimServer->getRanksServerLeader(); 
    929      //     for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 
    930      //       event.push(*itRank,1,msg) ; 
    931      //     clientPrimServer->sendEvent(event); 
    932      //   } 
    933      //   else clientPrimServer->sendEvent(event); 
    934      // } 
    9351002   } 
    9361003 
     
    9481015   { 
    9491016     // The creation of header file should be delegated to server2, for now 
    950       if (hasClient && hasServer) 
    951       {         
    952         sendCreateFileHeader(); 
    953       } 
     1017      // if (hasClient && hasServer) 
     1018      // {         
     1019      //   sendCreateFileHeader(); 
     1020      // } 
    9541021       
    9551022      if (!hasClient && hasServer)  
    9561023        createFileHeader(); 
     1024   } 
     1025 
     1026   //! Client side: Send a message to do some post processing on server 
     1027   void CContext::sendProcessingGridOfEnabledFields() 
     1028   { 
     1029      // Use correct context client to send message 
     1030     CContextClient* contextClientTmp = (0 != clientPrimServer) ? clientPrimServer : client; 
     1031     CEventClient event(getType(),EVENT_ID_PROCESS_GRID_ENABLED_FIELDS); 
     1032 
     1033     if (contextClientTmp->isServerLeader()) 
     1034     { 
     1035       CMessage msg; 
     1036       msg<<this->getIdServer(); 
     1037       const std::list<int>& ranks = contextClientTmp->getRanksServerLeader(); 
     1038       for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 
     1039         event.push(*itRank,1,msg); 
     1040       contextClientTmp->sendEvent(event); 
     1041     } 
     1042     else contextClientTmp->sendEvent(event); 
     1043   } 
     1044 
     1045   //! Server side: Receive a message to do some post processing 
     1046   void CContext::recvProcessingGridOfEnabledFields(CEventServer& event) 
     1047   { 
     1048      CBufferIn* buffer=event.subEvents.begin()->buffer; 
     1049      string id; 
     1050      *buffer>>id; 
     1051      // get(id)->processGridEnabledFields(); 
    9571052   } 
    9581053 
     
    9801075       else contextClientTmp->sendEvent(event); 
    9811076     } 
    982  
    983      // if (hasClient) 
    984      // { 
    985      //   if (!hasServer) 
    986      //   { 
    987      //     CEventClient event(getType(),EVENT_ID_POST_PROCESS); 
    988      //     if (client->isServerLeader()) 
    989      //     { 
    990      //       CMessage msg; 
    991      //       msg<<this->getIdServer(); 
    992      //       const std::list<int>& ranks = client->getRanksServerLeader(); 
    993      //       for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 
    994      //         event.push(*itRank,1,msg); 
    995      //       client->sendEvent(event); 
    996      //     } 
    997      //     else client->sendEvent(event); 
    998      //   } 
    999      //   else 
    1000      //   { 
    1001      //     CEventClient event(getType(),EVENT_ID_POST_PROCESS); 
    1002      //     if (clientPrimServer->isServerLeader()) 
    1003      //     { 
    1004      //       CMessage msg; 
    1005      //       msg<<this->getIdServer(); 
    1006      //       const std::list<int>& ranks = clientPrimServer->getRanksServerLeader(); 
    1007      //       for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 
    1008      //         event.push(*itRank,1,msg); 
    1009      //       clientPrimServer->sendEvent(event); 
    1010      //     } 
    1011      //     else clientPrimServer->sendEvent(event); 
    1012      //   } 
    1013      // } 
    10141077   } 
    10151078 
     
    10751138      // Check if some axis, domains or grids are eligible to for compressed indexed output. 
    10761139      // Warning: This must be done after solving the inheritance and before the rest of post-processing 
    1077       checkAxisDomainsGridsEligibilityForCompressedOutput(); 
     1140      checkAxisDomainsGridsEligibilityForCompressedOutput();       
    10781141 
    10791142      // Check if some automatic time series should be generated 
    10801143      // Warning: This must be done after solving the inheritance and before the rest of post-processing 
    1081       if (!hasServer) 
    1082         prepareTimeseries(); 
     1144      // prepareTimeseries(); 
     1145 
     1146      // The timeseries should only be prepared in client 
     1147      if (hasClient && !hasServer) prepareTimeseries(); 
    10831148 
    10841149      //Initialisation du vecteur 'enabledFiles' contenant la liste des fichiers à sortir. 
    10851150      this->findEnabledFiles(); 
    1086       this->findEnabledReadModeFiles(); 
     1151      // this->findEnabledReadModeFiles(); 
     1152      // For now, only read files with client and only one level server 
     1153      if (hasClient && !hasServer) this->findEnabledReadModeFiles(); 
     1154 
    10871155 
    10881156      // Find all enabled fields of each file 
    10891157      this->findAllEnabledFields(); 
    1090       this->findAllEnabledFieldsInReadModeFiles(); 
     1158      // this->findAllEnabledFieldsInReadModeFiles(); 
     1159      // For now, only read files with client and only one level server 
     1160      if (hasClient && !hasServer) this->findAllEnabledFieldsInReadModeFiles(); 
    10911161 
    10921162//     if (hasClient) 
     
    10971167     } 
    10981168 
     1169      // // Only search and rebuild all reference objects of enable fields, don't transform 
     1170      // this->solveOnlyRefOfEnabledFields(false); 
     1171 
     1172      // // Search and rebuild all reference object of enabled fields 
     1173      // this->solveAllRefOfEnabledFields(false); 
     1174 
     1175      // // Find all fields with read access from the public API 
     1176      // findFieldsWithReadAccess(); 
     1177      // // and solve the all reference for them 
     1178      // solveAllRefOfFieldsWithReadAccess(); 
     1179 
    10991180      // Only search and rebuild all reference objects of enable fields, don't transform 
    1100       this->solveOnlyRefOfEnabledFields(false); 
     1181      if (hasClient) this->solveOnlyRefOfEnabledFields(false); 
    11011182 
    11021183      // Search and rebuild all reference object of enabled fields 
    1103       this->solveAllRefOfEnabledFields(false); 
     1184      // if (hasClient) this->solveAllRefOfEnabledFields(false); 
    11041185 
    11051186      // Find all fields with read access from the public API 
    1106       findFieldsWithReadAccess(); 
     1187      if (hasClient && !hasServer) findFieldsWithReadAccess(); 
    11071188      // and solve the all reference for them 
    1108       solveAllRefOfFieldsWithReadAccess(); 
     1189      if (hasClient && !hasServer) solveAllRefOfFieldsWithReadAccess(); 
    11091190 
    11101191      isPostProcessed = true; 
Note: See TracChangeset for help on using the changeset viewer.