📄 indicationservice.cpp
字号:
// // A message type not supported by the Indication Service // Should not reach here // // << Mon Apr 29 16:29:10 2002 mdd >> PEG_TRACE_STRING(TRC_INDICATION_SERVICE, Tracer::LEVEL3, "IndicationService::handleEnqueue(msg *) rcv'd unsupported msg " + String(MessageTypeToString(message->getType()))); // Note: not setting Content-Language in the response CIMRequestMessage* cimRequest = dynamic_cast<CIMRequestMessage*>(message); CIMResponseMessage* response = cimRequest->buildResponse(); response->cimException = PEGASUS_CIM_EXCEPTION_L( CIM_ERR_NOT_SUPPORTED, MessageLoaderParms( "IndicationService.IndicationService.UNSUPPORTED_OPERATION", "The requested operation is not supported or not recognized " "by the indication service.")), _enqueueResponse (cimRequest, response); break; }#ifdef PEGASUS_INDICATION_PERFINST stopWatch.stop(); Tracer::trace (TRC_INDICATION_SERVICE_INTERNAL, Tracer::LEVEL2, "%s: %.3f seconds", MessageTypeToString(message->getType()), stopWatch.getElapsed());#endif delete message;}void IndicationService::handleEnqueue(void){ Message * message = dequeue(); PEGASUS_ASSERT(message != 0); handleEnqueue(message);}void IndicationService::_initialize (void){ PEG_METHOD_ENTER (TRC_INDICATION_SERVICE, "IndicationService::_initialize");#ifdef PEGASUS_INDICATION_PERFINST Stopwatch stopWatch; stopWatch.start();#endif Array <CIMInstance> activeSubscriptions; Array <CIMInstance> noProviderSubscriptions; Boolean invalidInstance = false; // // Find required services // NOTE: Indication Service expects to find exactly one Provider Manager // Service and exactly one Handler Manager Service // Array <Uint32> pmservices; find_services (PEGASUS_QUEUENAME_PROVIDERMANAGER_CPP, 0, 0, &pmservices); Threads::yield (); PEGASUS_ASSERT (pmservices.size () == 1); _providerManager = pmservices [0]; Array <Uint32> hmservices; find_services (PEGASUS_QUEUENAME_INDHANDLERMANAGER, 0, 0, &hmservices); Threads::yield (); PEGASUS_ASSERT (hmservices.size () == 1); _handlerService = hmservices [0]; // // Set arrays of valid and supported property values // // Note: Valid values are defined by the CIM Event Schema MOF // Supported values are a subset of the valid values // Some valid values, as defined in the MOF, are not currently supported // by the Pegasus IndicationService // _validStates.append (STATE_UNKNOWN); _validStates.append (STATE_OTHER); _validStates.append (STATE_ENABLED); _validStates.append (STATE_ENABLEDDEGRADED); _validStates.append (STATE_DISABLED); _supportedStates.append (STATE_ENABLED); _supportedStates.append (STATE_DISABLED); _validRepeatPolicies.append (_POLICY_UNKNOWN); _validRepeatPolicies.append (_POLICY_OTHER); _validRepeatPolicies.append (_POLICY_NONE); _validRepeatPolicies.append (_POLICY_SUPPRESS); _validRepeatPolicies.append (_POLICY_DELAY); _supportedRepeatPolicies.append (_POLICY_UNKNOWN); _supportedRepeatPolicies.append (_POLICY_OTHER); _supportedRepeatPolicies.append (_POLICY_NONE); _supportedRepeatPolicies.append (_POLICY_SUPPRESS); _supportedRepeatPolicies.append (_POLICY_DELAY); _validErrorPolicies.append (_ERRORPOLICY_OTHER); _validErrorPolicies.append (_ERRORPOLICY_IGNORE); _validErrorPolicies.append (_ERRORPOLICY_DISABLE); _validErrorPolicies.append (_ERRORPOLICY_REMOVE); _supportedErrorPolicies.append (_ERRORPOLICY_IGNORE); _supportedErrorPolicies.append (_ERRORPOLICY_DISABLE); _supportedErrorPolicies.append (_ERRORPOLICY_REMOVE); _validPersistenceTypes.append (PERSISTENCE_OTHER); _validPersistenceTypes.append (PERSISTENCE_PERMANENT); _validPersistenceTypes.append (PERSISTENCE_TRANSIENT); _supportedPersistenceTypes.append (PERSISTENCE_PERMANENT); _supportedPersistenceTypes.append (PERSISTENCE_TRANSIENT); _validSNMPVersion.append (SNMPV1_TRAP); _validSNMPVersion.append (SNMPV2C_TRAP); _validSNMPVersion.append (SNMPV2C_INFORM); _validSNMPVersion.append (SNMPV3_TRAP); _validSNMPVersion.append (SNMPV3_INFORM); _supportedSNMPVersion.append (SNMPV1_TRAP); _supportedSNMPVersion.append (SNMPV2C_TRAP); // // Set arrays of names of supported properties for each class // // Currently, all properties in these classes in CIM 2.5 through CIM 2.9 // final schemas are supported. If support for a new class is added, a new // list of names of supported properties for the class must be added as a // private member to the IndicationService class, and the array values // must be appended here. When support for a new property is added, the // property name must be appended to the appropriate array(s) here. // _supportedSubscriptionProperties.append (PEGASUS_PROPERTYNAME_FILTER); _supportedSubscriptionProperties.append (PEGASUS_PROPERTYNAME_HANDLER); _supportedSubscriptionProperties.append (_PROPERTY_ONFATALERRORPOLICY); _supportedSubscriptionProperties.append (_PROPERTY_OTHERONFATALERRORPOLICY); _supportedSubscriptionProperties.append (_PROPERTY_FAILURETRIGGERTIMEINTERVAL); _supportedSubscriptionProperties.append (PEGASUS_PROPERTYNAME_SUBSCRIPTION_STATE); _supportedSubscriptionProperties.append (_PROPERTY_OTHERSTATE); _supportedSubscriptionProperties.append (_PROPERTY_LASTCHANGE); _supportedSubscriptionProperties.append (_PROPERTY_DURATION); _supportedSubscriptionProperties.append (_PROPERTY_STARTTIME); _supportedSubscriptionProperties.append (_PROPERTY_TIMEREMAINING); _supportedSubscriptionProperties.append (_PROPERTY_REPEATNOTIFICATIONPOLICY); _supportedSubscriptionProperties.append (_PROPERTY_OTHERREPEATNOTIFICATIONPOLICY); _supportedSubscriptionProperties.append (_PROPERTY_REPEATNOTIFICATIONINTERVAL); _supportedSubscriptionProperties.append (_PROPERTY_REPEATNOTIFICATIONGAP); _supportedSubscriptionProperties.append (_PROPERTY_REPEATNOTIFICATIONCOUNT); _supportedFormattedSubscriptionProperties = _supportedSubscriptionProperties; _supportedFormattedSubscriptionProperties.append (_PROPERTY_TEXTFORMATOWNINGENTITY); _supportedFormattedSubscriptionProperties.append (_PROPERTY_TEXTFORMATID); _supportedFormattedSubscriptionProperties.append (_PROPERTY_TEXTFORMAT); _supportedFormattedSubscriptionProperties.append (_PROPERTY_TEXTFORMATPARAMETERS); _supportedFilterProperties.append (_PROPERTY_CAPTION); _supportedFilterProperties.append (_PROPERTY_DESCRIPTION); _supportedFilterProperties.append (_PROPERTY_ELEMENTNAME); _supportedFilterProperties.append (_PROPERTY_SYSTEMCREATIONCLASSNAME); _supportedFilterProperties.append (_PROPERTY_SYSTEMNAME); _supportedFilterProperties.append (PEGASUS_PROPERTYNAME_CREATIONCLASSNAME); _supportedFilterProperties.append (PEGASUS_PROPERTYNAME_NAME); _supportedFilterProperties.append (_PROPERTY_SOURCENAMESPACE); _supportedFilterProperties.append (PEGASUS_PROPERTYNAME_QUERY); _supportedFilterProperties.append (PEGASUS_PROPERTYNAME_QUERYLANGUAGE); Array <CIMName> commonListenerDestinationProperties; commonListenerDestinationProperties.append (_PROPERTY_CAPTION); commonListenerDestinationProperties.append (_PROPERTY_DESCRIPTION); commonListenerDestinationProperties.append (_PROPERTY_ELEMENTNAME); commonListenerDestinationProperties.append (_PROPERTY_SYSTEMCREATIONCLASSNAME); commonListenerDestinationProperties.append (_PROPERTY_SYSTEMNAME); commonListenerDestinationProperties.append (PEGASUS_PROPERTYNAME_CREATIONCLASSNAME); commonListenerDestinationProperties.append (PEGASUS_PROPERTYNAME_NAME); commonListenerDestinationProperties.append (PEGASUS_PROPERTYNAME_PERSISTENCETYPE); commonListenerDestinationProperties.append (_PROPERTY_OTHERPERSISTENCETYPE); _supportedCIMXMLHandlerProperties = commonListenerDestinationProperties; _supportedCIMXMLHandlerProperties.append (_PROPERTY_OWNER); _supportedCIMXMLHandlerProperties.append (PEGASUS_PROPERTYNAME_LSTNRDST_DESTINATION); _supportedCIMXMLListenerDestinationProperties = commonListenerDestinationProperties; _supportedCIMXMLListenerDestinationProperties.append (PEGASUS_PROPERTYNAME_LSTNRDST_DESTINATION); _supportedSNMPHandlerProperties = commonListenerDestinationProperties; _supportedSNMPHandlerProperties.append (_PROPERTY_OWNER); _supportedSNMPHandlerProperties.append (PEGASUS_PROPERTYNAME_LSTNRDST_TARGETHOST); _supportedSNMPHandlerProperties.append (_PROPERTY_TARGETHOSTFORMAT); _supportedSNMPHandlerProperties.append (_PROPERTY_OTHERTARGETHOSTFORMAT); _supportedSNMPHandlerProperties.append (_PROPERTY_PORTNUMBER); _supportedSNMPHandlerProperties.append (PEGASUS_PROPERTYNAME_SNMPVERSION); _supportedSNMPHandlerProperties.append (_PROPERTY_SNMPSECURITYNAME); _supportedSNMPHandlerProperties.append (_PROPERTY_SNMPENGINEID); _supportedSyslogListenerDestinationProperties = commonListenerDestinationProperties; _supportedEmailListenerDestinationProperties = commonListenerDestinationProperties; _supportedEmailListenerDestinationProperties.append (PEGASUS_PROPERTYNAME_LSTNRDST_MAILTO); _supportedEmailListenerDestinationProperties.append (PEGASUS_PROPERTYNAME_LSTNRDST_MAILCC); _supportedEmailListenerDestinationProperties.append (PEGASUS_PROPERTYNAME_LSTNRDST_MAILSUBJECT); // // Get existing active subscriptions from each namespace in the repository // invalidInstance = _subscriptionRepository->getActiveSubscriptions (activeSubscriptions); noProviderSubscriptions.clear (); Tracer::trace (TRC_INDICATION_SERVICE, Tracer::LEVEL4, "%u active subscription(s) found on initialization", activeSubscriptions.size ()); String condition; String query; String queryLanguage; CIMPropertyList propertyList; Array <ProviderClassList> indicationProviders; for (Uint32 i = 0; i < activeSubscriptions.size (); i++) { // // Check for expired subscription // try { if (_isExpired (activeSubscriptions [i])) { CIMObjectPath path = activeSubscriptions [i].getPath (); Tracer::trace (TRC_INDICATION_SERVICE, Tracer::LEVEL4, "Deleting expired subscription on initialization: %s", (const char *) path.toString ().getCString ()); _deleteExpiredSubscription (path); // If subscription is expired delete the subscription // and continue on to the next one. continue; } } catch (DateTimeOutOfRangeException& e) { // // This instance from the repository is invalid // Log a message and skip it // Logger::put_l (Logger::STANDARD_LOG, System::CIMSERVER, Logger::WARNING, _MSG_INVALID_INSTANCE_KEY, _MSG_INVALID_INSTANCE, e.getMessage ()); continue; } CIMNamespaceName sourceNameSpace; Array <CIMName> indicationSubclasses; _getCreateParams (activeSubscriptions [i], indicationSubclasses, indicationProviders, propertyList, sourceNameSpace, condition, query, queryLanguage); if (indicationProviders.size () == 0) { Tracer::trace (TRC_INDICATION_SERVICE, Tracer::LEVEL4, "No providers found for subscription on initialization: %s", (const char *) activeSubscriptions [i].getPath ().toString ().getCString ()); // // There are no providers that can support this subscription // Implement the subscription's On Fatal Error Policy // If subscription is not disabled or removed, // Append this subscription to no provider list and // Insert entries into the subscription hash tables // if (!_subscriptionRepository->reconcileFatalError (activeSubscriptions [i])) { noProviderSubscriptions.append (activeSubscriptions [i]); _subscriptionTable->insertSubscription (activeSubscriptions [i], indicationProviders, indicationSubclasses, sourceNameSpace); } continue; } // // Send Create request message to each provider // NOTE: These Create requests are not associated with a user request, // so there is no associated authType or userName // The Creator from the subscription instance is used for userName, // and authType is not set // CIMInstance instance = activeSubscriptions [i]; String creator; if (!_getCreator (instance, creator)) { // // This instance from the repository is corrupted // Skip it // invalidInstance = true; continue; }//l10n start // Get the language tags that were saved with the subscription instance AcceptLanguageList acceptLangs; Uint32 propIndex = instance.findProperty (PEGASUS_PROPERTYNAME_INDSUB_ACCEPTLANGS); if (propIndex != PEG_NOT_FOUND) { String acceptLangsString; instance.getProperty(propIndex).getValue().get(acceptLangsString); if (acceptLangsString.size()) { acceptLangs = LanguageParser::parseAcceptLanguageHeader( acceptLangsString); } } ContentLanguageList contentLangs; propIndex = instance.findProperty (PEGASUS_PROPERTYNAME_INDSUB_CONTENTLANGS); if (propIndex != PEG_NOT_FOUND) { String contentLangsString; instance.getProperty(propIndex).getValue().get(contentLangsString); if (contentLangsString.size()) { contentLangs = LanguageParser::parseContentLanguageHeader( contentLangsString); } }// l10n end // // Send Create request message to each provider // Note: SendWait is used instead of SendAsync. Initialization must // deal with multiple subscriptions, each with multiple providers. // Using SendWait eliminates the need for a callback and the necessity // to handle multiple levels of aggregation, which would add // significant complexity. Since initialization cannot complete // anyway until responses have been received for all subscriptions, // from all the providers, use of SendWait should not cause a // significant performance issue. //
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -