(file) Return to StressTestController.cpp CVS log (file) (dir) Up to [Pegasus] / pegasus / test / StressTestController

Diff for /pegasus/test/StressTestController/StressTestController.cpp between version 1.1.2.2 and 1.1.2.3

version 1.1.2.2, 2006/04/19 22:00:44 version 1.1.2.3, 2006/04/24 19:15:09
Line 53 
Line 53 
 // //
 //Windows //Windows
 // //
 #ifdef PEGASUS_PLATFORM_WIN32_IX86_MSVC  #ifdef PEGASUS_OS_TYPE_WINDOWS
 #include <windows.h>     /* for DWORD etc. */ #include <windows.h>     /* for DWORD etc. */
 typedef DWORD pid_t;     /* getpid() and others */ typedef DWORD pid_t;     /* getpid() and others */
 #include <process.h> #include <process.h>
Line 78 
Line 78 
  
 static void endAllTests(int signum); static void endAllTests(int signum);
  
 static void cleanupProcess(void);  static void cleanupProcess();
  
 static String convertUint64toString(Uint64 x); static String convertUint64toString(Uint64 x);
  
Line 98 
Line 98 
 /** /**
     The command name.     The command name.
  */  */
 const char   StressTestControllerCommand::COMMAND_NAME []    = "TestStressTestController";  const char StressTestControllerCommand::COMMAND_NAME [] =
                 "TestStressTestController";
  
  
 /** /**
Line 106 
Line 107 
 */ */
 char StressTestControllerCommand::FILENAME []                = "default_stresstest.conf"; char StressTestControllerCommand::FILENAME []                = "default_stresstest.conf";
 char StressTestControllerCommand::TESTDIR[]                  = "/test/"; char StressTestControllerCommand::TESTDIR[]                  = "/test/";
 char StressTestControllerCommand::STRESSTESTDIR[]            = "/StressTestController/";  char StressTestControllerCommand::STRESSTESTDIR[] = "StressTestController/";
 char StressTestControllerCommand::LOGDIR[]                   = "/log/";  char StressTestControllerCommand::LOGDIR[] = "log/";
 char StressTestControllerCommand::BINDIR[]                   = "/bin/"; char StressTestControllerCommand::BINDIR[]                   = "/bin/";
 char StressTestControllerCommand::DEFAULT_CFGDIR[]           = "/test/StressTestController/";  char StressTestControllerCommand::DEFAULT_CFGDIR[] =
 char StressTestControllerCommand::DEFAULT_LOGDIR[]           = "/test/StressTestController/log/";        STRESSTEST_DEFAULTCFGDIR;
 char StressTestControllerCommand::DEFAULT_TMPDIR[]           = "/test/StressTestController/tmp/";  char StressTestControllerCommand::DEFAULT_LOGDIR[] =
            "/test/StressTestController/log/";
   char StressTestControllerCommand::DEFAULT_TMPDIR[] =
            "/test/StressTestController/tmp/";
  
 String DEFAULT_BINDIR                                        = String::EMPTY; String DEFAULT_BINDIR                                        = String::EMPTY;
  
Line 315 
Line 319 
 /** /**
  * Message resource name  * Message resource name
  */  */
 static const char MSG_PATH []                                = "pegasus/pegasusCLI";  
 static const char PASSWORD_PROMPT []                         = static const char PASSWORD_PROMPT []                         =
                                                               "Please enter your password: ";                                                               "Please enter your password: ";
 static const char PASSWORD_BLANK []                          = static const char PASSWORD_BLANK []                          =
Line 370 
Line 373 
     _propertyTable       = new Table;     _propertyTable       = new Table;
  
     // Client Information     // Client Information
     _clientCommands      = NULL;      _clientCommands = 0;
     _clientDurations     = NULL;      _clientDurations = 0;
     _clientDelays        = NULL;      _clientDelays = 0;
  
     // Get environment variables:     // Get environment variables:
     //     //
     pegasusRoot          = getenv("PEGASUS_ROOT");  
     pegasusHome          = getenv("PEGASUS_HOME");     pegasusHome          = getenv("PEGASUS_HOME");
  
     DEFAULT_BINDIR       = String(pegasusHome);     DEFAULT_BINDIR       = String(pegasusHome);
     DEFAULT_BINDIR.append(BINDIR);     DEFAULT_BINDIR.append(BINDIR);
  
     StressTestLogFile    = String::EMPTY;      _stressTestLogFile = String::EMPTY;
  
     StressTestClientPIDFile      = String::EMPTY;      _stressTestClientPIDFile = String::EMPTY;
  
     StressTestClientLogFile      = String::EMPTY;      _stressTestClientLogFile = String::EMPTY;
  
     tmpStressTestClientPIDFile   = String::EMPTY;      _tmpStressTestClientPIDFile = String::EMPTY;
  
  
  
     usage                = String (_USAGE);      _usage = String (_USAGE);
  
     usage.append (COMMAND_NAME);      _usage.append (COMMAND_NAME);
 #ifndef DISABLE_SUPPORT_FOR_REMOTE_CONNECTIONS #ifndef DISABLE_SUPPORT_FOR_REMOTE_CONNECTIONS
     usage.append (" [ -");      _usage.append (" [ -");
     usage.append (_OPTION_SSL);      _usage.append (_OPTION_SSL);
     usage.append (" ] [ -");      _usage.append (" ] [ -");
     usage.append (_OPTION_HOSTNAME);      _usage.append (_OPTION_HOSTNAME);
     usage.append (" hostname ] [ -");      _usage.append (" hostname ] [ -");
     usage.append (_OPTION_PORTNUMBER);      _usage.append (_OPTION_PORTNUMBER);
     usage.append (" portnumber ]\n                            [ -");      _usage.append (" portnumber ]\n                            [ -");
     usage.append (_OPTION_USERNAME);      _usage.append (_OPTION_USERNAME);
     usage.append (" username ] [ -");      _usage.append (" username ] [ -");
     usage.append (_OPTION_PASSWORD);      _usage.append (_OPTION_PASSWORD);
     usage.append (" password ]");      _usage.append (" password ]");
 #endif #endif
     usage.append (" [ --");      _usage.append (" [ --");
     usage.append (LONG_HELP);      _usage.append (LONG_HELP);
     usage.append(" ]\n                            [ --").append(LONG_VERSION).append(" ]");      _usage.append(" ]\n");
     usage.append(" [ --").append(LONG_VERBOSE).append(" ]").append(" [<config_filename>] \n");      _usage.append("                            ");
       _usage.append("[ --").append(LONG_VERSION).append(" ]");
     usage.append("Options : \n");      _usage.append(" [ --").append(LONG_VERBOSE).append(" ]").append(\
     usage.append("    -h         - Connect to CIM Server on specified hostname\n");          " [<config_filename>] \n");
     usage.append("    --help     - Display this help message\n");  
     usage.append("    -p         - Connect to CIM Server on specified portnumber\n");      _usage.append("Options : \n");
     usage.append("    -s         - Use SSL protocol between 'stressTestController' client\n");      _usage.append("    -h         - Connect to CIM Server on specified ");
     usage.append("                 and the CIM Server\n");      _usage.append("hostname. \n");
     //usage.append("    -t         - Specify response timeout value in milliseconds\n");      _usage.append("    --help     - Display this help message.\n");
     usage.append("    -u         - Connect to CIM Server using the specified username\n");      _usage.append("    -p         - Connect to CIM Server on specified ");
     usage.append("    --version  - Display CIM Server version number\n");      _usage.append("portnumber.\n");
     usage.append("    --verbose  - Display verbose information\n");      _usage.append("    -s         - Use SSL protocol between Stress Test ");
     usage.append("    -w         - Connect to CIM Server using the specified password\n");      _usage.append("Client\n");
     usage.append("\nOperands : \n");      _usage.append("                 and the CIM Server\n");
     usage.append("   <config_filename>\n");      _usage.append("    -u         - Connect to CIM Server using the specified");
     usage.append("               - Specifies the name of the configuration file that is to be used \n");      _usage.append(" username\n");
     usage.append("                 for the tests.\n");      _usage.append("    --version  - Display CIM Server version number\n");
       _usage.append("    --verbose  - Display verbose information\n");
       _usage.append("    -w         - Connect to CIM Server using the specified");
       _usage.append(" password\n");
       _usage.append("\nOperands : \n");
       _usage.append("   <config_filename>\n");
       _usage.append("               - Specifies the name of the configuration ");
       _usage.append("file that is to be used \n");
       _usage.append("                 for the tests.\n");
  
     setUsage(usage);      setUsage(_usage);
  
 } /* StressTestControllerCommand  */ } /* StressTestControllerCommand  */
  
Line 461 
Line 471 
     ofstream      log_file;     ofstream      log_file;
  
     // opens  the log file     // opens  the log file
     OpenAppend(log_file,StressTestLogFile);      OpenAppend(log_file,_stressTestLogFile);
  
     if (!log_file)     if (!log_file)
     {     {
        if(verboseEnabled)        if(verboseEnabled)
        {        {
           cout<<StressTestControllerCommand::COMMAND_NAME<<"::Cannot get file "<<StressTestLogFile<<endl;              cout<<StressTestControllerCommand::COMMAND_NAME<<
                   "::Cannot get file "<<_stressTestLogFile<<endl;
        }        }
  
     }     }
     log_file<<StressTestControllerCommand::COMMAND_NAME<<":: Preparing to set up parameters: "<<endl;      log_file<<StressTestControllerCommand::COMMAND_NAME<<
           ":: Preparing to set up parameters: "<<endl;
  
     //     //
     //  Construct GetOptString     //  Construct GetOptString
Line 536 
Line 548 
                 //                 //
                 // more than one _configFilePath argument was found                 // more than one _configFilePath argument was found
                 //                 //
                 log_file<<StressTestControllerCommand::COMMAND_NAME<<"::More than one arguement was found "<<endl;                  log_file<<StressTestControllerCommand::COMMAND_NAME<<
                       "::More than one arguement was found "<<endl;
                 log_file.close();                 log_file.close();
                 UnexpectedArgumentException e (                  UnexpectedArgumentException e(getOpts[i].Value());
                                getOpts [i].Value ());  
                 throw e;                 throw e;
             }             }
             _configFilePath = getOpts [i].Value ();             _configFilePath = getOpts [i].Value ();
Line 569 
Line 581 
                          if(verboseEnabled)                          if(verboseEnabled)
                          {                          {
                              cout<<StressTestControllerCommand::COMMAND_NAME;                              cout<<StressTestControllerCommand::COMMAND_NAME;
                              cout<<"::Property Name name already saved: "<<"hostname"<<endl;                               cout<<"::Property Name name already saved: "<<
                                    "hostname"<<endl;
                          }                          }
                     }                     }
                     break;                     break;
                 }                 }
   
                 case _OPTION_PORTNUMBER:                 case _OPTION_PORTNUMBER:
                 {                 {
                     if (getOpts.isSet (_OPTION_PORTNUMBER) > 1)                     if (getOpts.isSet (_OPTION_PORTNUMBER) > 1)
Line 586 
Line 598 
                         DuplicateOptionException e (_OPTION_PORTNUMBER);                         DuplicateOptionException e (_OPTION_PORTNUMBER);
                         throw e;                         throw e;
                     }                     }
   
                     _portNumberStr = getOpts [i].Value ();                     _portNumberStr = getOpts [i].Value ();
   
                     try                     try
                     {                     {
                         getOpts [i].Value (_portNumber);                         getOpts [i].Value (_portNumber);
Line 596 
Line 606 
                     catch (const TypeMismatchException&)                     catch (const TypeMismatchException&)
                     {                     {
                         log_file.close();                         log_file.close();
                         InvalidOptionArgumentException e (_portNumberStr, _OPTION_PORTNUMBER);                          InvalidOptionArgumentException e(
                               _portNumberStr,
                               _OPTION_PORTNUMBER);
                         throw e;                         throw e;
                     }                     }
                     _portNumberSpecified = true;                     _portNumberSpecified = true;
Line 605 
Line 617 
                         if(verboseEnabled)                         if(verboseEnabled)
                         {                         {
                            cout<<StressTestControllerCommand::COMMAND_NAME;                            cout<<StressTestControllerCommand::COMMAND_NAME;
                            cout<<"::Property Name:duplicate name already saved: "<<"port"<<endl;                             cout<<"::Property Name:duplicate name already saved:"
                                  <<"port"<<endl;
                         }                         }
                     }                     }
                     break;                     break;
                 }                 }
   
                 case _OPTION_SSL:                 case _OPTION_SSL:
                 {                 {
                     //                     //
Line 626 
Line 638 
                            if(verboseEnabled)                            if(verboseEnabled)
                            {                            {
                               cout<<StressTestControllerCommand::COMMAND_NAME;                               cout<<StressTestControllerCommand::COMMAND_NAME;
                               cout<<"::Property Name already saved: "<<"port"<<endl;                                cout<<"::Property Name already saved: "<<"port"<<
                                     endl;
                            }                            }
                        }                        }
                     }                     }
Line 635 
Line 648 
                         if(verboseEnabled)                         if(verboseEnabled)
                         {                         {
                             cout<<StressTestControllerCommand::COMMAND_NAME;                             cout<<StressTestControllerCommand::COMMAND_NAME;
                             cout<<"::Property Name already saved: "<<"ssl"<<endl;                              cout<<"::Property Name already saved: "<<"ssl"<<
                                   endl;
                         }                         }
                     }                     }
                     break;                     break;
Line 658 
Line 672 
                         if(verboseEnabled)                         if(verboseEnabled)
                         {                         {
                             cout<<StressTestControllerCommand::COMMAND_NAME;                             cout<<StressTestControllerCommand::COMMAND_NAME;
                             cout<< "::Property Name already saved: "<<"username"<<endl;                              cout<< "::Property Name already saved: "<<
                                   "username"<<endl;
                         }                         }
                     }                     }
                     break;                     break;
                 }                 }
   
                 case _OPTION_PASSWORD:                 case _OPTION_PASSWORD:
                 {                 {
                     if (getOpts.isSet (_OPTION_PASSWORD) > 1)                     if (getOpts.isSet (_OPTION_PASSWORD) > 1)
Line 682 
Line 696 
                         if(verboseEnabled)                         if(verboseEnabled)
                         {                         {
                             cout<<StressTestControllerCommand::COMMAND_NAME;                             cout<<StressTestControllerCommand::COMMAND_NAME;
                             cout<<"::Property Name already saved: "<<"password"<<endl;                              cout<<"::Property Name already saved: "<<
                                   "password"<<endl;
                         }                         }
                     }                     }
                     break;                     break;
Line 695 
Line 710 
                     //  PEP#167 unless an empty '-' is specified                     //  PEP#167 unless an empty '-' is specified
                     //                     //
                     log_file.close();                     log_file.close();
                     String ErrReport = String(StressTestControllerCommand::COMMAND_NAME);                      String ErrReport =
                           String(StressTestControllerCommand::COMMAND_NAME);
                     ErrReport.append("::Invalid or unknown option specified");                     ErrReport.append("::Invalid or unknown option specified");
                     throw StressTestControllerException(ErrReport);                     throw StressTestControllerException(ErrReport);
  
                     //DuplicateOptionException e (_OPTION_PASSWORD);  
                     //throw e;  
                     break;                     break;
                }                }
             }             }
Line 770 
Line 784 
        //        //
        if (!_clientTable[j].lookup(NAME, clientName))        if (!_clientTable[j].lookup(NAME, clientName))
        {        {
             log_file<<StressTestControllerCommand::COMMAND_NAME<<"::Required property NAME not found."<<endl;              log_file<<StressTestControllerCommand::COMMAND_NAME<<
                    "::Required property NAME not found."<<endl;
             return false;             return false;
        }        }
        //        //
Line 789 
Line 804 
               if(_hostNameSpecified)               if(_hostNameSpecified)
               {               {
                   client_command.append(_hostName);                   client_command.append(_hostName);
               } else                  }
                   else
                   {
                   client_command.append(i.value());                   client_command.append(i.value());
           }           }
               }
           else if (String::equalNoCase(i.key(),NAME))           else if (String::equalNoCase(i.key(),NAME))
           {           {
                // should be ignored - already saved using clientName                // should be ignored - already saved using clientName
Line 804 
Line 822 
               if(_portNumberSpecified)               if(_portNumberSpecified)
               {               {
                   client_command.append(_portNumberStr);                   client_command.append(_portNumberStr);
               } else                  }
                   else
                   {
                   client_command.append(i.value());                   client_command.append(i.value());
           }           }
               }
           else if (String::equalNoCase(i.key(),SSL))           else if (String::equalNoCase(i.key(),SSL))
           {           {
               client_command.append(" -");               client_command.append(" -");
Line 859 
Line 880 
                      ||(String::equalNoCase(i.key(),CLIENTDURATION)))                      ||(String::equalNoCase(i.key(),CLIENTDURATION)))
           {           {
                // do nothing here                // do nothing here
                //   - will be utilized to run the clients later.                  //   will be utilized to run the clients later.
           }           }
           else           else
           {           {
Line 874 
Line 895 
         // Include verbose if enabled to clients         // Include verbose if enabled to clients
         //         //
         if(verboseEnabled)         if(verboseEnabled)
           {
                 client_command.append(" -verbose ");                 client_command.append(" -verbose ");
           }
  
         //         //
         // Acquire all the common properties listed in the property table from config file          // Acquire all the common properties listed in the property table
         // and include it as part of the client command as required.          // from config file and include it as part of the client command
         //          // as required.
         for (Table::Iterator k = _propertyTable->start(); k; k++)         for (Table::Iterator k = _propertyTable->start(); k; k++)
         {         {
               String propertyValue = String::EMPTY;               String propertyValue = String::EMPTY;
Line 887 
Line 910 
               // listed for the clients.               // listed for the clients.
               if (!_clientTable[j].lookup(k.key(), propertyValue))               if (!_clientTable[j].lookup(k.key(), propertyValue))
               {               {
   
                   // Include options other than ToleranceLevel                   // Include options other than ToleranceLevel
                   // clientDuration,clientwait and Duration                   // clientDuration,clientwait and Duration
                   // in the command string for the clients.                   // in the command string for the clients.
Line 909 
Line 931 
                       }                       }
               }               }
               //               //
               // Use default duration if one was not specified in the Config file              // Use default duration if one was not specified in the Config file.
               //               //
               if (String::equalNoCase(k.key(),DURATION))               if (String::equalNoCase(k.key(),DURATION))
               {               {
                   duration = atof(k.value().getCString());                   duration = atof(k.value().getCString());
               } else              }
               else
               {
                   duration = _duration;                   duration = _duration;
               }
         } /* for (Table::Iterator k = _propertyTable->start(); k; k++) */         } /* for (Table::Iterator k = _propertyTable->start(); k; k++) */
  
         //         //
         // Looking up table while ignoring cases for Client Duration/Client Wait          // Looking up table while ignoring cases for Client Duration/Wait.
         //         //
         for (Table::Iterator k = _clientTable[j].start(); k; k++)         for (Table::Iterator k = _clientTable[j].start(); k; k++)
         {         {
             // Overwrite duration if client duration set             // Overwrite duration if client duration set
             if (String::equalNoCase(k.key(),CLIENTDURATION))             if (String::equalNoCase(k.key(),CLIENTDURATION))
               {
                   duration = atof(k.value().getCString());                   duration = atof(k.value().getCString());
               }
             if (String::equalNoCase(k.key(),CLIENTWAIT))             if (String::equalNoCase(k.key(),CLIENTWAIT))
               {
                   delay = atof(k.value().getCString());                   delay = atof(k.value().getCString());
         }         }
           }
  
        //        //
        //  Save the generated command to corresponding element in clientCommand array          // Save the generated command to corresponding element in the
           // clientCommand array.
        //        //
        _clientCommands[j]     = client_command;        _clientCommands[j]     = client_command;
  
Line 944 
Line 974 
        //        //
        // Saving logs        // Saving logs
        //        //
        log_file<<StressTestControllerCommand::COMMAND_NAME<<"::Client Command[";          log_file<<StressTestControllerCommand::COMMAND_NAME<<
               "::Client Command[";
        log_file<<j<<"]"<<endl;        log_file<<j<<"]"<<endl;
        log_file<<"  "<<_clientCommands[j]<<endl;        log_file<<"  "<<_clientCommands[j]<<endl;
        log_file<<"   Client Duration: "<<convertUint64toString(_clientDurations[j])<<endl;          log_file<<"   Client Duration: "<<
        log_file<<"   Client Delay: "<<convertUint64toString(_clientDelays[j])<<endl;              convertUint64toString(_clientDurations[j])<<endl;
           log_file<<
               "   Client Delay: "<<convertUint64toString(_clientDelays[j])<<endl;
  
        //        //
        // Verbose        // Verbose
        //        //
        if(verboseEnabled)        if(verboseEnabled)
        {        {
           cout<<StressTestControllerCommand::COMMAND_NAME<<"::Client Command[";              cout<<
                   StressTestControllerCommand::COMMAND_NAME<<"::Client Command[";
           cout<<j<<"]"<<endl;           cout<<j<<"]"<<endl;
           cout<<"  "<<_clientCommands[j]<<endl;           cout<<"  "<<_clientCommands[j]<<endl;
           cout<<"   Client Duration: "<<convertUint64toString(_clientDurations[j])<<endl;              cout<<"   Client Duration: "<<
           cout<<"   Client Delay: "<<convertUint64toString(_clientDelays[j])<<endl;                  convertUint64toString(_clientDurations[j])<<endl;
               cout<<"   Client Delay: "<<convertUint64toString(_clientDelays[j])<<
                   endl;
        }        }
     } /* for(Uint32 j=0; j< _clientCount; j++) */     } /* for(Uint32 j=0; j< _clientCount; j++) */
     return true;     return true;
Line 988 
Line 1024 
              1                  if an error occurs in executing the command              1                  if an error occurs in executing the command
  
  */  */
 Uint32 StressTestControllerCommand::execute (ostream& outPrintWriter,  Uint32 StressTestControllerCommand::execute (
       ostream& outPrintWriter,
                                  ostream& errPrintWriter)                                  ostream& errPrintWriter)
 { {
  
Line 997 
Line 1034 
    Uint64 nowMilliseconds           = 0;    Uint64 nowMilliseconds           = 0;
    Uint64 stopMilliseconds          = 0;    Uint64 stopMilliseconds          = 0;
    Uint64 timeoutMilliseconds       = 0;    Uint64 timeoutMilliseconds       = 0;
    Uint64 *clientStartMilliseconds  = NULL;      Uint64 *clientStartMilliseconds = 0;
    Uint64 *clientStopMilliseconds   = NULL;      Uint64 *clientStopMilliseconds = 0;
    Uint64 *clientDelayMilliseconds  = NULL;      Uint64 *clientDelayMilliseconds = 0;
    Boolean *clientStopped           = NULL;      Boolean *clientStopped = 0;
    Boolean *clientDelayed           = NULL;      Boolean *clientDelayed = 0;
    String act_command               = String::EMPTY;    String act_command               = String::EMPTY;
    Boolean TestFailed               = false;    Boolean TestFailed               = false;
    char str[15];    char str[15];
Line 1018 
Line 1055 
     //     //
     // open the file     // open the file
     //     //
     OpenAppend(log_file,StressTestLogFile);      OpenAppend(log_file,_stressTestLogFile);
  
     //     //
     // Failed to read log file.     // Failed to read log file.
Line 1029 
Line 1066 
        if(verboseEnabled)        if(verboseEnabled)
        {        {
            outPrintWriter<<StressTestControllerCommand::COMMAND_NAME;            outPrintWriter<<StressTestControllerCommand::COMMAND_NAME;
            outPrintWriter<<"Cannot read file "<<StressTestLogFile<<endl;              outPrintWriter<<"Cannot read file "<<_stressTestLogFile<<endl;
        }        }
        return RC_ERROR;        return RC_ERROR;
     }     }
Line 1039 
Line 1076 
     //     //
     if ( _operationType == OPERATION_TYPE_HELP )     if ( _operationType == OPERATION_TYPE_HELP )
     {     {
         outPrintWriter << usage << endl;          outPrintWriter << _usage << endl;
         log_file<<StressTestControllerCommand::COMMAND_NAME<<"::Listing usage information "<<endl;          log_file<<StressTestControllerCommand::COMMAND_NAME<<
               "::Listing usage information "<<endl;
         log_file.close();         log_file.close();
         //         //
         //  No need for the client pid and log file.         //  No need for the client pid and log file.
         //         //
         FileSystem::removeFile(StressTestClientPIDFile);          FileSystem::removeFile(_stressTestClientPIDFile);
         FileSystem::removeFile(StressTestClientLogFile);          FileSystem::removeFile(_stressTestClientLogFile);
         return (RC_SUCCESS);         return (RC_SUCCESS);
     }     }
     //     //
Line 1055 
Line 1093 
     else if ( _operationType == OPERATION_TYPE_VERSION )     else if ( _operationType == OPERATION_TYPE_VERSION )
     {     {
         outPrintWriter << "Version " << PEGASUS_PRODUCT_VERSION << endl;         outPrintWriter << "Version " << PEGASUS_PRODUCT_VERSION << endl;
         log_file<<StressTestControllerCommand::COMMAND_NAME<<"::Listing version information "<<endl;          log_file<<StressTestControllerCommand::COMMAND_NAME<<
               "::Listing version information "<<endl;
         log_file<<"Version " << PEGASUS_PRODUCT_VERSION << endl;         log_file<<"Version " << PEGASUS_PRODUCT_VERSION << endl;
         log_file.close();         log_file.close();
         //         //
         //  No need for the client pid and log file.         //  No need for the client pid and log file.
         //         //
         FileSystem::removeFile(StressTestClientPIDFile);          FileSystem::removeFile(_stressTestClientPIDFile);
         FileSystem::removeFile(StressTestClientLogFile);          FileSystem::removeFile(_stressTestClientLogFile);
         return (RC_SUCCESS);         return (RC_SUCCESS);
     }     }
  
Line 1085 
Line 1124 
     else     else
     {     {
         errPrintWriter << "Stress Tests must have at least one Client." << endl;         errPrintWriter << "Stress Tests must have at least one Client." << endl;
         log_file<<StressTestControllerCommand::COMMAND_NAME<<"::Stress Tests must have at least one Client."<<endl;          log_file<<StressTestControllerCommand::COMMAND_NAME<<
               "::Stress Tests must have at least one Client."<<endl;
         log_file.close();         log_file.close();
         return (RC_ERROR);         return (RC_ERROR);
     }     }
Line 1104 
Line 1144 
       timeoutMilliseconds = (Uint64)convertmin2millisecs(_duration);       timeoutMilliseconds = (Uint64)convertmin2millisecs(_duration);
       stopMilliseconds    = nowMilliseconds + timeoutMilliseconds;       stopMilliseconds    = nowMilliseconds + timeoutMilliseconds;
  
       log_file<<StressTestControllerCommand::COMMAND_NAME<<":: Test Duration information "<<endl;          log_file<<StressTestControllerCommand::COMMAND_NAME<<
       log_file<<"  Start Time in milliseconds: "<<convertUint64toString(startMilliseconds)<<endl;              ":: Test Duration information "<<endl;
       log_file<<"  Total duration in milliseconds: "<<convertUint64toString(timeoutMilliseconds)<<endl;          log_file<<"  Start Time in milliseconds: "<<
       log_file<<"  Actual Stop Time in milliseconds: "<<convertUint64toString(stopMilliseconds)<<endl;              convertUint64toString(startMilliseconds)<<endl;
           log_file<<"  Total duration in milliseconds: "<<
               convertUint64toString(timeoutMilliseconds)<<endl;
           log_file<<"  Actual Stop Time in milliseconds: "<<
               convertUint64toString(stopMilliseconds)<<endl;
       //       //
       //  Verbose details for Stress Test duration       //  Verbose details for Stress Test duration
       //       //
       if(verboseEnabled)       if(verboseEnabled)
       {       {
          outPrintWriter<<StressTestControllerCommand::COMMAND_NAME<<":: Test Duration information "<<endl;              outPrintWriter<<StressTestControllerCommand::COMMAND_NAME<<
          outPrintWriter<<"  Start Time in milliseconds: "<<convertUint64toString(startMilliseconds)<<endl;                  ":: Test Duration information "<<endl;
          outPrintWriter<<"  Total duration in milliseconds: "<<convertUint64toString(timeoutMilliseconds)<<endl;              outPrintWriter<<"  Start Time in milliseconds: "<<
          outPrintWriter<<"  Actual Stop Time in milliseconds: "<<convertUint64toString(stopMilliseconds)<<endl;                  convertUint64toString(startMilliseconds)<<endl;
               outPrintWriter<<"  Total duration in milliseconds: "<<
                   convertUint64toString(timeoutMilliseconds)<<endl;
               outPrintWriter<<
                   "  Actual Stop Time in milliseconds: "<<
                   convertUint64toString(stopMilliseconds)<<endl;
       }       }
  
       //       //
Line 1124 
Line 1173 
       //  the CHECKUP_INTERVAL. This should give the clients enough time       //  the CHECKUP_INTERVAL. This should give the clients enough time
       //  to update its PID, status  etc.       //  to update its PID, status  etc.
       //       //
       Uint64 nextCheckupInMillisecs = (Uint64)convertmin2millisecs(2 * CHECKUP_INTERVAL) + nowMilliseconds;          Uint64 nextCheckupInMillisecs =
              (Uint64)convertmin2millisecs(2 * CHECKUP_INTERVAL) + nowMilliseconds;
   
       //       //
       //  Main "while" loop where the clients are initiated.       //  Main "while" loop where the clients are initiated.
       //       //
Line 1137 
Line 1185 
         // Small delay in the while loop seemed to reduce the CPU usage         // Small delay in the while loop seemed to reduce the CPU usage
         // considerably  in Windows. (From 80% to 1%)         // considerably  in Windows. (From 80% to 1%)
         //         //
 #ifndef PEGASUS_PLATFORM_WIN32_IX86_MSVC  #ifndef PEGASUS_OS_TYPE_WINDOWS
     sleep(RUN_DELAY);     sleep(RUN_DELAY);
 #else #else
     Sleep(RUN_DELAY * 1000);     Sleep(RUN_DELAY * 1000);
