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

📄 providermanagerservice.cpp

📁 Pegasus is an open-source implementationof the DMTF CIM and WBEM standards. It is designed to be por
💻 CPP
📖 第 1 页 / 共 3 页
字号:
    }    //    // Start an idle provider unload thread    //    if (_thread_pool->allocate_and_awaken((void*)this,            ProviderManagerService::_unloadIdleProvidersHandler) !=                PEGASUS_THREAD_OK)    {        Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, Logger::TRACE,            "Not enough threads to unload idle providers.");        Tracer::trace(TRC_PROVIDERMANAGER, Tracer::LEVEL2,            "Could not allocate thread for %s to unload idle providers.",            getQueueName());        // If we fail to allocate a thread, don't retry now.        _unloadIdleProvidersBusy--;        PEG_METHOD_EXIT();        return;    }    // Note: _unloadIdleProvidersBusy is decremented in    // _unloadIdleProvidersHandler    PEG_METHOD_EXIT();}ThreadReturnType PEGASUS_THREAD_CDECLProviderManagerService::_unloadIdleProvidersHandler(void* arg) throw(){    ProviderManagerService* myself =        reinterpret_cast<ProviderManagerService*>(arg);    try    {        PEG_METHOD_ENTER(TRC_PROVIDERMANAGER,            "ProviderManagerService::_unloadIdleProvidersHandler");        if (myself->_basicProviderManagerRouter)        {            try            {                myself->_basicProviderManagerRouter->unloadIdleProviders();            }            catch (...)            {                // Ignore errors                PEG_TRACE_STRING(TRC_PROVIDERMANAGER, Tracer::LEVEL2,                    "Unexpected exception from "                        "BasicProviderManagerRouter::_unloadIdleProviders");            }        }        if (myself->_oopProviderManagerRouter)        {            try            {                myself->_oopProviderManagerRouter->unloadIdleProviders();            }            catch (...)            {                // Ignore errors                PEG_TRACE_STRING(TRC_PROVIDERMANAGER, Tracer::LEVEL2,                    "Unexpected exception from "                        "OOPProviderManagerRouter::_unloadIdleProviders");            }        }        myself->_unloadIdleProvidersBusy--;        PEG_METHOD_EXIT();    }    catch (...)    {        // Ignore errors        PEG_TRACE_STRING(TRC_PROVIDERMANAGER, Tracer::LEVEL2,            "Unexpected exception in _unloadIdleProvidersHandler");        myself->_unloadIdleProvidersBusy--;    }    return ThreadReturnType(0);}// Updates the providerModule instance and the ProviderRegistrationManager//// This method is used to update the provider module status when the module is// disabled or enabled.  If a Degraded status has been set (appended) to the// OperationalStatus, it is cleared (removed) when the module is disabled or// enabled.//void ProviderManagerService::_updateProviderModuleStatus(    CIMInstance& providerModule,    const Array<Uint16>& removeStatus,    const Array<Uint16>& appendStatus){    PEG_METHOD_ENTER(TRC_PROVIDERMANAGER,        "ProviderManagerService::_updateProviderModuleStatus");    Array<Uint16> operationalStatus;    String providerModuleName;    Uint32 pos = providerModule.findProperty(CIMName("Name"));    PEGASUS_ASSERT(pos != PEG_NOT_FOUND);    providerModule.getProperty(pos).getValue().get(providerModuleName);    //    // get operational status    //    pos = providerModule.findProperty(CIMName("OperationalStatus"));    PEGASUS_ASSERT(pos != PEG_NOT_FOUND);    CIMProperty operationalStatusProperty = providerModule.getProperty(pos);    if (_providerRegistrationManager->updateProviderModuleStatus(        providerModuleName, removeStatus, appendStatus, operationalStatus) ==        false)    {        throw PEGASUS_CIM_EXCEPTION_L(            CIM_ERR_FAILED,            MessageLoaderParms(                "ProviderManager.ProviderManagerService."                    "SET_MODULE_STATUS_FAILED",                "set module status failed."));    }    operationalStatusProperty.setValue(CIMValue(operationalStatus));    PEG_METHOD_EXIT();}void ProviderManagerService::indicationCallback(    CIMProcessIndicationRequestMessage* request){    if (request->operationContext.contains(AcceptLanguageListContainer::NAME))    {        AcceptLanguageListContainer cntr =            request->operationContext.get(AcceptLanguageListContainer::NAME);    }    else    {        request->operationContext.insert(            AcceptLanguageListContainer(AcceptLanguageList()));    }    if (_indicationServiceQueueId == PEG_NOT_FOUND)    {        Array<Uint32> serviceIds;        providerManagerService->find_services(            PEGASUS_QUEUENAME_INDICATIONSERVICE, 0, 0, &serviceIds);        PEGASUS_ASSERT(serviceIds.size() != 0);        _indicationServiceQueueId = serviceIds[0];    }    request->queueIds = QueueIdStack(        _indicationServiceQueueId, providerManagerService->getQueueId());    AsyncLegacyOperationStart * asyncRequest =        new AsyncLegacyOperationStart(        0,        _indicationServiceQueueId,        request,        _indicationServiceQueueId);    providerManagerService->SendForget(asyncRequest);#ifdef PEGASUS_INDICATIONS_Q_THRESHOLD    // See Comments in config.mak asociated with    //  PEGASUS_INDICATIONS_Q_THRESHOLD    //    // if INDICATIONS_Q_STALL THRESHOLD is gt 0    // then if there are over INDICATIONS_Q_STALL_THRESHOLD    //           indications in the queue    //      then force this provider to sleep until the queue count    //      is lower than INDICATIONS_Q_RESUME_THRESHOLDstatic Mutex   indicationThresholdReportedLock;static Boolean indicationThresholdReported = false;#define INDICATIONS_Q_STALL_THRESHOLD PEGASUS_INDICATIONS_Q_THRESHOLD#define INDICATIONS_Q_RESUME_THRESHOLD \    (int)(PEGASUS_INDICATIONS_Q_THRESHOLD*.90)#define INDICATIONS_Q_STALL_DURATION 250 // milli-seconds    MessageQueue* indicationsQueue =        MessageQueue::lookup(_indicationServiceQueueId);    if (((MessageQueueService *)indicationsQueue)->getIncomingCount() >            INDICATIONS_Q_STALL_THRESHOLD)    {        AutoMutex indicationThresholdReportedAutoMutex(            indicationThresholdReportedLock);        if (!indicationThresholdReported)        {            indicationThresholdReported = true;            indicationThresholdReportedAutoMutex.unlock();            // make log entry to record que max exceeded            Logger::put(                Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION,                "Indication generation stalled: maximum queue count ($0) "                    "exceeded.",                INDICATIONS_Q_STALL_THRESHOLD);        }        else        {            indicationThresholdReportedAutoMutex.unlock();        }        while (((MessageQueueService *)indicationsQueue)->getIncomingCount() >                   INDICATIONS_Q_RESUME_THRESHOLD)        {            Threads::sleep(INDICATIONS_Q_STALL_DURATION);        }        AutoMutex indicationThresholdReportedAutoMutex1(            indicationThresholdReportedLock);        if (indicationThresholdReported)        {            indicationThresholdReported = false;            indicationThresholdReportedAutoMutex1.unlock();            Logger::put(                Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION,                "Indication generation resumed: current queue count = $0",                ((MessageQueueService *)indicationsQueue)->getIncomingCount());        }        else        {            indicationThresholdReportedAutoMutex1.unlock();        }    }#endif /* INDICATIONS_Q_STALL_THRESHOLD */}void ProviderManagerService::providerModuleFailureCallback    (const String & moduleName,     const String & userName,     Uint16 userContext){    PEG_METHOD_ENTER (TRC_PROVIDERMANAGER,        "ProviderManagerService::providerModuleFailureCallback");    if (userContext == PG_PROVMODULE_USERCTXT_REQUESTOR)    {        Logger::put_l (            Logger::STANDARD_LOG, System::CIMSERVER, Logger::WARNING,            "ProviderManager.OOPProviderManagerRouter."                "OOP_PROVIDER_MODULE_USER_CTXT_FAILURE_DETECTED",            "A failure was detected in provider module $0 with"                " user context $1.",            moduleName, userName);    }    else  //  not requestor context    {        Logger::put_l (            Logger::STANDARD_LOG, System::CIMSERVER, Logger::WARNING,            "ProviderManager.OOPProviderManagerRouter."                "OOP_PROVIDER_MODULE_FAILURE_DETECTED",            "A failure was detected in provider module $0.",            moduleName);    }    //    //  Create Notify Provider Fail request message    //    CIMNotifyProviderFailRequestMessage * request =        new CIMNotifyProviderFailRequestMessage            (XmlWriter::getNextMessageId (),            moduleName,            userName,            QueueIdStack ());    //    //  Send Notify Provider Fail request message to Indication Service    //    if (_indicationServiceQueueId == PEG_NOT_FOUND)    {        Array <Uint32> serviceIds;        providerManagerService->find_services            (PEGASUS_QUEUENAME_INDICATIONSERVICE, 0, 0, &serviceIds);        PEGASUS_ASSERT (serviceIds.size () != 0);        _indicationServiceQueueId = serviceIds [0];    }    request->queueIds = QueueIdStack        (_indicationServiceQueueId, providerManagerService->getQueueId ());    AsyncLegacyOperationStart * asyncRequest = new AsyncLegacyOperationStart(        0,        _indicationServiceQueueId,        request,        _indicationServiceQueueId);    AutoPtr <AsyncReply> asyncReply        (providerManagerService->SendWait (asyncRequest));    AutoPtr <CIMNotifyProviderFailResponseMessage> response        (reinterpret_cast <CIMNotifyProviderFailResponseMessage *>            ((dynamic_cast <AsyncLegacyOperationResult *>            (asyncReply.get ()))->get_result ()));    if (response->cimException.getCode () != CIM_ERR_SUCCESS)    {        PEG_TRACE_STRING (TRC_DISCARDED_DATA, Tracer::LEVEL2,            "Unexpected exception in providerModuleFailureCallback: " +            response->cimException.getMessage ());    }    else    {        //        //  Successful response        //  Examine result to see if any subscriptions were affected        //        if (response->numSubscriptionsAffected > 0)        {            //            //  Subscriptions were affected            //  Update the provider module status to Degraded            //            try            {                CIMInstance providerModule;                CIMKeyBinding keyBinding(                    _PROPERTY_PROVIDERMODULE_NAME,                    moduleName,                    CIMKeyBinding::STRING);                Array<CIMKeyBinding> kbArray;                kbArray.append(keyBinding);                CIMObjectPath modulePath("", PEGASUS_NAMESPACENAME_INTEROP,                    PEGASUS_CLASSNAME_PROVIDERMODULE, kbArray);                providerModule =                    providerManagerService->_providerRegistrationManager->                        getInstance(                            modulePath, false, false, CIMPropertyList());                Array<Uint16> removeStatus;                Array<Uint16> appendStatus;                removeStatus.append(CIM_MSE_OPSTATUS_VALUE_OK);                appendStatus.append(CIM_MSE_OPSTATUS_VALUE_DEGRADED);                providerManagerService->_updateProviderModuleStatus(                    providerModule, removeStatus, appendStatus);            }            catch (const Exception & e)            {                PEG_TRACE_STRING(TRC_DISCARDED_DATA, Tracer::LEVEL2,                    "Failed to update provider module status: " +                    e.getMessage());            }            //            //  Log a warning message since subscriptions were affected            //            Logger::put_l (                Logger::STANDARD_LOG, System::CIMSERVER, Logger::WARNING,                "ProviderManager.OOPProviderManagerRouter."                    "OOP_PROVIDER_MODULE_SUBSCRIPTIONS_AFFECTED",                "The generation of indications by providers in module $0 "                "may be affected.  To ensure these providers are serving "                "active subscriptions, disable and then re-enable this "                "module using the cimprovider command.",                moduleName);        }    }    PEG_METHOD_EXIT();}PEGASUS_NAMESPACE_END

⌨️ 快捷键说明

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