source: XIOS/dev/dev_olga/src/server.cpp @ 1077

Last change on this file since 1077 was 1077, checked in by oabramkina, 7 years ago

dev: Intermediate commit

Done:
Registries: ok with two server levels

To do (on a single server level):
test_complete
reading

  • Property copyright set to
    Software name : XIOS (Xml I/O Server)
    http://forge.ipsl.jussieu.fr/ioserver
    Creation date : January 2009
    Licence : CeCCIL version2
    see license file in root directory : Licence_CeCILL_V2-en.txt
    or http://www.cecill.info/licences/Licence_CeCILL_V2-en.html
    Holder : CEA/LSCE (Laboratoire des Sciences du CLimat et de l'Environnement)
    CNRS/IPSL (Institut Pierre Simon Laplace)
    Project Manager : Yann Meurdesoif
    yann.meurdesoif@cea.fr
  • Property svn:eol-style set to native
File size: 20.6 KB
RevLine 
[490]1#include "globalScopeData.hpp"
[591]2#include "xios_spl.hpp"
[300]3#include "cxios.hpp"
[342]4#include "server.hpp"
[983]5#include "client.hpp"
[300]6#include "type.hpp"
7#include "context.hpp"
[352]8#include "object_template.hpp"
[300]9#include "oasis_cinterface.hpp"
10#include <boost/functional/hash.hpp>
11#include <boost/algorithm/string.hpp>
[382]12#include "mpi.hpp"
[347]13#include "tracer.hpp"
14#include "timer.hpp"
[492]15#include "event_scheduler.hpp"
[300]16
[335]17namespace xios
[490]18{
[300]19    MPI_Comm CServer::intraComm ;
[992]20    list<MPI_Comm> CServer::interCommLeft ;
21    list<MPI_Comm> CServer::interCommRight ;
[1054]22//    list<MPI_Comm> CServer::interComm ;
[655]23    std::list<MPI_Comm> CServer::contextInterComms;
[1071]24    std::list<MPI_Comm> CServer::contextIntraComms;
[1021]25    int CServer::serverLevel = 0 ;
[1071]26    int CServer::serverLeader_ = 0;
27    int CServer::serverSize_ = 0;
[1021]28    int CServer::nbPools = 0;
29    int CServer::poolId = 0;
[1071]30    int CServer::nbContexts_ = 0;
[983]31    bool CServer::isRoot = false ;
[1077]32    int CServer::rank_ = INVALID_RANK;
[490]33    StdOFStream CServer::m_infoStream;
[523]34    StdOFStream CServer::m_errorStream;
[490]35    map<string,CContext*> CServer::contextList ;
[300]36    bool CServer::finished=false ;
37    bool CServer::is_MPI_Initialized ;
[597]38    CEventScheduler* CServer::eventScheduler = 0;
[983]39
40//---------------------------------------------------------------
41/*!
42 * \fn void CServer::initialize(void)
[1054]43 * Creates intraComm for each possible type of servers (classical, primary or secondary).
44 * In case of secondary servers intraComm is created for each secondary server pool.
45 * (For now the assumption is that there is one proc per pool.)
46 * Creates the following lists of interComms:
47 *   classical server -- interCommLeft
48 *   primary server -- interCommLeft and interCommRight
49 *   secondary server -- interComm for each pool.
[983]50 */
[300]51    void CServer::initialize(void)
52    {
53      int initialized ;
54      MPI_Initialized(&initialized) ;
55      if (initialized) is_MPI_Initialized=true ;
56      else is_MPI_Initialized=false ;
[490]57
[300]58      // Not using OASIS
59      if (!CXios::usingOasis)
60      {
[490]61
62        if (!is_MPI_Initialized)
[300]63        {
[925]64          MPI_Init(NULL, NULL);
[300]65        }
[359]66        CTimer::get("XIOS").resume() ;
[490]67
68        boost::hash<string> hashString ;
[1021]69//        unsigned long hashServer1 = hashString(CXios::xiosCodeIdPrm);
70//        unsigned long hashServer2 = hashString(CXios::xiosCodeIdSnd);
71//        unsigned long hashServer = (CXios::serverLevel < 2)  ? hashServer1 : hashServer2;
72        unsigned long hashServer = hashString(CXios::xiosCodeId);
[490]73
[300]74        unsigned long* hashAll ;
[490]75
76//        int rank ;
[300]77        int size ;
78        int myColor ;
79        int i,c ;
[1021]80        MPI_Comm newComm, serversComm;
[490]81
[983]82        MPI_Comm_size(CXios::globalComm, &size) ;
[1077]83        MPI_Comm_rank(CXios::globalComm, &rank_);
[1009]84
[300]85        hashAll=new unsigned long[size] ;
[983]86        MPI_Allgather(&hashServer, 1, MPI_LONG, hashAll, 1, MPI_LONG, CXios::globalComm) ;
[490]87
[1021]88        map<unsigned long, int> colors ;
[300]89        map<unsigned long, int> leaders ;
90        map<unsigned long, int>::iterator it ;
[490]91
[300]92        for(i=0,c=0;i<size;i++)
93        {
94          if (colors.find(hashAll[i])==colors.end())
95          {
96            colors[hashAll[i]]=c ;
97            leaders[hashAll[i]]=i ;
98            c++ ;
99          }
100        }
[490]101
[1021]102        // Setting the number of secondary pools
103        myColor = colors[hashServer];
104        if (CXios::usingServer2)
[1009]105        {
[1077]106          int serverRank = rank_ - leaders[hashServer]; // server proc rank starting 0
[1071]107          serverSize_ = size - leaders[hashServer];
108          nbPools = serverSize_ * CXios::ratioServer2 / 100;
109          if ( serverRank < (serverSize_ - nbPools) )
[1009]110          {
[1021]111            serverLevel = 1;
[1009]112          }
[1021]113          else
[1009]114          {
[1021]115            serverLevel = 2;
[1071]116            poolId = serverRank - serverSize_ + nbPools;
[1077]117            myColor = rank_;
[1009]118          }
119        }
120
[1077]121        MPI_Comm_split(CXios::globalComm, myColor, rank_, &intraComm) ;
[1009]122
[1021]123        if (serverLevel == 0)
[983]124        {
125          int clientLeader;
126          for(it=leaders.begin();it!=leaders.end();it++)
127          {
128            if (it->first!=hashServer)
129            {
130              clientLeader=it->second ;
131              int intraCommSize, intraCommRank ;
132              MPI_Comm_size(intraComm,&intraCommSize) ;
133              MPI_Comm_rank(intraComm,&intraCommRank) ;
[1077]134              info(50)<<"intercommCreate::server "<<rank_<<" intraCommSize : "<<intraCommSize
[983]135                       <<" intraCommRank :"<<intraCommRank<<"  clientLeader "<< clientLeader<<endl ;
[490]136
[1009]137              MPI_Intercomm_create(intraComm, 0, CXios::globalComm, clientLeader, 0, &newComm) ;
[992]138               interCommLeft.push_back(newComm) ;
[983]139            }
140          }
141        }
[1021]142        else if (serverLevel == 1)
[983]143        {
[1054]144          int clientLeader, srvSndLeader;
145          int srvPrmLeader ;
[1021]146          for (it=leaders.begin();it!=leaders.end();it++)
[983]147          {
[1021]148            if (it->first != hashServer)
[983]149            {
[1021]150              clientLeader=it->second ;
151              int intraCommSize, intraCommRank ;
152              MPI_Comm_size(intraComm, &intraCommSize) ;
153              MPI_Comm_rank(intraComm, &intraCommRank) ;
[1077]154              info(50)<<"intercommCreate::server "<<rank_<<" intraCommSize : "<<intraCommSize
[1021]155                       <<" intraCommRank :"<<intraCommRank<<"  clientLeader "<< clientLeader<<endl ;
156              MPI_Intercomm_create(intraComm, 0, CXios::globalComm, clientLeader, 0, &newComm) ;
157              interCommLeft.push_back(newComm) ;
[983]158            }
159            else
[1071]160              serverLeader_ = it->second;
[1021]161          }
[1009]162
[1021]163          for (int i = 0; i < nbPools; ++i)
[983]164          {
[1071]165            srvSndLeader = serverLeader_ + serverSize_ - nbPools + i;
[1054]166            int intraCommSize, intraCommRank ;
167            MPI_Comm_size(intraComm, &intraCommSize) ;
168            MPI_Comm_rank(intraComm, &intraCommRank) ;
[1077]169            info(50)<<"intercommCreate::client "<<rank_<<" intraCommSize : "<<intraCommSize
[1054]170                <<" intraCommRank :"<<intraCommRank<<"  clientLeader "<< srvSndLeader<<endl ;
171            MPI_Intercomm_create(intraComm, 0, CXios::globalComm, srvSndLeader, 0, &newComm) ;
172            interCommRight.push_back(newComm) ;
[1021]173          }
174        } // primary server
175        else
176        {
177          int clientLeader;
178          clientLeader = leaders[hashString(CXios::xiosCodeId)];
179          int intraCommSize, intraCommRank ;
180          MPI_Comm_size(intraComm, &intraCommSize) ;
181          MPI_Comm_rank(intraComm, &intraCommRank) ;
[1077]182          info(50)<<"intercommCreate::server "<<rank_<<" intraCommSize : "<<intraCommSize
[1021]183                   <<" intraCommRank :"<<intraCommRank<<"  clientLeader "<< clientLeader<<endl ;
[983]184
[1021]185          MPI_Intercomm_create(intraComm, 0, CXios::globalComm, clientLeader, 0, &newComm) ;
186          interCommLeft.push_back(newComm) ;
187        } // secondary server
[983]188
189        delete [] hashAll ;
190
[300]191      }
192      // using OASIS
193      else
194      {
[490]195//        int rank ,size;
196        int size;
197        if (!is_MPI_Initialized) oasis_init(CXios::xiosCodeId);
198
[359]199        CTimer::get("XIOS").resume() ;
[655]200        MPI_Comm localComm;
201        oasis_get_localcomm(localComm);
202        MPI_Comm_dup(localComm, &intraComm);
203
[1077]204        MPI_Comm_rank(intraComm,&rank_) ;
[300]205        MPI_Comm_size(intraComm,&size) ;
206        string codesId=CXios::getin<string>("oasis_codes_id") ;
[490]207
[300]208        vector<string> splitted ;
[483]209        boost::split( splitted, codesId, boost::is_any_of(","), boost::token_compress_on ) ;
[300]210        vector<string>::iterator it ;
211
212        MPI_Comm newComm ;
213        int globalRank ;
214        MPI_Comm_rank(CXios::globalComm,&globalRank);
[490]215
[300]216        for(it=splitted.begin();it!=splitted.end();it++)
217        {
218          oasis_get_intercomm(newComm,*it) ;
[1077]219          if (rank_==0) MPI_Send(&globalRank,1,MPI_INT,0,0,newComm) ;
[300]220          MPI_Comm_remote_size(newComm,&size);
[1054]221//          interComm.push_back(newComm) ;
222          interCommLeft.push_back(newComm) ;
[300]223        }
[492]224              oasis_enddef() ;
[300]225      }
[490]226
[1077]227      MPI_Comm_rank(intraComm, &rank_) ;
228      if (rank_==0) isRoot=true;
[490]229      else isRoot=false;
[492]230     
231      eventScheduler = new CEventScheduler(intraComm) ;
[300]232    }
[490]233
[300]234    void CServer::finalize(void)
235    {
[983]236
[361]237      CTimer::get("XIOS").suspend() ;
[697]238     
[492]239      delete eventScheduler ;
[655]240
241      for (std::list<MPI_Comm>::iterator it = contextInterComms.begin(); it != contextInterComms.end(); it++)
242        MPI_Comm_free(&(*it));
[983]243
[1071]244      for (std::list<MPI_Comm>::iterator it = contextIntraComms.begin(); it != contextIntraComms.end(); it++)
245        MPI_Comm_free(&(*it));
246
[992]247//      for (std::list<MPI_Comm>::iterator it = interComm.begin(); it != interComm.end(); it++)
248//        MPI_Comm_free(&(*it));
249
[1077]250//        for (std::list<MPI_Comm>::iterator it = interCommLeft.begin(); it != interCommLeft.end(); it++)
251//          MPI_Comm_free(&(*it));
[983]252
[1054]253        for (std::list<MPI_Comm>::iterator it = interCommRight.begin(); it != interCommRight.end(); it++)
254          MPI_Comm_free(&(*it));
[992]255
[655]256      MPI_Comm_free(&intraComm);
257
[300]258      if (!is_MPI_Initialized)
[490]259      {
[300]260        if (CXios::usingOasis) oasis_finalize();
261        else MPI_Finalize() ;
262      }
[347]263      report(0)<<"Performance report : Time spent for XIOS : "<<CTimer::get("XIOS server").getCumulatedTime()<<endl  ;
264      report(0)<<"Performance report : Time spent in processing events : "<<CTimer::get("Process events").getCumulatedTime()<<endl  ;
265      report(0)<<"Performance report : Ratio : "<<CTimer::get("Process events").getCumulatedTime()/CTimer::get("XIOS server").getCumulatedTime()*100.<<"%"<<endl  ;
[300]266    }
[490]267
[300]268     void CServer::eventLoop(void)
269     {
270       bool stop=false ;
[490]271
[347]272       CTimer::get("XIOS server").resume() ;
[300]273       while(!stop)
274       {
[983]275
[300]276         if (isRoot)
277         {
278           listenContext();
279           if (!finished) listenFinalize() ;
280         }
281         else
282         {
283           listenRootContext();
284           if (!finished) listenRootFinalize() ;
285         }
[490]286
[300]287         contextEventLoop() ;
[1054]288//         if (finished && contextList.empty()) stop=true ;
[300]289         if (finished && contextList.empty()) stop=true ;
[956]290         eventScheduler->checkEvent() ;
[983]291
[300]292       }
[347]293       CTimer::get("XIOS server").suspend() ;
[300]294     }
[490]295
[300]296     void CServer::listenFinalize(void)
297     {
[992]298        list<MPI_Comm>::iterator it, itr;
[300]299        int msg ;
300        int flag ;
[490]301
[992]302        for(it=interCommLeft.begin();it!=interCommLeft.end();it++)
[300]303        {
304           MPI_Status status ;
[347]305           traceOff() ;
[300]306           MPI_Iprobe(0,0,*it,&flag,&status) ;
[347]307           traceOn() ;
[300]308           if (flag==true)
309           {
[1054]310              MPI_Recv(&msg,1,MPI_INT,0,0,*it,&status) ;
311              info(20)<<" CServer : Receive client finalize"<<endl ;
312              // Sending server finalize message to secondary servers (if any)
313              for(itr=interCommRight.begin();itr!=interCommRight.end();itr++)
314              {
315                MPI_Send(&msg,1,MPI_INT,0,0,*itr) ;
316              }
[655]317              MPI_Comm_free(&(*it));
[992]318              interCommLeft.erase(it) ;
[300]319              break ;
320            }
321         }
[490]322
[1054]323         if (interCommLeft.empty())
[300]324         {
325           int i,size ;
326           MPI_Comm_size(intraComm,&size) ;
327           MPI_Request* requests= new MPI_Request[size-1] ;
328           MPI_Status* status= new MPI_Status[size-1] ;
[490]329
[300]330           for(int i=1;i<size;i++) MPI_Isend(&msg,1,MPI_INT,i,4,intraComm,&requests[i-1]) ;
331           MPI_Waitall(size-1,requests,status) ;
332
333           finished=true ;
334           delete [] requests ;
335           delete [] status ;
336         }
337     }
[490]338
339
[300]340     void CServer::listenRootFinalize()
341     {
342        int flag ;
343        MPI_Status status ;
344        int msg ;
[490]345
[347]346        traceOff() ;
[300]347        MPI_Iprobe(0,4,intraComm, &flag, &status) ;
[347]348        traceOn() ;
[300]349        if (flag==true)
350        {
351           MPI_Recv(&msg,1,MPI_INT,0,4,intraComm,&status) ;
352           finished=true ;
353        }
354      }
[490]355
[300]356     void CServer::listenContext(void)
357     {
[490]358
[300]359       MPI_Status status ;
360       int flag ;
361       static void* buffer ;
362       static MPI_Request request ;
363       static bool recept=false ;
364       int rank ;
365       int count ;
[490]366
[300]367       if (recept==false)
368       {
[347]369         traceOff() ;
[300]370         MPI_Iprobe(MPI_ANY_SOURCE,1,CXios::globalComm, &flag, &status) ;
[347]371         traceOn() ;
[490]372         if (flag==true)
[300]373         {
374           rank=status.MPI_SOURCE ;
375           MPI_Get_count(&status,MPI_CHAR,&count) ;
376           buffer=new char[count] ;
377           MPI_Irecv(buffer,count,MPI_CHAR,rank,1,CXios::globalComm,&request) ;
[490]378           recept=true ;
[300]379         }
380       }
381       else
382       {
[347]383         traceOff() ;
[300]384         MPI_Test(&request,&flag,&status) ;
[347]385         traceOn() ;
[300]386         if (flag==true)
387         {
388           rank=status.MPI_SOURCE ;
389           MPI_Get_count(&status,MPI_CHAR,&count) ;
390           recvContextMessage(buffer,count) ;
[1054]391           delete [] buffer;
[490]392           recept=false ;
[300]393         }
394       }
395     }
[490]396
[300]397     void CServer::recvContextMessage(void* buff,int count)
398     {
[983]399       static map<string,contextMessage> recvContextId;
[300]400       map<string,contextMessage>::iterator it ;
401       CBufferIn buffer(buff,count) ;
402       string id ;
403       int clientLeader ;
404       int nbMessage ;
405
406       buffer>>id>>nbMessage>>clientLeader ;
[490]407
[300]408       it=recvContextId.find(id) ;
409       if (it==recvContextId.end())
[490]410       {
[300]411         contextMessage msg={0,0} ;
412         pair<map<string,contextMessage>::iterator,bool> ret ;
413         ret=recvContextId.insert(pair<string,contextMessage>(id,msg)) ;
414         it=ret.first ;
[490]415       }
[300]416       it->second.nbRecv+=1 ;
417       it->second.leaderRank+=clientLeader ;
[490]418
[300]419       if (it->second.nbRecv==nbMessage)
[490]420       {
[300]421         int size ;
422         MPI_Comm_size(intraComm,&size) ;
423         MPI_Request* requests= new MPI_Request[size-1] ;
424         MPI_Status* status= new MPI_Status[size-1] ;
[490]425
[300]426         for(int i=1;i<size;i++)
427         {
428            MPI_Isend(buff,count,MPI_CHAR,i,2,intraComm,&requests[i-1]) ;
429         }
430         MPI_Waitall(size-1,requests,status) ;
431         registerContext(buff,count,it->second.leaderRank) ;
432
433         recvContextId.erase(it) ;
434         delete [] requests ;
435         delete [] status ;
436
437       }
[490]438     }
439
[300]440     void CServer::listenRootContext(void)
441     {
442       MPI_Status status ;
443       int flag ;
444       static void* buffer ;
445       static MPI_Request request ;
446       static bool recept=false ;
447       int rank ;
448       int count ;
449       const int root=0 ;
[490]450
[300]451       if (recept==false)
452       {
[347]453         traceOff() ;
[300]454         MPI_Iprobe(root,2,intraComm, &flag, &status) ;
[347]455         traceOn() ;
[490]456         if (flag==true)
[300]457         {
458           MPI_Get_count(&status,MPI_CHAR,&count) ;
459           buffer=new char[count] ;
460           MPI_Irecv(buffer,count,MPI_CHAR,root,2,intraComm,&request) ;
[490]461           recept=true ;
[300]462         }
463       }
464       else
465       {
466         MPI_Test(&request,&flag,&status) ;
467         if (flag==true)
468         {
469           MPI_Get_count(&status,MPI_CHAR,&count) ;
470           registerContext(buffer,count) ;
471           delete [] buffer ;
[490]472           recept=false ;
[300]473         }
474       }
[490]475     }
476
[655]477     void CServer::registerContext(void* buff, int count, int leaderRank)
[300]478     {
479       string contextId;
[655]480       CBufferIn buffer(buff, count);
481       buffer >> contextId;
[983]482       CContext* context;
[300]483
[680]484       info(20) << "CServer : Register new Context : " << contextId << endl;
[490]485
[680]486       if (contextList.find(contextId) != contextList.end())
487         ERROR("void CServer::registerContext(void* buff, int count, int leaderRank)",
488               << "Context '" << contextId << "' has already been registred");
[490]489
[983]490       context=CContext::create(contextId);
[655]491       contextList[contextId]=context;
492
[1071]493       // Primary or classical server: initialize its own server (CContextServer)
494       MPI_Comm inter;
[1054]495       if (serverLevel < 2)
496       {
497         MPI_Comm contextInterComm;
498         MPI_Intercomm_create(intraComm, 0, CXios::globalComm, leaderRank, 10+leaderRank, &contextInterComm);
499         MPI_Intercomm_merge(contextInterComm,1,&inter);
500         MPI_Barrier(inter);
501         MPI_Comm_free(&inter);
502         context->initServer(intraComm,contextInterComm);
503         contextInterComms.push_back(contextInterComm);
[1071]504
[1054]505       }
[1071]506       // Secondary server: initialize its own server (CContextServer)
[1054]507       else if (serverLevel == 2)
508       {
[1071]509         MPI_Comm_dup(interCommLeft.front(), &inter);
510         contextInterComms.push_back(inter);
511         context->initServer(intraComm, contextInterComms.back());
512//         context->initServer(intraComm, interCommLeft.front());
[1054]513       }
514
515       // Primary server: send create context message to secondary servers and initialize its own client (CContextClient)
[1021]516       if (serverLevel == 1)
[983]517       {
[1054]518         int i = 0, size;
519         CMessage msg;
520         int messageSize;
521         MPI_Comm_size(intraComm, &size) ;
522         for (std::list<MPI_Comm>::iterator it = interCommRight.begin(); it != interCommRight.end(); it++, ++i)
523         {
524           StdString str = contextId +"_server_" + boost::lexical_cast<string>(i);
[1077]525           msg<<str<<size<<rank_ ;
[1054]526           messageSize = msg.size() ;
527           buff = new char[messageSize] ;
528           CBufferOut buffer(buff,messageSize) ;
529           buffer<<msg ;
[1071]530           int sndServerGloRanks = serverSize_-nbPools+serverLeader_ +i;  // the assumption is that there is only one proc per secondary server pool
[1054]531           MPI_Send(buff, buffer.count(), MPI_CHAR, sndServerGloRanks, 1, CXios::globalComm) ;
[1071]532           MPI_Comm_dup(*it, &inter);
533           contextInterComms.push_back(inter);
534           MPI_Comm_dup(intraComm, &inter);
535           contextIntraComms.push_back(inter);
536           context->initClient(contextIntraComms.back(), contextInterComms.back()) ;
537//           context->initClient(intraComm, contextPrimInterComms.back()) ;
538//           context->initClient(intraComm, *it) ;
[1054]539           delete [] buff ;
540         }
[1071]541         ++nbContexts_;
[983]542       }
[490]543     }
544
[300]545     void CServer::contextEventLoop(void)
546     {
547       bool finished ;
[1054]548
[300]549       map<string,CContext*>::iterator it ;
[983]550
[490]551       for(it=contextList.begin();it!=contextList.end();it++)
[300]552       {
[1054]553         finished=it->second->isFinalized();
[300]554         if (finished)
555         {
[1077]556           it->second->freeComms();  // deallocate internally allocated context communicators
[300]557           contextList.erase(it) ;
558           break ;
559         }
[1054]560         else
561           finished=it->second->checkBuffersAndListen();
[300]562       }
563     }
[490]564
565     //! Get rank of the current process
566     int CServer::getRank()
567     {
[1077]568       return rank_;
[490]569     }
570
[523]571    /*!
572    * Open a file specified by a suffix and an extension and use it for the given file buffer.
573    * The file name will be suffix+rank+extension.
574    *
575    * \param fileName[in] protype file name
576    * \param ext [in] extension of the file
577    * \param fb [in/out] the file buffer
578    */
579    void CServer::openStream(const StdString& fileName, const StdString& ext, std::filebuf* fb)
580    {
581      StdStringStream fileNameClient;
582      int numDigit = 0;
583      int size = 0;
[1021]584      int id;
[523]585      MPI_Comm_size(CXios::globalComm, &size);
586      while (size)
587      {
588        size /= 10;
589        ++numDigit;
590      }
[497]591
[1021]592      if (!CXios::usingServer2)
593        id = getRank();
[1009]594      else
[1021]595      {
596        if (serverLevel == 1)
[1077]597          id = rank_;
[1021]598        else
599          id = poolId;
600      }
601      fileNameClient << fileName << "_" << std::setfill('0') << std::setw(numDigit) << id << ext;
[523]602      fb->open(fileNameClient.str().c_str(), std::ios::out);
603      if (!fb->is_open())
604        ERROR("void CServer::openStream(const StdString& fileName, const StdString& ext, std::filebuf* fb)",
605              << std::endl << "Can not open <" << fileNameClient << "> file to write the server log(s).");
606    }
[490]607
[523]608    /*!
609    * \brief Open a file stream to write the info logs
610    * Open a file stream with a specific file name suffix+rank
611    * to write the info logs.
612    * \param fileName [in] protype file name
613    */
614    void CServer::openInfoStream(const StdString& fileName)
615    {
616      std::filebuf* fb = m_infoStream.rdbuf();
617      openStream(fileName, ".out", fb);
[490]618
[523]619      info.write2File(fb);
620      report.write2File(fb);
621    }
[490]622
[523]623    //! Write the info logs to standard output
624    void CServer::openInfoStream()
625    {
626      info.write2StdOut();
627      report.write2StdOut();
628    }
[490]629
[523]630    //! Close the info logs file if it opens
631    void CServer::closeInfoStream()
632    {
633      if (m_infoStream.is_open()) m_infoStream.close();
634    }
635
636    /*!
637    * \brief Open a file stream to write the error log
638    * Open a file stream with a specific file name suffix+rank
639    * to write the error log.
640    * \param fileName [in] protype file name
641    */
642    void CServer::openErrorStream(const StdString& fileName)
643    {
644      std::filebuf* fb = m_errorStream.rdbuf();
645      openStream(fileName, ".err", fb);
646
647      error.write2File(fb);
648    }
649
650    //! Write the error log to standard error output
651    void CServer::openErrorStream()
652    {
653      error.write2StdErr();
654    }
655
656    //! Close the error log file if it opens
657    void CServer::closeErrorStream()
658    {
659      if (m_errorStream.is_open()) m_errorStream.close();
660    }
[300]661}
Note: See TracBrowser for help on using the repository browser.