Line 1147 
Line 1195 
          // So the clients can be gracefully shutdown.          // So the clients can be gracefully shutdown.
          if(Quit)          if(Quit)
          {          {
              log_file<<"Test interrupted by either SIGINT or SIGABORT."<<endl;                  log_file<<
                       "Test interrupted by either SIGINT or SIGABORT."<<endl;
              TestFailed = true;              TestFailed = true;
              break;              break;
          }          }
Line 1156 
Line 1205 
          //          //
          if(!actual_client)          if(!actual_client)
          {          {
              log_file<<StressTestControllerCommand::COMMAND_NAME<<"::Running the following tests: "<<endl;                  log_file<<StressTestControllerCommand::COMMAND_NAME<<
              outPrintWriter<<StressTestControllerCommand::COMMAND_NAME<<"::Running the following tests: "<<endl;                      "::Running the following tests: "<<endl;
                   outPrintWriter<<StressTestControllerCommand::COMMAND_NAME<<
                       "::Running the following tests: "<<endl;
              for(Uint32 j=0; j< _clientCount; j++)              for(Uint32 j=0; j< _clientCount; j++)
              {              {
                  String clientInst = String::EMPTY;                  String clientInst = String::EMPTY;
Line 1166 
Line 1217 
                  //                  //
                  if (!_clientTable[j].lookup(INSTANCE, clientInst))                  if (!_clientTable[j].lookup(INSTANCE, clientInst))
                  {                  {
                      throw InvalidPropertyValue(INSTANCE, clientInst);                          String ErrReport = String("Invalid Property Value: ");
                      //throw UnrecognizedConfigProperty(HOSTNAME);                          ErrReport.append(INSTANCE);
                           ErrReport.append("=");
                           ErrReport.append(clientInst);
                           throw StressTestControllerException(ErrReport);
                  }                  }
                  clientInstance[j] = atoi(clientInst.getCString());                  clientInstance[j] = atoi(clientInst.getCString());
  
                  //                  //
                  // Acquire and set client specific duration                  // Acquire and set client specific duration
                  //                  //
                  clientStartMilliseconds[j]=TimeValue::getCurrentTime().toMilliseconds();                      clientStartMilliseconds[j] =
                  clientStopMilliseconds[j]=clientStartMilliseconds[j] + _clientDurations[j];                          TimeValue::getCurrentTime().toMilliseconds();
                       clientStopMilliseconds[j] =
                           clientStartMilliseconds[j] + _clientDurations[j];
  
                 //                 //
                 // for verbose only                 // for verbose only
Line 1184 
Line 1240 
                 {                 {
                    outPrintWriter<<"Client:"<<"["<<j<<"]"<<endl;                    outPrintWriter<<"Client:"<<"["<<j<<"]"<<endl;
                    log_file<<"Client:"<<"["<<j<<"]"<<endl;                    log_file<<"Client:"<<"["<<j<<"]"<<endl;
                    outPrintWriter<<"ClientStart:"<<convertUint64toString(clientStartMilliseconds[j])<<endl;                          outPrintWriter<<"ClientStart:"<<
                    outPrintWriter<<"ClientStop:"<<convertUint64toString(clientStopMilliseconds[j])<<endl;                              convertUint64toString(clientStartMilliseconds[j])<<
                    outPrintWriter<<"ClientDuration:"<<convertUint64toString(_clientDurations[j])<<endl;                              endl;
                    log_file<<"ClientStart:"<<convertUint64toString(clientStartMilliseconds[j])<<endl;                          outPrintWriter<<"ClientStop:"<<
                    log_file<<"ClientStop:"<<convertUint64toString(clientStopMilliseconds[j])<<endl;                              convertUint64toString(clientStopMilliseconds[j])<<
                    log_file<<"ClientDuration:"<<convertUint64toString(_clientDurations[j])<<endl;                              endl;
                           outPrintWriter<<"ClientDuration:"<<
                               convertUint64toString(_clientDurations[j])<<endl;
                           log_file<<"ClientStart:"<<
                               convertUint64toString(clientStartMilliseconds[j])<<
                               endl;
                           log_file<<"ClientStop:"<<
                               convertUint64toString(clientStopMilliseconds[j])<<
                               endl;
                           log_file<<
                               "ClientDuration:"<<
                               convertUint64toString(_clientDurations[j])<<endl;
                       }
                       log_file<<
                           "Number of instances of this client: "<<
                           clientInstance[j]<<endl;
                       if(verboseEnabled)
                       {
                           outPrintWriter<<
                               "Number of instances of this client:"<<
                               clientInstance[j]<<endl;
                 }                 }
                 log_file<<"Number of instances of this client: "<<clientInstance[j]<<endl;  
                 if(verboseEnabled)  
                    outPrintWriter<<"Number of instances of this client:"<<clientInstance[j]<<endl;  
                 //                 //
                 // Execute each instance of the client.                 // Execute each instance of the client.
                 //   - Additional required parameters are added to the commands                      //   - Additional required parameters are added to the
                       //     commands.
                 //     like, -clientid, -pidfile, -clientlog                 //     like, -clientid, -pidfile, -clientlog
                 for(int instanceID =0;instanceID<clientInstance[j];instanceID++)                      for (int instanceID =0;instanceID<clientInstance[j];
                            instanceID++)
                 {                 {
                     outPrintWriter<<"Running Client("<<actual_client<<")"<<endl;                          outPrintWriter<<
                     log_file<<"Running Client("<<actual_client<<")"<<endl;                              "Running Client("<<actual_client<<")"<<endl;
                           log_file<<
                               "Running Client("<<actual_client<<")"<<endl;
                     act_command=String::EMPTY;                     act_command=String::EMPTY;
 #ifdef PEGASUS_PLATFORM_WIN32_IX86_MSVC  #ifdef PEGASUS_OS_TYPE_WINDOWS
                     act_command.append("start ");                     act_command.append("start ");
 #endif #endif
                     //                     //
Line 1215 
Line 1292 
                     act_command.append(str);                     act_command.append(str);
                     act_command.append(" -pidfile ");                     act_command.append(" -pidfile ");
                     act_command.append(" \"");                     act_command.append(" \"");
                     act_command.append(StressTestClientPIDFile);                          act_command.append(_stressTestClientPIDFile);
                     act_command.append("\"");                     act_command.append("\"");
                     act_command.append(" -clientlog");                     act_command.append(" -clientlog");
                     act_command.append(" \"");                     act_command.append(" \"");
                     act_command.append(StressTestClientLogFile);                          act_command.append(_stressTestClientLogFile);
                     act_command.append("\"");                     act_command.append("\"");
                     act_command.append("&");                     act_command.append("&");
                     if(verboseEnabled)                     if(verboseEnabled)
                     {                     {
                        outPrintWriter<<"  "<<act_command<<endl;                        outPrintWriter<<"  "<<act_command<<endl;
                        tmTime = getCurrentActualTime();                        tmTime = getCurrentActualTime();
                        strftime(strTime,256,"%d/%m/%Y at %H:%M:%S\n",&tmTime);                              strftime(
                        log_file<<StressTestControllerCommand::COMMAND_NAME<<"::Running following command on "<<strTime<<endl;                                  strTime,
                        log_file<<"     ("<<actual_client<<") \n"<<act_command<<endl;                                  256,
                                   "%d/%m/%Y at %H:%M:%S\n",
                                   &tmTime);
                               log_file<<
                                   StressTestControllerCommand::COMMAND_NAME<<
                                   "::Running following command on "<<
                                   strTime<<endl;
                               log_file<<"     ("<<actual_client<<") \n"<<
                                   act_command<<endl;
                     }                     }
  
                     //                     //
Line 1243 
Line 1328 
                     {                     {
                        log_file<<"Command failed to Execute."<<endl;                        log_file<<"Command failed to Execute."<<endl;
                        if(verboseEnabled)                        if(verboseEnabled)
                           outPrintWriter<<"Command failed to Execute."<<endl;                              {
                                   outPrintWriter<<
                                       "Command failed to Execute."<<endl;
                               }
                     }                     }
                     // Increment the actual number of clients                     // Increment the actual number of clients
                     ++actual_client;                     ++actual_client;
                 } /* for(int instanceID =0;instanceID<clientInstance[j];instanceID++) */                      } /* for(int instanceID =0;instanceID<clientInstance[j]...*/
  
              }/* for(Uint32 j=0; j< _clientCount; j++) */              }/* for(Uint32 j=0; j< _clientCount; j++) */
  
Line 1269 
Line 1357 
                 clientTimeStamp[i]      = nowMilliseconds;                 clientTimeStamp[i]      = nowMilliseconds;
                 prev_clientTimeStamp[i] = nowMilliseconds;                 prev_clientTimeStamp[i] = nowMilliseconds;
              }              }
              log_file<<StressTestControllerCommand::COMMAND_NAME<<"::Getting client PID's and status. "<<endl;                  log_file<<StressTestControllerCommand::COMMAND_NAME<<
                       "::Getting client PID's and status. "<<endl;
              if(verboseEnabled)              if(verboseEnabled)
                  outPrintWriter <<StressTestControllerCommand::COMMAND_NAME<<"::Getting client PID's and status. "<<endl;                  {
              int rc = getClientPIDs(actual_client,log_file);                      outPrintWriter<<StressTestControllerCommand::COMMAND_NAME<<
                           "::Getting client PID's and status. "<<endl;
                   }
                   int rc = _getClientPIDs(actual_client,log_file);
              if(!rc)              if(!rc)
              {              {
                  outPrintWriter<<"Failed to communicate with clients."<<endl;                      outPrintWriter<<
                  log_file<<StressTestControllerCommand::COMMAND_NAME<<"::Failed to communicate with clients. "<<endl;                          "Failed to communicate with clients."<<endl;
                  log_file<<"                    ::Failed to get client PID & status. "<<endl;                      log_file<<StressTestControllerCommand::COMMAND_NAME<<
                           "::Failed to communicate with clients. "<<endl;
                       log_file<<
                       "                    ::Failed to get client PID & status. "
                           <<endl;
                  TestFailed = true;                  TestFailed = true;
                  break;                  break;
              }              }
Line 1292 
Line 1388 
              */              */
  
               // Retreive all the client PIDs               // Retreive all the client PIDs
               int rc = getClientPIDs(actual_client,log_file);                  int rc = _getClientPIDs(actual_client,log_file);
  
               //               //
               // Get Current Time               // Get Current Time
