⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 testmodelwalkstressclient.cpp

📁 Pegasus is an open-source implementationof the DMTF CIM and WBEM standards. It is designed to be por
💻 CPP
📖 第 1 页 / 共 2 页
字号:
            if (status != CLIENT_PASS)            {                status = CLIENT_PASS;                tmsc.logInfo(clientId, clientPid, status, pidFile);            }            enumerateInstanceRelatedInfo(tmsc, client, classNames,                nameSpacesArray[i], clientPid, clientLog, clientId, status,                pidFile );        }    }      if (verboseTest)    {        errorInfo.clear();        errorInfo.append("+++++ Successfully Enumerated classes ");        errorInfo.append("in Namespaces +++++");        tmsc.errorLog(clientPid, clientLog, errorInfo);        errorInfo.clear();    }}/**    MAIN*/int main(int argc, char** argv){    OptionManager om;    TestModelWalkStressClient tmsc;    Uint32 validArg = 0;    struct OptionRow *newOptionsTable = 0;    Uint32 newOptionsCount = 0;    Uint32 cOptionCount =  0;    //    // Variables need to connect to server.     //    Boolean useSSL;    String host;    Uint32 portNumber = 0;    String portStr;    String userName;    String password;    String help;    Boolean connectedToHost = false;    //    // Variables needed to do loging and status checking.    //    String pidFile;    String clientId;    pid_t clientPid;    String clientLog, stopClient;    char pid_str[15];    //    // Number of times the command succeeded.     //    Uint32 successCount=0;    //    // Number of iterations after which logErrorPercentage() is called.    //    Uint32 iteration=0;    //    // Total number of times the command was executed.    //    Uint32 totalCount=0;    //    // timeout.    //    Uint32 timeout = 30000;    //    // This try block includes all the options gathering function.    //    try    {        //        // client specific options if any.        //        struct OptionRow *cOptionTable = 0;         newOptionsCount = cOptionCount;        try        {            //            // Generate new option table for this client using            // the OptionManager.            //                        newOptionsTable = tmsc.generateClientOptions(cOptionTable,                cOptionCount,newOptionsCount);            validArg = tmsc.GetOptions(om, argc, argv, newOptionsTable,                newOptionsCount);        }        catch (Exception& e)        {            PEGASUS_STD(cerr) << argv[0] << ": " << e.getMessage()                              << PEGASUS_STD(endl);            exit(1);        }        catch (...)        {            PEGASUS_STD(cerr) << argv[0] << ": Error in Options operation "                              << PEGASUS_STD(endl);            exit(1);        }        verboseTest = om.isTrue("verbose");        om.lookupValue("username", userName);        om.lookupValue("password", password);        om.lookupIntegerValue("timeout",timeout);        useSSL =  om.isTrue("ssl");        om.lookupValue("hostname",host);        om.lookupValue("port",portStr);        if (portStr.getCString())        {            sscanf (portStr.getCString (), "%u", &portNumber);        }                //        // Setting default ports.        //        if (!portNumber)        {            if (useSSL)            {                portNumber = 5989;            }            else            {                portNumber = 5988;            }        }        //        // default host is localhost.        //        if (host == String::EMPTY)        {            host = String("localhost");        }        //        // Signal Handling - SIGINT        //        signal(SIGINT, endTest);        om.lookupValue("clientid", clientId);        om.lookupValue("pidfile", pidFile);        clientPid = getpid();        om.lookupValue("clientlog", clientLog);        om.lookupValue("help", help);    }// end of option Try block    catch (Exception& e)    {        PEGASUS_STD(cerr) << argv[0] << ": " << e.getMessage()                          << PEGASUS_STD(endl);        exit(1);    }    catch (...)    {        PEGASUS_STD(cerr) << argv[0] << ": Unknown Error gathering options "                          << PEGASUS_STD(endl);        exit(1);    }    /* Checking whether the user asked for HELP Info...    if (om.valueEquals("help", "true"))    {        String header = "Usage ";        header.append(argv[0]);        header.append(" -parameters -n [namespace] -c [classname] ");        header.append(" -clientId [clientId] -pidFile [pidFile] ");        header.append(" -clientLog [clientLog]");        String trailer = "Assumes localhost:5988 if host not specified";        trailer.append("\nHost may be of the form name or name:port");        trailer.append("\nPort 5988 assumed if port number missing.");        om.printOptionsHelpTxt(header, trailer);        exit(0);    } */    try    {        //        // Timer Start.        //        tmsc.startTime();        tmsc.logInfo(clientId, clientPid, status, pidFile);        //        // connect the client.        //        CIMClient* client = new CIMClient();        sprintf(pid_str, "%d", clientPid);        stopClient = String::EMPTY;        stopClient.append(FileSystem::extractFilePath(pidFile));        stopClient.append("STOP_");        stopClient.append(pid_str);        //        // This loop executes till the client gets stop signal from        // controller.        //        while (!quit)        {            if (FileSystem::exists(stopClient))            {                if (verboseTest)                {                    String mes("Ending client. ");                    tmsc.errorLog(clientPid, clientLog, mes);                 }                break;            }                if (!verboseTest)                {#ifdef PEGASUS_OS_TYPE_WINDOWS                    freopen("nul","w",stdout);#else                     freopen("/dev/null","w",stdout);#endif                }            if (!connectedToHost)            {                try                {                    tmsc.connectClient( client, host, portNumber, userName,                        password, useSSL, timeout, verboseTest);                    connectedToHost = true;                                       //                   // Client has successfully connected to server.                   // update status if previously not Success.                   //                   if (status != CLIENT_PASS)                   {                       status = CLIENT_PASS;                       tmsc.logInfo(clientId, clientPid, status, pidFile);                   }                }                catch (CannotConnectException)                {                    status = CLIENT_UNKNOWN;                    tmsc.logInfo(clientId, clientPid, status, pidFile);                    connectedToHost = false;                }                catch (CIMException &e)                {                    status = CLIENT_UNKNOWN;                    tmsc.logInfo(clientId, clientPid, status, pidFile);                    connectedToHost = false;                    String mes(e.getMessage());                    tmsc.errorLog(clientPid, clientLog, mes);                }                catch (Exception &e)                {                    status = CLIENT_UNKNOWN;                    tmsc.logInfo(clientId, clientPid, status, pidFile);                    connectedToHost = false;                    String mes(e.getMessage());                    tmsc.errorLog(clientPid, clientLog, mes);                }                catch (...)                {                    status = CLIENT_UNKNOWN;                    tmsc.logInfo(clientId, clientPid, status, pidFile);                    connectedToHost = false;                    String mes("Error connencting to server in ModleWalk");                    mes.append(" client ");                    tmsc.errorLog(clientPid, clientLog,mes);                }            }/* end of if (!connectedToHost). */            iteration++;            totalCount++;            if (connectedToHost)            {                try                {                    Array<CIMNamespaceName> nameSpacesArray;                    //                    // Enumerate all the namespaces here.                    //                    nameSpacesArray = getNameSpaces(                                          tmsc,                                          client,                                          om,                                          clientPid,                                          clientLog,                                          clientId,                                          status,                                          pidFile);                    //                    // Enumerate all qualifiers in the namespaces.                    //                    enumerateAllQualifiers(                        tmsc,                        client,                         nameSpacesArray,                        clientPid,                        clientLog,                        clientId,                        status,                        pidFile);                    //                    // Enumerate all the class related info here.                    //                    enumerateClassRelatedInfo(                        tmsc,                        client,                        om,                        nameSpacesArray,                        clientPid,                        clientLog,                        clientId,                        status,                        pidFile);                    successCount++;                }                //                // This specail catch block in needed so that we will know if                // the connenction was lost. We then connect on the next time                // through the loop.                //                                catch (CannotConnectException)                {                    status = CLIENT_UNKNOWN;                    tmsc.logInfo(clientId, clientPid, status, pidFile);                    connectedToHost = false;                }                catch (CIMException &cimE)                {                    status = CLIENT_FAIL;                    tmsc.logInfo(clientId, clientPid, status, pidFile);                    String mes(cimE.getMessage());                    tmsc.errorLog(clientPid, clientLog, mes);                }                catch (Exception &exp)                {                    status = CLIENT_FAIL;                    tmsc.logInfo(clientId, clientPid, status, pidFile);                    String mes(exp.getMessage());                    tmsc.errorLog(clientPid, clientLog, mes);                }                catch (...)                {                    status = CLIENT_FAIL;                    tmsc.logInfo(clientId, clientPid, status, pidFile);                    String mes("Unknown Error during ModelWalk Execution");                    tmsc.errorLog(clientPid, clientLog, mes);                }                nextCheck = tmsc.checkTime();                if (nextCheck)                {                    tmsc.logInfo(clientId, clientPid, status, pidFile);                    nextCheck = false;                }                //                // If verbose is set, log success percentage for every 100                // iterations. If verbose is not set, log success percentage                // for every 10000 iterations.                //                if (verboseTest)                {                    if (iteration == 100)                    {                        tmsc.logErrorPercentage(                            successCount,                             totalCount,                             clientPid,                            clientLog,                            clientName);                        iteration = 0;                    }                }                else                {                    if (iteration == 1000)                    {                        tmsc.logErrorPercentage(                            successCount,                            totalCount,                            clientPid,                            clientLog,                            clientName);                        iteration = 0;                    }                }            }        } // end of while (!quit).    }    catch (Exception &exp)    {        String expStr("Exception in ModelWalk client, causing it to exit: ");        expStr.append(exp.getMessage());        tmsc.errorLog(clientPid, clientLog, expStr);        if (verboseTest)        {            PEGASUS_STD(cerr) << expStr.getCString() << PEGASUS_STD(endl);        }    }    catch (...)    {        String expStr("General Exception in ModelWalk, causing it to exit");        tmsc.errorLog(clientPid, clientLog, expStr);        if (verboseTest)        {            PEGASUS_STD(cerr) << expStr.getCString() << PEGASUS_STD(endl);        }    }//// One second delay before shutdown.//#ifndef PEGASUS_OS_TYPE_WINDOWS    sleep(1);#else    Sleep(1000);#endif    if (FileSystem::exists(stopClient))    {        //        // Remove STOP file here.         //        FileSystem::removeFile(stopClient);    }       if (verboseTest)    {        errorInfo.clear();        errorInfo.append("+++++ TestModelWalkStressClient Terminated ");        errorInfo.append("Normally +++++");        tmsc.errorLog(clientPid, clientLog, errorInfo);        errorInfo.clear();    }    return 0;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -