summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorcarolann.graves <carolann.graves>2005-08-10 19:42:49 +0000
committercarolann.graves <carolann.graves>2005-08-10 19:42:49 +0000
commit7b8dfd946a074e07f5f5074df73c6690d1d5a693 (patch)
tree162981070bb4a1d0e6913a92792a72943259ee7a /src
parentbb918a22e13bdfea2f3f8b457998b1e665d23750 (diff)
downloadtog-pegasus-7b8dfd946a074e07f5f5074df73c6690d1d5a693.zip
tog-pegasus-7b8dfd946a074e07f5f5074df73c6690d1d5a693.tar.gz
tog-pegasus-7b8dfd946a074e07f5f5074df73c6690d1d5a693.tar.xz
BUG#: 4010
TITLE: SubscriptionTable must include Filter and Handler Namespace in Active Subscriptions key DESCRIPTION: Modified SubscriptionTable to use Subscription object path as Active Subscriptions table key.
Diffstat (limited to 'src')
-rw-r--r--src/Pegasus/Common/HashTable.h17
-rw-r--r--src/Pegasus/IndicationService/SubscriptionTable.cpp109
-rw-r--r--src/Pegasus/IndicationService/SubscriptionTable.h20
-rw-r--r--src/Pegasus/IndicationService/tests/Subscription/Subscription.cpp41
4 files changed, 125 insertions, 62 deletions
diff --git a/src/Pegasus/Common/HashTable.h b/src/Pegasus/Common/HashTable.h
index e50c0b0..ada2ac3 100644
--- a/src/Pegasus/Common/HashTable.h
+++ b/src/Pegasus/Common/HashTable.h
@@ -39,6 +39,7 @@
#include <Pegasus/Common/Config.h>
#include <Pegasus/Common/String.h>
+#include <Pegasus/Common/CIMObjectPath.h>
#include <Pegasus/Common/Linkage.h>
PEGASUS_NAMESPACE_BEGIN
@@ -61,6 +62,14 @@ PEGASUS_TEMPLATE_SPECIALIZATION struct HashFunc<Uint32>
static Uint32 hash(Uint32 x) { return x + 13; }
};
+PEGASUS_TEMPLATE_SPECIALIZATION struct HashFunc <CIMObjectPath>
+{
+ static Uint32 hash (const CIMObjectPath & path)
+ {
+ return path.makeHashCode ();
+ }
+};
+
/*
Hash function object that converts to lowercase.
@@ -96,6 +105,14 @@ struct EqualFunc
}
};
+PEGASUS_TEMPLATE_SPECIALIZATION struct EqualFunc <CIMObjectPath>
+{
+ static Boolean equal (const CIMObjectPath & x, const CIMObjectPath & y)
+ {
+ return x.identical (y);
+ }
+};
+
/*
Equal function object that can be used by HashTable to compare keys that
should be treated as case insensitive.
diff --git a/src/Pegasus/IndicationService/SubscriptionTable.cpp b/src/Pegasus/IndicationService/SubscriptionTable.cpp
index 6eb5240..9c8a795 100644
--- a/src/Pegasus/IndicationService/SubscriptionTable.cpp
+++ b/src/Pegasus/IndicationService/SubscriptionTable.cpp
@@ -66,7 +66,7 @@ Boolean SubscriptionTable::getSubscriptionEntry (
"SubscriptionTable::getSubscriptionEntry");
Boolean succeeded = false;
- String activeSubscriptionsKey = _generateActiveSubscriptionsKey
+ CIMObjectPath activeSubscriptionsKey = _generateActiveSubscriptionsKey
(subscriptionPath);
if (_lockedLookupActiveSubscriptionsEntry
(activeSubscriptionsKey, tableValue))
@@ -79,7 +79,7 @@ Boolean SubscriptionTable::getSubscriptionEntry (
// Subscription not found in Active Subscriptions table
//
PEG_TRACE_STRING (TRC_INDICATION_SERVICE_INTERNAL, Tracer::LEVEL2,
- "Subscription (" + activeSubscriptionsKey +
+ "Subscription (" + activeSubscriptionsKey.toString () +
") not found in ActiveSubscriptionsTable");
}
@@ -122,9 +122,9 @@ Array <CIMInstance> SubscriptionTable::getMatchingSubscriptions (
// Check if the provider who generated this indication
// accepted this subscription
//
- String activeSubscriptionsKey =
+ CIMObjectPath activeSubscriptionsKey =
_generateActiveSubscriptionsKey
- (subscriptions [j].getPath ());
+ (subscriptions [j].getPath ());
ActiveSubscriptionsTableEntry tableValue;
if (_lockedLookupActiveSubscriptionsEntry
(activeSubscriptionsKey, tableValue))
@@ -213,8 +213,9 @@ Array <CIMInstance> SubscriptionTable::getAndUpdateProviderSubscriptions (
//
// Update the entry in the active subscriptions hash table
//
- String activeSubscriptionsKey = _generateActiveSubscriptionsKey
- (providerSubscriptions [k].getPath ());
+ CIMObjectPath activeSubscriptionsKey =
+ _generateActiveSubscriptionsKey
+ (providerSubscriptions [k].getPath ());
ActiveSubscriptionsTableEntry tableValue;
if (_activeSubscriptionsTable.lookup (activeSubscriptionsKey,
tableValue))
@@ -268,7 +269,7 @@ Array <CIMInstance> SubscriptionTable::getAndUpdateProviderSubscriptions (
Tracer::LEVEL2,
"Provider (" + provider.getPath().toString() +
") not found in list for Subscription (" +
- activeSubscriptionsKey +
+ activeSubscriptionsKey.toString () +
") in ActiveSubscriptionsTable");
}
}
@@ -276,7 +277,7 @@ Array <CIMInstance> SubscriptionTable::getAndUpdateProviderSubscriptions (
{
PEG_TRACE_STRING (TRC_INDICATION_SERVICE_INTERNAL,
Tracer::LEVEL2,
- "Subscription (" + activeSubscriptionsKey +
+ "Subscription (" + activeSubscriptionsKey.toString () +
") not found in ActiveSubscriptionsTable");
//
// The subscription may have been deleted in the mean time
@@ -290,60 +291,46 @@ Array <CIMInstance> SubscriptionTable::getAndUpdateProviderSubscriptions (
return providerSubscriptions;
}
-String SubscriptionTable::_generateActiveSubscriptionsKey (
+CIMObjectPath SubscriptionTable::_generateActiveSubscriptionsKey (
const CIMObjectPath & subscription) const
{
- String activeSubscriptionsKey;
-
- //
- // Append subscription namespace name to key
- //
- activeSubscriptionsKey.append
- (subscription.getNameSpace ().getString());
-
//
- // Get filter and handler key bindings from subscription reference
+ // Get filter and handler object paths from subscription Filter and Handler
+ // reference property values
//
Array<CIMKeyBinding> subscriptionKB = subscription.getKeyBindings ();
- Array<CIMKeyBinding> filterKB;
- Array<CIMKeyBinding> handlerKB;
+ CIMObjectPath filterPath;
+ CIMObjectPath handlerPath;
for (Uint32 i = 0; i < subscriptionKB.size (); i++)
{
if ((subscriptionKB [i].getName () == _PROPERTY_FILTER) &&
(subscriptionKB [i].getType () == CIMKeyBinding::REFERENCE))
{
- CIMObjectPath filterRef (subscriptionKB [i].getValue ());
- filterKB = filterRef.getKeyBindings ();
+ filterPath = subscriptionKB [i].getValue ();
}
if ((subscriptionKB [i].getName () == _PROPERTY_HANDLER) &&
(subscriptionKB [i].getType () == CIMKeyBinding::REFERENCE))
{
- CIMObjectPath handlerRef (subscriptionKB [i].getValue ());
- handlerKB = handlerRef.getKeyBindings ();
+ handlerPath = subscriptionKB [i].getValue ();
}
}
//
- // Append subscription filter key values to key
+ // Construct subscription object name for key
//
- for (Uint32 j = 0; j < filterKB.size (); j++)
- {
- activeSubscriptionsKey.append (filterKB [j].getValue ());
- }
-
- //
- // Append subscription handler key values to key
- //
- for (Uint32 k = 0; k < handlerKB.size (); k++)
- {
- activeSubscriptionsKey.append (handlerKB [k].getValue ());
- }
+ filterPath.setHost (String::EMPTY);
+ handlerPath.setHost (String::EMPTY);
+ Array <CIMKeyBinding> kb;
+ kb.append (CIMKeyBinding (_PROPERTY_FILTER, CIMValue (filterPath)));
+ kb.append (CIMKeyBinding (_PROPERTY_HANDLER, CIMValue (handlerPath)));
+ CIMObjectPath activeSubscriptionsKey ("", subscription.getNameSpace (),
+ subscription.getClassName (), kb);
return activeSubscriptionsKey;
}
Boolean SubscriptionTable::_lockedLookupActiveSubscriptionsEntry (
- const String & key,
+ const CIMObjectPath & key,
ActiveSubscriptionsTableEntry & tableEntry) const
{
ReadLock lock(_activeSubscriptionsTableLock);
@@ -358,13 +345,18 @@ void SubscriptionTable::_insertActiveSubscriptionsEntry (
PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
"SubscriptionTable::_insertActiveSubscriptionsEntry");
- String activeSubscriptionsKey = _generateActiveSubscriptionsKey
+ CIMObjectPath activeSubscriptionsKey = _generateActiveSubscriptionsKey
(subscription.getPath ());
ActiveSubscriptionsTableEntry entry;
entry.subscription = subscription;
entry.providers = providers;
- _activeSubscriptionsTable.insert (activeSubscriptionsKey, entry);
+ //
+ // Insert returns true on success, false if duplicate key
+ //
+ Boolean succeeded = _activeSubscriptionsTable.insert
+ (activeSubscriptionsKey, entry);
+ PEGASUS_ASSERT (succeeded);
#ifdef PEGASUS_INDICATION_HASHTRACE
String traceString;
@@ -392,16 +384,22 @@ void SubscriptionTable::_insertActiveSubscriptionsEntry (
}
void SubscriptionTable::_removeActiveSubscriptionsEntry (
- const String & key)
+ const CIMObjectPath & key)
{
PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
"SubscriptionTable::_removeActiveSubscriptionsEntry");
- _activeSubscriptionsTable.remove (key);
+ //
+ // Remove returns true on success, false if not found
+ //
+ Boolean succeeded = _activeSubscriptionsTable.remove (key);
+ PEGASUS_ASSERT (succeeded);
+
#ifdef PEGASUS_INDICATION_HASHTRACE
PEG_TRACE_STRING (TRC_INDICATION_SERVICE_INTERNAL,
Tracer::LEVEL3,
- "REMOVED _activeSubscriptionsTable entry: " + key);
+ "REMOVED _activeSubscriptionsTable entry: " +
+ key.toString ());
#endif
PEG_METHOD_EXIT ();
@@ -450,7 +448,12 @@ void SubscriptionTable::_insertSubscriptionClassesEntry (
entry.sourceNamespaceName = sourceNamespaceName;
entry.subscriptions = subscriptions;
- _subscriptionClassesTable.insert (subscriptionClassesKey, entry);
+ //
+ // Insert returns true on success, false if duplicate key
+ //
+ Boolean succeeded = _subscriptionClassesTable.insert
+ (subscriptionClassesKey, entry);
+ PEGASUS_ASSERT (succeeded);
#ifdef PEGASUS_INDICATION_HASHTRACE
String traceString;
@@ -475,7 +478,11 @@ void SubscriptionTable::_removeSubscriptionClassesEntry (
PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
"SubscriptionTable::_removeSubscriptionClassesEntry");
- _subscriptionClassesTable.remove (key);
+ //
+ // Remove returns true on success, false if not found
+ //
+ Boolean succeeded = _subscriptionClassesTable.remove (key);
+ PEGASUS_ASSERT (succeeded);
#ifdef PEGASUS_INDICATION_HASHTRACE
PEG_TRACE_STRING (TRC_INDICATION_SERVICE_INTERNAL, Tracer::LEVEL3,
@@ -558,7 +565,7 @@ void SubscriptionTable::updateProviders (
PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
"SubscriptionTable::updateProviders");
- String activeSubscriptionsKey = _generateActiveSubscriptionsKey
+ CIMObjectPath activeSubscriptionsKey = _generateActiveSubscriptionsKey
(subscriptionPath);
ActiveSubscriptionsTableEntry tableValue;
{
@@ -592,7 +599,7 @@ void SubscriptionTable::updateProviders (
"Provider " +
IndicationService::getProviderLogString (p) +
" already in list for Subscription (" +
- activeSubscriptionsKey +
+ activeSubscriptionsKey.toString () +
") in ActiveSubscriptionsTable");
}
}
@@ -613,7 +620,7 @@ void SubscriptionTable::updateProviders (
"Provider " +
IndicationService::getProviderLogString (p) +
" not found in list for Subscription (" +
- activeSubscriptionsKey +
+ activeSubscriptionsKey.toString () +
") in ActiveSubscriptionsTable");
}
}
@@ -621,7 +628,7 @@ void SubscriptionTable::updateProviders (
else
{
PEG_TRACE_STRING (TRC_INDICATION_SERVICE_INTERNAL, Tracer::LEVEL2,
- "Subscription (" + activeSubscriptionsKey +
+ "Subscription (" + activeSubscriptionsKey.toString () +
") not found in ActiveSubscriptionsTable");
//
@@ -642,7 +649,7 @@ void SubscriptionTable::updateClasses (
PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
"SubscriptionTable::updateClasses");
- String activeSubscriptionsKey = _generateActiveSubscriptionsKey
+ CIMObjectPath activeSubscriptionsKey = _generateActiveSubscriptionsKey
(subscriptionPath);
ActiveSubscriptionsTableEntry tableValue;
@@ -684,7 +691,7 @@ void SubscriptionTable::updateClasses (
Tracer::LEVEL2,
"Provider (" + provider.getPath ().toString () +
") not found in list for Subscription (" +
- activeSubscriptionsKey +
+ activeSubscriptionsKey.toString () +
") in ActiveSubscriptionsTable");
}
}
diff --git a/src/Pegasus/IndicationService/SubscriptionTable.h b/src/Pegasus/IndicationService/SubscriptionTable.h
index ced798a..bf8aeee 100644
--- a/src/Pegasus/IndicationService/SubscriptionTable.h
+++ b/src/Pegasus/IndicationService/SubscriptionTable.h
@@ -72,9 +72,7 @@ struct ActiveSubscriptionsTableEntry
ProviderClassList structs representing the providers, if any, currently
serving each subscription and the relevant indication subclasses served by
each provider.
- The Key is generated by concatenating the namespace name of the
- subscription instance, and the subscription instance key values (filter and
- handler key values).
+ The Key is the object path of the subscription instance.
Entries are inserted into the table on initialization, when an enabled
subscription instance is created, or when a subscription instance is
modified to be enabled.
@@ -98,10 +96,10 @@ struct ActiveSubscriptionsTableEntry
The terminate() function, when the CIM Server is being shut down, iterates
through the table to retrieve all active subscriptions.
*/
-typedef HashTable <String,
+typedef HashTable <CIMObjectPath,
ActiveSubscriptionsTableEntry,
- EqualFunc <String>,
- HashFunc <String> > ActiveSubscriptionsTable;
+ EqualFunc <CIMObjectPath>,
+ HashFunc <CIMObjectPath> > ActiveSubscriptionsTable;
/**
Entry for SubscriptionClasses table
@@ -331,14 +329,14 @@ public:
private:
/**
- Generates a unique String key for the Active Subscriptions table from
- the subscription namespace name and key values.
+ Generates a unique CIMObjectPath key for the Active Subscriptions table
+ from the subscription object path.
@param subscription the subscription object path
@return the generated key
*/
- String _generateActiveSubscriptionsKey (
+ CIMObjectPath _generateActiveSubscriptionsKey (
const CIMObjectPath & subscription) const;
/**
@@ -351,7 +349,7 @@ private:
@return true if the key is found in the table; false otherwise
*/
Boolean _lockedLookupActiveSubscriptionsEntry (
- const String & key,
+ const CIMObjectPath & key,
ActiveSubscriptionsTableEntry & tableEntry) const;
/**
@@ -372,7 +370,7 @@ private:
@param key the key of the entry to remove
*/
void _removeActiveSubscriptionsEntry (
- const String & key);
+ const CIMObjectPath & key);
/**
Generates a unique String key for the Subscription Classes table from
diff --git a/src/Pegasus/IndicationService/tests/Subscription/Subscription.cpp b/src/Pegasus/IndicationService/tests/Subscription/Subscription.cpp
index 75b83e8..6f22c8d 100644
--- a/src/Pegasus/IndicationService/tests/Subscription/Subscription.cpp
+++ b/src/Pegasus/IndicationService/tests/Subscription/Subscription.cpp
@@ -1747,6 +1747,22 @@ void _valid (CIMClient & client, String& qlang)
String::EMPTY, String::EMPTY, NAMESPACE1, NAMESPACE2);
//
+ // Create subscription in which Filter and Handler reference property
+ // values differ only in Namespace
+ //
+ CIMInstance subscription16 = _buildSubscriptionInstance
+ (fPath2, PEGASUS_CLASSNAME_LSTNRDST_CIMXML, hPath2);
+ CIMObjectPath s16Path = client.createInstance (NAMESPACE3, subscription16);
+
+ _checkSubscriptionPath (s16Path, "Filter11",
+ PEGASUS_CLASSNAME_LSTNRDST_CIMXML, "ListenerDestination05",
+ String::EMPTY, String::EMPTY, NAMESPACE2, NAMESPACE1);
+
+ _deleteSubscriptionInstance (client, "Filter11",
+ PEGASUS_CLASSNAME_LSTNRDST_CIMXML, "ListenerDestination05",
+ String::EMPTY, String::EMPTY, NAMESPACE2, NAMESPACE1, NAMESPACE3);
+
+ //
// Create another transient CIMXML listener destination in a different
// namespace
//
@@ -3355,6 +3371,21 @@ void _error (CIMClient & client)
String::EMPTY, String::EMPTY, NAMESPACE1, NAMESPACE2);
//
+ // Ensure a duplicate Subscription may not be created
+ //
+ try
+ {
+ CIMInstance subscription17 = _buildSubscriptionInstance
+ (fPath, PEGASUS_CLASSNAME_LSTNRDST_CIMXML, hPath);
+ CIMObjectPath s17Path = client.createInstance (NAMESPACE3,
+ subscription17);
+ }
+ catch (CIMException & e)
+ {
+ _checkExceptionCode (e, CIM_ERR_ALREADY_EXISTS);
+ }
+
+ //
// Filter: Attempt to delete a filter referenced by a subscription
// A Filter referenced by a subscription may not be deleted
//
@@ -4431,6 +4462,16 @@ void _cleanup (CIMClient & client)
{
}
+ try
+ {
+ _deleteSubscriptionInstance (client, "Filter11",
+ PEGASUS_CLASSNAME_LSTNRDST_CIMXML, "ListenerDestination05",
+ String::EMPTY, String::EMPTY, NAMESPACE2, NAMESPACE1, NAMESPACE3);
+ }
+ catch (...)
+ {
+ }
+
//
// Delete handler instances
//