Line 1307 
Line 1403 
                  //                  //
                  //  Set up the next tolerance time                  //  Set up the next tolerance time
                  //                  //
                  nextCheckupInMillisecs = (Uint64)convertmin2millisecs(CHECKUP_INTERVAL)\                      nextCheckupInMillisecs =
                                           + nowMilliseconds;                             (Uint64)convertmin2millisecs(CHECKUP_INTERVAL) +
                              nowMilliseconds;
                  //                  //
                  //  End tests when failed to acquire the Client PID  or status                      //  End tests when failed to acquire the Client PID  or
                       //  status.
                  //                  //
                  if(!rc)                  if(!rc)
                  {                  {
                     outPrintWriter<<"Failed to communicate with clients."<<endl;                          outPrintWriter<<
                     log_file<<StressTestControllerCommand::COMMAND_NAME<<"::Failed to communicate with clients. "<<endl;                              "Failed to communicate with clients."<<endl;
                     log_file<<StressTestControllerCommand::COMMAND_NAME<<"::Get Client PID FAILED. "<<endl;                          log_file<<StressTestControllerCommand::COMMAND_NAME<<
                               "::Failed to communicate with clients. "<<endl;
                           log_file<<StressTestControllerCommand::COMMAND_NAME<<
                               "::Get Client PID FAILED. "<<endl;
                     TestFailed = true;                     TestFailed = true;
                     break;                     break;
                  }                  }
                 log_file<<StressTestControllerCommand::COMMAND_NAME<<"::Checking current tolerance level. "<<endl;                      log_file<<StressTestControllerCommand::COMMAND_NAME<<
                           "::Checking current tolerance level. "<<endl;
                 //                 //
                 // Output Client info if verbose is enabled.                 // Output Client info if verbose is enabled.
                 //                 //
                 if(verboseEnabled)                 if(verboseEnabled)
                 {                 {
                     outPrintWriter<<StressTestControllerCommand::COMMAND_NAME<<"::Checking current tolerance level. "<<endl;                          outPrintWriter<<
                               StressTestControllerCommand::COMMAND_NAME<<
                               "::Checking current tolerance level. "<<endl;
                     for(int i=0;i< actual_client; i++)                     for(int i=0;i< actual_client; i++)
                     {                     {
                        outPrintWriter <<" Client: "<<i;                        outPrintWriter <<" Client: "<<i;
Line 1335 
Line 1439 
                        log_file <<" Client: "<<i;                        log_file <<" Client: "<<i;
                        log_file <<" PID: "<<clientPIDs[i]<<", ";                        log_file <<" PID: "<<clientPIDs[i]<<", ";
                        log_file <<" Status: "<<clientStatus[i]<<", ";                        log_file <<" Status: "<<clientStatus[i]<<", ";
                        log_file<<"   TimeStamp: "<<convertUint64toString(clientTimeStamp[i])<<endl;                              log_file<<"   TimeStamp: "<<
                                   convertUint64toString(clientTimeStamp[i])<<
                                   endl;
                     }                     }
                 }                 }
                 //                 //
                 // Check the actual tolerance level                 // Check the actual tolerance level
                 //                 //
                 Boolean withinTolerance = checkToleranceLevel(actual_client,nowMilliseconds,log_file);                      Boolean withinTolerance = _checkToleranceLevel(
                                                     actual_client,
                                                     nowMilliseconds,
                                                     log_file);
                 //                 //
                 //  End tests if not within tolerance                 //  End tests if not within tolerance
                 //                 //
                 if(!withinTolerance)                 if(!withinTolerance)
                 {                 {
                      log_file<<"FAILED::Tests NOT within tolerance."<<endl;                      log_file<<"FAILED::Tests NOT within tolerance."<<endl;
                      errPrintWriter<<"FAILED::Tests NOT within tolerance."<<endl;                          errPrintWriter<<"FAILED::Tests NOT within tolerance."
                                         <<endl;
                      TestFailed = true;                      TestFailed = true;
                      break;                      break;
                 }                 }
                 //                 //
                 //  Within Tolerance - Continue tests.                 //  Within Tolerance - Continue tests.
                 //                 //
                 log_file<<"********Tests are within tolerance.********* "<<endl;                      log_file<<"********Tests are within tolerance.********* "<<
                               endl;
                 if(verboseEnabled)                 if(verboseEnabled)
                     outPrintWriter<<" ********Tests are within tolerance.**********"<<endl;                      {
                           outPrintWriter<<
              } /* if(nowMilliseconds >= nextCheckupInMillisecs) -- Tolerance Level check*/                             " ********Tests are within tolerance.**********"<<
                              endl;
                       }
                   } /* if (nowMilliseconds >= nextCheckupInMillisecs)*/
              //              //
              // Stop clients with delay              // Stop clients with delay
              //              //
              for(Uint32 clientID=0; clientID < _clientCount; clientID++)              for(Uint32 clientID=0; clientID < _clientCount; clientID++)
              {              {
                  // Get Current time                  // Get Current time
                  nowMilliseconds = TimeValue::getCurrentTime().toMilliseconds();                      nowMilliseconds =
                           TimeValue::getCurrentTime().toMilliseconds();
  
                  //                  //
                  // Stop only running clients as required.                  // Stop only running clients as required.
Line 1381 
Line 1496 
                          //                          //
                          // Stop all the instances of this client                          // Stop all the instances of this client
                          //                          //
                          for(int instanceID =0;instanceID<clientInstance[clientID];instanceID++)                              for (int instanceID =0;
                          {                                   instanceID<clientInstance[clientID];
                              log_file<<"Stopping client:("<<clientID+instanceID<<")"<<endl;                                   instanceID++)
                              log_file<<"  with PID = "<<clientPIDs[clientID+instanceID]<<endl;                              {
                              outPrintWriter<<"Stopping client:("<<clientID+instanceID<<")"<<endl;                                  log_file<<"Stopping client:("<<
                              outPrintWriter<<"  with PID = "<<clientPIDs[clientID+instanceID]<<endl;                                      clientID+instanceID<<")"<<endl;
                                   log_file<<"  with PID = "<<
                                       clientPIDs[clientID+instanceID]<<endl;
                                   outPrintWriter<<"Stopping client:("<<
                                       clientID+instanceID<<")"<<endl;
                                   outPrintWriter<<"  with PID = "<<
                                       clientPIDs[clientID+instanceID]<<endl;
                              if(verboseEnabled)                              if(verboseEnabled)
                              {                              {
                                   tmTime = getCurrentActualTime();                                   tmTime = getCurrentActualTime();
                                   strftime(strTime,256,"%d/%m/%Y at %H:%M:%S\n",&tmTime);                                      strftime(
                                           strTime,
                                           256,
                                           "%d/%m/%Y at %H:%M:%S\n",
                                           &tmTime);
                                   log_file<<"    Stopped on "<<strTime<<endl;                                   log_file<<"    Stopped on "<<strTime<<endl;
                              }                              }
                              String stopClientFile = String::EMPTY;                              String stopClientFile = String::EMPTY;
                              stopClientFile.append(pegasusHome);                              stopClientFile.append(pegasusHome);
                              stopClientFile.append(DEFAULT_TMPDIR);                              stopClientFile.append(DEFAULT_TMPDIR);
                              stopClientFile.append("STOP_");                              stopClientFile.append("STOP_");
                              sprintf(str,"%d",clientPIDs[clientID+instanceID]);                                  sprintf(
                                       str,
                                       "%d",
                                       clientPIDs[clientID+instanceID]);
                              stopClientFile.append(str);                              stopClientFile.append(str);
                              // Required for Windows                              // Required for Windows
                              ofstream stop_file(stopClientFile.getCString(),ios::out);                                  ofstream stop_file(
                              stop_file << "Stop Client PID : "<<clientPIDs[clientID + instanceID]<<endl;                                      stopClientFile.getCString(),
                                       ios::out);
                                   stop_file << "Stop Client PID : "<<
                                             clientPIDs[clientID + instanceID]<<
                                             endl;
                              stop_file.close();                              stop_file.close();
 #ifndef PEGASUS_PLATFORM_WIN32_IX86_MSVC  #ifndef PEGASUS_OS_TYPE_WINDOWS
                              // one more way to stop the clients.                              // one more way to stop the clients.
                              int rc = kill(clientPIDs[clientID+instanceID], SIGINT);                                  int rc =
                                     kill(clientPIDs[clientID+instanceID], SIGINT);
                              if(rc)                              if(rc)
                              {                              {
                                  outPrintWriter<<"FAILED to stop client:("<<clientID+instanceID<<")"<<endl;                                      outPrintWriter<<"FAILED to stop client:("<<
                                  log_file<<"FAILED to stop client:("<<clientID + instanceID<<")"<<endl;                                          clientID+instanceID<<")"<<endl;
                                       log_file<<"FAILED to stop client:("<<
                                           clientID + instanceID<<")"<<endl;
                              }                              }
 #endif #endif
                              // Set the client as inactive.                              // Set the client as inactive.
                              clientActive[clientID + instanceID] = false;                              clientActive[clientID + instanceID] = false;
                          }                              }/* for (int instanceID =0;instanceID<clientInst..*/
                          // indicate that the client was stopped.                          // indicate that the client was stopped.
                          clientStopped[clientID] = true;                          clientStopped[clientID] = true;
                          //                          //
Line 1422 
Line 1557 
                          //                          //
                          if(_clientDelays[clientID] !=0)                          if(_clientDelays[clientID] !=0)
                          {                          {
                              clientDelayMilliseconds[clientID]=nowMilliseconds + _clientDelays[clientID];                                  clientDelayMilliseconds[clientID] =
                                       nowMilliseconds + _clientDelays[clientID];
                              clientDelayed[clientID] = true;                              clientDelayed[clientID] = true;
                          }                          }
                     } /* if(clientStopMilliseconds[clientID]<= nowMilliseconds) */                          } /* if (clientStopMilliseconds[clientID]<= nowMilli..*/
                  }  /*  if(!clientStopped[clientID]) */                  }  /*  if(!clientStopped[clientID]) */
                  else                  else
                  {                  {
Line 1435 
Line 1571 
                     if(clientDelayed[clientID])                     if(clientDelayed[clientID])
                     {                     {
                        // When waiting period is consumed.                        // When waiting period is consumed.
                        if(clientDelayMilliseconds[clientID]<= nowMilliseconds)                              if (clientDelayMilliseconds[clientID]<=
                                   nowMilliseconds)
                        {                        {
                            //                            //
                            //  Restart all the instances of the client.                            //  Restart all the instances of the client.
                            //                            //
                            for(int instanceID =0;instanceID<clientInstance[clientID];instanceID++)                                  for (int instanceID =0;
                                       instanceID<clientInstance[clientID];
                                       instanceID++)
                            {                            {
                                act_command=String::EMPTY;                                act_command=String::EMPTY;
 #ifdef PEGASUS_PLATFORM_WIN32_IX86_MSVC  #ifdef PEGASUS_OS_TYPE_WINDOWS
                                act_command.append("start ");                                act_command.append("start ");
 #endif #endif
                                act_command.append(_clientCommands[clientID].getCString());                                      act_command.append(
                                           _clientCommands[clientID].getCString());
                                act_command.append(" -clientid ");                                act_command.append(" -clientid ");
                                sprintf(str,"%d",clientID+instanceID);                                sprintf(str,"%d",clientID+instanceID);
                                act_command.append(str);                                act_command.append(str);
                                act_command.append(" -pidfile ");                                act_command.append(" -pidfile ");
                                act_command.append(" \"");                                act_command.append(" \"");
                                act_command.append(StressTestClientPIDFile);                                      act_command.append(_stressTestClientPIDFile);
                                act_command.append("\"");                                act_command.append("\"");
                                act_command.append(" -clientlog");                                act_command.append(" -clientlog");
                                act_command.append(" \"");                                act_command.append(" \"");
                                act_command.append(StressTestClientLogFile);                                      act_command.append(_stressTestClientLogFile);
                                act_command.append("\"");                                act_command.append("\"");
                                act_command.append("&");                                act_command.append("&");
                                log_file<<"Restarting client:("<<clientID+instanceID<<")"<<endl;                                      log_file<<"Restarting client:("<<
                                outPrintWriter<<"Restarting client:("<<clientID+instanceID<<")"<<endl;                                          clientID+instanceID<<")"<<endl;
                                       outPrintWriter<<"Restarting client:("<<
                                           clientID+instanceID<<")"<<endl;
                                if(verboseEnabled)                                if(verboseEnabled)
                                {                                {
                                    outPrintWriter<<"  "<<act_command<<endl;                                    outPrintWriter<<"  "<<act_command<<endl;
                                    log_file<<"     ("<<clientID+instanceID<<") \n"<<act_command<<endl;                                          log_file<<"     ("<<
                                               clientID+instanceID<<
                                               ") \n"<<act_command<<endl;
                                    tmTime = getCurrentActualTime();                                    tmTime = getCurrentActualTime();
                                    strftime(strTime,256,"%d/%m/%Y at %H:%M:%S\n",&tmTime);                                          strftime(
                                    log_file<<"   Restarted on "<<strTime<<endl;                                              strTime,
                                               256,
                                               "%d/%m/%Y at %H:%M:%S\n",
                                               &tmTime);
                                           log_file<<"   Restarted on "<<
                                               strTime<<endl;
                                }                                }
                                int rc = system(act_command.getCString());                                int rc = system(act_command.getCString());
                                if(rc)                                if(rc)
                                {                                {
                                      log_file<<"Command failed to Execute."<<endl;                                          log_file<<"Command failed to Execute."<<
                                               endl;
                                      if(verboseEnabled)                                      if(verboseEnabled)
                                         outPrintWriter<<act_command <<"Command failed to Execute."<<endl;                                          {
                                               outPrintWriter<<act_command<<
                                                   "Command failed to Execute."<<
                                                   endl;
                                }                                }
                                clientActive[clientID+instanceID] = true;  
                            }                            }
                            clientStopMilliseconds[clientID]=nowMilliseconds + _clientDurations[clientID];                                      clientActive[clientID+instanceID] = true;
                                   } /* for (int instanceID =0;instanceID .. */
                                   clientStopMilliseconds[clientID] =
                                       nowMilliseconds +
                                       _clientDurations[clientID];
                            clientStopped[clientID] = false;                            clientStopped[clientID] = false;
                            clientDelayed[clientID] = false;                            clientDelayed[clientID] = false;
                        } /* if(clientDelayMilliseconds[clientID]<= nowMilliseconds) */                              }/* if(clientDelayMilliseconds[clientID]<=nowMi.. */
                    } /* if(clientDelayed[clientID]) */                    } /* if(clientDelayed[clientID]) */
                 }                      } /* else ..*/
              } /* for(Uint32 clientID=0; clientID < _clientCount; clientID++) */              } /* for(Uint32 clientID=0; clientID < _clientCount; clientID++) */
          } /* else for if(!actual_client) */          } /* else for if(!actual_client) */
          //          //
Line 1497 
Line 1653 
  
     catch (const StressTestControllerException& e)     catch (const StressTestControllerException& e)
     {     {
         errPrintWriter << StressTestControllerCommand::COMMAND_NAME << ": " << e.getMessage () << endl;          errPrintWriter << StressTestControllerCommand::COMMAND_NAME <<
               ": " << e.getMessage () << endl;
         return (RC_ERROR);         return (RC_ERROR);
     }     }
  
Line 1511 
Line 1668 
     // just before the tests were ended to add     // just before the tests were ended to add
     // its pid to the pid file.     // its pid to the pid file.
  
 #ifndef PEGASUS_PLATFORM_WIN32_IX86_MSVC  #ifndef PEGASUS_OS_TYPE_WINDOWS
     sleep(STOP_DELAY);     sleep(STOP_DELAY);
 #else #else
     Sleep(STOP_DELAY * 1000);     Sleep(STOP_DELAY * 1000);
Line 1520 
Line 1677 
     //     //
     // get all the clientPIDs before it is stopped.     // get all the clientPIDs before it is stopped.
     //     //
     int rc = getClientPIDs(actual_client,log_file);      int rc = _getClientPIDs(actual_client,log_file);
     if(!rc)     if(!rc)
     {     {
        outPrintWriter<<"Failed to communicate with clients."<<endl;        outPrintWriter<<"Failed to communicate with clients."<<endl;
        log_file<<StressTestControllerCommand::COMMAND_NAME<<"::Failed to communicate with clients. "<<endl;          log_file<<StressTestControllerCommand::COMMAND_NAME<<
        log_file<<"                    ::Failed to get client PID & status. "<<endl;              "::Failed to communicate with clients. "<<endl;
           log_file<<"                    ::Failed to get client PID & status. "<<
               endl;
        TestFailed = true;        TestFailed = true;
     }     }
     tmTime = getCurrentActualTime();     tmTime = getCurrentActualTime();
Line 1534 
Line 1693 
     for(int i=0;i<actual_client;i++)     for(int i=0;i<actual_client;i++)
     {     {
        if(verboseEnabled)        if(verboseEnabled)
           outPrintWriter<<"Stopping Client("<<i<<") with PID:"<<clientPIDs[i]<<endl;          {
               outPrintWriter<<"Stopping Client("<<i<<") with PID:"<<
                   clientPIDs[i]<<endl;
           }
        log_file<<"Stopping Client("<<i<<") with PID:"<<clientPIDs[i]<<endl;        log_file<<"Stopping Client("<<i<<") with PID:"<<clientPIDs[i]<<endl;
        // Required for Windows        // Required for Windows
        String stopClientFile = String::EMPTY;        String stopClientFile = String::EMPTY;
Line 1546 
Line 1708 
        ofstream stop_file(stopClientFile.getCString(),ios::out);        ofstream stop_file(stopClientFile.getCString(),ios::out);
        stop_file << "Stop Client PID : "<<clientPIDs[i]<<endl;        stop_file << "Stop Client PID : "<<clientPIDs[i]<<endl;
        stop_file.close();        stop_file.close();
 #ifndef PEGASUS_PLATFORM_WIN32_IX86_MSVC  #ifndef PEGASUS_OS_TYPE_WINDOWS
        // Another way to stop the client        // Another way to stop the client
        int rc = 0;        int rc = 0;
        rc = kill(clientPIDs[i], SIGINT);        rc = kill(clientPIDs[i], SIGINT);
        if(rc)        if(rc)
        {        {
           if(verboseEnabled)           if(verboseEnabled)
              {
              outPrintWriter<<"Failed to stop client:("<<i<<")"<<endl;              outPrintWriter<<"Failed to stop client:("<<i<<")"<<endl;
              }
           log_file<<"Failed to stop client:("<<i<<")"<<endl;           log_file<<"Failed to stop client:("<<i<<")"<<endl;
        }        }
 #endif #endif
     }     }
     if(verboseEnabled)     if(verboseEnabled)
       {
       outPrintWriter<<"Cleaning all resources"<<endl;       outPrintWriter<<"Cleaning all resources"<<endl;
       }
     log_file<<"Cleaning all resources."<<endl;     log_file<<"Cleaning all resources."<<endl;
     cleanupProcess();     cleanupProcess();
  
     //     //
     // Waiting to allow clients to shutdown     // Waiting to allow clients to shutdown
     //     //
 #ifndef PEGASUS_PLATFORM_WIN32_IX86_MSVC  #ifndef PEGASUS_OS_TYPE_WINDOWS
     sleep(SHUTDOWN_DELAY);     sleep(SHUTDOWN_DELAY);
 #else #else
     Sleep(SHUTDOWN_DELAY * 1000);     Sleep(SHUTDOWN_DELAY * 1000);
Line 1582 
Line 1748 
  
  
 /* /*
     Retrieves the contents of the config file if specified or uses default values from      Retrieves the contents of the config file if specified or uses default
     either the default config file      values from either the default config file
  
     @param   fileName           The specified or default config file for the     @param   fileName           The specified or default config file for the
                                 tests.                                 tests.
Line 1593 
Line 1759 
              false              if file was not read successfully.              false              if file was not read successfully.
  
  */  */
 Boolean StressTestControllerCommand::getFileContent(String fileName,ostream& log_file)  Boolean StressTestControllerCommand::getFileContent(
       String fileName,
       ostream& log_file)
 { {
     String configData       = String::EMPTY;     String configData       = String::EMPTY;
     String line;     String line;
Line 1611 
Line 1779 
     Open(ifs,fileName);     Open(ifs,fileName);
     if (!ifs)     if (!ifs)
     {     {
        log_file<<StressTestControllerCommand::COMMAND_NAME<<"::Cannot read config file: "<<fileName<<endl;          log_file<<StressTestControllerCommand::COMMAND_NAME<<
               "::Cannot read config file: "<<fileName<<endl;
        throw NoSuchFile(fileName);        throw NoSuchFile(fileName);
        return false;  
     }     }
  
     log_file<<StressTestControllerCommand::COMMAND_NAME<<"::Storing client details. "<<endl;      log_file<<StressTestControllerCommand::COMMAND_NAME <<
           "::Storing client details. "<<endl;
     if(verboseEnabled)     if(verboseEnabled)
         cout<<StressTestControllerCommand::COMMAND_NAME<<"::Storing config details. "<<endl;      {
           cout<<StressTestControllerCommand::COMMAND_NAME<<
               "::Storing config details. "<<endl;
       }
     //     //
     // Get each line of the file.     // Get each line of the file.
     //     //
Line 1628 
Line 1800 
         IsAClient = false;         IsAClient = false;
         name = String::EMPTY;         name = String::EMPTY;
         value = String::EMPTY;         value = String::EMPTY;
         try {          try
           {
            //            //
            // Parse each line of Config file            // Parse each line of Config file
            //            //
            parseLine(line,lineNumber,name,value,log_file);              _parseLine(line,lineNumber,name,value,log_file);
         }         }
         //         //
         // catch all the exceptions if any thrown from parseLine         // catch all the exceptions if any thrown from parseLine
Line 1649 
Line 1822 
             ErrReports.append(line_num);             ErrReports.append(line_num);
             ErrReports.append(":: ");             ErrReports.append(":: ");
             ErrReports.append(msg.getCString());             ErrReports.append(msg.getCString());
             log_file<<StressTestControllerCommand::COMMAND_NAME<<"::"<<msg<<endl;              log_file<<StressTestControllerCommand::COMMAND_NAME<<"::"
                   <<msg<<endl;
             isSuccess = false;             isSuccess = false;
         }         }
         catch(...)         catch(...)
Line 1661 
Line 1835 
            ErrReports.append(line_num);            ErrReports.append(line_num);
            ErrReports.append(":: ");            ErrReports.append(":: ");
            ErrReports.append("Unknown exception caught.");            ErrReports.append("Unknown exception caught.");
            log_file<<StressTestControllerCommand::COMMAND_NAME<<":Unknown exception caught when parsing line."<<endl;              log_file<<StressTestControllerCommand::COMMAND_NAME<<
            cerr<<StressTestControllerCommand::COMMAND_NAME<<":Unknown exception caught when parsing line."<<endl;                  ":Unknown exception caught when parsing line."<<endl;
               cerr<<StressTestControllerCommand::COMMAND_NAME <<
                  ":Unknown exception caught when parsing line."<<endl;
            return false;            return false;
         }         }
  
Line 1680 
Line 1856 
            _currClient=name;            _currClient=name;
            _currClientCount=_clientCount;            _currClientCount=_clientCount;
                // save the client details in a table                // save the client details in a table
            if(!storeClientDetails(name,value))              if (!_storeClientDetails(name,value))
            {            {
               log_file<<StressTestControllerCommand::COMMAND_NAME<<"::Syntax error found in line#"<<lineNumber<<" of config file: "<<fileName<<endl;                  log_file<<StressTestControllerCommand::COMMAND_NAME<<
                       "::Syntax error found in line#"<<lineNumber<<
                       " of config file: "<<fileName<<endl;
               isSuccess = false;               isSuccess = false;
            }            }
         }         }
Line 1706 
Line 1884 
                    // Duplicate property, ignore the new property value.                    // Duplicate property, ignore the new property value.
                    //                    //
 #ifdef DEBUG #ifdef DEBUG
                    cout<< "Property Name:duplicate name already saved: "<<name<<endl;                      cout<< "Property Name:duplicate name already saved: "<<
                           name<<endl;
 #endif #endif
                    log_file<<StressTestControllerCommand::COMMAND_NAME<<"::Duplicate property name "<<name<<" already saved."<<endl;                      log_file<<StressTestControllerCommand::COMMAND_NAME<<
                           "::Duplicate property name "<<name<<" already saved."<<
                           endl;
                }                }
              }              }
          }          }
Line 1723 
Line 1904 
        ErrReports.append("\n    ");        ErrReports.append("\n    ");
        ErrReports.append(StressTestControllerCommand::COMMAND_NAME);        ErrReports.append(StressTestControllerCommand::COMMAND_NAME);
        ErrReports.append("::No clients found.");        ErrReports.append("::No clients found.");
        log_file<<StressTestControllerCommand::COMMAND_NAME<<"::No clients found in"<<" config file: "<<fileName<<endl;          log_file<<StressTestControllerCommand::COMMAND_NAME <<
               "::No clients found in"<<" config file: "<<fileName<<endl;
        isSuccess = false;        isSuccess = false;
     }     }
     //     //
Line 1736 
Line 1918 
        //        //
        cleanupProcess();        cleanupProcess();
        throw StressTestControllerException(ErrReports);        throw StressTestControllerException(ErrReports);
        return isSuccess;  
     }     }
  
     log_file<<StressTestControllerCommand::COMMAND_NAME<<"::Common Properties:"<<endl;      log_file<<StressTestControllerCommand::COMMAND_NAME<<
           "::Common Properties:"<<endl;
     if(verboseEnabled)     if(verboseEnabled)
       cout<<StressTestControllerCommand::COMMAND_NAME<<"::Common Properties:"<<endl;      {
           cout<<StressTestControllerCommand::COMMAND_NAME<<
               "::Common Properties:"<<endl;
       }
     for (Table::Iterator i = _propertyTable->start(); i; i++)     for (Table::Iterator i = _propertyTable->start(); i; i++)
     {     {
        log_file<<"      "<<i.key()<<"\t= "<<i.value()<<endl;        log_file<<"      "<<i.key()<<"\t= "<<i.value()<<endl;
        if(verboseEnabled)        if(verboseEnabled)
           {
           cout<<"      "<<i.key()<<"\t= "<<i.value()<<endl;           cout<<"      "<<i.key()<<"\t= "<<i.value()<<endl;
     }     }
       }
     if(verboseEnabled)     if(verboseEnabled)
     {     {
        cout<<"Total clients found:"<<_clientCount<<endl;        cout<<"Total clients found:"<<_clientCount<<endl;
        cout<<"CLIENT TABLE CONTENTS:"<<endl;        cout<<"CLIENT TABLE CONTENTS:"<<endl;
     }     }
     log_file<<StressTestControllerCommand::COMMAND_NAME<<"::Client Properties:"<<endl;      log_file<<StressTestControllerCommand::COMMAND_NAME<<
           "::Client Properties:"<<endl;
     for(Uint32 j = 0; j < _clientCount; j++)     for(Uint32 j = 0; j < _clientCount; j++)
     {     {
        log_file<<"Client information #"<<j+1<<" from config file:"<<endl;        log_file<<"Client information #"<<j+1<<" from config file:"<<endl;
        if(verboseEnabled)        if(verboseEnabled)
           {
           cout<<"Client("<<j<<")"<<endl;           cout<<"Client("<<j<<")"<<endl;
           }
        for (Table::Iterator i = _clientTable[j].start(); i; i++)        for (Table::Iterator i = _clientTable[j].start(); i; i++)
        {        {
           log_file<<"    "<<i.key()<<"    = "<<i.value()<<endl;           log_file<<"    "<<i.key()<<"    = "<<i.value()<<endl;
Line 1771 
Line 1961 
  
  
     if(isSuccess)     if(isSuccess)
        log_file<<StressTestControllerCommand::COMMAND_NAME<<"::Successfully retreived config values from"<<" config file: "<<fileName<<endl;      {
          log_file<<StressTestControllerCommand::COMMAND_NAME<<
              "::Successfully retreived config values from" <<
              " config file: "<<fileName<<endl;
       }
     return isSuccess;     return isSuccess;
 }/* getFileContent */ }/* getFileContent */
  
Line 1792 
Line 1986 
  */  */
  
  
 Boolean StressTestControllerCommand::validateConfiguration(String & vars,const String & value,ostream& log_file)  Boolean StressTestControllerCommand::_validateConfiguration(
       String & vars,
       const String & value,
       ostream& log_file)
 { {
     Boolean IsValid = false;     Boolean IsValid = false;
  
Line 1804 
Line 2001 
         if(!IsAClient)         if(!IsAClient)
         {         {
           if(!_hostNameSpecified)           if(!_hostNameSpecified)
               {
             _hostName = value;             _hostName = value;
         }         }
           }
         else         else
         {         {
              // Should  IP addresses if specified be converted to hostname for comparision?  
  
            if(_hostName != String::EMPTY)            if(_hostName != String::EMPTY)
            {            {
               if (!String::equalNoCase(value,_hostName))               if (!String::equalNoCase(value,_hostName))
               {               {
                  log_file<<StressTestControllerCommand::COMMAND_NAME<<"::Multiple hostnames were found. "<<endl;                      log_file<<StressTestControllerCommand::COMMAND_NAME<<
                           "::Multiple hostnames were found. "<<endl;
                  if(verboseEnabled)                  if(verboseEnabled)
                    cout<<StressTestControllerCommand::COMMAND_NAME<<"::Multiple hostnames were found. "<<endl;                      {
                           cout<<StressTestControllerCommand::COMMAND_NAME <<
                               "::Multiple hostnames were found. "<<endl;
                       }
                  return false;                  return false;
               }               }
            }            }
            else            else
               {
               _hostName = value;               _hostName = value;
               }
         }         }
     }     }
     else if (String::equalNoCase(vars,PORTNUMBER))     else if (String::equalNoCase(vars,PORTNUMBER))
Line 1831 
Line 2034 
         vars.append(PORTNUMBER);         vars.append(PORTNUMBER);
         Uint32 vPortNumber = atoi(value.getCString());         Uint32 vPortNumber = atoi(value.getCString());
  
         log_file<<StressTestControllerCommand::COMMAND_NAME<<"::Portnumber  specified in config = "<<vPortNumber<<endl;          log_file<<StressTestControllerCommand::COMMAND_NAME <<
               "::Portnumber  specified in config = "<<vPortNumber<<endl;
         if(verboseEnabled)         if(verboseEnabled)
            cout<<StressTestControllerCommand::COMMAND_NAME<<"::Portnumber  specified in config = "<<vPortNumber<<endl;          {
               cout<<StressTestControllerCommand::COMMAND_NAME <<
                   "::Portnumber  specified in config = "<<vPortNumber<<endl;
           }
         if (vPortNumber > _MAX_PORTNUMBER)         if (vPortNumber > _MAX_PORTNUMBER)
         {         {
            //            //
            //  Portnumber out of valid range            //  Portnumber out of valid range
            //            //
            if(verboseEnabled)            if(verboseEnabled)
               cout<<StressTestControllerCommand::COMMAND_NAME<<"::Invalid portnumber  was found. "<<endl;              {
                   cout<<StressTestControllerCommand::COMMAND_NAME <<
            log_file<<StressTestControllerCommand::COMMAND_NAME<<"::Invalid portnumber  was found. "<<endl;                      "::Invalid portnumber  was found. "<<endl;
               }
               log_file<<StressTestControllerCommand::COMMAND_NAME<<
                   "::Invalid portnumber  was found. "<<endl;
            return false;            return false;
         }         }
         if(!_portNumberSpecified)         if(!_portNumberSpecified)
           {
            _portNumber = atoi(value.getCString());            _portNumber = atoi(value.getCString());
   
   
     }     }
   
       }/* else if (String::equalNoCase ... */
     else if (String::equalNoCase(vars,SSL))     else if (String::equalNoCase(vars,SSL))
     {     {
         log_file<<StressTestControllerCommand::COMMAND_NAME<<"::SSL enabled in config. "<<endl;          log_file<<StressTestControllerCommand::COMMAND_NAME<<
               "::SSL enabled in config. "<<endl;
         if(!_useSSL)         if(!_useSSL)
         {         {
            _useSSL = true;            _useSSL = true;
Line 1862 
Line 2074 
     {     {
         vars=String::EMPTY;         vars=String::EMPTY;
         vars.append(USERNAME);         vars.append(USERNAME);
         log_file<<StressTestControllerCommand::COMMAND_NAME<<"::UserName  specified in config = "<<value<<endl;          log_file<<StressTestControllerCommand::COMMAND_NAME<<
               "::UserName  specified in config = "<<value<<endl;
         if(!_userNameSpecified)         if(!_userNameSpecified)
         {         {
            _userName = value;            _userName = value;
Line 1876 
Line 2089 
         {         {
            _password = value;            _password = value;
         }         }
         log_file<<StressTestControllerCommand::COMMAND_NAME<<"::Password  specified in config = "<<value<<endl;          log_file<<StressTestControllerCommand::COMMAND_NAME<<
               "::Password  specified in config = "<<value<<endl;
     }     }
     else if (String::equalNoCase(vars,DURATION))     else if (String::equalNoCase(vars,DURATION))
     {     {
Line 1888 
Line 2102 
            _duration = atof(value.getCString());            _duration = atof(value.getCString());
            if (_duration > _MIN_DURATION)            if (_duration > _MIN_DURATION)
            {            {
               log_file<<StressTestControllerCommand::COMMAND_NAME<<"::Duration  specified in config = "<<value<<endl;                  log_file<<StressTestControllerCommand::COMMAND_NAME<<
                       "::Duration  specified in config = "<<value<<endl;
            }            }
            else            else
            {            {
               log_file<<StressTestControllerCommand::COMMAND_NAME<<"::Invalid Duration  was specified. "<<endl;                  log_file<<StressTestControllerCommand::COMMAND_NAME<<
                       "::Invalid Duration  was specified. "<<endl;
               return false;               return false;
            }            }
         }         }
Line 1900 
Line 2116 
     else if (String::equalNoCase(vars,TOLERANCELEVEL))     else if (String::equalNoCase(vars,TOLERANCELEVEL))
     {     {
         _toleranceLevel =  atoi(value.getCString());         _toleranceLevel =  atoi(value.getCString());
         log_file<<StressTestControllerCommand::COMMAND_NAME<<"::ToleranceLevel  specified in config = "<<value<<endl;          log_file<<StressTestControllerCommand::COMMAND_NAME<<
               "::ToleranceLevel  specified in config = "<<value<<endl;
         if(_toleranceLevel > _MAX_TOLERANCE)         if(_toleranceLevel > _MAX_TOLERANCE)
         {         {
            if(verboseEnabled)            if(verboseEnabled)
               cout<<StressTestControllerCommand::COMMAND_NAME<<"::Invalid Tolerance level  was specified. "<<endl;              {
            log_file<<StressTestControllerCommand::COMMAND_NAME<<"::Invalid Tolerance level  was specified. "<<endl;                  cout<<StressTestControllerCommand::COMMAND_NAME <<
                       "::Invalid Tolerance level  was specified. "<<endl;
               }
               log_file<<StressTestControllerCommand::COMMAND_NAME<<
                   "::Invalid Tolerance level  was specified. "<<endl;
  
            return false;            return false;
         }         }
Line 1913 
Line 2134 
     else if (String::equalNoCase(vars,NAMESPACE))     else if (String::equalNoCase(vars,NAMESPACE))
     {     {
         _nameSpace = value;         _nameSpace = value;
         log_file<<StressTestControllerCommand::COMMAND_NAME<<"::NameSpace  specified in config = "<<value<<endl;          log_file<<StressTestControllerCommand::COMMAND_NAME <<
               "::NameSpace  specified in config = "<<value<<endl;
     }     }
     else if (String::equalNoCase(vars,CLASSNAME))     else if (String::equalNoCase(vars,CLASSNAME))
     {     {
         _className = value;         _className = value;
         log_file<<StressTestControllerCommand::COMMAND_NAME<<"::Class name  specified in config = "<<value<<endl;          log_file<<StressTestControllerCommand::COMMAND_NAME<<
               "::Class name  specified in config = "<<value<<endl;
     }     }
     else     else
     {     {
Line 1941 
Line 2164 
            //            //
            String clientName = String(DEFAULT_BINDIR);            String clientName = String(DEFAULT_BINDIR);
            clientName.append(vars.getCString());            clientName.append(vars.getCString());
 #ifdef PEGASUS_PLATFORM_WIN32_IX86_MSVC  #ifdef PEGASUS_OS_TYPE_WINDOWS
            clientName.append(".exe");            clientName.append(".exe");
 #endif #endif
            if (!FileSystem::exists(clientName))            if (!FileSystem::exists(clientName))
Line 1954 
Line 2177 
                    clientName = String(DEFAULT_BINDIR);                    clientName = String(DEFAULT_BINDIR);
                    testString.append(vars.getCString());                    testString.append(vars.getCString());
                    clientName.append(testString.getCString());                    clientName.append(testString.getCString());
 #ifdef PEGASUS_PLATFORM_WIN32_IX86_MSVC  #ifdef PEGASUS_OS_TYPE_WINDOWS
                    clientName.append(".exe");                    clientName.append(".exe");
 #endif #endif
                    if (!FileSystem::exists(clientName))                    if (!FileSystem::exists(clientName))
Line 1968 
Line 2191 
                       vars=String::EMPTY;                       vars=String::EMPTY;
                       vars.append(testString.getCString());                       vars.append(testString.getCString());
                     }                     }
                } else                 }
                  else
                  {
   
                   // Invalid client name                   // Invalid client name
                   IsValid = false;                   IsValid = false;
            }            }
              }
            else            else
            {            {
               IsValid = true;               IsValid = true;
Line 1980 
Line 2207 
            {            {
               if(verboseEnabled)               if(verboseEnabled)
               {               {
                    cout<<StressTestControllerCommand::COMMAND_NAME<<"::Invalid Client Name = "<<vars<<endl;                    cout<<StressTestControllerCommand::COMMAND_NAME <<
                         "::Invalid Client Name = "<<vars<<endl;
               }               }
               String ErrReport = String("Invalid Client Name:");               String ErrReport = String("Invalid Client Name:");
               ErrReport.append(vars.getCString());               ErrReport.append(vars.getCString());
Line 1988 
Line 2216 
            }            }
            return IsValid;            return IsValid;
        }        }
         log_file<<StressTestControllerCommand::COMMAND_NAME<<"::"<<vars<<" = "<<value<<endl;          log_file<<StressTestControllerCommand::COMMAND_NAME<<"::"<<vars<<
               " = "<<value<<endl;
          //
        //otherwise accept the properties listed with the clients.        //otherwise accept the properties listed with the clients.
          //
     }     }
     return true;     return true;
  
 } /* validateConfiguration */  } /* _validateConfiguration */
  
 /* /*
     Retrieves the client specific options from the config file.     Retrieves the client specific options from the config file.
Line 2012 
Line 2243 
  
  
  */  */
 void StressTestControllerCommand::getClientOptions(const Char16* p,ostream& log_file)  void StressTestControllerCommand::_getClientOptions(
       const Char16* p,
       ostream& log_file)
 { {
      //      //
      // Get the property name      // Get the property name
Line 2031 
Line 2264 
         }         }
         if (!(isalpha(*p) || *p == '_'))         if (!(isalpha(*p) || *p == '_'))
         {         {
             String ErrReport = String("Syntax Error Client option name:");              throw StressTestControllerException(StressTestControllerException::INVALID_OPTION);
             throw StressTestControllerException(ErrReport);  
             return;  
         }         }
  
         name.append(*p++);         name.append(*p++);
Line 2057 
Line 2288 
         //         //
         if (*p != '=')         if (*p != '=')
         {         {
             String ErrReport = String("Syntax Error Client option operator:");              throw StressTestControllerException(StressTestControllerException::INVALID_OPERATOR);
             throw StressTestControllerException(ErrReport);  
             return;  
         }         }
  
         p++;         p++;
Line 2077 
Line 2306 
         //         //
  
         while (*p && *p != ']' && *p != ',')         while (*p && *p != ']' && *p != ',')
           {
             value.append(*p++);             value.append(*p++);
           }
         //         //
         // Skip whitespace after value         // Skip whitespace after value
         //         //
Line 2089 
Line 2320 
  
         if(*p !=']' && *p != ',')         if(*p !=']' && *p != ',')
         {         {
             String ErrReport = String("Missing closing square brace:");              throw StressTestControllerException(StressTestControllerException::MISSING_BRACE);
             throw StressTestControllerException(ErrReport);  
             return;  
         }         }
         if(value == String::EMPTY)         if(value == String::EMPTY)
         {         {
             String ErrReport = String("Missing value for client option:");              throw StressTestControllerException(StressTestControllerException::MISSING_VALUE);
             throw StressTestControllerException(ErrReport);  
             return;  
         }         }
  
 #ifdef DEBUG #ifdef DEBUG
Line 2107 
Line 2334 
         //         //
         // validate client property         // validate client property
         //         //
         Boolean IsValid=validateConfiguration(name,value,log_file);          Boolean IsValid=_validateConfiguration(name,value,log_file);
         if(!IsValid)         if(!IsValid)
         {         {
            throw InvalidClientPropertyValue(name, value);              String ErrReport = String("Invalid Client property value: ");
               ErrReport.append(name);
               ErrReport.append("=");
               ErrReport.append(value);
               throw StressTestControllerException(ErrReport);
         }         }
         //         //
         // Save client property in client table if valid.         // Save client property in client table if valid.
Line 2123 
Line 2354 
             //             //
            log_file<< "duplicate name already saved: "<<name<<endl;            log_file<< "duplicate name already saved: "<<name<<endl;
            if(verboseEnabled)            if(verboseEnabled)
              {
               cout<< "duplicate name already saved: "<<name<<endl;               cout<< "duplicate name already saved: "<<name<<endl;
         }         }
           }
         if(*p ==',')         if(*p ==',')
         {         {
             name = String::EMPTY;             name = String::EMPTY;
Line 2138 
Line 2371 
      {      {
         String ErrReport = String("Missing Name & Value for client option:");         String ErrReport = String("Missing Name & Value for client option:");
         throw StressTestControllerException(ErrReport);         throw StressTestControllerException(ErrReport);
         return;  
      }      }
 } /* getClientOptions */  } /* _getClientOptions */
  
  
 /* /*
Line 2167 
Line 2399 
              false           Failed to read the status & PIDs of clients.              false           Failed to read the status & PIDs of clients.
  
  */  */
 Boolean StressTestControllerCommand::getClientPIDs(int actual_clients,ostream& log_file)  Boolean StressTestControllerCommand::_getClientPIDs(
       int actual_clients,
       ostream& log_file)
 { {
  
     ifstream ifs;     ifstream ifs;
Line 2175 
Line 2409 
     //     //
     // Make a temp copy of the file     // Make a temp copy of the file
     //     //
     Boolean cTempFile = FileSystem::copyFile(StressTestClientPIDFile,      Boolean cTempFile = FileSystem::copyFile(
         tmpStressTestClientPIDFile);          _stressTestClientPIDFile,
           _tmpStressTestClientPIDFile);
  
     if(!cTempFile)     if(!cTempFile)
     {     {
        cout<<"Cannot copy file "<<StressTestClientPIDFile<<endl;          cout<<"Cannot copy file "<<_stressTestClientPIDFile<<endl;
        log_file<<StressTestControllerCommand::COMMAND_NAME<<"::Cannot copy PID file: "<<StressTestClientPIDFile<<endl;          log_file<<StressTestControllerCommand::COMMAND_NAME<<
               "::Cannot copy PID file: "<<_stressTestClientPIDFile<<endl;
        return (false);        return (false);
   
     }     }
     //     //
     // Open the temp PID file and retreive all the client PIDs and status     // Open the temp PID file and retreive all the client PIDs and status
     //     //
     Open(ifs,tmpStressTestClientPIDFile);      Open(ifs,_tmpStressTestClientPIDFile);
  
     String line;     String line;
  
Line 2207 
Line 2442 
 #endif #endif
         p = line.getChar16Data();         p = line.getChar16Data();
  
         while (*p && isspace(*p)) p++;          while (*p && isspace(*p))
           {
               p++;
           }
  
         //         //
         // Skip comment lines         // Skip comment lines
         //         //
         if ((!*p)||(*p == '#')) continue;          if ((!*p)||(*p == '#'))
           {
               continue;
           }
  
         // Get the client ID         // Get the client ID
         String client = String::EMPTY;         String client = String::EMPTY;
         while (isalnum(*p) || *p == '_') client.append(*p++);          while (isalnum(*p) || *p == '_')
           {
               client.append(*p++);
           }
  
         // Skip whitespace after property name         // Skip whitespace after property name
         while (*p && isspace(*p)) p++;          while (*p && isspace(*p))
           {
               p++;
           }
  
         // Expecting a colon         // Expecting a colon
         if (*p != ':')         if (*p != ':')
         {         {
             ifs.close();             ifs.close();
             log_file<<StressTestControllerCommand::COMMAND_NAME<<"::Syntax Error in PID file line number:"<<lineNumber<<endl;              log_file<<StressTestControllerCommand::COMMAND_NAME<<
             FileSystem::removeFile(tmpStressTestClientPIDFile);                  "::Syntax Error in PID file line number:"<<lineNumber<<endl;
               FileSystem::removeFile(_tmpStressTestClientPIDFile);
             return(isSuccess = false);             return(isSuccess = false);
             //throw ConfigFileSyntaxError(StressTestClientPIDFile, lineNumber);  
         }         }
  
         //         //
Line 2240 
Line 2487 
         if (*p != ':')         if (*p != ':')
         {         {
             ifs.close();             ifs.close();
             log_file<<StressTestControllerCommand::COMMAND_NAME<<"::Syntax Error in PID file line number:"<<lineNumber<<endl;              log_file<<StressTestControllerCommand::COMMAND_NAME<<
             FileSystem::removeFile(tmpStressTestClientPIDFile);                  "::Syntax Error in PID file line number:"<<lineNumber<<endl;
               FileSystem::removeFile(_tmpStressTestClientPIDFile);
             return(isSuccess = false);             return(isSuccess = false);
             //throw ConfigFileSyntaxError(StressTestClientPIDFile, lineNumber);  
         }         }
  
         //         //
Line 2254 
Line 2501 
         //         //
         // Skip whitespace after colon         // Skip whitespace after colon
         //         //
         while (*p && isspace(*p)) p++;          while (*p && isspace(*p))
           {
               p++;
           }
  
         // Get the client PID         // Get the client PID
         String clntPID = String::EMPTY;         String clntPID = String::EMPTY;
         while (isalnum(*p) || *p == '_') clntPID.append(*p++);          while (isalnum(*p) || *p == '_')
           {
               clntPID.append(*p++);
           }
  
         // Skip whitespace after property name         // Skip whitespace after property name
         while (*p && isspace(*p)) p++;          while (*p && isspace(*p))
           {
               p++;
           }
  
         //         //
         // Expecting a colon         // Expecting a colon
Line 2269 
Line 2525 
         if (*p != ':')         if (*p != ':')
         {         {
             ifs.close();             ifs.close();
             log_file<<StressTestControllerCommand::COMMAND_NAME<<"::Syntax Error in PID file line number:"<<lineNumber<<endl;              log_file<<StressTestControllerCommand::COMMAND_NAME <<
             FileSystem::removeFile(tmpStressTestClientPIDFile);                  "::Syntax Error in PID file line number:"<<lineNumber<<endl;
               FileSystem::removeFile(_tmpStressTestClientPIDFile);
             return(isSuccess = false);             return(isSuccess = false);
             //throw ConfigFileSyntaxError(StressTestClientPIDFile, lineNumber);  
         }         }
  
         //         //
Line 2286 
Line 2542 
         if (*p != ':')         if (*p != ':')
         {         {
             ifs.close();             ifs.close();
             log_file<<StressTestControllerCommand::COMMAND_NAME<<"::Syntax Error in PID file line number:"<<lineNumber<<endl;              log_file<<StressTestControllerCommand::COMMAND_NAME <<
             FileSystem::removeFile(tmpStressTestClientPIDFile);                  "::Syntax Error in PID file line number:"<<lineNumber<<endl;
               FileSystem::removeFile(_tmpStressTestClientPIDFile);
             return(isSuccess = false);             return(isSuccess = false);
             //throw ConfigFileSyntaxError(StressTestClientPIDFile, lineNumber);  
         }         }
         p++;         p++;
   
         // Skip whitespace after the colon if any         // Skip whitespace after the colon if any
         while (*p && isspace(*p)) p++;          while (*p && isspace(*p))
           {
               p++;
           }
  
         String clntStatus = String::EMPTY;         String clntStatus = String::EMPTY;
         while (isalnum(*p) || *p == '_') clntStatus.append(*p++);          while (isalnum(*p) || *p == '_')
           {
               clntStatus.append(*p++);
           }
  
         // Skip whitespace after property name         // Skip whitespace after property name
         while (*p && isspace(*p)) p++;          while (*p && isspace(*p))
           {
               p++;
           }
  
         //         //
         // Expecting a colon         // Expecting a colon
Line 2307 
Line 2573 
         if (*p != ':')         if (*p != ':')
         {         {
             ifs.close();             ifs.close();
             log_file<<StressTestControllerCommand::COMMAND_NAME<<"::Syntax Error in PID file line number:"<<lineNumber<<endl;              log_file<<StressTestControllerCommand::COMMAND_NAME <<
             FileSystem::removeFile(tmpStressTestClientPIDFile);                  "::Syntax Error in PID file line number:"<<lineNumber<<endl;
               FileSystem::removeFile(_tmpStressTestClientPIDFile);
             return(isSuccess = false);             return(isSuccess = false);
             //throw ConfigFileSyntaxError(StressTestClientPIDFile, lineNumber);  
         }         }
  
         //         //
Line 2321 
Line 2587 
         if (*p != ':')         if (*p != ':')
         {         {
             ifs.close();             ifs.close();
             log_file<<StressTestControllerCommand::COMMAND_NAME<<"::Syntax Error in PID file line number:"<<lineNumber<<endl;              log_file<<StressTestControllerCommand::COMMAND_NAME<<
             FileSystem::removeFile(tmpStressTestClientPIDFile);                  "::Syntax Error in PID file line number:"<<lineNumber<<endl;
               FileSystem::removeFile(_tmpStressTestClientPIDFile);
             return(isSuccess = false);             return(isSuccess = false);
             //throw ConfigFileSyntaxError(StressTestClientPIDFile, lineNumber);  
         }         }
         //         //
         // next character in line.         // next character in line.
         //         //
         p++;         p++;
         // Skip whitespace after the colon if any         // Skip whitespace after the colon if any
         while (*p && isspace(*p)) p++;          while (*p && isspace(*p))
           {
               p++;
           }
  
         // Get the client timestamp         // Get the client timestamp
         String clntTmStmp = String::EMPTY;         String clntTmStmp = String::EMPTY;
         while (isalnum(*p)) clntTmStmp.append(*p++);          while (isalnum(*p))
           {
               clntTmStmp.append(*p++);
           }
  
         //         //
         // Store the PID, Status and TimeStamp for each client         // Store the PID, Status and TimeStamp for each client
         //         //
         if(atoi(client.getCString()) <= actual_clients)         if(atoi(client.getCString()) <= actual_clients)
         {         {
             clientPIDs[atoi(client.getCString())]=(pid_t)atoi(clntPID.getCString());              clientPIDs[atoi(client.getCString())] =
             clientStatus[atoi(client.getCString())]=(pid_t)atoi(clntStatus.getCString());                  (pid_t)atoi(clntPID.getCString());
             sscanf((const char*)clntTmStmp.getCString(), "%" PEGASUS_64BIT_CONVERSION_WIDTH "u", &clientTimeStamp[atoi(client.getCString())]);              clientStatus[atoi(client.getCString())] =
         }else {                  (pid_t)atoi(clntStatus.getCString());
               sscanf(
                   (const char*)clntTmStmp.getCString(),
                   "%" PEGASUS_64BIT_CONVERSION_WIDTH "u",
                   &clientTimeStamp[atoi(client.getCString())]);
           }
           else
           {
             if(verboseEnabled)             if(verboseEnabled)
             {             {
                log_file<<StressTestControllerCommand::COMMAND_NAME<<"::Unknown client PID for client#"<<atoi(client.getCString())<<" read at line number:"<<lineNumber<<endl;                  log_file<<StressTestControllerCommand::COMMAND_NAME<<
                       "::Unknown client PID for client#"<<
                       atoi(client.getCString())<<
                       " read at line number:"<<lineNumber<<endl;
                cout<<"Unknown Client PID recieved"<<endl;                cout<<"Unknown Client PID recieved"<<endl;
            }            }
         }         }
Line 2357 
Line 2638 
   //   //
   // remove the temporary file.   // remove the temporary file.
   //   //
   FileSystem::removeFile(tmpStressTestClientPIDFile);      FileSystem::removeFile(_tmpStressTestClientPIDFile);
   return(isSuccess = true);   return(isSuccess = true);
 }/* getClientPIDs */  }/* _getClientPIDs */
  
 /* /*
    Parses specified line to retrieve valid config data for the stress tests.    Parses specified line to retrieve valid config data for the stress tests.
Line 2388 
Line 2669 
     @return  true            Succesfully parsed the line.     @return  true            Succesfully parsed the line.
              false           Failed to parse the lines successfully.              false           Failed to parse the lines successfully.
  */  */
 Boolean StressTestControllerCommand::parseLine(const String & line,int lineNumber,String &name, String &value,ostream& log_file)  Boolean StressTestControllerCommand::_parseLine(
       const String & line,
       int lineNumber,
       String &name,
       String &value,
       ostream& log_file)
 { {
  
     const Char16* p;     const Char16* p;
     p = line.getChar16Data();     p = line.getChar16Data();
   
     //     //
     // Skip whitespace     // Skip whitespace
     //     //
Line 2400 
Line 2687 
     {     {
        p++;        p++;
     }     }
   
     //     //
     //  Ignore empty lines     //  Ignore empty lines
     //     //
Line 2408 
Line 2696 
        IgnoreLine = true;        IgnoreLine = true;
        return IgnoreLine;        return IgnoreLine;
     }     }
   
     //     //
     // Skip comment lines     // Skip comment lines
     //     //
Line 2416 
Line 2705 
        IgnoreLine = true;        IgnoreLine = true;
        return IgnoreLine;        return IgnoreLine;
     }     }
   
     //     //
     // Retreive all the Client Options     // Retreive all the Client Options
     //   "[" indicates start of client options.     //   "[" indicates start of client options.
Line 2449 
Line 2739 
           //           //
           //  get and validate client options           //  get and validate client options
           //           //
           getClientOptions(p,log_file);             _getClientOptions(p,log_file);
        }        }
        catch(Exception& e)        catch(Exception& e)
        {        {
Line 2461 
Line 2751 
                msg.append(line.getCString());                msg.append(line.getCString());
            }            }
            throw StressTestControllerException(msg);            throw StressTestControllerException(msg);
            return false;  
        }        }
         catch(...)         catch(...)
         {         {
            // throw what was caught            // throw what was caught
            String msg = String("Unknown exception caught when geting client options.");             String msg = String(
            log_file<<StressTestControllerCommand::COMMAND_NAME<<":Unknown exception caught when geting client options."<<endl;                 "Unknown exception caught when geting client options.");
            cerr<<StressTestControllerCommand::COMMAND_NAME<<":Unknown exception caught when geting client options."<<endl;             log_file<<StressTestControllerCommand::COMMAND_NAME <<
                  ":Unknown exception caught when geting client options."<<endl;
              cerr<<StressTestControllerCommand::COMMAND_NAME <<
                  ":Unknown exception caught when geting client options."<<endl;
            throw StressTestControllerException(msg);            throw StressTestControllerException(msg);
            return false;  
         }         }
  
        //        //
Line 2478 
Line 2769 
        //        //
        return true;        return true;
     }     }
   
     //     //
     // Get Common Properties     // Get Common Properties
     //     //
     name = String::EMPTY;     name = String::EMPTY;
   
     //     //
     // Invalid Common Property name     // Invalid Common Property name
     //     //
     if (!(isalpha(*p) || *p == '_'))     if (!(isalpha(*p) || *p == '_'))
     {     {
         throw InvalidPropertyValue(name, value);         String ErrReport = String("Invalid Property Value: ");
          ErrReport.append(name);
          ErrReport.append("=");
          ErrReport.append(value);
          throw StressTestControllerException(ErrReport);
     }     }
   
     //     //
     // Save the property Name     // Save the property Name
     //     //
Line 2497 
Line 2795 
     {     {
         name.append(*p++);         name.append(*p++);
     }     }
   
     //     //
     // Skip whitespace after property name     // Skip whitespace after property name
     //     //
Line 2504 
Line 2803 
     {     {
         p++;         p++;
     }     }
   
     //     //
     // Expect an equal sign     // Expect an equal sign
     //     //
     if (*p != '=')     if (*p != '=')
     {     {
         throw InvalidPropertyValue(name, value);         String ErrReport = String("Invalid Property Value: ");
          ErrReport.append(name);
          ErrReport.append("=");
          ErrReport.append(value);
          throw StressTestControllerException(ErrReport);
     }     }
   
     //     //
     // go to next     // go to next
     //     //
Line 2544 
Line 2849 
     //     //
     try     try
     {     {
        IsValid=validateConfiguration(name,value,log_file);          IsValid=_validateConfiguration(name,value,log_file);
     }     }
     catch(Exception& e)     catch(Exception& e)
     {     {
         String msg(e.getMessage());         String msg(e.getMessage());
         throw StressTestControllerException(msg);         throw StressTestControllerException(msg);
         return false;  
     }     }
     if(!IsValid)     if(!IsValid)
     {     {
        throw InvalidPropertyValue(name, value);         String ErrReport = String("Invalid Property Value: ");
        return false;         ErrReport.append(name);
          ErrReport.append("=");
          ErrReport.append(value);
          throw StressTestControllerException(ErrReport);
     }     }
     return true;     return true;
 } /* parseLine */  } /* _parseLine */
  
 /* /*
     Storing client details in a table.     Storing client details in a table.
Line 2571 
Line 2878 
     @return  true            Succesfully stored the name or instance.     @return  true            Succesfully stored the name or instance.
              false           Failed to store the name or instance.              false           Failed to store the name or instance.
  */  */
 Boolean StressTestControllerCommand::storeClientDetails(String name, String value)  Boolean StressTestControllerCommand::_storeClientDetails(
       String name,
       String value)
 { {
  
     //     //
Line 2598 
Line 2907 
         // Duplicate property, ignore the new property value.         // Duplicate property, ignore the new property value.
         //         //
         if(verboseEnabled)         if(verboseEnabled)
           {
             cout<< "Duplicate Client already saved: "<<endl;             cout<< "Duplicate Client already saved: "<<endl;
           }
         return false;         return false;
     }     }
   
     //     //
     // Store the number of instances for the client in the table     // Store the number of instances for the client in the table
     //     //
     if (!_clientTable[_clientCount].insert(INSTANCE, value))     if (!_clientTable[_clientCount].insert(INSTANCE, value))
     {     {
   
        //        //
        // Duplicate property, ignore the new property value.        // Duplicate property, ignore the new property value.
        //        //
        if(verboseEnabled)        if(verboseEnabled)
          {
           cout<< "Duplicate Instance already saved: "<<endl;           cout<< "Duplicate Instance already saved: "<<endl;
          }
        return false;        return false;
     }     }
     ++_clientCount;     ++_clientCount;
     return true;     return true;
 } /* storeClientDetails */  } /* _storeClientDetails */
  
 /* /*
     Will check the current tolerance level of the running clients with     Will check the current tolerance level of the running clients with
Line 2627 
Line 2942 
     @return  true            Clients with tolerance.     @return  true            Clients with tolerance.
              false           Clients failed tolerance.              false           Clients failed tolerance.
  */  */
 Boolean StressTestControllerCommand::checkToleranceLevel(int actual_client, Uint64 nowMilliseconds,ostream& log_file)  Boolean StressTestControllerCommand::_checkToleranceLevel(
       int actual_client,
       Uint64 nowMilliseconds,
       ostream& log_file)
 { {
   
    int count         = 0;    int count         = 0;
    int failed_count = 0;    int failed_count = 0;
    Uint64 lastUpdateinMilliSec =0;    Uint64 lastUpdateinMilliSec =0;
Line 2645 
Line 2962 
           ++count;           ++count;
           //           //
           // Validate the timestamps:           // Validate the timestamps:
           //  The timestamps on the status is compared to the previous timestamp              //  The timestamps on the status is compared to the previous
           //  to ensure that the status has been updated within the previous 2 updates              //  timestamp to ensure that the status has been updated within
               //  the previous 2 updates.
           //           //
           if(clientStatus[i]== VALID_RESPONSE)           if(clientStatus[i]== VALID_RESPONSE)
           {           {
Line 2657 
Line 2975 
                // longer than 2 * checkup interval                // longer than 2 * checkup interval
                //                //
                if((clientTimeStamp[i] == prev_clientTimeStamp[i])                if((clientTimeStamp[i] == prev_clientTimeStamp[i])
                   && (lastUpdateinMilliSec >= (2 * (Uint64)convertmin2millisecs(CHECKUP_INTERVAL))))                     && (lastUpdateinMilliSec >=
                      (2 * (Uint64)convertmin2millisecs(CHECKUP_INTERVAL))))
                {                {
                   if(verboseEnabled)                   if(verboseEnabled)
                    {                    {
                        log_file <<" Status not updated for client ("<<i<<")pid :"<<clientPIDs[i]<<endl;                          log_file <<" Status not updated for client (" <<i<<
                        log_file << "        for the past " << 2*(CHECKUP_INTERVAL) << " minutes." << endl;                              ")pid :"<<clientPIDs[i]<<endl;
                        cout <<" Status not updated for client ("<<i<<")pid :"<<clientPIDs[i]<<endl;                          log_file << "        for the past " <<
                        cout << "        for the past " << 2*(CHECKUP_INTERVAL) << " minutes." << endl;                              2*(CHECKUP_INTERVAL) << " minutes." << endl;
                           cout<<" Status not updated for client ("<<i<<")pid :"<<
                               clientPIDs[i]<<endl;
                           cout<<"        for the past " << 2*(CHECKUP_INTERVAL)<<
                               " minutes." << endl;
                    }                    }
   
                       ++failed_count;                       ++failed_count;
   
                }                }
           }           }
           //           //
           // If unknown status - server or client may be hung.           // If unknown status - server or client may be hung.
           // Two consective failures will be counted as a failed client              // Two consective failures on the same client will be counted
               // as a failed client.
           //           //
           if(((clientStatus[i]== NO_RESPONSE)           if(((clientStatus[i]== NO_RESPONSE)
             ||(clientStatus[i]== INVALID_RESPONSE))             ||(clientStatus[i]== INVALID_RESPONSE))
Line 2684 
Line 3006 
               {               {
                  if(clientStatus[i]== INVALID_RESPONSE)                  if(clientStatus[i]== INVALID_RESPONSE)
                  {                  {
                      log_file<<" Recieved an Invalid response Status from client ("<< i <<") pid :"<<clientPIDs[i]<<endl;                          log_file<<
                               "Recieved an Invalid response Status from client("<<
                               i <<") pid :"<<clientPIDs[i]<<endl;
                  }                  }
                  else                  else
                      log_file<<" Recieved a no response Status from client ("<<i <<") pid :"<<clientPIDs[i]<<endl;                      {
                           log_file<<"Recieved a no response Status from client("<<
                               i <<") pid :"<<clientPIDs[i]<<endl;
               }               }
               ++failed_count;  
           }           }
                   ++failed_count;
               } /* if (((clientStatus[i]== NO_RESPONSE) ... */
           // Save previous time stamp of client           // Save previous time stamp of client
           prev_clientTimeStamp[i] = clientTimeStamp[i];           prev_clientTimeStamp[i] = clientTimeStamp[i];
           prev_clientStatus[i] = clientStatus[i];           prev_clientStatus[i] = clientStatus[i];
       }          } /* if (clientActive[i]) */
    }    }
    // check actual tolerance    // check actual tolerance
    if(count > 0)    if(count > 0)
    {    {
       double curr_tolerancePercent = getToleranceInPercent(failed_count,(double)count);          double curr_tolerancePercent = getToleranceInPercent(
                                              failed_count,
                                              (double)count);
       if(verboseEnabled)       if(verboseEnabled)
       {       {
          cout<<" total running clients ="<<count<<endl;          cout<<" total running clients ="<<count<<endl;
Line 2719 
Line 3048 
    }    }
    // All process are stopped.    // All process are stopped.
    return(withinTolerance = true);    return(withinTolerance = true);
 } /* checkToleranceLevel */  } /* _checkToleranceLevel */
  
  
 /* /*
Line 2742 
Line 3071 
  
    log_file << "Populating default configuration for stress Tests." << endl;    log_file << "Populating default configuration for stress Tests." << endl;
    if(verboseEnabled)    if(verboseEnabled)
       {
       cout << "Populating default configuration for stress Tests." << endl;       cout << "Populating default configuration for stress Tests." << endl;
       }
    // Populating default client attributes    // Populating default client attributes
    for(Uint32 i=0;i<_clientCount; i++)    for(Uint32 i=0;i<_clientCount; i++)
    {    {
   
        //        //
        // Adding the default instance value to each client table        // Adding the default instance value to each client table
        if (!_clientTable[i].insert(INSTANCE, DEFAULT_INSTANCE))        if (!_clientTable[i].insert(INSTANCE, DEFAULT_INSTANCE))
        {        {
            log_file <<  "Duplicate name already saved: "<<INSTANCE<<endl;            log_file <<  "Duplicate name already saved: "<<INSTANCE<<endl;
            if(verboseEnabled)            if(verboseEnabled)
               {
               cout<< "duplicate name already saved: "<<INSTANCE<<endl;               cout<< "duplicate name already saved: "<<INSTANCE<<endl;
        }        }
           }
        switch (i)        switch (i)
        {        {
            case 0:            case 0:
Line 2764 
Line 3095 
                {                {
                   log_file <<  "Duplicate name already saved: "<<NAME<<endl;                   log_file <<  "Duplicate name already saved: "<<NAME<<endl;
                   if(verboseEnabled)                   if(verboseEnabled)
                       {
                     cout<< "Duplicate name already saved: "<<NAME<<endl;                     cout<< "Duplicate name already saved: "<<NAME<<endl;
                }                }
                   }
                log_file << "Stress Test Client Name:" <<MODELWALK_CLIENT<< endl;                log_file << "Stress Test Client Name:" <<MODELWALK_CLIENT<< endl;
                if(verboseEnabled)                if(verboseEnabled)
                   {
                    cout << "Stress Test Client Name:" <<MODELWALK_CLIENT<< endl;                    cout << "Stress Test Client Name:" <<MODELWALK_CLIENT<< endl;
                   }
   
                break;                break;
            }            }
            case 1:            case 1:
Line 2777 
Line 3113 
                {                {
                   log_file <<  "Duplicate name already saved: "<<NAME<<endl;                   log_file <<  "Duplicate name already saved: "<<NAME<<endl;
                   if(verboseEnabled)                   if(verboseEnabled)
                       {
                     cout<< "Duplicate name already saved: "<<NAME<<endl;                     cout<< "Duplicate name already saved: "<<NAME<<endl;
                }                }
                   }
                log_file << "Stress Test Client Name:" <<WRAPPER_CLIENT<< endl;                log_file << "Stress Test Client Name:" <<WRAPPER_CLIENT<< endl;
                if(verboseEnabled)                if(verboseEnabled)
                   {
                    cout << "Stress Test Client Name:" <<WRAPPER_CLIENT<< endl;                    cout << "Stress Test Client Name:" <<WRAPPER_CLIENT<< endl;
                   }
                if (!_clientTable[i].insert(CLIENTNAME, "CLI"))                if (!_clientTable[i].insert(CLIENTNAME, "CLI"))
                {                {
                   log_file<< "Duplicate name already saved: "<<CLIENTNAME<<endl;                      log_file<< "Duplicate name already saved: "<<
                           CLIENTNAME<<endl;
                   if(verboseEnabled)                   if(verboseEnabled)
                      cout<< "Duplicate name already saved: "<<CLIENTNAME<<endl;                      {
                           cout<< "Duplicate name already saved: "<<
                               CLIENTNAME<<endl;
                       }
                }                }
                if (!_clientTable[i].insert(OPTIONS, "niall"))                if (!_clientTable[i].insert(OPTIONS, "niall"))
                {                {
                   log_file<< "Duplicate name already saved: "<<OPTIONS<<endl;                   log_file<< "Duplicate name already saved: "<<OPTIONS<<endl;
                   if(verboseEnabled)                   if(verboseEnabled)
                       {
                      cout<< "Duplicate name already saved: "<<OPTIONS<<endl;                      cout<< "Duplicate name already saved: "<<OPTIONS<<endl;
                }                }
                log_file << "            Client Command &  options: CLI niall" << endl;  
                if(verboseEnabled)  
                    cout << "            Client Command &  options: CLI niall" << endl;  
                break;  
            }            }
                   log_file<< "            Client Command &  options: CLI niall"<<
                       endl;
                   if (verboseEnabled)
                   {
                      cout<< "            Client Command &  options: CLI niall"<<
                          endl;
        }        }
                   break;
               } /* case 1: */
           } /* switch(i) */
    } /* for(Uint32 i=0;i<_clientCount; i++) */    } /* for(Uint32 i=0;i<_clientCount; i++) */
  
 } /* getDefaultClients */ } /* getDefaultClients */
