Changeset 1025 for XIOS/dev/dev_olga/src/node/context.cpp
- Timestamp:
- 01/11/17 15:14:22 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/dev/dev_olga/src/node/context.cpp
r1021 r1025 29 29 , idServer_(), client(0), server(0) 30 30 // , clientPrimServer(0), serverPrimServer(0) 31 , allProcessed(false) 31 32 { /* Ne rien faire de plus */ } 32 33 … … 37 38 , idServer_(), client(0), server(0) 38 39 // , clientPrimServer(0), serverPrimServer(0) 40 , allProcessed(false) 39 41 { /* Ne rien faire de plus */ } 40 42 … … 475 477 } 476 478 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 477 551 /*! 478 552 \brief Close all the context defintion and do processing data … … 487 561 { 488 562 // 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 // } 521 598 522 599 523 600 // 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(); 525 605 526 606 // There are some processings that should be done after all of above. For example: check mask or index 607 this->buildFilterGraphOfEnabledFields(); 608 527 609 if (hasClient && !hasServer) 528 610 { 529 this->buildFilterGraphOfEnabledFields(); // references are resolved here (access xml file)611 // this->buildFilterGraphOfEnabledFields(); // references are resolved here (access xml file) 530 612 buildFilterGraphOfFieldsWithReadAccess(); 531 this->solveAllRefOfEnabledFields(true);613 // this->solveAllRefOfEnabledFields(true); 532 614 } 533 615 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(); 534 621 // // Now tell server that it can process all messages from client 535 622 //// if (hasClient && !hasServer) this->sendCloseDefinition(); 536 //if (hasClient) this->sendCloseDefinition();623 if (hasClient) this->sendCloseDefinition(); 537 624 538 625 // Nettoyage de l'arborescence … … 564 651 (void)this->enabledReadModeFiles[i]->readAttributesOfEnabledFieldsInReadMode(); 565 652 } 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 566 679 567 680 void CContext::solveOnlyRefOfEnabledFields(bool sendToServer) … … 754 867 recvRegistry(event); 755 868 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; 758 878 default : 759 879 ERROR("bool CContext::dispatchEvent(CEventServer& event)", … … 802 922 *buffer>>id; 803 923 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 // } 808 928 } 809 929 … … 833 953 else contextClientTmp->sendEvent(event); 834 954 } 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 // else850 // {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 // }862 955 } 863 956 … … 907 1000 else contextClientTmp->sendEvent(event); 908 1001 } 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 // else923 // {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 // }935 1002 } 936 1003 … … 948 1015 { 949 1016 // 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 // } 954 1021 955 1022 if (!hasClient && hasServer) 956 1023 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(); 957 1052 } 958 1053 … … 980 1075 else contextClientTmp->sendEvent(event); 981 1076 } 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 // else1000 // {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 // }1014 1077 } 1015 1078 … … 1075 1138 // Check if some axis, domains or grids are eligible to for compressed indexed output. 1076 1139 // Warning: This must be done after solving the inheritance and before the rest of post-processing 1077 checkAxisDomainsGridsEligibilityForCompressedOutput(); 1140 checkAxisDomainsGridsEligibilityForCompressedOutput(); 1078 1141 1079 1142 // Check if some automatic time series should be generated 1080 1143 // 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(); 1083 1148 1084 1149 //Initialisation du vecteur 'enabledFiles' contenant la liste des fichiers à sortir. 1085 1150 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 1087 1155 1088 1156 // Find all enabled fields of each file 1089 1157 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(); 1091 1161 1092 1162 // if (hasClient) … … 1097 1167 } 1098 1168 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 1099 1180 // Only search and rebuild all reference objects of enable fields, don't transform 1100 this->solveOnlyRefOfEnabledFields(false);1181 if (hasClient) this->solveOnlyRefOfEnabledFields(false); 1101 1182 1102 1183 // Search and rebuild all reference object of enabled fields 1103 this->solveAllRefOfEnabledFields(false);1184 // if (hasClient) this->solveAllRefOfEnabledFields(false); 1104 1185 1105 1186 // Find all fields with read access from the public API 1106 findFieldsWithReadAccess();1187 if (hasClient && !hasServer) findFieldsWithReadAccess(); 1107 1188 // and solve the all reference for them 1108 solveAllRefOfFieldsWithReadAccess();1189 if (hasClient && !hasServer) solveAllRefOfFieldsWithReadAccess(); 1109 1190 1110 1191 isPostProcessed = true;
Note: See TracChangeset
for help on using the changeset viewer.