Logo Search packages:      
Sourcecode: maxdb-7.5.00 version File versions

int main ( int  argcIn,
char *  argvIn[] 
)

main function

This program is can either be started from the command line manually or the DBMServer starts it if DBM parameter RunEventDispatcher is set to "yes". DB connect data must be on the command line (with -d, -u, -n). Reads arguments from command line and initializes the event dispatcher class.

Definition at line 886 of file DBMCli_EventDispatcherMain.cpp.

References Tools_ParameterParser::addFormalParameter(), SAPDBErr_MessageList::ClearMessageList(), DBMCli_EventDispatcher::DBMCli_EventDispatcher(), DBMCli_EventDispatcher::DumpError(), DBMCli_EventDispatcher::DumpInfo(), Tools_PipeCall::ErrorReason(), Tools_Parameter::getName(), Tools_Parameter::getValue(), SAPDBErr_MessageList::ID(), SAPDBErr_MessageList::IsEmpty(), DBMCli_EventDispatcher::isListening(), Tools_ParameterParser::isParameterlistValid(), Tools_ParameterParser::isParameterSet(), DBMCli_EventListener::LastMessage(), SAPDBErr_MessageList::Message(), SAPDBErr_MessageList::NextMessage(), PRG_FATAL, DBMCli_Logo::PrintLogo(), Tools_ParameterParser::printUsage(), DBMCli_Logo::PrintVersion(), Tools_PipeCall::ReadArguments(), DBMCli_EventDispatcher::Run(), Tools_ParameterParser::setActualParameters(), DBMCli_EventingBranding::sProductName, DBMCli_EventingBranding::sVersionLabel, and SAPDBErr_MessageList::Type().

{
    int        argc            = 0; 
    char **    argv            = NULL;
    int nRC = Tools_PipeCall::ReadArguments(
            argcIn,
            argvIn,
            argc,
            argv,
            Tools_PipeCall::ReadXUser | Tools_PipeCall::PromptForUserOnRequest);

    if( nRC != 0 ) {
        fprintf(stderr, "%s: could not read arguments from commandline. reason: %s\n",
            argvIn[0],
            Tools_PipeCall::ErrorReason());
        fflush(stderr);
        exit(1);
    }


    // read arguments
    pParameterParser  = new Tools_ParameterParser();

    DBMCli_String sName, sDesc;
    //node
    sName = "n";
    sDesc = "node      (name of servernode)";
    Tools_Parameter node(sName, sDesc, false);
    //dbname
    sName = "d";
    sDesc = "dbname    (name of datbase)";
    Tools_Parameter db(sName, sDesc);
    //userpw
    sName = "u";
    sDesc = "user,pwd  (user for authorization; prompt if empty)";
    Tools_Parameter userpw(sName, sDesc, false);
    //configuration file
    sName = "cf";
    sDesc = "cfgfile   (configuration file)";
    Tools_Parameter cfgfile(sName, sDesc, false);
    //log file
    sName = "lf";
    sDesc = "logfile   (log file)";
    Tools_Parameter logfile(sName, sDesc, false);
    //verbosity
    sName = "q";
    sDesc = "quiet     (no output to stdout)";
    Tools_Parameter quietmode(sName, sDesc, false, false);
    //reconnect after loss of connection
    sName = "r";
    sDesc = "reconnect (try reconnect after loss of connection)";
    Tools_Parameter reconnect(sName, sDesc, false, false);
    //
    sName = "U";
    sDesc = "user_key  (from XUSER)";
    Tools_Parameter xuserkey(sName, sDesc, false, true);

    pParameterParser->addFormalParameter(node);
    pParameterParser->addFormalParameter(db);
    pParameterParser->addFormalParameter(userpw);
    pParameterParser->addFormalParameter(xuserkey);
    pParameterParser->addFormalParameter(logfile);
    pParameterParser->addFormalParameter(cfgfile);
    pParameterParser->addFormalParameter(quietmode);
    pParameterParser->addFormalParameter(reconnect);

    pParameterParser->setActualParameters( argc, argv );

    if( !pParameterParser->isParameterSet(quietmode.getName()) ) {
        DBMCli_Logo oLogo;
        oLogo.PrintLogo(DBMCli_EventingBranding::sProductName + ", Dispatcher", true);
        oLogo.PrintVersion(DBMCli_EventingBranding::sVersionLabel, true);
    }

    if( !pParameterParser->isParameterlistValid() ){
        pParameterParser->printUsage(stderr);
        delete pParameterParser;
        exit(PRG_FATAL);
    }

  SAPDBErr_MessageList   oMessageList;
  SAPDBErr_MessageList* pMsg(&oMessageList);
  oMessageList.ClearMessageList();

  int exitCode(0);

  // parameter list was valid, so create dispatcher
  pDispatcher = new DBMCli_EventDispatcher(node.getValue(),
                                           db.getValue(),
                                           userpw.getValue(),
                                           cfgfile.getValue(),
                                           logfile.getValue(),
                                           pParameterParser->isParameterSet(reconnect),
                                           pParameterParser->isParameterSet(quietmode),
                                           oMessageList);

  // did something go wrong during dispatcher creation?
  if( !(pDispatcher->isListening() && oMessageList.IsEmpty()) ) {
    exitCode = PRG_FATAL;
  }
  else {
    // start listening
    pDispatcher->Run();

    if (!pDispatcher->LastMessage().IsEmpty()) {
        const SAPDBErr_MessageList* pMsg = &(pDispatcher->LastMessage());
      
        if( !oMessageList.IsEmpty() ) {
            bool foundError(false);
            pDispatcher->DumpInfo("\nmessages during listening:");      
            while( pMsg != NULL ) {
                char buf[32];
                sprintf(buf, "%d", pMsg->ID());
                if( pMsg->Type() == SAPDBErr_MessageList::Error ) {
                    foundError = true;
                    pDispatcher->DumpError("\n%s (errorcode %d)\n", pMsg->Message(), buf);
                }
                else {
                    pDispatcher->DumpInfo("\n%s (errorcode %d)\n", pMsg->Message(), buf);
                }
                pMsg = pMsg->NextMessage();
            }
            if( foundError )
                exitCode = PRG_FATAL;
        }
    } // end if
  }
  delete pDispatcher;
  delete pParameterParser;
  return exitCode;
} // end main


Generated by  Doxygen 1.6.0   Back to index