Line 2829 
Line 3179 
    sprintf(pid_str, "%d", getpid());    sprintf(pid_str, "%d", getpid());
  
    // Stress Controller Log file    // Stress Controller Log file
    StressTestLogFile.append(pegasusHome);      _stressTestLogFile.append(pegasusHome);
    StressTestLogFile.append(TESTDIR);      _stressTestLogFile.append(TESTDIR);
    FileSystem::makeDirectory(StressTestLogFile);      FileSystem::makeDirectory(_stressTestLogFile);
    StressTestLogFile.append(STRESSTESTDIR);      _stressTestLogFile.append(STRESSTESTDIR);
    FileSystem::makeDirectory(StressTestLogFile);      FileSystem::makeDirectory(_stressTestLogFile);
    StressTestLogFile.append(LOGDIR);      _stressTestLogFile.append(LOGDIR);
    FileSystem::makeDirectory(StressTestLogFile);      FileSystem::makeDirectory(_stressTestLogFile);
    StressTestLogFile.append(pid_str);      _stressTestLogFile.append(pid_str);
    StressTestLogFile.append("_stressTest_");      _stressTestLogFile.append("_stressTest_");
    StressTestLogFile.append(strTime);      _stressTestLogFile.append(strTime);
    StressTestLogFile.append("log");      _stressTestLogFile.append("log");
  
    // StressClient PID  file    // StressClient PID  file
    StressTestClientPIDFile.append(pegasusHome);      _stressTestClientPIDFile.append(pegasusHome);
    StressTestClientPIDFile.append(DEFAULT_TMPDIR);      _stressTestClientPIDFile.append(DEFAULT_TMPDIR);
    FileSystem::makeDirectory(StressTestClientPIDFile);      FileSystem::makeDirectory(_stressTestClientPIDFile);
    StressTestClientPIDFile.append(pid_str);      _stressTestClientPIDFile.append(pid_str);
    StressTestClientPIDFile.append("_StressTestClients");      _stressTestClientPIDFile.append("_StressTestClients");
    StressTestClientPIDFile.append(strTime);      _stressTestClientPIDFile.append(strTime);
    StressTestClientPIDFile.append("pid");      _stressTestClientPIDFile.append("pid");
  
    // StressClient Log  file    // StressClient Log  file
    StressTestClientLogFile.append(pegasusHome);      _stressTestClientLogFile.append(pegasusHome);
    StressTestClientLogFile.append(DEFAULT_LOGDIR);      _stressTestClientLogFile.append(DEFAULT_LOGDIR);
    StressTestClientLogFile.append(pid_str);      _stressTestClientLogFile.append(pid_str);
    StressTestClientLogFile.append("_StressTestClients");      _stressTestClientLogFile.append("_StressTestClients");
    StressTestClientLogFile.append(".log");      _stressTestClientLogFile.append(".log");
  
    // Temporary StressClient PID/status  file    // Temporary StressClient PID/status  file
    tmpStressTestClientPIDFile.append(pegasusHome);      _tmpStressTestClientPIDFile.append(pegasusHome);
    tmpStressTestClientPIDFile.append(DEFAULT_TMPDIR);      _tmpStressTestClientPIDFile.append(DEFAULT_TMPDIR);
    tmpStressTestClientPIDFile.append(pid_str);      _tmpStressTestClientPIDFile.append(pid_str);
    tmpStressTestClientPIDFile.append("TEMP");      _tmpStressTestClientPIDFile.append("TEMP");
    tmpStressTestClientPIDFile.append("_Clients");      _tmpStressTestClientPIDFile.append("_Clients");
    tmpStressTestClientPIDFile.append(".pid");      _tmpStressTestClientPIDFile.append(".pid");
  
    // Translate slashed for appropriate OS    // Translate slashed for appropriate OS
    FileSystem::translateSlashes(StressTestClientPIDFile);      FileSystem::translateSlashes(_stressTestClientPIDFile);
    FileSystem::translateSlashes(StressTestClientLogFile);      FileSystem::translateSlashes(_stressTestClientLogFile);
    FileSystem::translateSlashes(StressTestLogFile);      FileSystem::translateSlashes(_stressTestLogFile);
    FileSystem::translateSlashes(tmpStressTestClientPIDFile);      FileSystem::translateSlashes(_tmpStressTestClientPIDFile);
  
     // open the file     // open the file
     OpenAppend(log_file,StressTestLogFile);      OpenAppend(log_file,_stressTestLogFile);
     Open(pid_file,StressTestClientPIDFile);      Open(pid_file,_stressTestClientPIDFile);
     Open(clntlog_file,StressTestClientLogFile);      Open(clntlog_file,_stressTestClientLogFile);
  
     //     //
     //  Failed to open the log file     //  Failed to open the log file
Line 2884 
Line 3234 
        log_file.close();        log_file.close();
        pid_file.close();        pid_file.close();
        clntlog_file.close();        clntlog_file.close();
        cout<<"Cannot get file "<<StressTestLogFile<<endl;         cout<<"Cannot get file "<<_stressTestLogFile<<endl;
        return false;        return false;
  
     }     }
Line 2893 
Line 3243 
     //     //
     if (!pid_file)     if (!pid_file)
     {     {
        cout<<"Cannot get file "<<StressTestClientPIDFile<<endl;         cout<<"Cannot get file "<<_stressTestClientPIDFile<<endl;
        log_file<<StressTestControllerCommand::COMMAND_NAME<<"Cannot read file "<<StressTestClientPIDFile<<endl;         log_file<<StressTestControllerCommand::COMMAND_NAME<<
              "Cannot read file "<<_stressTestClientPIDFile<<endl;
        log_file.close();        log_file.close();
        clntlog_file.close();        clntlog_file.close();
        return false;        return false;
Line 2904 
Line 3255 
     //     //
     if (!clntlog_file)     if (!clntlog_file)
     {     {
        log_file<<StressTestControllerCommand::COMMAND_NAME<<"Cannot read file "<<StressTestClientLogFile<<endl;         log_file<<StressTestControllerCommand::COMMAND_NAME<<
              "Cannot read file "<<_stressTestClientLogFile<<endl;
        log_file.close();        log_file.close();
        pid_file.close();        pid_file.close();
        return false;        return false;
     }     }
   
     //     //
     // Successfully opened all the files.     // Successfully opened all the files.
     //     //
     pid_file<<"#"<<StressTestControllerCommand::COMMAND_NAME<<" has the following clients:: \n";      pid_file<<"#"<<StressTestControllerCommand::COMMAND_NAME<<
     clntlog_file<<"#"<<StressTestControllerCommand::COMMAND_NAME<<"::Process ID:"<<getpid()<<endl;          " has the following clients:: \n";
       clntlog_file<<"#"<<StressTestControllerCommand::COMMAND_NAME<<
           "::Process ID:"<<getpid()<<endl;
     clntlog_file.close();     clntlog_file.close();
     pid_file.close();     pid_file.close();
     return true;     return true;
Line 2925 
Line 3280 
     - Unused log files & pid files are removed here.     - Unused log files & pid files are removed here.
  
  */  */
 void StressTestControllerCommand::removeUnusedFiles(void)  void StressTestControllerCommand::removeUnusedFiles()
 { {
       FileSystem::removeFile(StressTestClientPIDFile);      FileSystem::removeFile(_stressTestClientPIDFile);
       FileSystem::removeFile(StressTestClientLogFile);      FileSystem::removeFile(_stressTestClientLogFile);
 } }
  
 PEGASUS_NAMESPACE_END PEGASUS_NAMESPACE_END
Line 2937 
Line 3292 
     Cleanup function for stressTestController to free allocated     Cleanup function for stressTestController to free allocated
     memory used to execute clients.     memory used to execute clients.
  */  */
 void cleanupProcess(void)  void cleanupProcess()
 { {
  
     delete [] clientPIDs;     delete [] clientPIDs;
Line 2952 
Line 3307 
 /* /*
     This will generate the current time.     This will generate the current time.
  */  */
 struct tm getCurrentActualTime(void)  struct tm getCurrentActualTime()
 { {
    struct tm tmTime;    struct tm tmTime;
    time_t inTime=time(NULL);    time_t inTime=time(NULL);
 #ifdef PEGASUS_PLATFORM_WIN32_IX86_MSVC  #ifdef PEGASUS_OS_TYPE_WINDOWS
    tmTime=*localtime(&inTime);    tmTime=*localtime(&inTime);
 #else #else
    localtime_r(&inTime,&tmTime);    localtime_r(&inTime,&tmTime);
Line 2977 
Line 3332 
       {       {
          case SIGINT:          case SIGINT:
          {          {
             cout <<StressTestControllerCommand::COMMAND_NAME<< "::Recieved interupt signal SIGINT!"<<endl;                  cout<<StressTestControllerCommand::COMMAND_NAME<<
                       "::Recieved interupt signal SIGINT!"<<endl;
             break;             break;
          }          }
          case SIGABRT:          case SIGABRT:
          {          {
             cout <<StressTestControllerCommand::COMMAND_NAME<< "::Recieved signal SIGABRT!"<<endl;                  cout<<StressTestControllerCommand::COMMAND_NAME<<
                       "::Recieved signal SIGABRT!"<<endl;
             break;             break;
          }          }
          default:          default:
          {          {
            cout<<StressTestControllerCommand::COMMAND_NAME<<"::Recieved Signal ( "<<signum<<"!" <<endl;                  cout<<StressTestControllerCommand::COMMAND_NAME<<
                       "::Recieved Signal ( "<<signum<<"!" <<endl;
            break;            break;
          }          }
       }       }
Line 3011 
Line 3369 
     char buffer[32];     char buffer[32];
     sprintf(buffer, "%" PEGASUS_64BIT_CONVERSION_WIDTH "u", x);     sprintf(buffer, "%" PEGASUS_64BIT_CONVERSION_WIDTH "u", x);
     return(String(buffer));     return(String(buffer));
 }  }/* convertUint64toString(..) */


Legend:
Removed from v.1.1.2.2  
changed lines
  Added in v.1.1.2.3

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2