📄 subscriptiontable.cpp
字号:
//%2006//////////////////////////////////////////////////////////////////////////// Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development// Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.// Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.;// IBM Corp.; EMC Corporation, The Open Group.// Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;// IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.// Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;// EMC Corporation; VERITAS Software Corporation; The Open Group.// Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;// EMC Corporation; Symantec Corporation; The Open Group.//// Permission is hereby granted, free of charge, to any person obtaining a copy// of this software and associated documentation files (the "Software"), to// deal in the Software without restriction, including without limitation the// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or// sell copies of the Software, and to permit persons to whom the Software is// furnished to do so, subject to the following conditions:// // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN// ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED// "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT// LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN// ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.////==============================================================================//// Author: Carol Ann Krug Graves, Hewlett-Packard Company// (carolann_graves@hp.com)//// Modified By: // Sean Keenan, Hewlett-Packard Company (sean.keenan@hp.com)// Aruran, IBM (ashanmug@in.ibm.com) for Bug# 3603////%/////////////////////////////////////////////////////////////////////////////#include <Pegasus/Common/Config.h>#include <Pegasus/Common/Constants.h>#include <Pegasus/Common/Tracer.h>#include "IndicationConstants.h"#include "IndicationService.h"#include "SubscriptionTable.h"PEGASUS_USING_STD;PEGASUS_NAMESPACE_BEGINSubscriptionTable::SubscriptionTable ( SubscriptionRepository * subscriptionRepository) : _subscriptionRepository (subscriptionRepository){}SubscriptionTable::~SubscriptionTable (){}Boolean SubscriptionTable::getSubscriptionEntry ( const CIMObjectPath & subscriptionPath, ActiveSubscriptionsTableEntry & tableValue) const{ PEG_METHOD_ENTER (TRC_INDICATION_SERVICE, "SubscriptionTable::getSubscriptionEntry"); Boolean succeeded = false; CIMObjectPath activeSubscriptionsKey = _generateActiveSubscriptionsKey (subscriptionPath); if (_lockedLookupActiveSubscriptionsEntry (activeSubscriptionsKey, tableValue)) { succeeded = true; } else { // // Subscription not found in Active Subscriptions table // PEG_TRACE_STRING (TRC_INDICATION_SERVICE_INTERNAL, Tracer::LEVEL2, "Subscription (" + activeSubscriptionsKey.toString () + ") not found in ActiveSubscriptionsTable"); } PEG_METHOD_EXIT (); return succeeded;}Array <CIMInstance> SubscriptionTable::getMatchingSubscriptions ( const CIMName & supportedClass, const Array <CIMNamespaceName> nameSpaces, const Boolean checkProvider, const CIMInstance & provider) const{ PEG_METHOD_ENTER (TRC_INDICATION_SERVICE, "SubscriptionTable::getMatchingSubscriptions"); Array <CIMInstance> matchingSubscriptions; Array <CIMInstance> subscriptions; for (Uint32 i = 0; i < nameSpaces.size (); i++) { // // Look up the indicationClass-sourceNamespace pair in the // Subscription Classes table // String subscriptionClassesKey = _generateSubscriptionClassesKey (supportedClass, nameSpaces [i]); SubscriptionClassesTableEntry tableValue; if (_lockedLookupSubscriptionClassesEntry (subscriptionClassesKey, tableValue)) { subscriptions = tableValue.subscriptions; for (Uint32 j = 0; j < subscriptions.size (); j++) { Boolean match = true; if (checkProvider) { // // Check if the provider who generated this indication // accepted this subscription // CIMObjectPath activeSubscriptionsKey = _generateActiveSubscriptionsKey (subscriptions [j].getPath ()); ActiveSubscriptionsTableEntry tableValue; if (_lockedLookupActiveSubscriptionsEntry (activeSubscriptionsKey, tableValue)) { // // If provider is not in list, it did not accept the // subscription // if ((providerInList (provider, tableValue)) == PEG_NOT_FOUND) { match = false; break; } } } if (match) { // // Add current subscription to list // matchingSubscriptions.append (subscriptions [j]); } } } } PEG_METHOD_EXIT (); return matchingSubscriptions;}Array <CIMInstance> SubscriptionTable::reflectProviderDisable ( const CIMInstance & provider){ PEG_METHOD_ENTER (TRC_INDICATION_SERVICE, "SubscriptionTable::reflectProviderDisable"); Array <CIMInstance> providerSubscriptions; // // Iterate through the subscription table to find subscriptions served by // the provider // NOTE: updating entries (remove and insert) while iterating through the // table does not work reliably, and it is not clear if that is supposed to // work; for now, the SubscriptionTable first iterates through the // active subscriptions table to find subscriptions served by the // provider, then looks up and updates each affected subscription // { // // Acquire and hold the write lock during the entire // lookup/remove/insert process, allowing competing threads to apply // their logic over a consistent view of the data. // Do not call any other methods that need // _activeSubscriptionsTableLock. // WriteLock lock (_activeSubscriptionsTableLock); for (ActiveSubscriptionsTable::Iterator i = _activeSubscriptionsTable.start (); i; i++) { // // If provider matches, append subscription to the list // ActiveSubscriptionsTableEntry tableValue = i.value (); for (Uint32 j = 0; j < tableValue.providers.size (); j++) { if (tableValue.providers [j].provider.getPath ().identical (provider.getPath ())) { // // Add the subscription to the list // providerSubscriptions.append (tableValue.subscription); break; } } } // // Look up and update hash table entry for each affected subscription // for (Uint32 k = 0; k < providerSubscriptions.size (); k++) { // // Update the entry in the active subscriptions hash table // CIMObjectPath activeSubscriptionsKey = _generateActiveSubscriptionsKey (providerSubscriptions [k].getPath ()); ActiveSubscriptionsTableEntry tableValue; if (_activeSubscriptionsTable.lookup (activeSubscriptionsKey, tableValue)) { // // Remove the provider from the list of providers serving the // subscription // Uint32 providerIndex = providerInList (provider, tableValue); if (providerIndex != PEG_NOT_FOUND) { tableValue.providers.remove (providerIndex); _updateSubscriptionProviders (activeSubscriptionsKey, tableValue.subscription, tableValue.providers); } else { PEG_TRACE_STRING (TRC_INDICATION_SERVICE_INTERNAL, Tracer::LEVEL2, "Provider (" + provider.getPath().toString() + ") not found in list for Subscription (" + activeSubscriptionsKey.toString () + ") in ActiveSubscriptionsTable"); } } else { PEG_TRACE_STRING (TRC_INDICATION_SERVICE_INTERNAL, Tracer::LEVEL2, "Subscription (" + activeSubscriptionsKey.toString () + ") not found in ActiveSubscriptionsTable"); // // The subscription may have been deleted in the mean time // If so, no further update is required // } } } PEG_METHOD_EXIT (); return providerSubscriptions;}Array <ActiveSubscriptionsTableEntry>SubscriptionTable::reflectProviderModuleFailure (const String & moduleName, const String & userName, Boolean authenticationEnabled){ PEG_METHOD_ENTER (TRC_INDICATION_SERVICE, "SubscriptionTable::reflectProviderModuleFailure"); Array <ActiveSubscriptionsTableEntry> providerModuleSubscriptions; // // Iterate through the subscription table to find subscriptions served by // a provider in the specified module, with the specified userName as the // subscription creator // NOTE: updating entries (remove and insert) while iterating through the // table is not allowed // The SubscriptionTable first iterates through the active subscriptions // table to find matching subscriptions served by a provider in the // specified module, then looks up and updates each affected subscription // { // // Acquire and hold the write lock during the entire // lookup/remove/insert process, allowing competing threads to apply // their logic over a consistent view of the data. // Do not call any other methods that need // _activeSubscriptionsTableLock. // WriteLock lock (_activeSubscriptionsTableLock); for (ActiveSubscriptionsTable::Iterator i = _activeSubscriptionsTable.start (); i; i++) { ActiveSubscriptionsTableEntry tableValue; // // Get subscription creator // tableValue = i.value (); String creator; CIMValue creatorValue = tableValue.subscription.getProperty (tableValue.subscription.findProperty (PEGASUS_PROPERTYNAME_INDSUB_CREATOR)).getValue(); creatorValue.get (creator); Array <ProviderClassList> failedProviderList; for (Uint32 j = 0; j < tableValue.providers.size (); j++) { // // Get provider module name // String providerModuleName; CIMValue nameValue = tableValue.providers [j].providerModule.getProperty (tableValue.providers [j].providerModule.findProperty (PEGASUS_PROPERTYNAME_NAME)).getValue (); nameValue.get (providerModuleName); // // Get module user context setting // Uint16 moduleContext = PEGASUS_DEFAULT_PROV_USERCTXT; CIMValue contextValue = tableValue.providers [j].providerModule.getProperty (tableValue.providers [j].providerModule.findProperty (PEGASUS_PROPERTYNAME_MODULE_USERCONTEXT)).getValue (); if (!contextValue.isNull ()) { contextValue.get (moduleContext); } // // If provider module name matches, // add provider to the list of failed providers // if (providerModuleName == moduleName) { // // If authentication is enabled, and module was run as
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -