ddscomm.cc File Reference

#include <cstdlib>
#include <unistd.h>
#include "TROOT.h"
#include "TSystem.h"
#include "MessageService/MsgService.h"
#include "Dispatcher/DDS.h"
#include "Dispatcher/DDSClient.h"
#include "Dispatcher/DDSPSStatus.h"

Go to the source code of this file.

Functions

TROOT root ("ddscomm","MINOS Data Dispatcher System communications")
 CVSID ("$Id: ddscomm.cc,v 1.9 2009/02/28 21:46:12 gmieg Exp $")
int main (int argc, char **argv)

Function Documentation

CVSID ( "$Id: ddscomm.  cc,
v 1.9 2009/02/28 21:46:12 gmieg Exp $"   
)
int main ( int  argc,
char **  argv 
)

Definition at line 42 of file ddscomm.cc.

References DDS::AsString(), exit(), DDSClient::GetPSStatus(), DDSClient::GetStatus(), gSystem(), hostname, Msg::kInfo, DDS::kMessageUnknown, DDS::kOk, DDS::kPort, DDS::kShutdown, DDS::kStatus, Munits::ms, MSGSTREAM, port, and Lit::Print().

00042                                 {
00043 
00044   MsgStream& ms = MSGSTREAM("DDS",Msg::kInfo);
00045 
00046   // Determine host name of current machine, default port #, default msg type
00047   const char* hostname = gSystem -> HostName();  
00048   Int_t port = DDS::kPort;
00049   DDS::EMessageType msgrequest = DDS::kStatus;
00050 
00051   gROOT -> SetBatch(kTRUE);
00052 
00053   // Process the command line arguments
00054   int c;
00055   bool isreport = false;
00056   while ((c = getopt(argc,argv,"i:p:srh")) != -1) {
00057     switch (c) {
00058     case 'i':
00059       hostname = optarg;
00060       break;
00061     case 'p':
00062       port = atoi(optarg);
00063       break;
00064     case 's':
00065       msgrequest = DDS::kShutdown;
00066       break;
00067     case 'r':
00068       msgrequest = DDS::kStatus;
00069       isreport = true;
00070       break;
00071     case 'h':
00072       fprintf(stderr,"usage: %s -i<host ip> -p<port #> -r -s\n",argv[0]);
00073       fprintf(stderr," -i: ip address of ddsparentserver (default is local ip)\n");
00074       fprintf(stderr," -p: port # ddsparentserver listens on (default is %i)\n",DDS::kPort);
00075       fprintf(stderr," -r: report full status of ddsparentserver\n");
00076       fprintf(stderr," -s: shutdown ddsparentserver\n");
00077       fprintf(stderr," -h: print this message\n");
00078       fprintf(stderr,"no opt: prints brief status of ddsparentserver\n");
00079       exit(0);
00080       break;
00081     default:
00082       fprintf(stderr,"unknown command line option:%c\n",(char)optopt);
00083       exit(1);
00084       break;
00085     }
00086   }
00087 
00088   int retstat=0;
00089   DDSClient* ddsclient = 0;
00090   if (msgrequest != DDS::kMessageUnknown) {
00091 
00092     const DDSPSStatus* psstatus = 0;
00093     switch (msgrequest) {
00094     
00095     case DDS::kShutdown:
00096       ms << "Sending shutdown message to parent server on host " 
00097          << hostname << " port " << port << "." << endl;
00098       // Need to fix how this is done
00099       ddsclient = new DDSClient(hostname,port,msgrequest);
00100       delete ddsclient;
00101       break;
00102 
00103     case DDS::kStatus:
00104       if ( isreport ) {
00105         ms << "Request full status report from parent server on host " 
00106            << hostname << " port " << port << "." << endl;
00107       }
00108       else {
00109         ms << "Request abbreviated status of parent server on host "
00110            << hostname << " port " << port << "." << endl;
00111       }
00112 
00113       ddsclient = new DDSClient(hostname,port,msgrequest);
00114       ms << "ddsparentserver " << hostname << " port " 
00115          << port << " status " << DDS::AsString(ddsclient->GetStatus()) 
00116          << endl;
00117       psstatus = ddsclient->GetPSStatus();
00118       if ( psstatus && isreport ) psstatus -> Print();
00119        
00120       if ( ddsclient->GetStatus() != DDS::kOk ) {
00121         retstat = 1;
00122       }
00123       delete ddsclient;
00124       
00125       break;
00126 
00127     default:
00128       break;
00129 
00130     }// end of msgrequest switch
00131   }
00132 
00133   return retstat;
00134 
00135 }

TROOT root ( "ddscomm"  ,
"MINOS Data Dispatcher System communications"   
)

Generated on 15 Jul 2018 for loon by  doxygen 1.6.1