1 karl 1.13 //%2006////////////////////////////////////////////////////////////////////////
|
2 kumpf 1.1 //
|
3 karl 1.4 // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development
4 // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.
5 // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.;
|
6 kumpf 1.1 // IBM Corp.; EMC Corporation, The Open Group.
|
7 karl 1.4 // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
8 // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
|
9 karl 1.5 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
10 // EMC Corporation; VERITAS Software Corporation; The Open Group.
|
11 karl 1.13 // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;
12 // EMC Corporation; Symantec Corporation; The Open Group.
|
13 kumpf 1.1 //
14 // Permission is hereby granted, free of charge, to any person obtaining a copy
15 // of this software and associated documentation files (the "Software"), to
16 // deal in the Software without restriction, including without limitation the
17 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
18 // sell copies of the Software, and to permit persons to whom the Software is
19 // furnished to do so, subject to the following conditions:
20 //
21 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
22 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
23 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
24 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
25 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
26 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
27 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 //
30 //==============================================================================
31 //
32 // Author: Carol Ann Krug Graves, Hewlett-Packard Company
33 // (carolann_graves@hp.com)
34 kumpf 1.1 //
|
35 aruran.ms 1.12 // Modified By: Aruran, IBM (ashanmug@in.ibm.com) for Bug# 3603, 3602
|
36 kumpf 1.1 //
37 //%/////////////////////////////////////////////////////////////////////////////
38
39 #ifndef Pegasus_SubscriptionTable_h
40 #define Pegasus_SubscriptionTable_h
41
42 #include <Pegasus/Common/Config.h>
43 #include <Pegasus/Server/Linkage.h>
44 #include <Pegasus/Common/CIMInstance.h>
45 #include <Pegasus/Common/CIMObjectPath.h>
46 #include <Pegasus/Common/String.h>
47 #include <Pegasus/Common/Array.h>
48 #include <Pegasus/Common/HashTable.h>
49
50 #include "ProviderClassList.h"
51 #include "SubscriptionRepository.h"
52
53 PEGASUS_NAMESPACE_BEGIN
54
55 class IndicationService;
56
57 kumpf 1.1 /**
58 Entry for ActiveSubscriptions table
59 */
60 struct ActiveSubscriptionsTableEntry
61 {
62 CIMInstance subscription;
63 Array <ProviderClassList> providers;
64 };
65
66 /**
67 Table for active subscription information
68
69 The ActiveSubscriptions table is used to keep track of active subscriptions.
|
70 carolann.graves 1.10 This table contains an entry for each subscription that is enabled
71 (value of SubscriptionState property is enabled).
72 Each entry consists of a Subscription instance, and a list of
73 ProviderClassList structs representing the providers, if any, currently
74 serving each subscription and the relevant indication subclasses served by
|
75 kumpf 1.1 each provider.
|
76 carolann.graves 1.11 The Key is the object path of the subscription instance.
|
77 carolann.graves 1.10 Entries are inserted into the table on initialization, when an enabled
78 subscription instance is created, or when a subscription instance is
|
79 kumpf 1.1 modified to be enabled.
80 Entries are removed from the table when an enabled subscription instance is
81 deleted, or when a subscription instance is modified to be disabled.
|
82 carolann.graves 1.10 Entries are updated (remove followed by insert) when a provider serving a
83 subscription is disabled or enabled, or a provider registration change
|
84 kumpf 1.1 occurs.
|
85 carolann.graves 1.10 The _handleProcessIndicationRequest() function, when a list of
86 subscriptions is included in request, looks up each subscription in the
|
87 kumpf 1.1 table.
88 The _handleNotifyProviderRegistrationRequest() function, once matching
|
89 carolann.graves 1.10 subscriptions have been identified, looks up the provider information for
|
90 kumpf 1.1 each matching subscription in the table.
|
91 carolann.graves 1.10 The _handleModifyInstanceRequest() and _handleDeleteInstanceRequest()
|
92 kumpf 1.1 functions, when sending delete requests to providers, look up the providers
93 for the subscription in the table.
|
94 carolann.graves 1.10 The _handleNotifyProviderTerminationRequest() function, when a provider is
95 disabled, iterates through the table to retrieve all active
|
96 kumpf 1.1 subscriptions being served by the provider.
|
97 carolann.graves 1.10 The terminate() function, when the CIM Server is being shut down, iterates
|
98 kumpf 1.1 through the table to retrieve all active subscriptions.
99 */
|
100 carolann.graves 1.11 typedef HashTable <CIMObjectPath,
|
101 carolann.graves 1.10 ActiveSubscriptionsTableEntry,
|
102 carolann.graves 1.11 EqualFunc <CIMObjectPath>,
103 HashFunc <CIMObjectPath> > ActiveSubscriptionsTable;
|
104 kumpf 1.1
105 /**
106 Entry for SubscriptionClasses table
107 */
108 struct SubscriptionClassesTableEntry
109 {
110 CIMName indicationClassName;
111 CIMNamespaceName sourceNamespaceName;
112 Array <CIMInstance> subscriptions;
113 };
114
115 /**
116 Table for subscription classes information
117
|
118 carolann.graves 1.10 The SubscriptionClasses Table is used to keep track of active subscriptions
|
119 kumpf 1.1 for each indication subclass-source namespace pair.
120 Each entry consists of an indication subclass name, a source namespace name,
121 and a list of subscription instances.
122 The Key is generated by concatenating the indication subclass name, and the
123 source namespace name.
|
124 carolann.graves 1.10 The _handleProcessIndicationRequest() function, when no list of
125 subscriptions is included in the request, looks up matching subscriptions
126 in the table, using the class name and namespace name of the indication
|
127 kumpf 1.1 instance.
128 The _handleNotifyProviderRegistrationRequest() function, when an indication
|
129 carolann.graves 1.10 provider registration instance has been created or deleted, looks up
130 matching subscriptions in the table, using the class name and namespace
131 names from the provider registration instance.
|
132 kumpf 1.1 */
133 typedef HashTable <String,
134 SubscriptionClassesTableEntry,
|
135 kumpf 1.2 EqualNoCaseFunc,
136 HashLowerCaseFunc> SubscriptionClassesTable;
|
137 kumpf 1.1
138 /**
139
|
140 carolann.graves 1.10 The SubscriptionTable class manages an in-memory cache of indication
141 subscription information in two hash tables. The Active Subscriptions
|
142 kumpf 1.1 table includes all enabled subscriptions along with the providers currently
|
143 carolann.graves 1.10 serving them. The Subscription Classes table includes the enabled
144 subscription instances for each indication class/namespace pair, based on
|
145 kumpf 1.1 the filter query and sourceNamespace.
146
147 @author Hewlett-Packard Company
148
149 */
150
|
151 carolann.graves 1.10 class PEGASUS_SERVER_LINKAGE SubscriptionTable
|
152 kumpf 1.1 {
153 public:
154
155 /**
156 Constructs a SubscriptionTable instance.
157 */
158 SubscriptionTable (
159 SubscriptionRepository * subscriptionRepository);
160
161 /**
162 Destructs a SubscriptionTable instance.
163 */
164 ~SubscriptionTable ();
165
166 /**
167 Inserts entries (or updates existing entries) for the specified
|
168 carolann.graves 1.10 subscription in the Active Subscriptions and Subscription Classes
|
169 kumpf 1.1 tables.
170
171 @param subscription the subscription instance
172 @param providers the list of providers
173 @param indicationSubclassNames the list of indication subclass names
174 @param sourceNamespaceName the source namespace name
175 */
|
176 carolann.graves 1.6 void insertSubscription (
|
177 kumpf 1.1 const CIMInstance & subscription,
178 const Array <ProviderClassList> & providers,
179 const Array <CIMName> & indicationSubclassNames,
180 const CIMNamespaceName & sourceNamespaceName);
181
182 /**
|
183 carolann.graves 1.10 Updates an entry in the Active Subscriptions table to either add a
|
184 kumpf 1.1 provider to or remove a provider from the list of providers serving the
185 subscription.
186
187 @param subscriptionPath the subscription object path
188 @param provider the provider to be added or removed
|
189 carolann.graves 1.10 @param addProvider indicates if adding or removing
|
190 kumpf 1.1 provider
191 */
|
192 carolann.graves 1.6 void updateProviders (
|
193 kumpf 1.1 const CIMObjectPath & subscriptionPath,
|
194 carolann.graves 1.7 const ProviderClassList & provider,
|
195 kumpf 1.1 Boolean addProvider);
196
197 /**
|
198 carolann.graves 1.10 Updates an entry in the Active Subscriptions table to either add a
|
199 kumpf 1.1 class to or remove a class from the list of indication subclasses served
200 by a provider serving the subscription.
201
202 @param subscriptionPath the subscription object path
203 @param provider the provider
204 @param className the class to be added or removed
205 */
206 void updateClasses (
207 const CIMObjectPath & subscriptionPath,
208 const CIMInstance & provider,
209 const CIMName & className);
210
211 /**
|
212 carolann.graves 1.10 Removes entries (or updates entries) for the specified subscription in
|
213 kumpf 1.1 the Active Subscriptions and Subscription Classes tables.
214
215 @param subscription the subscription instance
216 @param indicationSubclassNames the list of indication subclass names
217 @param sourceNamespaceName the source namespace name
|
218 carolann.graves 1.10 @param providers the list of providers that had been
|
219 kumpf 1.1 serving the subscription
220 */
|
221 carolann.graves 1.6 void removeSubscription (
|
222 kumpf 1.1 const CIMInstance & subscription,
223 const Array <CIMName> & indicationSubclassNames,
224 const CIMNamespaceName & sourceNamespaceName,
225 const Array <ProviderClassList> & providers);
226
227 /**
|
228 carolann.graves 1.10 Retrieves the Active Subscriptions table entry for the specified
229 subscription. If this function returns False, the value of tableValue
|
230 kumpf 1.1 is not changed.
231
|
232 carolann.graves 1.7 @param subscriptionPath the object path of the subscription
|
233 kumpf 1.1 @param tableValue the retrieved table entry
234
235 @return True, if the specified subscription table entry was found;
236 False otherwise
237 */
238 Boolean getSubscriptionEntry (
239 const CIMObjectPath & subscriptionPath,
|
240 aruran.ms 1.8 ActiveSubscriptionsTableEntry & tableValue) const;
|
241 kumpf 1.1
242 /**
243 Retrieves list of enabled subscription instances in the specified
|
244 carolann.graves 1.10 namespaces, where the subscription indication class matches or is a
245 superclass of the supported class. If the checkProvider parameter
246 value is True, a subscription is only included in the list returned if
|
247 kumpf 1.1 the specified provider accepted the subscription. If the checkProvider
248 parameter value is False, the provider parameter is not used (ignored).
249
250 @param supportedClass the supported class
251 @param nameSpaces the list of supported namespaces
252 @param checkProvider indicates whether provider acceptance is
253 checked
254 @param provider the provider (used if checkProvider True)
255
256 @return list of CIMInstance subscriptions
257 */
258 Array <CIMInstance> getMatchingSubscriptions (
259 const CIMName & supportedClass,
260 const Array <CIMNamespaceName> nameSpaces,
261 const Boolean checkProvider = false,
|
262 aruran.ms 1.8 const CIMInstance & provider = CIMInstance ()) const;
|
263 kumpf 1.1
264 /**
265 Retrieves list of enabled subscription instances in all namespaces,
|
266 carolann.graves 1.10 that are served by the specified provider. This function is called
267 when a provider is disabled. In the Active Subscriptions table, the
268 specified provider is removed from the list of providers serving the
269 subscription.
270
271 Note: this method may call the SubscriptionRepository
272 reconcileFatalError() method, which may call the CIMRepository
273 modifyInstance() or deleteInstance() method, while a WriteLock is held
274 on the Active Subscriptions table. The determination of whether the
275 SubscriptionRepository reconcileFatalError() method must be called (and
276 whether the repository must be updated) requires a lookup of the Active
277 Subscriptions table to see if any other providers are serving the
278 subscription. The SubscriptionRepository reconcileFatalError() method
279 does not need to access the repository to determine the subscription
280 policy, but if the policy is Disable or Remove, it does need to call the
281 CIMRepository modifyInstance() or deleteInstance() method. The return
282 value from the SubscriptionRepository reconcileFatalError() method (True
283 if the subscription was successfully disabled or removed) in turn
284 determines whether the entry in the Active Subscriptions table must be
285 updated or removed.
|
286 kumpf 1.1
287 @param provider the provider instance
288
289 @return list of CIMInstance subscriptions
290 */
|
291 carolann.graves 1.14 Array <CIMInstance> reflectProviderDisable (
|
292 aruran.ms 1.9 const CIMInstance & provider);
|
293 kumpf 1.1
294 /**
|
295 carolann.graves 1.14 Retrieves a list of subscription table entries for subscriptions that
296 were being served by providers in the specified provider module, where
297 the subscription creator matches the specified provider module userName.
298 The Active Subscriptions table is updated to reflect the fact that these
299 subscriptions are no longer being served by the provider(s) in the
300 failed provider module.
301 This method is called when notification is received that the specified
302 provider module has failed. In the Active Subscriptions table, any
303 provider in the specified provider module is removed from the list of
304 providers serving the subscription.
305 The returned list of Active Subscriptions table entries includes for
306 each subscription only those providers that are in the specified
307 (failed) provider module and therefore are no longer serving the
308 subscription.
309
310 @param moduleName the provider module name
311 @param userName the user name for the context in which
312 the provider module was invoked
313 @param authenticationEnabled indicates whether authentication is
314 currently enabled
315
316 carolann.graves 1.14 @return list of ActiveSubscriptionsTableEntry structs including the
317 subscriptions served by providers in the specified provider
318 module
319 */
320 Array <ActiveSubscriptionsTableEntry> reflectProviderModuleFailure (
321 const String & moduleName,
322 const String & userName,
323 Boolean authenticationEnabled);
324
325 /**
|
326 carolann.graves 1.10 Determines if the specified provider is in the list of providers
327 serving the subscription.
|
328 kumpf 1.1
329 @param provider the provider instance
330 @param tableValue the Active Subscriptions Table entry
331
332 @return The index of the provider in the list, if found;
333 PEG_NOT_FOUND otherwise
334 */
|
335 carolann.graves 1.10 Uint32 providerInList
|
336 kumpf 1.1 (const CIMInstance & provider,
337 const ActiveSubscriptionsTableEntry & tableValue) const;
338
339 /**
|
340 carolann.graves 1.10 Determines if the specified class is in the list of indication
341 subclasses served by the specified provider, serving the subscription.
|
342 kumpf 1.1
343 @param className the class name
|
344 carolann.graves 1.10 @param providerClasses a provider serving the subscription,
|
345 kumpf 1.1 with the indication classes served
346
347 @return The index of the class name in the list, if found;
348 PEG_NOT_FOUND otherwise
349 */
350 Uint32 classInList
351 (const CIMName & className,
352 const ProviderClassList & providerClasses) const;
353
|
354 kumpf 1.3 /**
|
355 carolann.graves 1.10 Removes all entries from the Active Subscriptions and Subscription
|
356 kumpf 1.3 Classes tables.
357 */
358 void clear ();
359
|
360 kumpf 1.1
361 private:
362
|
363 aruran.ms 1.12 /** Copy Constructor just to avoid the compiler provided one.
364 */
365 SubscriptionTable ( const SubscriptionTable& subscriptionTable );
366
367 /** Overloaded Assignment Operator
368 */
369 SubscriptionTable& operator=( const SubscriptionTable& rhs );
370
|
371 kumpf 1.1 /**
|
372 carolann.graves 1.11 Generates a unique CIMObjectPath key for the Active Subscriptions table
373 from the subscription object path.
|
374 kumpf 1.1
375 @param subscription the subscription object path
376
377 @return the generated key
378 */
|
379 carolann.graves 1.11 CIMObjectPath _generateActiveSubscriptionsKey (
|
380 kumpf 1.1 const CIMObjectPath & subscription) const;
381
382 /**
|
383 carolann.graves 1.10 Locks the _activeSubscriptionsTableLock for read access and looks
|
384 kumpf 1.1 up an entry in the Active Subscriptions table.
385
386 @param key the hash table key
387 @param tableEntry the table entry retrieved
388
389 @return true if the key is found in the table; false otherwise
390 */
391 Boolean _lockedLookupActiveSubscriptionsEntry (
|
392 carolann.graves 1.11 const CIMObjectPath & key,
|
393 aruran.ms 1.8 ActiveSubscriptionsTableEntry & tableEntry) const;
|
394 kumpf 1.1
395 /**
396 Inserts an entry into the Active Subscriptions table. The caller
|
397 carolann.graves 1.10 must first lock the _activeSubscriptionsTableLock for write access.
|
398 kumpf 1.1
399 @param subscription the subscription instance
|
400 carolann.graves 1.10 @param providers the list of providers
|
401 kumpf 1.1 */
402 void _insertActiveSubscriptionsEntry (
403 const CIMInstance & subscription,
|
404 aruran.ms 1.9 const Array <ProviderClassList> & providers);
|
405 kumpf 1.1
406 /**
407 Removes an entry from the Active Subscriptions table. The caller
|
408 carolann.graves 1.10 must first lock the _activeSubscriptionsTableLock for write access.
|
409 kumpf 1.1
410 @param key the key of the entry to remove
411 */
412 void _removeActiveSubscriptionsEntry (
|
413 carolann.graves 1.11 const CIMObjectPath & key);
|
414 kumpf 1.1
415 /**
416 Generates a unique String key for the Subscription Classes table from
417 the indication class name and source namespace name.
418
419 @param indicationClassName the indication class name
420 @param sourceNamespaceName the source namespace name
421
422 @return the generated key
423 */
424 String _generateSubscriptionClassesKey (
425 const CIMName & indicationClassName,
426 const CIMNamespaceName & sourceNamespaceName) const;
427
428 /**
429 Locks the _subscriptionClassesTableLock for read access and looks
430 up an entry in the Subscription Classes table.
431
432 @param key the hash table key
433 @param tableEntry the table entry retrieved
434
435 kumpf 1.1 @return true if the key is found in the table; false otherwise
436 */
437 Boolean _lockedLookupSubscriptionClassesEntry (
438 const String & key,
|
439 aruran.ms 1.8 SubscriptionClassesTableEntry & tableEntry) const;
|
440 kumpf 1.1
441 /**
|
442 carolann.graves 1.10 Inserts an entry into the Subscription Classes table. The caller must
443 first lock the _subscriptionClassesTableLock for write access.
|
444 kumpf 1.1
445 @param indicationClassName the indication class name
446 @param sourceNamespaceName the source namespace name
447 @param subscriptions the list of subscription instances
448 */
|
449 carolann.graves 1.10 void _insertSubscriptionClassesEntry (
|
450 kumpf 1.1 const CIMName & indicationClassName,
451 const CIMNamespaceName & sourceNamespaceName,
452 const Array <CIMInstance> & subscriptions);
453
454 /**
|
455 carolann.graves 1.10 Removes an entry from the Subscription Classes table. The caller must
456 first lock the _subscriptionClassesTableLock for write access.
|
457 kumpf 1.1
458 @param key the key of the entry to remove
459 */
|
460 carolann.graves 1.10 void _removeSubscriptionClassesEntry (
|
461 kumpf 1.1 const String & key);
462
463 /**
|
464 carolann.graves 1.14 Updates the providers for an entry in the Active Subscriptions table.
465 The caller must first lock the _activeSubscriptionsTableLock for write
466 access.
467
468 @param activeSubscriptionsKey the key of the entry to update
469 @param subscription the subscription instance for the entry
470 @param updatedProviderList the updated list of providers for the
471 entry (may be empty)
472 */
473 void _updateSubscriptionProviders (
474 const CIMObjectPath & activeSubscriptionsKey,
475 const CIMInstance & subscription,
476 const Array <ProviderClassList> & updatedProviderList);
477
478 /**
|
479 kumpf 1.1 Active Subscriptions information table. Access to this table is
480 controlled by the _activeSubscriptionsTableLock.
481 */
|
482 aruran.ms 1.9 ActiveSubscriptionsTable _activeSubscriptionsTable;
|
483 kumpf 1.1
484 /**
485 A lock to control access to the _activeSubscriptionsTable. Before
486 accessing the _activeSubscriptionsTable, one must first lock this for
487 read access. Before updating the _activeSubscriptionsTable, one must
488 first lock this for write access.
489 */
|
490 aruran.ms 1.8 mutable ReadWriteSem _activeSubscriptionsTableLock;
|
491 kumpf 1.1
492 /**
493 Subscription Classes information table. Access to this table is
494 controlled by the _subscriptionClassesTableLock.
495 */
496 SubscriptionClassesTable _subscriptionClassesTable;
497
498 /**
499 A lock to control access to the _subscriptionClassesTable. Before
500 accessing the _subscriptionClassesTable, one must first lock this for
501 read access. Before updating the _subscriptionClassesTable, one must
502 first lock this for write access.
503 */
|
504 aruran.ms 1.8 mutable ReadWriteSem _subscriptionClassesTableLock;
|
505 kumpf 1.1
506 SubscriptionRepository * _subscriptionRepository;
507 };
508
509 PEGASUS_NAMESPACE_END
510
511 #endif /* Pegasus_SubscriptionTable_h */
|