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

📄 cimserver.cpp

📁 Pegasus is an open-source implementationof the DMTF CIM and WBEM standards. It is designed to be por
💻 CPP
📖 第 1 页 / 共 4 页
字号:
    _sslContextMgr = new SSLContextManager();#ifdef PEGASUS_HAS_SSL    // Because this provider allows management of the cimserver truststore    // it needs to be available regardless of the value    // of sslClientVerificationMode config property.    ProviderMessageHandler* certificateProvider = new ProviderMessageHandler(        "CertificateProvider",        new CertificateProvider(_repository, _sslContextMgr),        0, 0, false);    _controlProviders.append(certificateProvider);    ModuleController::register_module(        PEGASUS_QUEUENAME_CONTROLSERVICE,        PEGASUS_MODULENAME_CERTIFICATEPROVIDER,        certificateProvider,        controlProviderReceiveMessageCallback,        0);#endif#ifndef PEGASUS_DISABLE_PERFINST    // Create the Statistical Data control provider    ProviderMessageHandler* cimomstatdataProvider = new ProviderMessageHandler(        "CIMOMStatDataProvider", new CIMOMStatDataProvider(), 0, 0, false);    _controlProviders.append(cimomstatdataProvider);    ModuleController::register_module(        PEGASUS_QUEUENAME_CONTROLSERVICE,        PEGASUS_MODULENAME_CIMOMSTATDATAPROVIDER,        cimomstatdataProvider,        controlProviderReceiveMessageCallback,        0);#endif#ifndef PEGASUS_DISABLE_CQL    // Create the Query Capabilities control provider    ProviderMessageHandler* cimquerycapprovider = new ProviderMessageHandler(        "CIMQueryCapabilitiesProvider",        new CIMQueryCapabilitiesProvider(),        0, 0, false);    _controlProviders.append(cimquerycapprovider);    ModuleController::register_module(        PEGASUS_QUEUENAME_CONTROLSERVICE,        PEGASUS_MODULENAME_CIMQUERYCAPPROVIDER,        cimquerycapprovider,        controlProviderReceiveMessageCallback,        0);#endif#if !defined(PEGASUS_DISABLE_PERFINST) || defined(PEGASUS_ENABLE_SLP)    // Create the interop control provider    ProviderMessageHandler* interopProvider = new ProviderMessageHandler(        "InteropProvider", new InteropProvider(_repository), 0, 0, false);    _controlProviders.append(interopProvider);    ModuleController::register_module(        PEGASUS_QUEUENAME_CONTROLSERVICE,        PEGASUS_MODULENAME_INTEROPPROVIDER,        interopProvider,        controlProviderReceiveMessageCallback,        0);#endif    _cimOperationRequestDispatcher = new CIMOperationRequestDispatcher(        _repository, _providerRegistrationManager);    _binaryMessageHandler =        new BinaryMessageHandler(_cimOperationRequestDispatcher);    _cimOperationResponseEncoder = new CIMOperationResponseEncoder;    //    // get the configured authentication and authorization flags    //    ConfigManager* configManager = ConfigManager::getInstance();    Boolean enableAuthentication = ConfigManager::parseBooleanValue(        configManager->getCurrentValue("enableAuthentication"));    //    // Create Authorization queue only if authentication is enabled    //    if ( enableAuthentication )    {        _cimOperationRequestAuthorizer = new CIMOperationRequestAuthorizer(            _cimOperationRequestDispatcher);        _cimOperationRequestDecoder = new CIMOperationRequestDecoder(            _cimOperationRequestAuthorizer,            _cimOperationResponseEncoder->getQueueId());    }    else    {        _cimOperationRequestAuthorizer = 0;        _cimOperationRequestDecoder = new CIMOperationRequestDecoder(            _cimOperationRequestDispatcher,            _cimOperationResponseEncoder->getQueueId());    }    _cimExportRequestDispatcher = new CIMExportRequestDispatcher();    _cimExportResponseEncoder = new CIMExportResponseEncoder;    _cimExportRequestDecoder = new CIMExportRequestDecoder(        _cimExportRequestDispatcher,        _cimExportResponseEncoder->getQueueId());    _httpAuthenticatorDelegator = new HTTPAuthenticatorDelegator(        _cimOperationRequestDecoder->getQueueId(),        _cimExportRequestDecoder->getQueueId(),        _repository);    // IMPORTANT-NU-20020513: Indication service must start after ExportService    // otherwise HandlerService started by indicationService will never    // get ExportQueue to export indications for existing subscriptions    _indicationService = 0;    if (ConfigManager::parseBooleanValue(        configManager->getCurrentValue("enableIndicationService")))    {        _indicationService = new IndicationService(            _repository, _providerRegistrationManager);    }    // Enable the signal handler to shutdown gracefully on SIGHUP and SIGTERM    getSigHandle()->registerHandler(PEGASUS_SIGHUP, shutdownSignalHandler);    getSigHandle()->activate(PEGASUS_SIGHUP);    getSigHandle()->registerHandler(PEGASUS_SIGTERM, shutdownSignalHandler);    getSigHandle()->activate(PEGASUS_SIGTERM);    //    // Set up an additional thread    // waiting for a stop command from the z/OS console    //#if defined PEGASUS_PLATFORM_ZOS_ZSERIES_IBM    {        pthread_t thid;        if ( pthread_create(&thid,NULL,waitForStopCommand,NULL) != 0 )        {            char str_errno2[10];            sprintf(str_errno2,"%08X",__errno2());            Logger::put_l(Logger::ERROR_LOG, "CIM Server", Logger::SEVERE,                "Server.CIMServer.NO_CONSOLE_THREAD.PEGASUS_OS_ZOS",                "CIM Server Console command thread cannot be created: "                    "$0 ( errno $1, reason code 0x$2 ).",                strerror(errno),                errno,                str_errno2);        }    }#endif    // Load and initialize providers registed with AutoStart = true    _providerRegistrationManager->initializeProviders();#ifndef PEGASUS_DISABLE_AUDIT_LOGGER    // Register audit logger initialize callback    AuditLogger::setInitializeCallback(auditLogInitializeCallback);    Boolean enableAuditLog = ConfigManager::parseBooleanValue(        configManager->getCurrentValue("enableAuditLog"));    if (enableAuditLog)    {        AuditLogger::setEnabled(enableAuditLog);    }#endif}CIMServer::~CIMServer (){    PEG_METHOD_ENTER (TRC_SERVER, "CIMServer::~CIMServer()");    // Wait until the Shutdown provider request has cleared through the    // system.    ShutdownService::getInstance(this)->waitUntilNoMoreRequests(false);    // Ok, shutdown all the MQSs. This shuts their communication channel.    ShutdownService::getInstance(this)->shutdownCimomServices();    // Start deleting the objects.    // The order is very important.    // The HTTPAcceptor depends on HTTPAuthenticationDelegator    for (Uint32 i = 0, n = _acceptors.size (); i < n; i++)    {        HTTPAcceptor* p = _acceptors[i];        delete p;    }    // IndicationService depends on ProviderManagerService,    // IndicationHandlerService, and ProviderRegistrationManager, and thus    // should be deleted before the ProviderManagerService,    // IndicationHandlerService, and ProviderRegistrationManager are deleted.    delete _indicationService;    // HTTPAuthenticationDelegator depends on CIMRepository,    // CIMOperationRequestDecoder and CIMExportRequestDecoder    delete _httpAuthenticatorDelegator;    delete _cimExportRequestDecoder;    delete _cimExportResponseEncoder;    delete _cimExportRequestDispatcher;    // CIMOperationRequestDecoder depends on CIMOperationRequestAuthorizer    // and CIMOperationResponseEncoder    delete _cimOperationRequestDecoder;    delete _cimOperationResponseEncoder;    // BinaryMessageHandler depends on CIMOperationRequestDispatcher    delete _binaryMessageHandler;    // CIMOperationRequestAuthorizer depends on    // CIMOperationRequestDispatcher    delete _cimOperationRequestAuthorizer;    // IndicationHandlerService uses CIMOperationRequestDispatcher    delete _handlerService;    // CIMOperationRequestDispatcher depends on    // CIMRepository and ProviderRegistrationManager.    // CIMOperationRequestDispatcher keeps an internal list of control    // providers. Must delete this before ModuleController.    delete _cimOperationRequestDispatcher;    // ModuleController takes care of deleting all wrappers around    // the control providers.    delete _controlService;    // Find all of the control providers (module)    // Must delete CIMOperationRequestDispatcher _before_ deleting each    // of the control provider. The CIMOperationRequestDispatcher keeps    // its own table of the internal providers (pointers).    for (Uint32 i = 0, n = _controlProviders.size(); i < n; i++)    {        ProviderMessageHandler* p = _controlProviders[i];        delete p->getProvider();        delete p;    }    // The SSL control providers use the SSL context manager.    delete _sslContextMgr;    // ProviderManagerService depends on ProviderRegistrationManager.    // Note that deleting the ProviderManagerService causes the    // DefaultProviderManager (if loaded) to get unloaded.  Dynamically    // unloading the DefaultProviderManager library affects (on HP-UX, at    // least) the statically loaded version of this library used by the    // ProviderMessageHandler wrapper for the control providers.  Deleting    // the ProviderManagerService after the control providers is a    // workaround for this problem.    delete _providerManager;    delete _providerRegistrationManager;    // Almost everybody uses the CIMRepository.    delete _repository;    // Destroy the singleton services    ConfigManager::destroy();    UserManager::destroy();    ShutdownService::destroy();    PEG_METHOD_EXIT ();}void CIMServer::addAcceptor(    Boolean localConnection,    Uint32 portNumber,    Boolean useSSL){    HTTPAcceptor* acceptor;    acceptor = new HTTPAcceptor(        _monitor,        _httpAuthenticatorDelegator,        localConnection,        portNumber,        useSSL ? _getSSLContext() : 0,        useSSL ? _sslContextMgr->getSSLContextObjectLock() : 0 );    ConfigManager* configManager = ConfigManager::getInstance();    String socketWriteConfigTimeout =        configManager->getCurrentValue("socketWriteTimeout");    // Set timeout value for server socket timeouts    // depending on config option    Uint32 socketWriteTimeout =        strtol(socketWriteConfigTimeout.getCString(), (char**)0, 10);    // equal what went wrong, there has to be a timeout    if (socketWriteTimeout == 0) socketWriteTimeout = 20;    acceptor->setSocketWriteTimeout(socketWriteTimeout);    _acceptors.append(acceptor);}void CIMServer::bind(){    PEG_METHOD_ENTER(TRC_SERVER, "CIMServer::bind()");    if (_acceptors.size() == 0)    {        MessageLoaderParms mlp = MessageLoaderParms(            "Server.CIMServer.BIND_FAILED",            "No CIM Server connections are enabled.");        throw BindFailedException(mlp);    }    for (Uint32 i=0; i<_acceptors.size(); i++)    {        _acceptors[i]->bind();    }    PEG_METHOD_EXIT();}void CIMServer::runForever(){    // Note: Trace code in this method will be invoked frequently.    if (!_dieNow)    {        struct timeval now;#ifdef PEGASUS_ENABLE_SLP# ifdef PEGASUS_SLP_REG_TIMEOUT        static struct timeval lastReregistrationTime = {0,0};        Time::gettimeofday(&now);        // If PEGASUS_SLP_REG_TIMEOUT (SLP registration timeout in minutes) is        // defined, then when this SLP registration timeout is exceeded, we        // need to call startSLPProvider() to update our registration with SLP.        // Convert SLP registration timeout to seconds for this check.        if (now.tv_sec - lastReregistrationTime.tv_sec >             (PEGASUS_SLP_REG_TIMEOUT * 60))        {            lastReregistrationTime.tv_sec = now.tv_sec;# endif            startSLPProvider();# ifdef PEGASUS_SLP_REG_TIMEOUT        }# endif // PEGASUS_SLP_REG_TIMEOUT#endif // PEGASUS_ENABLE_SLP        _monitor->run(500000);        static struct timeval lastIdleCleanupTime = {0, 0};        Time::gettimeofday(&now);        if (now.tv_sec - lastIdleCleanupTime.tv_sec > 300)        {            lastIdleCleanupTime.tv_sec = now.tv_sec;            try            {                _providerManager->unloadIdleProviders();                MessageQueueService::get_thread_pool()->cleanupIdleThreads();            }            catch (...)            {

⌨️ 快捷键说明

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