version 1.110, 2003/12/04 03:35:54
|
version 1.111, 2003/12/11 17:53:45
|
|
|
// Remove entries from the subscription hash tables | // Remove entries from the subscription hash tables |
// | // |
_removeFromHashTables (subscriptionInstance, | _removeFromHashTables (subscriptionInstance, |
indicationSubclasses, sourceNamespaceName); |
indicationSubclasses, sourceNamespaceName, |
|
indicationProviders); |
} | } |
} | } |
} | } |
|
|
"IndicationService::_providerInUse"); | "IndicationService::_providerInUse"); |
| |
// | // |
// Do not call any other methods that need _activeSubscriptionsTableLock |
// The caller must acquire a lock on the Active Subscriptions table |
|
// before calling |
// | // |
ReadLock lock (_activeSubscriptionsTableLock); |
|
| |
// | // |
// Iterate through the subscription table | // Iterate through the subscription table |
|
|
// At least one provider accepted the subscription | // At least one provider accepted the subscription |
// | // |
| |
// |
|
// Check each provider to see if it is not yet in use by any |
|
// subscription, and therefore must be enabled |
|
// |
|
Array <ProviderClassList> enableProviders; | Array <ProviderClassList> enableProviders; |
for (Uint32 k = 0; k < acceptedProviders.size (); k++) |
|
{ |
|
if (!_providerInUse (acceptedProviders [k].provider)) |
|
{ |
|
enableProviders.append (acceptedProviders [k]); |
|
} |
|
} |
|
| |
if (operationAggregate->getOrigType () == | if (operationAggregate->getOrigType () == |
CIM_NOTIFY_PROVIDER_REGISTRATION_REQUEST_MESSAGE) | CIM_NOTIFY_PROVIDER_REGISTRATION_REQUEST_MESSAGE) |
|
|
// | // |
// Update the entry in the active subscriptions hash table | // Update the entry in the active subscriptions hash table |
// | // |
String activeSubscriptionsKey = _generateActiveSubscriptionsKey |
enableProviders = _updateHashTable |
(request->subscriptionInstance.getPath ()); |
(request->subscriptionInstance.getPath (), provider, true); |
ActiveSubscriptionsTableEntry tableValue; |
|
if (_lockedLookupActiveSubscriptionsEntry (activeSubscriptionsKey, |
|
tableValue)) |
|
{ |
|
tableValue.providers.append (provider); |
|
{ |
|
WriteLock lock (_activeSubscriptionsTableLock); |
|
_removeActiveSubscriptionsEntry (activeSubscriptionsKey); |
|
_insertActiveSubscriptionsEntry (tableValue.subscription, |
|
tableValue.providers); |
|
} |
|
| |
// | // |
// Send Enable message to each provider that accepted | // Send Enable message to each provider that accepted |
// subscription | // subscription |
// | // |
|
if (enableProviders.size () > 0) |
|
{ |
_sendEnable (enableProviders, | _sendEnable (enableProviders, |
operationAggregate->getOrigRequest ()); | operationAggregate->getOrigRequest ()); |
} | } |
else |
|
{ |
|
PEG_TRACE_STRING (TRC_INDICATION_SERVICE, Tracer::LEVEL2, |
|
"Subscription (" + activeSubscriptionsKey + |
|
") not found in ActiveSubscriptionsTable"); |
|
// |
|
// The subscription may have been deleted in the mean time |
|
// If so, no further update is required |
|
// |
|
} |
|
} | } |
else if (operationAggregate->getOrigType () == | else if (operationAggregate->getOrigType () == |
CIM_NOTIFY_PROVIDER_ENABLE_REQUEST_MESSAGE) | CIM_NOTIFY_PROVIDER_ENABLE_REQUEST_MESSAGE) |
|
|
} | } |
} | } |
| |
|
|
// | // |
// Update the entry in the active subscriptions hash table | // Update the entry in the active subscriptions hash table |
// | // |
String activeSubscriptionsKey = _generateActiveSubscriptionsKey |
enableProviders = _updateHashTable |
(request->subscriptionInstance.getPath ()); |
(request->subscriptionInstance.getPath (), provider, true); |
ActiveSubscriptionsTableEntry tableValue; |
|
if (_lockedLookupActiveSubscriptionsEntry (activeSubscriptionsKey, |
|
tableValue)) |
|
{ |
|
tableValue.providers.append (provider); |
|
{ |
|
WriteLock lock (_activeSubscriptionsTableLock); |
|
_removeActiveSubscriptionsEntry (activeSubscriptionsKey); |
|
_insertActiveSubscriptionsEntry (tableValue.subscription, |
|
tableValue.providers); |
|
} |
|
| |
// | // |
// Send Enable message to each provider that accepted | // Send Enable message to each provider that accepted |
// subscription | // subscription |
// | // |
|
if (enableProviders.size () > 0) |
|
{ |
_sendEnable (enableProviders, | _sendEnable (enableProviders, |
operationAggregate->getOrigRequest ()); | operationAggregate->getOrigRequest ()); |
} | } |
else |
|
{ |
|
// |
|
// The subscription may have been deleted in the mean time |
|
// If so, no further update is required |
|
// |
|
PEG_TRACE_STRING (TRC_INDICATION_SERVICE, Tracer::LEVEL2, |
|
"Subscription (" + activeSubscriptionsKey + |
|
") not found in ActiveSubscriptionsTable"); |
|
} |
|
} | } |
else if (operationAggregate->getOrigType () == | else if (operationAggregate->getOrigType () == |
CIM_CREATE_INSTANCE_REQUEST_MESSAGE) | CIM_CREATE_INSTANCE_REQUEST_MESSAGE) |
|
|
// | // |
// Insert entries into the subscription hash tables | // Insert entries into the subscription hash tables |
// | // |
_insertToHashTables (instance, |
enableProviders = _insertToHashTables (instance, |
acceptedProviders, | acceptedProviders, |
operationAggregate->getIndicationSubclasses (), | operationAggregate->getIndicationSubclasses (), |
request->nameSpace); | request->nameSpace); |
|
|
// | // |
// Insert entries into the subscription hash tables | // Insert entries into the subscription hash tables |
// | // |
_insertToHashTables (request->subscriptionInstance, |
enableProviders = _insertToHashTables |
|
(request->subscriptionInstance, |
acceptedProviders, | acceptedProviders, |
operationAggregate->getIndicationSubclasses (), | operationAggregate->getIndicationSubclasses (), |
request->nameSpace); | request->nameSpace); |
|
|
(CIMDeleteSubscriptionRequestMessage *) | (CIMDeleteSubscriptionRequestMessage *) |
operationAggregate->getRequest (0); | operationAggregate->getRequest (0); |
| |
|
Array <ProviderClassList> disableProviders; |
|
|
if (operationAggregate->getOrigType () == | if (operationAggregate->getOrigType () == |
CIM_NOTIFY_PROVIDER_REGISTRATION_REQUEST_MESSAGE) | CIM_NOTIFY_PROVIDER_REGISTRATION_REQUEST_MESSAGE) |
{ | { |
|
|
// | // |
// Update the entry in the active subscriptions hash table | // Update the entry in the active subscriptions hash table |
// | // |
String activeSubscriptionsKey = _generateActiveSubscriptionsKey |
ProviderClassList provider; |
(request->subscriptionInstance.getPath ()); |
provider.provider = origRequest->provider; |
ActiveSubscriptionsTableEntry tableValue; |
disableProviders = _updateHashTable |
if (_lockedLookupActiveSubscriptionsEntry (activeSubscriptionsKey, |
(request->subscriptionInstance.getPath (), provider, false); |
tableValue)) |
|
{ |
|
Uint32 providerIndex = _providerInList (origRequest->provider, |
|
tableValue); |
|
if (providerIndex != PEG_NOT_FOUND) |
|
{ |
|
tableValue.providers.remove (providerIndex); |
|
{ |
|
WriteLock lock (_activeSubscriptionsTableLock); |
|
_removeActiveSubscriptionsEntry (activeSubscriptionsKey); |
|
_insertActiveSubscriptionsEntry (tableValue.subscription, |
|
tableValue.providers); |
|
} |
|
} |
|
else |
|
{ |
|
PEG_TRACE_STRING (TRC_INDICATION_SERVICE, Tracer::LEVEL2, |
|
"Provider (" + origRequest->provider.getPath().toString() + |
|
") not found in list for Subscription (" + |
|
activeSubscriptionsKey + |
|
") in ActiveSubscriptionsTable"); |
|
} |
|
} |
|
else |
|
{ |
|
PEG_TRACE_STRING (TRC_INDICATION_SERVICE, Tracer::LEVEL2, |
|
"Subscription (" + activeSubscriptionsKey + |
|
") not found in ActiveSubscriptionsTable"); |
|
} |
|
} | } |
| |
// | // |
|
|
// | // |
// Remove entries from the subscription hash tables | // Remove entries from the subscription hash tables |
// | // |
_removeFromHashTables (request->subscriptionInstance, |
disableProviders = _removeFromHashTables |
|
(request->subscriptionInstance, |
operationAggregate->getIndicationSubclasses (), | operationAggregate->getIndicationSubclasses (), |
request->nameSpace); |
request->nameSpace, |
} |
checkProviders); |
|
|
// |
|
// Check each provider to see if it's still in use by any subscription |
|
// |
|
Array <ProviderClassList> disableProviders; |
|
for (Uint32 j = 0; j < checkProviders.size (); j++) |
|
{ |
|
if (!_providerInUse (checkProviders [j].provider)) |
|
{ |
|
disableProviders.append (checkProviders [j]); |
|
} |
|
} | } |
| |
// | // |
|
|
PEG_METHOD_EXIT (); | PEG_METHOD_EXIT (); |
} | } |
| |
void IndicationService::_insertToHashTables ( |
Array <ProviderClassList> IndicationService::_insertToHashTables ( |
const CIMInstance & subscription, | const CIMInstance & subscription, |
const Array <ProviderClassList> & providers, | const Array <ProviderClassList> & providers, |
const Array <CIMName> & indicationSubclassNames, | const Array <CIMName> & indicationSubclassNames, |
|
|
PEG_METHOD_ENTER (TRC_INDICATION_SERVICE, | PEG_METHOD_ENTER (TRC_INDICATION_SERVICE, |
"IndicationService::_insertToHashTables"); | "IndicationService::_insertToHashTables"); |
| |
|
Array <ProviderClassList> enableProviders; |
|
|
// | // |
// Insert entry into active subscriptions table | // Insert entry into active subscriptions table |
// | // |
{ | { |
WriteLock lock(_activeSubscriptionsTableLock); | WriteLock lock(_activeSubscriptionsTableLock); |
|
|
|
// |
|
// If provider is not yet in the table, add to list of |
|
// providers to enable |
|
// |
|
for (Uint32 i = 0; i < providers.size (); i++) |
|
{ |
|
if (!_providerInUse (providers [i].provider)) |
|
{ |
|
enableProviders.append (providers [i]); |
|
} |
|
} |
_insertActiveSubscriptionsEntry (subscription, providers); | _insertActiveSubscriptionsEntry (subscription, providers); |
} | } |
| |
|
|
} | } |
| |
PEG_METHOD_EXIT (); | PEG_METHOD_EXIT (); |
|
return enableProviders; |
|
} |
|
|
|
Array <ProviderClassList> IndicationService::_updateHashTable ( |
|
const CIMObjectPath & subscriptionPath, |
|
const ProviderClassList & provider, |
|
Boolean addProvider) |
|
{ |
|
PEG_METHOD_ENTER (TRC_INDICATION_SERVICE, |
|
"IndicationService::_updateHashTable"); |
|
|
|
Array <ProviderClassList> providers; |
|
|
|
String activeSubscriptionsKey = _generateActiveSubscriptionsKey |
|
(subscriptionPath); |
|
ActiveSubscriptionsTableEntry tableValue; |
|
if (_lockedLookupActiveSubscriptionsEntry (activeSubscriptionsKey, |
|
tableValue)) |
|
{ |
|
Uint32 providerIndex = _providerInList (provider.provider, tableValue); |
|
if (addProvider) |
|
{ |
|
if (providerIndex == PEG_NOT_FOUND) |
|
{ |
|
tableValue.providers.append (provider); |
|
} |
|
else |
|
{ |
|
CIMInstance p = provider.provider; |
|
PEG_TRACE_STRING (TRC_INDICATION_SERVICE, Tracer::LEVEL2, |
|
"Provider " + _getProviderLogString (p) + |
|
" already in list for Subscription (" + |
|
activeSubscriptionsKey + |
|
") in ActiveSubscriptionsTable"); |
|
} |
|
} |
|
else |
|
{ |
|
if (providerIndex != PEG_NOT_FOUND) |
|
{ |
|
tableValue.providers.remove (providerIndex); |
|
} |
|
else |
|
{ |
|
CIMInstance p = provider.provider; |
|
PEG_TRACE_STRING (TRC_INDICATION_SERVICE, Tracer::LEVEL2, |
|
"Provider " + _getProviderLogString (p) + |
|
" not found in list for Subscription (" + |
|
activeSubscriptionsKey + |
|
") in ActiveSubscriptionsTable"); |
|
} |
|
} |
|
{ |
|
WriteLock lock (_activeSubscriptionsTableLock); |
|
_removeActiveSubscriptionsEntry (activeSubscriptionsKey); |
|
if (!_providerInUse (provider.provider)) |
|
{ |
|
providers.append (provider); |
|
} |
|
_insertActiveSubscriptionsEntry (tableValue.subscription, |
|
tableValue.providers); |
|
} |
|
} |
|
else |
|
{ |
|
PEG_TRACE_STRING (TRC_INDICATION_SERVICE, Tracer::LEVEL2, |
|
"Subscription (" + activeSubscriptionsKey + |
|
") 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 providers; |
} | } |
| |
void IndicationService::_removeFromHashTables ( |
Array <ProviderClassList> IndicationService::_removeFromHashTables ( |
const CIMInstance & subscription, | const CIMInstance & subscription, |
const Array <CIMName> & indicationSubclassNames, | const Array <CIMName> & indicationSubclassNames, |
const CIMNamespaceName & sourceNamespaceName) |
const CIMNamespaceName & sourceNamespaceName, |
|
const Array <ProviderClassList> & providers) |
{ | { |
PEG_METHOD_ENTER (TRC_INDICATION_SERVICE, | PEG_METHOD_ENTER (TRC_INDICATION_SERVICE, |
"IndicationService::_removeFromHashTables"); | "IndicationService::_removeFromHashTables"); |
| |
|
Array <ProviderClassList> disableProviders; |
|
|
// | // |
// Remove entry from active subscriptions table | // Remove entry from active subscriptions table |
// | // |
|
|
| |
_removeActiveSubscriptionsEntry ( | _removeActiveSubscriptionsEntry ( |
_generateActiveSubscriptionsKey (subscription.getPath ())); | _generateActiveSubscriptionsKey (subscription.getPath ())); |
|
|
|
for (Uint32 i = 0; i < providers.size (); i++) |
|
{ |
|
if (!_providerInUse (providers [i].provider)) |
|
{ |
|
disableProviders.append (providers [i]); |
|
} |
|
} |
} | } |
| |
// | // |
|
|
} | } |
| |
PEG_METHOD_EXIT (); | PEG_METHOD_EXIT (); |
|
return disableProviders; |
} | } |
| |
CIMInstance IndicationService::_createAlertInstance ( | CIMInstance IndicationService::_createAlertInstance ( |