📄 indicationservice.cpp
字号:
Array <ProviderClassList> acceptedProviders; acceptedProviders = _sendWaitCreateRequests (indicationProviders, sourceNameSpace, propertyList, condition, query, queryLanguage, activeSubscriptions [i], acceptLangs, contentLangs, creator); if (acceptedProviders.size () == 0) { Tracer::trace (TRC_INDICATION_SERVICE, Tracer::LEVEL4, "No providers accepted subscription on initialization: %s", (const char *) activeSubscriptions [i].getPath ().toString ().getCString ()); // // No providers accepted the subscription // Implement the subscription's On Fatal Error Policy // If subscription is not disabled or removed, send alert and // Insert entries into the subscription hash tables // if (!_subscriptionRepository->reconcileFatalError (activeSubscriptions [i])) { // // Insert entries into the subscription hash tables // _subscriptionTable->insertSubscription (activeSubscriptions [i], acceptedProviders, indicationSubclasses, sourceNameSpace);#if 0 // // Send alert // // // Send NoProviderAlertIndication to handler instances // ATTN: NoProviderAlertIndication must be defined // Array <CIMInstance> subscriptions; subscriptions.append (activeSubscriptions [i]); CIMInstance indicationInstance = _createAlertInstance (_CLASS_NO_PROVIDER_ALERT, subscriptions); Tracer::trace (TRC_INDICATION_SERVICE, Tracer::LEVEL4, "Sending NoProvider Alert for %u subscriptions", subscriptions.size ()); _sendAlerts (subscriptions, indicationInstance);#endif // // Get Subscription Filter Name and Handler Name // String logString = _getSubscriptionLogString (activeSubscriptions [i]); // // Log a message for the subscription // Logger::put_l (Logger::STANDARD_LOG, System::CIMSERVER, Logger::WARNING, _MSG_NO_PROVIDER_KEY, _MSG_NO_PROVIDER, logString, activeSubscriptions[i].getPath().getNameSpace().getString()); } } else { // // At least one provider accepted the subscription // Insert entries into the subscription hash tables // _subscriptionTable->insertSubscription (activeSubscriptions [i], acceptedProviders, indicationSubclasses, sourceNameSpace); } } // for each active subscription // // Log a message if any invalid instances were found // if (invalidInstance) { Logger::put_l (Logger::STANDARD_LOG, System::CIMSERVER, Logger::WARNING, _MSG_INVALID_INSTANCES_KEY, _MSG_INVALID_INSTANCES); } // // Log a message for any subscription for which there is no longer any // provider // if (noProviderSubscriptions.size () > 0) {#if 0 // // Send NoProviderAlertIndication to handler instances // ATTN: NoProviderAlertIndication must be defined // CIMInstance indicationInstance = _createAlertInstance (_CLASS_NO_PROVIDER_ALERT, noProviderSubscriptions); Tracer::trace (TRC_INDICATION_SERVICE, Tracer::LEVEL4, "Sending NoProvider Alert for %u subscriptions", noProviderSubscriptions.size ()); _sendAlerts (noProviderSubscriptions, indicationInstance);#endif // // Log a message for each subscription // for (Uint32 i = 0; i < noProviderSubscriptions.size (); i++) { // // Get Subscription Filter Name and Handler Name // String logString = _getSubscriptionLogString (noProviderSubscriptions [i]); Logger::put_l (Logger::STANDARD_LOG, System::CIMSERVER, Logger::WARNING, _MSG_NO_PROVIDER_KEY, _MSG_NO_PROVIDER, logString, noProviderSubscriptions[i].getPath().getNameSpace().getString()); } } // // Send message to tell Provider Manager that subscription // initialization is complete // Provider Manager calls providers' enableIndications method // _sendSubscriptionInitComplete ();#ifdef PEGASUS_INDICATION_PERFINST stopWatch.stop(); Tracer::trace (TRC_INDICATION_SERVICE_INTERNAL, Tracer::LEVEL2, "%s: %.3f seconds", "Initialize", stopWatch.getElapsed());#endif PEG_METHOD_EXIT ();}void IndicationService::_terminate (void){ PEG_METHOD_ENTER (TRC_INDICATION_SERVICE, "IndicationService::_terminate"); Array <CIMInstance> activeSubscriptions; CIMInstance indicationInstance; // // A message is already logged that CIM Server is shutting down -- // no need to log a message //#if 0 // // Get existing active subscriptions from hash table // activeSubscriptions = _getActiveSubscriptions (); if (activeSubscriptions.size () > 0) { // // Create CimomShutdownAlertIndication instance // ATTN: CimomShutdownAlertIndication must be defined // indicationInstance = _createAlertInstance (_CLASS_CIMOM_SHUTDOWN_ALERT, activeSubscriptions); // // Send CimomShutdownAlertIndication to each unique handler instance // Tracer::trace (TRC_INDICATION_SERVICE, Tracer::LEVEL4, "Sending CIMServerShutdown Alert for %u subscriptions", activeSubscriptions.size ()); _sendAlerts (activeSubscriptions, indicationInstance); }#endif // // Remove entries from the SubscriptionTable's Active Subscriptions and // Subscription Classes tables // // NOTE: The table entries are removed when the SubscriptionTable // destructor is called by the IndicationService destructor. However, // currently the IndicationService destructor is never called, so the // IndicationService must call the SubscriptionTable clear() function to // remove the table entries. _subscriptionTable->clear (); PEG_METHOD_EXIT ();}void IndicationService::_checkNonprivilegedAuthorization( const String & userName){ PEG_METHOD_ENTER (TRC_INDICATION_SERVICE, "IndicationService::_checkNonprivilegedAuthorization"); Boolean accessDenied = false; try { if (_enableSubscriptionsForNonprivilegedUsers) { PEG_METHOD_EXIT(); return; } else { PEG_TRACE_STRING (TRC_INDICATION_SERVICE, Tracer::LEVEL4, "_checkNonprivilegedAuthorization - checking whether user is privileged" + userName); if (!System::isPrivilegedUser(userName)) { accessDenied = true; } } } catch (...) { PEG_METHOD_EXIT(); throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, String::EMPTY); } if (accessDenied) { MessageLoaderParms parms(_MSG_NON_PRIVILEGED_ACCESS_DISABLED_KEY, _MSG_NON_PRIVILEGED_ACCESS_DISABLED, userName); PEG_METHOD_EXIT(); throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_ACCESS_DENIED, parms); }}void IndicationService::_handleCreateInstanceRequest (const Message * message){ PEG_METHOD_ENTER (TRC_INDICATION_SERVICE, "IndicationService::_handleCreateInstanceRequest"); CIMCreateInstanceRequestMessage* request = (CIMCreateInstanceRequestMessage*) message; CIMException cimException; Boolean responseSent = false; CIMObjectPath instanceRef; CIMInstance instance = request->newInstance.clone (); try { String userName = ((IdentityContainer)request->operationContext.get (IdentityContainer :: NAME)).getUserName(); _checkNonprivilegedAuthorization(userName); AcceptLanguageList acceptLangs = ((AcceptLanguageListContainer)request->operationContext.get (AcceptLanguageListContainer::NAME)).getLanguages(); ContentLanguageList contentLangs = ((ContentLanguageListContainer)request->operationContext.get (ContentLanguageListContainer::NAME)).getLanguages(); if (_canCreate (instance, request->nameSpace)) { // // If the instance is of the PEGASUS_CLASSNAME_INDSUBSCRIPTION // class or the PEGASUS_CLASSNAME_FORMATTEDINDSUBSCRIPTION // class and subscription state is enabled, determine if any // providers can serve the subscription // Uint16 subscriptionState; String condition; String query; String queryLanguage; CIMPropertyList requiredProperties; CIMNamespaceName sourceNameSpace; Array <CIMName> indicationSubclasses; Array <ProviderClassList> indicationProviders; if ((instance.getClassName ().equal (PEGASUS_CLASSNAME_INDSUBSCRIPTION)) || (instance.getClassName ().equal (PEGASUS_CLASSNAME_FORMATTEDINDSUBSCRIPTION))) { // // Get subscription state // // NOTE: _canCreate has already validated the // SubscriptionState property in the instance; if missing, it // was added with the default value; if null, it was set to // the default value; if invalid, an exception was thrown // CIMValue subscriptionStateValue; subscriptionStateValue = instance.getProperty (instance.findProperty (PEGASUS_PROPERTYNAME_SUBSCRIPTION_STATE)).getValue (); subscriptionStateValue.get (subscriptionState); if ((subscriptionState == STATE_ENABLED) || (subscriptionState == STATE_ENABLEDDEGRADED)) { _getCreateParams (instance, indicationSubclasses, indicationProviders, requiredProperties, sourceNameSpace, condition, query, queryLanguage); if (indicationProviders.size () == 0) { // // There are no providers that can support this // subscription // PEG_METHOD_EXIT (); // l10n // throw PEGASUS_CIM_EXCEPTION (CIM_ERR_NOT_SUPPORTED, // _MSG_NO_PROVIDERS); throw PEGASUS_CIM_EXCEPTION_L (CIM_ERR_NOT_SUPPORTED, MessageLoaderParms(_MSG_NO_PROVIDERS_KEY, _MSG_NO_PROVIDERS)); } // // Send Create request message to each provider // // l10n _sendAsyncCreateRequests (indicationProviders, sourceNameSpace, requiredProperties, condition, query, queryLanguage, instance, acceptLangs, contentLangs, request, indicationSubclasses, userName, request->authType); // // Response is sent from _handleCreateResponseAggregation // responseSent = true; } else { // // Create instance for disabled subscription // instanceRef = _subscriptionRepository->createInstance (instance, request->nameSpace, userName, acceptLangs, contentLangs, false); } } else { // // Create instance for filter or handler // instanceRef = _subscriptionRepository->createInstance (instance, request->nameSpace, userName, acceptLangs, contentLangs,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -