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