📄 subscriptiontable.cpp
字号:
// 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 // _subscriptionClassesTableLock. // WriteLock lock (_subscriptionClassesTableLock); for (Uint32 i = 0; i < indicationSubclassNames.size (); i++) { String subscriptionClassesKey = _generateSubscriptionClassesKey (indicationSubclassNames [i], sourceNamespaceName); SubscriptionClassesTableEntry tableValue; if (_subscriptionClassesTable.lookup (subscriptionClassesKey, tableValue)) { // // If entry exists for this IndicationClassName-SourceNamespace // pair, remove old entry and insert new entry // Array <CIMInstance> subscriptions = tableValue.subscriptions; subscriptions.append (subscription); _removeSubscriptionClassesEntry (subscriptionClassesKey); _insertSubscriptionClassesEntry (indicationSubclassNames [i], sourceNamespaceName, subscriptions); } else { // // If no entry exists for this // IndicationClassName-SourceNamespace pair, insert new entry // Array <CIMInstance> subscriptions; subscriptions.append (subscription); _insertSubscriptionClassesEntry (indicationSubclassNames [i], sourceNamespaceName, subscriptions); } } } PEG_METHOD_EXIT ();}void SubscriptionTable::updateProviders ( const CIMObjectPath & subscriptionPath, const ProviderClassList & provider, Boolean addProvider){ PEG_METHOD_ENTER (TRC_INDICATION_SERVICE, "SubscriptionTable::updateProviders"); CIMObjectPath activeSubscriptionsKey = _generateActiveSubscriptionsKey (subscriptionPath); ActiveSubscriptionsTableEntry tableValue; { // // 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); if (_activeSubscriptionsTable.lookup (activeSubscriptionsKey, tableValue)) { Uint32 providerIndex = providerInList (provider.provider, tableValue); if (addProvider) { if (providerIndex == PEG_NOT_FOUND) { tableValue.providers.append (provider); _removeActiveSubscriptionsEntry (activeSubscriptionsKey); _insertActiveSubscriptionsEntry (tableValue.subscription, tableValue.providers); } else { CIMInstance p = provider.provider; PEG_TRACE_STRING (TRC_INDICATION_SERVICE_INTERNAL, Tracer::LEVEL2, "Provider " + IndicationService::getProviderLogString (p) + " already in list for Subscription (" + activeSubscriptionsKey.toString () + ") in ActiveSubscriptionsTable"); } } else { if (providerIndex != PEG_NOT_FOUND) { tableValue.providers.remove (providerIndex); _removeActiveSubscriptionsEntry (activeSubscriptionsKey); _insertActiveSubscriptionsEntry (tableValue.subscription, tableValue.providers); } else { CIMInstance p = provider.provider; PEG_TRACE_STRING (TRC_INDICATION_SERVICE_INTERNAL, Tracer::LEVEL2, "Provider " + IndicationService::getProviderLogString (p) + " 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 ();}void SubscriptionTable::updateClasses ( const CIMObjectPath & subscriptionPath, const CIMInstance & provider, const CIMName & className){ PEG_METHOD_ENTER (TRC_INDICATION_SERVICE, "SubscriptionTable::updateClasses"); CIMObjectPath activeSubscriptionsKey = _generateActiveSubscriptionsKey (subscriptionPath); ActiveSubscriptionsTableEntry tableValue; { // // 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); if (_activeSubscriptionsTable.lookup (activeSubscriptionsKey, tableValue)) { Uint32 providerIndex = providerInList (provider, tableValue); if (providerIndex != PEG_NOT_FOUND) { Uint32 classIndex = classInList (className, tableValue.providers [providerIndex]); if (classIndex == PEG_NOT_FOUND) { tableValue.providers [providerIndex].classList.append (className); } else // classIndex != PEG_NOT_FOUND { tableValue.providers [providerIndex].classList.remove (classIndex); } _removeActiveSubscriptionsEntry (activeSubscriptionsKey); _insertActiveSubscriptionsEntry (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 { // // Subscription not found in Active Subscriptions table // } } PEG_METHOD_EXIT ();}void SubscriptionTable::removeSubscription ( const CIMInstance & subscription, const Array <CIMName> & indicationSubclassNames, const CIMNamespaceName & sourceNamespaceName, const Array <ProviderClassList> & providers){ PEG_METHOD_ENTER (TRC_INDICATION_SERVICE, "SubscriptionTable::removeSubscription"); // // Remove entry from active subscriptions table // { WriteLock lock(_activeSubscriptionsTableLock); _removeActiveSubscriptionsEntry ( _generateActiveSubscriptionsKey (subscription.getPath ())); } // // Remove or update entries in subscription classes table // { // // 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 // _subscriptionClassesTableLock. // WriteLock lock (_subscriptionClassesTableLock); for (Uint32 i = 0; i < indicationSubclassNames.size (); i++) { String subscriptionClassesKey = _generateSubscriptionClassesKey (indicationSubclassNames [i], sourceNamespaceName); SubscriptionClassesTableEntry tableValue; if (_subscriptionClassesTable.lookup (subscriptionClassesKey, tableValue)) { // // If entry exists for this IndicationClassName-SourceNamespace // pair, remove subscription from the list // Array <CIMInstance> subscriptions = tableValue.subscriptions; for (Uint32 j = 0; j < subscriptions.size (); j++) { if (subscriptions [j].getPath().identical (subscription.getPath())) { subscriptions.remove (j); } } // // Remove the old entry // _removeSubscriptionClassesEntry (subscriptionClassesKey); // // If there are still subscriptions in the list, insert the // new entry // if (subscriptions.size () > 0) { _insertSubscriptionClassesEntry ( indicationSubclassNames [i], sourceNamespaceName, subscriptions); } } else { // // Entry not found in Subscription Classes table // PEG_TRACE_STRING (TRC_INDICATION_SERVICE_INTERNAL, Tracer::LEVEL2, "Indication subclass and namespace (" + subscriptionClassesKey + ") not found in SubscriptionClassesTable"); } } } PEG_METHOD_EXIT ();}Uint32 SubscriptionTable::providerInList (const CIMInstance & provider, const ActiveSubscriptionsTableEntry & tableValue) const{ PEG_METHOD_ENTER (TRC_INDICATION_SERVICE, "SubscriptionTable::providerInList"); // // Look for the provider in the list // for (Uint32 i = 0; i < tableValue.providers.size (); i++) { if (tableValue.providers [i].provider.getPath ().identical (provider.getPath ())) { PEG_METHOD_EXIT (); return i; } } PEG_METHOD_EXIT (); return PEG_NOT_FOUND;}Uint32 SubscriptionTable::classInList (const CIMName & className, const ProviderClassList & providerClasses) const{ PEG_METHOD_ENTER (TRC_INDICATION_SERVICE, "SubscriptionTable::classInList"); // // Look for the class in the list // for (Uint32 i = 0; i < providerClasses.classList.size (); i++) { if (providerClasses.classList [i].equal (className)) { PEG_METHOD_EXIT (); return i; } } PEG_METHOD_EXIT (); return PEG_NOT_FOUND;}void SubscriptionTable::clear (){ PEG_METHOD_ENTER (TRC_INDICATION_SERVICE, "SubscriptionTable::clear"); { WriteLock lock (_activeSubscriptionsTableLock); _activeSubscriptionsTable.clear (); } { WriteLock lock (_subscriptionClassesTableLock); _subscriptionClassesTable.clear (); } PEG_METHOD_EXIT ();}PEGASUS_NAMESPACE_END
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -