Example #1
0
//
// initialize
//
void do_init(int pv_argc, char **ppp_argv) {
    char *lp_arg;
    int   lv_arg;
    bool  lv_attach;
    int   lv_ferr;
    char *lv_delay_s;

    lv_attach = false;
    for (lv_arg = 1; lv_arg < pv_argc; lv_arg++) {
        lp_arg = ppp_argv[lv_arg];
        if (strcmp(lp_arg, "-attach") == 0)
            lv_attach = true;
        else if (strcmp(lp_arg, "-shook") == 0)
            gv_shook = true;
        else if (strcmp(lp_arg, "-v") == 0)
            gv_verbose = true;
    }
    if (lv_attach)
        lv_ferr = msg_init_attach(&pv_argc, &ppp_argv, false, (char *) "$TSID0");
    else
        lv_ferr = msg_init(&pv_argc, &ppp_argv);
    assert(lv_ferr == XZFIL_ERR_OK);

    gv_time_refresh_delay = 200;  // 2 seconds
    lv_delay_s = getenv("TM_IDTMSRV_REFRESH_DELAY_SECONDS");
    if (lv_delay_s != NULL) {
       gv_time_refresh_delay = 100 * (atoi(lv_delay_s));      
    }
    if (gv_verbose){
        printf("TM_IDTMSRV_REFRESH_DELAY_SECONDS is %s.  Setting gv_time_refresh_delay to %d \n", lv_delay_s, gv_time_refresh_delay);
    }   

    if (gv_shook)
        msg_debug_hook("s", "s");
}
Example #2
0
//
// initialize
//
void do_init(int pv_argc, char **ppp_argv) {
    char *lp_arg;
    int   lv_arg;
    bool  lv_attach;
    int   lv_ferr;

    lv_attach = false;
    for (lv_arg = 1; lv_arg < pv_argc; lv_arg++) {
        lp_arg = ppp_argv[lv_arg];
        if (strcmp(lp_arg, "-attach") == 0)
            lv_attach = true;
        else if (strcmp(lp_arg, "-shook") == 0)
            gv_shook = true;
        else if (strcmp(lp_arg, "-v") == 0)
            gv_verbose = true;
    }
    if (lv_attach)
        lv_ferr = msg_init_attach(&pv_argc, &ppp_argv, false, (char *) "$TSID0");
    else
        lv_ferr = msg_init(&pv_argc, &ppp_argv);
    assert(lv_ferr == XZFIL_ERR_OK);

    if (gv_shook)
        msg_debug_hook("s", "s");
}
Example #3
0
//
// initialize
//
void do_init(int argc, char **argv) {
    int   arg;
    char *argp;
    bool  attach;
    int   ferr;

    attach = false;
    for (arg = 1; arg < argc; arg++) {
        argp = argv[arg];
        if (strcmp(argp, "-attach") == 0)
            attach = true;
        else if (strcmp(argp, "-shook") == 0)
            shook = true;
        else if (strcmp(argp, "-v") == 0)
            verbose = true;
    }
    if (attach)
        ferr = msg_init_attach(&argc, &argv, false, (char *) "$TSID0");
    else
        ferr = msg_init(&argc, &argv);
    assert(ferr == XZFIL_ERR_OK);

    if (shook)
        msg_debug_hook("s", "s");
}
Int32 main(Int32 argc, char **argv)
{
  dovers(argc, argv);

  IdentifyMyself::SetMyName(I_AM_ESP);
  msg_debug_hook("arkesp", "esp.hook");

  try {
    file_init(&argc, &argv);
  }
  catch (SB_Fatal_Excep &e) {
    exit(1);
  }
  try {
    file_mon_process_startup(true);

    // setup log4cpp, need to be done here so initLog4cpp can have access to 
    // process information since it is needed to compose the log name
    // the log name for the ESP should be based on the master process information
    // since the master and all its subordinate processes log to the same
    // log4cpp file
    QRLogger::instance().setModule(QRLogger::QRL_ESP);
    QRLogger::instance().initLog4cpp("log4cpp.trafodion.masterexe.config");
  }
  catch (SB_Fatal_Excep &e) {
    SQLMXLoggingArea::logExecRtInfo(__FILE__, __LINE__, e.what(), 0);
    exit(1);
  }

  atexit(my_mpi_fclose);
  // Leave this commented out unless you need to debug the argument
  // cracking code below and can't rely on the -debug option.  This
  // allows the esp to put up a dialog box and then you can manually
  // force the esp into debug.
  if (getenv("SQL_MSGBOX_PROCESS") != NULL)
	 { MessageBox( NULL, "Server: Process Launched",
		       "tdm_arkesp", MB_OK|MB_ICONINFORMATION );};

  NABoolean fastStart = TRUE;
  Int32 currArg = 1;
  while (currArg < argc && fastStart == TRUE)
  {
    if (strcmp("-noespfaststart", argv[currArg]) == 0)
      fastStart = FALSE;
    currArg++;
  }
  short retCode;
  if (fastStart)
  {
    GuaReceiveFastStart *guaReceiveFastStart = new GuaReceiveFastStart();
    retCode = runESP(argc,argv,guaReceiveFastStart);
  }
  else
    retCode = runESP(argc,argv);
  ENDTRANSACTION();

  return retCode;

}
Int32 main(Int32 argc, char **argv)
{
  dovers(argc, argv);

  IdentifyMyself::SetMyName(I_AM_ESP);
  msg_debug_hook("arkesp", "esp.hook");

  try {
    file_init(&argc, &argv);
  }
  catch (SB_Fatal_Excep &e) {
    exit(1);
  }
  try {
    file_mon_process_startup(true);

    // Initialize log4cxx 
    QRLogger::initLog4cxx(QRLogger::QRL_ESP);
  }
  catch (SB_Fatal_Excep &e) {
    SQLMXLoggingArea::logExecRtInfo(__FILE__, __LINE__, e.what(), 0);
    exit(1);
  }

  atexit(my_mpi_fclose);
  // Leave this commented out unless you need to debug the argument
  // cracking code below and can't rely on the -debug option.  This
  // allows the esp to put up a dialog box and then you can manually
  // force the esp into debug.
  if (getenv("SQL_MSGBOX_PROCESS") != NULL)
	 { MessageBox( NULL, "Server: Process Launched",
		       "tdm_arkesp", MB_OK|MB_ICONINFORMATION );};

  NABoolean fastStart = TRUE;
  Int32 currArg = 1;
  while (currArg < argc && fastStart == TRUE)
  {
    if (strcmp("-noespfaststart", argv[currArg]) == 0)
      fastStart = FALSE;
    currArg++;
  }
  short retCode;
  if (fastStart)
  {
    GuaReceiveFastStart *guaReceiveFastStart = new GuaReceiveFastStart();
    retCode = runESP(argc,argv,guaReceiveFastStart);
  }
  else
    retCode = runESP(argc,argv);
  ENDTRANSACTION();

  return retCode;

}
short my_mpi_setup (int argc, char* argv[] )
{
#ifdef MPI_
  file_init_attach(&argc,&argv,TRUE,"");
  file_mon_process_startup(FALSE);
#endif

  msg_debug_hook("NGG", "ngg.hook");

  return 0;
}
//
// initialize
//
void do_init(int argc, char **argv) {
    int   arg;
    char *argp;
    int   ferr;

    ferr = msg_init(&argc, &argv);
    assert(ferr == XZFIL_ERR_OK);

    for (arg = 1; arg < argc; arg++) {
        argp = argv[arg];
        if (strcmp(argp, "-chook") == 0)
            chook = true;
        else if (strcmp(argp, "-cb") == 0)
            cb = true;
        else if (strcmp(argp, "-client") == 0) {
        } else if (strcmp(argp, "-id") == 0) {
            idt = true;
        } else if (strcmp(argp, "-inst") == 0) {
            arg++;
        } else if (strcmp(argp, "-loop") == 0) {
            if ((arg + 1) < argc) {
               arg++;
               argp = argv[arg];
               loop = atoi(argp);
            } else {
                printf("-loop expecting <loop>\n");
                exit(1);
            }
        } else if (strcmp(argp, "-maxcp") == 0) {
            arg++;
        } else if (strcmp(argp, "-maxsp") == 0) {
            arg++;
        } else if (strcmp(argp, "-name") == 0) {
            arg++;
        } else if (strcmp(argp, "-v") == 0) {
            verbose = true;
        } else {
            printf("unknown argument=%s\n", argp);
            exit(1);
        }
    }

    if (chook)
        msg_debug_hook("c", "c");
    if (cb)
        do_reg_hash_cb(do_cb);

    ferr = msg_mon_process_startup(false);  // system messages?
    assert(ferr == XZFIL_ERR_OK);
}
Example #8
0
int main(int argc, char *argv[]) {
    bool  chook = false;
    int   ferr;
    int   loop = 10;
    TAD   zargs[] = {
      { "-chook",     TA_Bool, TA_NOMAX,    &chook     },
      { "-client",    TA_Ign,  TA_NOMAX,    NULL       },
      { "-loop",      TA_Int,  TA_NOMAX,    &loop      },
      { "-maxth",     TA_Int,  MAX_THR,     &maxth     },
      { "-server",    TA_Ign,  TA_NOMAX,    NULL       },
      { "-tol",       TA_Int,  TA_NOMAX,    &to_tol    },
      { "-v",         TA_Bool, TA_NOMAX,    &verbose   },
      { "",           TA_End,  TA_NOMAX,    NULL       }
    };

    msfs_util_init(&argc, &argv, msg_debug_hook);
    arg_proc_args(zargs, false, argc, argv);
    if (chook)
        msg_debug_hook("c", "c");
    util_test_start(true);
    ferr = msg_mon_process_startup(true);  // system messages?
    TEST_CHK_FEOK(ferr);
    util_gethostname(my_name, sizeof(my_name));

#if 0 // reproduce bug 1570
    // - add sleep(1) in sb_timer_setitimer when pv_to != 0
#endif
    test_cancel();
    test_timers();
    test_timers_alloc();
    test_thread1();
    test_cancel_cb();
    test_timers_cb();
    test_thread3();
#if 0 // reproduce bug 728
// - must add sleep(1) after call-to-sb_timer_comp_q_remove() in MSG_LISTEN_
    test_thread2();
#endif

    ferr = msg_mon_process_shutdown();
    TEST_CHK_FEOK(ferr);
    util_test_finish(true);
    return 0;
}
Example #9
0
short my_mpi_setup (int* argc, char** argv[] )
{
  static short bMpiSetupCalled = 0;
  short retcode = 0;

  if (bMpiSetupCalled == 1) {
    return 0;
  }

  bMpiSetupCalled = 1;
#ifdef MPI_
  file_init_attach(argc,argv,1,"");
  retcode = file_mon_process_startup(1); /* server? */      /* ADD */
#endif

  if (retcode == 0) {
    msg_debug_hook("NGG", "ngg.hook");
  }

  return retcode;
}
Example #10
0
Int32 main(Int32 argc, char *argv[])
{
  dovers(argc, argv);

  try
  {
    file_init_attach(&argc, &argv, TRUE, (char *)"");
    sq_fs_dllmain();
    msg_debug_hook("tdm_arkqms", "tdm_arkqms.hook");
    file_mon_process_startup(true);
    atexit(my_mpi_fclose);
  }
  // LCOV_EXCL_START :rfi
  catch (...)
  {
    cerr << "Error while initializing messaging system. Exiting..." << endl;
    exit(1);
  }
  // LCOV_EXCL_STOP

  NABoolean performSMDInit = FALSE;
  NABoolean performXMLInit = FALSE;

  // Uncomment to allow time to attach debugger before initialization. The
  // MessageBox thing below uses an env var and won't work unless QMS is run
  // from a command-line in the shell that defines the env var.
  //Sleep(30000);

  QRLogger::instance().setModule(QRLogger::QRL_QMS);
  QRLogger::instance().initLog4cxx("log4cxx.qms.config");
 
  QRLogger::log(CAT_QMS_MAIN, LL_INFO, "=================================================");
  QRLogger::log(CAT_QMS_MAIN, LL_INFO, "=================================================");
  QRLogger::log(CAT_QMS_MAIN, LL_INFO, "=================================================");
  QRLogger::log(CAT_QMS_MAIN, LL_INFO, "QMS process was started.");
  QRLogger::log(CAT_QMS_MAIN, LL_INFO, "QMS invoked with %d arguments.", argc);
  for (Int32 i=0; i<argc; i++)
    QRLogger::log(CAT_QMS_MAIN, LL_DEBUG, "  argument %d = %s", i, argv[i]);

  IpcEnvironment* env = NULL;
  QmsGuaReceiveControlConnection* conn = NULL;

  // If invoked via the message interface, -oss will be the program
  // parameter after the program name.
  NABoolean commandLineInterface = (strncmp(argv[1], "-guardian", 9) != 0);

  // For message interface, initialize IPC so it will return to qmm from the
  // process creation code before we begin qms initialization.
  if (!commandLineInterface)
  {
    conn = initializeIPC(env);
    QRLogger::log(CAT_QMS_MAIN, LL_DEBUG, "QMS invoked via messaging interface.");
  }
  else
    QRLogger::log(CAT_QMS_MAIN, LL_DEBUG, "QMS invoked via command-line interface.");

  // Create the singleton instances of Qms and QmsInitializer.
  NAHeap qmsHeap("QMS Heap", NAMemory::DERIVED_FROM_SYS_HEAP, (Lng32)131072);
  Qms& qms = *Qms::getInstance(&qmsHeap);
  QmsInitializer& qmsInitializer = *QmsInitializer::getInstance(&qms);

  // If the command line interface was used, batch process the set of requests
  // specified in the input file.
  if (commandLineInterface)
  {
    try
    {
      return QRCommandLineRequest::processCommandLine(argc, argv);
    }
    catch (QRException e)
    {
      // Ignore exceptions for now.
      QRLogger::log(CAT_QMS_MAIN, LL_ERROR, "QMS aborted.");
      return -1;
    }
  }

  cout << "Waiting for messages..." << endl;

  while (TRUE)
    {
      conn->wait();
      //env->getAllConnections()->waitOnAll(IpcInfiniteTimeout, FALSE);
    }

} // End of mainline
Int32 main(Int32 argc, char **argv)
{
  dovers(argc, argv);
  msg_debug_hook("mxsscp", "mxsscp.hook");
  try {
    file_init_attach(&argc, &argv, TRUE, (char *)"");
  }
  catch (SB_Fatal_Excep &e) {
    SQLMXLoggingArea::logExecRtInfo(__FILE__, __LINE__, e.what(), 0);
    exit(1);
  }

  try {
    file_mon_process_startup(true);
  }
  catch (SB_Fatal_Excep &e) {
    SQLMXLoggingArea::logExecRtInfo(__FILE__, __LINE__, e.what(), 0);
    exit(1);
  }

  atexit(my_mpi_fclose);
  // setup log4cxx, need to be done here so initLog4cxx can have access to
  // process information since it is needed to compose the log name
  // the log4cxx log name for this ssmp process  will be
  // based on this process' node number sscp_<nid>.log
  QRLogger::instance().setModule(QRLogger::QRL_SSCP);
  QRLogger::instance().initLog4cxx("log4cxx.trafodion.sscp.config");

  // Synchronize C and C++ output streams
  ios::sync_with_stdio();

#ifdef _DEBUG
  // Redirect stdout and stderr to files named in environment
  // variables
  const char *stdOutFile = getenv("SQ_SSCP_STDOUT");
  const char *stdErrFile = getenv("SQ_SSCP_STDERR");
  Int32 fdOut = -1;
  Int32 fdErr = -1;

  if (stdOutFile && stdOutFile[0])
  {
    fdOut = open(stdOutFile,
                 O_WRONLY | O_APPEND | O_CREAT | O_SYNC,
                 S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
    if (fdOut >= 0)
    {
      fprintf(stderr, "[Redirecting MXSSCP stdout to %s]\n", stdOutFile);
      fflush(stderr);
      dup2(fdOut, fileno(stdout));
    }
    else
    {
      fprintf(stderr, "*** WARNING: could not open %s for redirection: %s.\n",
              stdOutFile, strerror(errno));
    }
  }

  if (stdErrFile && stdErrFile[0])
  {
    fdErr = open(stdErrFile,
                 O_WRONLY | O_APPEND | O_CREAT | O_SYNC,
                 S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
    if (fdErr >= 0)
    {
      fprintf(stderr, "[Redirecting MXUDR stderr to %s]\n", stdErrFile);
      fflush(stderr);
      dup2(fdErr, fileno(stderr));
    }
    else
    {
      fprintf(stderr, "*** WARNING: could not open %s for redirection: %s.\n",
              stdErrFile, strerror(errno));
    }
  }
  runServer(argc, argv);

  if (fdOut >= 0)
  {
    close(fdOut);
  }
  if (fdErr >= 0)
  {
    close(fdErr);
  }
#else
  runServer(argc, argv);
#endif
  return 0;
}
Example #12
0
Int32 main (Int32 argc, char *argv[])
{
  dovers(argc, argv);

  // check this before file_init_attach overwrites the user env
  NABoolean sync_with_stdio = (getenv("NO_SYNC_WITH_STDIO") == NULL);

  try
  {
    file_init_attach(&argc, &argv, TRUE, (char *)"");
    msg_debug_hook("sqlci", "sqlci.hook");
    file_mon_process_startup2(true, false);
    atexit(my_mpi_fclose);
  }
  catch (...)
  {
    cerr << "Error while initializing messaging system. Please make sure Trafodion is started and up. Exiting..." << endl;
    exit(1);
  }

  if (sync_with_stdio)
    ios::sync_with_stdio();


  // Establish app user id from the current NT process user identity.
  // This must be done explicitly until the "shadow-process" mechanism
  // is fully implemented.  (It is done too late in cli/Context.cpp.)
  // FX: I'm not sure whether the following code applies
  // 	 to NT only.

 
  // process command line options
  char * in_filename = NULL;
  char * input_string = NULL;
  char * out_filename = NULL;
  char * sock_port = NULL;
  NAString user_name("");
  Int32 i = 1;
  for (; i < argc; i++)
    processOption(argc, argv, 
                           i, 
                          (const char *&)in_filename, 
                          (const char *&)input_string,
                          (const char *&)out_filename,
                          (char *&)sock_port,
                          user_name
      );

  if (sock_port) 
  {
  }  

  // create a SQLCI object
  SqlciEnv * sqlci = new SqlciEnv();
  global_sqlci_env = sqlci;

  if (user_name.length() > 0)
    sqlci->setUserNameFromCommandLine(user_name);


  if (setjmp(ExportJmpBuf))
  {

    printf("\nSQLCI terminating due to assertion failure");
    delete sqlci;
    exit(1); // NAExit(1);
  } 

  ExportJmpBufPtr = &ExportJmpBuf;

  if ((!in_filename) &&
      (out_filename))
    {
      sqlci->setNoBanner(TRUE);

      // create a logfile with the name out_filename.
      // Do not do that if an in_filename is specified. Users should
      // put the log command in the input file.
      char * logf = new char[strlen("LOG ") + 
			    strlen(out_filename) + 
			    strlen(" clear;") +
			    1];
      sprintf(logf, "LOG %s clear;", out_filename);
      sqlci->run(NULL, logf);
      delete logf;

      sqlci->get_logfile()->setNoDisplay(TRUE);
    }

  // setup log4cxx, need to be done here so initLog4cxx can have access to
  // process information since it is needed to compose the log name
  QRLogger::initLog4cxx(QRLogger::QRL_MXEXE);

  // run it -- this is where the action is!
  if (in_filename || input_string)
    sqlci->run(in_filename, input_string);
  else
    sqlci->run();
    
  if ((!in_filename) &&
      (out_filename))
    {
      sqlci->run(NULL, (char *)"LOG;");
    }

  // Now we are done, delete SQLCI object
  delete sqlci;
#ifdef _DEBUG_RTS
  removeProcess();
#endif
#ifdef _DEBUG
  // Delete all contexts
  GetCliGlobals()->deleteContexts();
#endif  // _DEBUG
  return 0;
}
Example #13
0
int main(int argc, char *argv[]) {
    bool      client = false;
    bool      client2 = false;
    int       close_count;
    int       cnid;
    int       cpid;
    int       ferr;
    bool      fin = false;
    int       inx;
    int       lerr;
    int       loop = 10;
    int       oid;
    char     *sname = (char *) "$srv";
    BMS_SRE   sre;
    bool      verbose = false;
    TAD       zargs[] = {
      { "-client",    TA_Bool, TA_NOMAX,    &client    },
      { "-client2",   TA_Bool, TA_NOMAX,    &client2   },
      { "-loop",      TA_Int,  TA_NOMAX,    &loop      },
      { "-server",    TA_Ign,  TA_NOMAX,    NULL       },
      { "-v",         TA_Bool, TA_NOMAX,    &verbose   },
      { "-verbose",   TA_Ign,  TA_NOMAX,    NULL       },
      { "",           TA_End,  TA_NOMAX,    NULL       }
    };

    arg_proc_args(zargs, false, argc, argv);
    ferr = msg_init(&argc, &argv);
    TEST_CHK_FEOK(ferr);
    util_test_start(client);
    ferr = msg_mon_process_startup(true); // system messages
    TEST_CHK_FEOK(ferr);
    if (client) {
        msg_debug_hook("c", "c");
        sprintf(cprog, "%s/%s", getenv("PWD"), argv[0]);
        for (inx = 0; inx < argc; inx++) {
            if (strcmp(argv[inx], "-client") == 0)
                argv[inx] = (char *) "-client2";
        }
        for (inx = 0; inx < loop; inx++) {
            if (verbose)
                printf("cli: newproc, inx=%d\n", inx);
            sprintf(cname, "$cli%d", inx);
            cnid = -1;
            ferr = msg_mon_start_process(cprog,                  // prog
                                         cname,                  // name
                                         NULL,                   // ret_name
                                         argc,                   // argc
                                         argv,                   // argv
                                         TPT_REF(cphandle),      // phandle
                                         false,                  // open
                                         NULL,                   // oid
                                         MS_ProcessType_Generic, // type
                                         0,                      // priority
                                         false,                  // debug
                                         false,                  // backup
                                         &cnid,                  // nid
                                         &cpid,                  // pid
                                         NULL,                   // infile
                                         NULL);                  // outfile
            TEST_CHK_FEOK(ferr);
        }
    } else if (client2) {
        if (verbose)
            printf("cli: open\n");
        ferr = msg_mon_open_process(sname,  // name
                                    TPT_REF(sphandle),
                                    &oid);
        TEST_CHK_FEOK(ferr);
    } else {
        msg_mon_enable_mon_messages(true);
        close_count = 0;
        for (inx = 0; !fin; inx++) {
            do {
                lerr = XWAIT(LREQ, -1);
                lerr = BMSG_LISTEN_((short *) &sre, // sre
                                    0,              // listenopts
                                    0);             // listenertag
            } while (lerr == BSRETYPE_NOWORK);
            if (sre.sre_flags & XSRE_MON) {
                ferr = BMSG_READDATA_(sre.sre_msgId,  // msgid
                                      recv_buffer,    // reqdata
                                      BUFSIZ);        // bytecount
                MS_Mon_Msg *msg = (MS_Mon_Msg *) recv_buffer;
                if (verbose)
                    printf("srv: rcvd mon msg=%d, inx=%d\n", msg->type, inx);
                if (msg->type == MS_MsgType_Close)
                    if (++close_count >= loop)
                        fin = true;
            }
            if (verbose)
                printf("srv: reply, inx=%d\n", inx);
            BMSG_REPLY_(sre.sre_msgId,       // msgid
                        NULL,                // replyctrl
                        0,                   // replyctrlsize
                        NULL,                // replydata
                        0,                   // replydatasize
                        0,                   // errorclass
                        NULL);               // newphandle
        }
    }

    ferr = msg_mon_process_shutdown();
    TEST_CHK_FEOK(ferr);
    util_test_finish(client);
    return 0;
}