1 martin 1.26 //%LICENSE////////////////////////////////////////////////////////////////
|
2 martin 1.27 //
|
3 martin 1.26 // Licensed to The Open Group (TOG) under one or more contributor license
4 // agreements. Refer to the OpenPegasusNOTICE.txt file distributed with
5 // this work for additional information regarding copyright ownership.
6 // Each contributor licenses this file to you under the OpenPegasus Open
7 // Source License; you may not use this file except in compliance with the
8 // License.
|
9 martin 1.27 //
|
10 martin 1.26 // Permission is hereby granted, free of charge, to any person obtaining a
11 // copy of this software and associated documentation files (the "Software"),
12 // to deal in the Software without restriction, including without limitation
13 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
14 // and/or sell copies of the Software, and to permit persons to whom the
15 // Software is furnished to do so, subject to the following conditions:
|
16 martin 1.27 //
|
17 martin 1.26 // The above copyright notice and this permission notice shall be included
18 // in all copies or substantial portions of the Software.
|
19 martin 1.27 //
|
20 martin 1.26 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
21 martin 1.27 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
22 martin 1.26 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
23 // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
24 // CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
25 // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
26 // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
27 martin 1.27 //
|
28 martin 1.26 //////////////////////////////////////////////////////////////////////////
|
29 kumpf 1.1 //
30 //%/////////////////////////////////////////////////////////////////////////////
31
32 #include <Pegasus/Common/Config.h>
33 #include <Pegasus/Common/Constants.h>
34 #include <Pegasus/Common/Tracer.h>
35
36 #include "IndicationConstants.h"
37 #include "IndicationService.h"
38 #include "SubscriptionTable.h"
39
|
40 yi.zhou 1.17 #ifdef PEGASUS_ENABLE_INDICATION_COUNT
41 # include "ProviderIndicationCountTable.h"
42 #endif
43
|
44 kumpf 1.1 PEGASUS_USING_STD;
45
46 PEGASUS_NAMESPACE_BEGIN
47
48 SubscriptionTable::SubscriptionTable (
49 SubscriptionRepository * subscriptionRepository)
50 : _subscriptionRepository (subscriptionRepository)
51 {
52 }
53
54 SubscriptionTable::~SubscriptionTable ()
55 {
56 }
57
58 Boolean SubscriptionTable::getSubscriptionEntry (
59 const CIMObjectPath & subscriptionPath,
|
60 carolann.graves 1.9 ActiveSubscriptionsTableEntry & tableValue) const
|
61 kumpf 1.1 {
62 PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
63 "SubscriptionTable::getSubscriptionEntry");
64
65 Boolean succeeded = false;
|
66 ashok.pathak 1.29.8.1 SubscriptionKey activeSubscriptionsKey =
67 SubscriptionKey(subscriptionPath);
|
68 carolann.graves 1.9 if (_lockedLookupActiveSubscriptionsEntry
|
69 kumpf 1.1 (activeSubscriptionsKey, tableValue))
70 {
71 succeeded = true;
72 }
73 else
74 {
75 //
76 // Subscription not found in Active Subscriptions table
77 //
|
78 thilo.boehm 1.25 PEG_TRACE((TRC_INDICATION_SERVICE, Tracer::LEVEL1,
|
79 thilo.boehm 1.23 "Subscription (%s) not found in ActiveSubscriptionsTable",
|
80 ashok.pathak 1.29.8.1 (const char*)activeSubscriptionsKey.toString().getCString()));
|
81 kumpf 1.1 }
82
83 PEG_METHOD_EXIT ();
84 return succeeded;
85 }
86
87 Array <CIMInstance> SubscriptionTable::getMatchingSubscriptions (
88 const CIMName & supportedClass,
89 const Array <CIMNamespaceName> nameSpaces,
90 const Boolean checkProvider,
|
91 aruran.ms 1.7 const CIMInstance & provider) const
|
92 kumpf 1.1 {
93 PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
94 "SubscriptionTable::getMatchingSubscriptions");
95
96 Array <CIMInstance> matchingSubscriptions;
97 Array <CIMInstance> subscriptions;
98
99 for (Uint32 i = 0; i < nameSpaces.size (); i++)
100 {
101 //
|
102 carolann.graves 1.9 // Look up the indicationClass-sourceNamespace pair in the
|
103 kumpf 1.1 // Subscription Classes table
104 //
|
105 carolann.graves 1.9 String subscriptionClassesKey = _generateSubscriptionClassesKey
|
106 kumpf 1.1 (supportedClass, nameSpaces [i]);
|
107 kumpf 1.22 SubscriptionClassesTableEntry scTableValue;
108 if (_lockedLookupSubscriptionClassesEntry(
109 subscriptionClassesKey, scTableValue))
|
110 kumpf 1.1 {
|
111 kumpf 1.22 subscriptions = scTableValue.subscriptions;
|
112 kumpf 1.1 for (Uint32 j = 0; j < subscriptions.size (); j++)
113 {
114 Boolean match = true;
115
116 if (checkProvider)
117 {
118 //
|
119 carolann.graves 1.9 // Check if the provider who generated this indication
|
120 kumpf 1.1 // accepted this subscription
121 //
|
122 ashok.pathak 1.29.8.1 SubscriptionKey activeSubscriptionsKey =
123 SubscriptionKey(subscriptions [j].getPath ());
|
124 kumpf 1.22 ActiveSubscriptionsTableEntry asTableValue;
125 if (_lockedLookupActiveSubscriptionsEntry(
126 activeSubscriptionsKey, asTableValue))
|
127 kumpf 1.1 {
128 //
129 // If provider is not in list, it did not accept the
130 // subscription
131 //
|
132 kumpf 1.22 if ((providerInList(provider, asTableValue)) ==
133 PEG_NOT_FOUND)
|
134 kumpf 1.1 {
135 match = false;
136 break;
137 }
138 }
139 }
140
141 if (match)
142 {
143 //
144 // Add current subscription to list
145 //
146 matchingSubscriptions.append (subscriptions [j]);
147 }
148 }
149 }
150 }
151
152 PEG_METHOD_EXIT ();
153 return matchingSubscriptions;
154 }
155 kumpf 1.1
|
156 carolann.graves 1.12 Array <CIMInstance> SubscriptionTable::reflectProviderDisable (
|
157 aruran.ms 1.8 const CIMInstance & provider)
|
158 kumpf 1.1 {
159 PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
|
160 carolann.graves 1.12 "SubscriptionTable::reflectProviderDisable");
|
161 kumpf 1.1
162 Array <CIMInstance> providerSubscriptions;
163
164 //
165 // Iterate through the subscription table to find subscriptions served by
166 // the provider
|
167 carolann.graves 1.9 // NOTE: updating entries (remove and insert) while iterating through the
|
168 kumpf 1.1 // table does not work reliably, and it is not clear if that is supposed to
|
169 carolann.graves 1.9 // work; for now, the SubscriptionTable first iterates through the
170 // active subscriptions table to find subscriptions served by the
171 // provider, then looks up and updates each affected subscription
|
172 kumpf 1.1 //
173 {
174 //
|
175 carolann.graves 1.9 // Acquire and hold the write lock during the entire
176 // lookup/remove/insert process, allowing competing threads to apply
177 // their logic over a consistent view of the data.
|
178 kumpf 1.14 // Do not call any other methods that need
|
179 carolann.graves 1.9 // _activeSubscriptionsTableLock.
|
180 kumpf 1.1 //
|
181 carolann.graves 1.9 WriteLock lock (_activeSubscriptionsTableLock);
|
182 kumpf 1.1
183 for (ActiveSubscriptionsTable::Iterator i =
184 _activeSubscriptionsTable.start (); i; i++)
185 {
186 //
187 // If provider matches, append subscription to the list
188 //
|
189 kumpf 1.22 ActiveSubscriptionsTableEntry asTableValue = i.value();
190 for (Uint32 j = 0; j < asTableValue.providers.size(); j++)
|
191 kumpf 1.1 {
|
192 kumpf 1.22 if (asTableValue.providers[j].provider.getPath().identical(
193 provider.getPath()))
|
194 kumpf 1.1 {
195 //
196 // Add the subscription to the list
197 //
|
198 kumpf 1.22 providerSubscriptions.append(asTableValue.subscription);
|
199 kumpf 1.1 break;
200 }
201 }
202 }
203
204 //
|
205 carolann.graves 1.9 // Look up and update hash table entry for each affected subscription
|
206 kumpf 1.1 //
|
207 carolann.graves 1.9 for (Uint32 k = 0; k < providerSubscriptions.size (); k++)
|
208 kumpf 1.1 {
209 //
|
210 carolann.graves 1.9 // Update the entry in the active subscriptions hash table
|
211 kumpf 1.1 //
|
212 ashok.pathak 1.29.8.1 SubscriptionKey activeSubscriptionsKey =
213 SubscriptionKey(providerSubscriptions [k].getPath ());
|
214 kumpf 1.22 ActiveSubscriptionsTableEntry asTableValue;
215 if (_activeSubscriptionsTable.lookup(
216 activeSubscriptionsKey, asTableValue))
|
217 kumpf 1.1 {
|
218 carolann.graves 1.9 //
219 // Remove the provider from the list of providers serving the
220 // subscription
221 //
|
222 kumpf 1.22 Uint32 providerIndex = providerInList(provider, asTableValue);
|
223 carolann.graves 1.9 if (providerIndex != PEG_NOT_FOUND)
|
224 kumpf 1.1 {
|
225 kumpf 1.22 asTableValue.providers.remove(providerIndex);
|
226 carolann.graves 1.12
|
227 kumpf 1.22 _updateSubscriptionProviders(
228 activeSubscriptionsKey,
229 asTableValue.subscription,
230 asTableValue.providers);
|
231 carolann.graves 1.9 }
232 else
233 {
|
234 thilo.boehm 1.25 PEG_TRACE((TRC_INDICATION_SERVICE,Tracer::LEVEL2,
|
235 thilo.boehm 1.23 "Provider (%s) not found in list for Subscription (%s)"
|
236 kumpf 1.28 " in ActiveSubscriptionsTable",
|
237 thilo.boehm 1.23 (const char*)provider.getPath().toString().getCString(),
|
238 ashok.pathak 1.29.8.1 (const char*)
239 activeSubscriptionsKey.toString().getCString()));
|
240 kumpf 1.1 }
241 }
242 else
243 {
|
244 thilo.boehm 1.25 PEG_TRACE((TRC_INDICATION_SERVICE,Tracer::LEVEL2,
|
245 thilo.boehm 1.23 "Subscription (%s) not found in ActiveSubscriptionsTable",
|
246 ashok.pathak 1.29.8.1 (const char*)
247 activeSubscriptionsKey.toString().getCString()));
|
248 carolann.graves 1.9 //
249 // The subscription may have been deleted in the mean time
250 // If so, no further update is required
251 //
|
252 kumpf 1.1 }
253 }
254 }
255
256 PEG_METHOD_EXIT ();
257 return providerSubscriptions;
258 }
259
|
260 carolann.graves 1.12 Array <ActiveSubscriptionsTableEntry>
261 SubscriptionTable::reflectProviderModuleFailure
262 (const String & moduleName,
263 const String & userName,
264 Boolean authenticationEnabled)
265 {
266 PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
267 "SubscriptionTable::reflectProviderModuleFailure");
268
269 Array <ActiveSubscriptionsTableEntry> providerModuleSubscriptions;
270
271 //
272 // Iterate through the subscription table to find subscriptions served by
273 // a provider in the specified module, with the specified userName as the
274 // subscription creator
275 // NOTE: updating entries (remove and insert) while iterating through the
276 // table is not allowed
277 // The SubscriptionTable first iterates through the active subscriptions
278 // table to find matching subscriptions served by a provider in the
279 // specified module, then looks up and updates each affected subscription
280 //
281 carolann.graves 1.12 {
282 //
283 // Acquire and hold the write lock during the entire
284 // lookup/remove/insert process, allowing competing threads to apply
285 // their logic over a consistent view of the data.
|
286 kumpf 1.14 // Do not call any other methods that need
|
287 carolann.graves 1.12 // _activeSubscriptionsTableLock.
288 //
289 WriteLock lock (_activeSubscriptionsTableLock);
290
291 for (ActiveSubscriptionsTable::Iterator i =
292 _activeSubscriptionsTable.start (); i; i++)
293 {
|
294 kumpf 1.22 ActiveSubscriptionsTableEntry asTableValue;
|
295 carolann.graves 1.12 //
296 // Get subscription creator
297 //
|
298 kumpf 1.22 asTableValue = i.value();
|
299 carolann.graves 1.12 String creator;
|
300 kumpf 1.22 CIMValue creatorValue = asTableValue.subscription.getProperty(
301 asTableValue.subscription.findProperty(
302 PEGASUS_PROPERTYNAME_INDSUB_CREATOR)).getValue();
|
303 carolann.graves 1.12 creatorValue.get (creator);
304
305 Array <ProviderClassList> failedProviderList;
|
306 kumpf 1.22 for (Uint32 j = 0; j < asTableValue.providers.size(); j++)
|
307 carolann.graves 1.12 {
308 //
309 // Get provider module name
310 //
311 String providerModuleName;
312 CIMValue nameValue =
|
313 kumpf 1.22 asTableValue.providers[j].providerModule.getProperty(
314 asTableValue.providers[j].providerModule.findProperty(
315 PEGASUS_PROPERTYNAME_NAME)).getValue();
|
316 carolann.graves 1.12 nameValue.get (providerModuleName);
317
318 //
319 // Get module user context setting
320 //
321 Uint16 moduleContext = PEGASUS_DEFAULT_PROV_USERCTXT;
|
322 kumpf 1.14 CIMValue contextValue =
|
323 kumpf 1.22 asTableValue.providers[j].providerModule.getProperty(
324 asTableValue.providers [j].providerModule.findProperty(
325 PEGASUS_PROPERTYNAME_MODULE_USERCONTEXT)).
326 getValue();
|
327 carolann.graves 1.12 if (!contextValue.isNull ())
328 {
329 contextValue.get (moduleContext);
330 }
331
332 //
|
333 kumpf 1.14 // If provider module name matches,
|
334 carolann.graves 1.12 // add provider to the list of failed providers
335 //
336 if (providerModuleName == moduleName)
337 {
338 //
339 // If authentication is enabled, and module was run as
340 // requestor, subscription creator must also match module
341 // user context name, to add provider to the list of
342 // failed providers
343 //
344 if ((moduleContext != PG_PROVMODULE_USERCTXT_REQUESTOR) ||
345 (!authenticationEnabled) || (creator == userName))
346 {
347 //
348 // Add the provider to the list
349 //
|
350 kumpf 1.22 failedProviderList.append(asTableValue.providers[j]);
|
351 carolann.graves 1.12 }
352 } // if provider module name matches
353 } // for each subscription provider
354
355 //
356 // If there were any failed providers, add the subscription
357 // entry to the list of affected subscriptions
358 //
359 if (failedProviderList.size () > 0)
360 {
361 ActiveSubscriptionsTableEntry subscription;
|
362 kumpf 1.22 subscription.subscription = asTableValue.subscription;
|
363 carolann.graves 1.12 subscription.providers = failedProviderList;
364 providerModuleSubscriptions.append (subscription);
365 }
366 }
367
368 //
369 // Look up and update hash table entry for each affected subscription
370 //
371 for (Uint32 k = 0; k < providerModuleSubscriptions.size (); k++)
372 {
373 //
374 // Update the entry in the active subscriptions hash table
375 //
|
376 ashok.pathak 1.29.8.1 SubscriptionKey activeSubscriptionsKey =
377 SubscriptionKey(
378 providerModuleSubscriptions[k].subscription.getPath());
|
379 kumpf 1.22 ActiveSubscriptionsTableEntry asTableValue;
380 if (_activeSubscriptionsTable.lookup(
381 activeSubscriptionsKey, asTableValue))
|
382 carolann.graves 1.12 {
|
383 kumpf 1.14 Array <ProviderClassList> updatedProviderList;
|
384 kumpf 1.22 for (Uint32 l = 0; l < asTableValue.providers.size(); l++)
|
385 carolann.graves 1.12 {
386 String providerModuleName;
387 CIMValue nameValue =
|
388 kumpf 1.22 asTableValue.providers[l].providerModule.getProperty(
389 asTableValue.providers[l].providerModule.
390 findProperty(PEGASUS_PROPERTYNAME_NAME)).getValue();
|
391 carolann.graves 1.12 nameValue.get (providerModuleName);
392 if (providerModuleName != moduleName)
393 {
394 //
395 // Provider is not in the failed module
396 // Append provider to list of providers still serving
397 // the subscription
398 //
|
399 kumpf 1.22 updatedProviderList.append(asTableValue.providers[l]);
|
400 carolann.graves 1.12 }
401 }
402
|
403 kumpf 1.22 _updateSubscriptionProviders(
404 activeSubscriptionsKey,
405 asTableValue.subscription,
406 updatedProviderList);
|
407 carolann.graves 1.12 }
408 }
409 }
410
411 PEG_METHOD_EXIT ();
412 return providerModuleSubscriptions;
413 }
414
|
415 kumpf 1.1 Boolean SubscriptionTable::_lockedLookupActiveSubscriptionsEntry (
|
416 ashok.pathak 1.29.8.1 const SubscriptionKey & key,
|
417 aruran.ms 1.7 ActiveSubscriptionsTableEntry & tableEntry) const
|
418 kumpf 1.1 {
419 ReadLock lock(_activeSubscriptionsTableLock);
420
421 return (_activeSubscriptionsTable.lookup (key, tableEntry));
422 }
423
424 void SubscriptionTable::_insertActiveSubscriptionsEntry (
425 const CIMInstance & subscription,
|
426 aruran.ms 1.8 const Array <ProviderClassList> & providers)
|
427 kumpf 1.1 {
428 PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
429 "SubscriptionTable::_insertActiveSubscriptionsEntry");
430
|
431 ashok.pathak 1.29.8.1 SubscriptionKey activeSubscriptionsKey =
432 SubscriptionKey(subscription.getPath ());
|
433 kumpf 1.1 ActiveSubscriptionsTableEntry entry;
434 entry.subscription = subscription;
435 entry.providers = providers;
436
|
437 carolann.graves 1.10 //
438 // Insert returns true on success, false if duplicate key
439 //
440 Boolean succeeded = _activeSubscriptionsTable.insert
441 (activeSubscriptionsKey, entry);
442 PEGASUS_ASSERT (succeeded);
|
443 kumpf 1.1
444 #ifdef PEGASUS_INDICATION_HASHTRACE
445 String traceString;
446 traceString.append (activeSubscriptionsKey);
447 traceString.append (" Providers: ");
448 for (Uint32 i = 0; i < providers.size (); i++)
449 {
|
450 carolann.graves 1.9 String providerName = providers [i].provider.getProperty
451 (providers [i].provider.findProperty
|
452 w.otsuka 1.13 (PEGASUS_PROPERTYNAME_NAME)).getValue ().toString ();
|
453 kumpf 1.1 traceString.append (providerName);
454 traceString.append (" Classes: ");
455 for (Uint32 j = 0; j < providers[i].classList.size (); j++)
456 {
|
457 carolann.graves 1.9 traceString.append (providers[i].classList[j].getString());
|
458 kumpf 1.1 traceString.append (" ");
459 }
460 }
|
461 carolann.graves 1.9
|
462 thilo.boehm 1.25 PEG_TRACE((TRC_INDICATION_SERVICE, Tracer::LEVEL4,
|
463 thilo.boehm 1.23 "INSERTED _activeSubscriptionsTable entry: %s",
464 (const char*)traceString.getCString()));
|
465 kumpf 1.1 #endif
466
467 PEG_METHOD_EXIT ();
468 }
469
470 void SubscriptionTable::_removeActiveSubscriptionsEntry (
|
471 ashok.pathak 1.29.8.1 const SubscriptionKey & key)
|
472 kumpf 1.1 {
473 PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
474 "SubscriptionTable::_removeActiveSubscriptionsEntry");
475
|
476 carolann.graves 1.10 //
477 // Remove returns true on success, false if not found
478 //
479 Boolean succeeded = _activeSubscriptionsTable.remove (key);
480 PEGASUS_ASSERT (succeeded);
481
|
482 kumpf 1.1 #ifdef PEGASUS_INDICATION_HASHTRACE
|
483 thilo.boehm 1.25 PEG_TRACE((TRC_INDICATION_SERVICE,Tracer::LEVEL4,
|
484 thilo.boehm 1.23 "REMOVED _activeSubscriptionsTable entry: %s",
|
485 ashok.pathak 1.29.8.1 (const char*)key.toString().getCString()));
|
486 kumpf 1.1 #endif
487
488 PEG_METHOD_EXIT ();
489 }
490
491 String SubscriptionTable::_generateSubscriptionClassesKey (
492 const CIMName & indicationClassName,
493 const CIMNamespaceName & sourceNamespaceName) const
494 {
495 String subscriptionClassesKey;
496
497 //
498 // Append indication class name to key
499 //
500 subscriptionClassesKey.append (indicationClassName.getString ());
501
502 //
503 // Append source namespace name to key
504 //
505 subscriptionClassesKey.append (sourceNamespaceName.getString ());
506
507 kumpf 1.1 return subscriptionClassesKey;
508 }
509
510 Boolean SubscriptionTable::_lockedLookupSubscriptionClassesEntry (
511 const String & key,
|
512 aruran.ms 1.7 SubscriptionClassesTableEntry & tableEntry) const
|
513 kumpf 1.1 {
514 ReadLock lock(_subscriptionClassesTableLock);
515
516 return (_subscriptionClassesTable.lookup (key, tableEntry));
517 }
518
|
519 carolann.graves 1.9 void SubscriptionTable::_insertSubscriptionClassesEntry (
|
520 kumpf 1.1 const CIMName & indicationClassName,
521 const CIMNamespaceName & sourceNamespaceName,
522 const Array <CIMInstance> & subscriptions)
523 {
524 PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
|
525 carolann.graves 1.9 "SubscriptionTable::_insertSubscriptionClassesEntry");
|
526 kumpf 1.1
527 String subscriptionClassesKey = _generateSubscriptionClassesKey
528 (indicationClassName, sourceNamespaceName);
529 SubscriptionClassesTableEntry entry;
530 entry.indicationClassName = indicationClassName;
531 entry.sourceNamespaceName = sourceNamespaceName;
532 entry.subscriptions = subscriptions;
|
533 carolann.graves 1.9
|
534 carolann.graves 1.10 //
535 // Insert returns true on success, false if duplicate key
536 //
537 Boolean succeeded = _subscriptionClassesTable.insert
538 (subscriptionClassesKey, entry);
539 PEGASUS_ASSERT (succeeded);
|
540 kumpf 1.1
541 #ifdef PEGASUS_INDICATION_HASHTRACE
542 String traceString;
543 traceString.append (subscriptionClassesKey);
544 traceString.append (" Subscriptions: ");
545 for (Uint32 i = 0; i < subscriptions.size (); i++)
546 {
|
547 carolann.graves 1.9 traceString.append (subscriptions [i].getPath ().toString());
|
548 kumpf 1.1 traceString.append (" ");
549 }
|
550 carolann.graves 1.9
|
551 thilo.boehm 1.25 PEG_TRACE((TRC_INDICATION_SERVICE, Tracer::LEVEL4,
|
552 thilo.boehm 1.23 "INSERTED _subscriptionClassesTable entry: %s",
553 (const char*)traceString.getCString()));
|
554 kumpf 1.1 #endif
555
556 PEG_METHOD_EXIT ();
557 }
558
|
559 carolann.graves 1.9 void SubscriptionTable::_removeSubscriptionClassesEntry (
|
560 kumpf 1.1 const String & key)
561 {
562 PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
|
563 carolann.graves 1.9 "SubscriptionTable::_removeSubscriptionClassesEntry");
|
564 kumpf 1.1
|
565 carolann.graves 1.10 //
566 // Remove returns true on success, false if not found
567 //
568 Boolean succeeded = _subscriptionClassesTable.remove (key);
569 PEGASUS_ASSERT (succeeded);
|
570 kumpf 1.1
571 #ifdef PEGASUS_INDICATION_HASHTRACE
|
572 thilo.boehm 1.25 PEG_TRACE((TRC_INDICATION_SERVICE, Tracer::LEVEL4,
|
573 thilo.boehm 1.23 "REMOVED _subscriptionClassesTable entry: %s",
574 (const char*)key.getCString()));
|
575 kumpf 1.1 #endif
576
577 PEG_METHOD_EXIT ();
578 }
579
|
580 carolann.graves 1.12 void SubscriptionTable::_updateSubscriptionProviders
|
581 ashok.pathak 1.29.8.1 (const SubscriptionKey & activeSubscriptionsKey,
|
582 carolann.graves 1.12 const CIMInstance & subscription,
583 const Array <ProviderClassList> & updatedProviderList)
584 {
585 PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
586 "SubscriptionTable::_updateSubscriptionProviders");
587
588 if (updatedProviderList.size () > 0)
589 {
590 //
591 // At least one provider is still serving the
592 // subscription
593 // Update entry in Active Subscriptions table
594 //
595 _removeActiveSubscriptionsEntry (activeSubscriptionsKey);
596 _insertActiveSubscriptionsEntry (subscription, updatedProviderList);
597 }
598 else
599 {
600 //
601 // The disabled or failed provider(s) was (were) the only provider(s)
602 // serving the subscription
603 carolann.graves 1.12 // Implement the subscription's On Fatal Error Policy
604 //
605 Boolean removedOrDisabled =
606 _subscriptionRepository->reconcileFatalError (subscription);
607 _removeActiveSubscriptionsEntry (activeSubscriptionsKey);
608 if (!removedOrDisabled)
609 {
610 //
611 // If subscription was not disabled or deleted
612 // Update entry in Active Subscriptions table
613 // Note that in this case the updatedProviderList is
614 // empty - no providers are serving the subscription
615 // currently
616 //
617 _insertActiveSubscriptionsEntry (subscription,
618 updatedProviderList);
619 }
|
620 s.kodali 1.19 else
621 {
622 // Delete subscription entries from SubscriptionClassesTable.
623 WriteLock lock(_subscriptionClassesTableLock);
|
624 kumpf 1.22 Array<SubscriptionClassesTableEntry> scTableValues;
|
625 s.kodali 1.19 for (SubscriptionClassesTable::Iterator i =
626 _subscriptionClassesTable.start(); i; i++)
627 {
628 SubscriptionClassesTableEntry value = i.value();
629 for (Uint32 j = 0, n = value.subscriptions.size(); j < n; ++j)
630 {
631 if (value.subscriptions[j].getPath().identical(
632 subscription.getPath()))
633 {
634 value.subscriptions.remove(j);
|
635 kumpf 1.22 scTableValues.append(value);
|
636 s.kodali 1.19 break;
637 }
638 }
639 }
|
640 kumpf 1.22 for (Uint32 i = 0, n = scTableValues.size(); i < n; ++i)
|
641 s.kodali 1.19 {
642 String subscriptionClassesKey = _generateSubscriptionClassesKey(
|
643 kumpf 1.22 scTableValues[i].indicationClassName,
644 scTableValues[i].sourceNamespaceName);
|
645 s.kodali 1.19 // If this is the only subscription for this class-namespace
646 // pair delete the entry else update the subscription list
|
647 kumpf 1.28 // for this class-namespace pair.
|
648 kumpf 1.22 if (scTableValues[i].subscriptions.size())
|
649 kumpf 1.28 {
|
650 s.kodali 1.19 SubscriptionClassesTableEntry *entry = 0;
651 _subscriptionClassesTable.lookupReference(
652 subscriptionClassesKey,
653 entry);
654 PEGASUS_ASSERT(entry);
|
655 kumpf 1.22 entry->subscriptions = scTableValues[i].subscriptions;
|
656 s.kodali 1.19 }
657 else
658 {
659 _removeSubscriptionClassesEntry(subscriptionClassesKey);
660 }
661 }
662 }
|
663 carolann.graves 1.12 }
664
665 PEG_METHOD_EXIT ();
666 }
667
|
668 carolann.graves 1.6 void SubscriptionTable::insertSubscription (
|
669 kumpf 1.1 const CIMInstance & subscription,
670 const Array <ProviderClassList> & providers,
671 const Array <CIMName> & indicationSubclassNames,
672 const CIMNamespaceName & sourceNamespaceName)
673 {
674 PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
675 "SubscriptionTable::insertSubscription");
676
677 //
|
678 carolann.graves 1.9 // Insert entry into active subscriptions table
|
679 kumpf 1.1 //
680 {
681 WriteLock lock(_activeSubscriptionsTableLock);
682
|
683 yi.zhou 1.17 _insertActiveSubscriptionsEntry(subscription, providers);
|
684 kumpf 1.1 }
685
686 //
|
687 carolann.graves 1.9 // Insert or update entries in subscription classes table
|
688 kumpf 1.1 //
689 {
|
690 carolann.graves 1.9 //
691 // Acquire and hold the write lock during the entire
692 // lookup/remove/insert process, allowing competing threads to apply
693 // their logic over a consistent view of the data.
|
694 kumpf 1.14 // Do not call any other methods that need
|
695 carolann.graves 1.9 // _subscriptionClassesTableLock.
696 //
697 WriteLock lock (_subscriptionClassesTableLock);
698 for (Uint32 i = 0; i < indicationSubclassNames.size (); i++)
|
699 kumpf 1.1 {
|
700 carolann.graves 1.9 String subscriptionClassesKey = _generateSubscriptionClassesKey
701 (indicationSubclassNames [i], sourceNamespaceName);
|
702 kumpf 1.22 SubscriptionClassesTableEntry scTableValue;
703 if (_subscriptionClassesTable.lookup(
704 subscriptionClassesKey, scTableValue))
|
705 carolann.graves 1.9 {
706 //
707 // If entry exists for this IndicationClassName-SourceNamespace
708 // pair, remove old entry and insert new entry
709 //
|
710 kumpf 1.22 Array<CIMInstance> subscriptions = scTableValue.subscriptions;
|
711 carolann.graves 1.9 subscriptions.append (subscription);
712 _removeSubscriptionClassesEntry (subscriptionClassesKey);
713 _insertSubscriptionClassesEntry (indicationSubclassNames [i],
714 sourceNamespaceName, subscriptions);
715 }
716 else
717 {
718 //
719 // If no entry exists for this
720 // IndicationClassName-SourceNamespace pair, insert new entry
721 //
722 Array <CIMInstance> subscriptions;
723 subscriptions.append (subscription);
724 _insertSubscriptionClassesEntry (indicationSubclassNames [i],
725 sourceNamespaceName, subscriptions);
726 }
|
727 kumpf 1.1 }
728 }
729
730 PEG_METHOD_EXIT ();
731 }
732
|
733 carolann.graves 1.6 void SubscriptionTable::updateProviders (
|
734 kumpf 1.1 const CIMObjectPath & subscriptionPath,
735 const ProviderClassList & provider,
736 Boolean addProvider)
737 {
738 PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
739 "SubscriptionTable::updateProviders");
740
|
741 ashok.pathak 1.29.8.1 SubscriptionKey activeSubscriptionsKey =
742 SubscriptionKey(subscriptionPath);
743
|
744 kumpf 1.22 ActiveSubscriptionsTableEntry asTableValue;
|
745 kumpf 1.1 {
|
746 carolann.graves 1.9 //
747 // Acquire and hold the write lock during the entire
748 // lookup/remove/insert process, allowing competing threads to apply
749 // their logic over a consistent view of the data.
|
750 kumpf 1.14 // Do not call any other methods that need
|
751 carolann.graves 1.9 // _activeSubscriptionsTableLock.
752 //
753 WriteLock lock (_activeSubscriptionsTableLock);
|
754 kumpf 1.22 if (_activeSubscriptionsTable.lookup(
755 activeSubscriptionsKey, asTableValue))
|
756 kumpf 1.1 {
|
757 kumpf 1.22 Uint32 providerIndex =
758 providerInList(provider.provider, asTableValue);
|
759 carolann.graves 1.9 if (addProvider)
|
760 kumpf 1.1 {
|
761 carolann.graves 1.9 if (providerIndex == PEG_NOT_FOUND)
762 {
|
763 kumpf 1.22 asTableValue.providers.append(provider);
764 _removeActiveSubscriptionsEntry(activeSubscriptionsKey);
765 _insertActiveSubscriptionsEntry(
766 asTableValue.subscription,
767 asTableValue.providers);
|
768 carolann.graves 1.9 }
769 else
770 {
771 CIMInstance p = provider.provider;
|
772 thilo.boehm 1.25 PEG_TRACE((TRC_INDICATION_SERVICE,Tracer::LEVEL2,
|
773 thilo.boehm 1.23 "Provider %s already in list for Subscription (%s) "
774 "in ActiveSubscriptionsTable",
775 (const char*)IndicationService::getProviderLogString(p)
776 .getCString(),
|
777 ashok.pathak 1.29.8.1 (const char*)activeSubscriptionsKey
778 .toString().getCString()));
|
779 carolann.graves 1.9 }
|
780 kumpf 1.1 }
781 else
782 {
|
783 carolann.graves 1.9 if (providerIndex != PEG_NOT_FOUND)
784 {
|
785 kumpf 1.22 asTableValue.providers.remove(providerIndex);
786 _removeActiveSubscriptionsEntry(activeSubscriptionsKey);
787 _insertActiveSubscriptionsEntry(
788 asTableValue.subscription,
789 asTableValue.providers);
|
790 carolann.graves 1.9 }
791 else
792 {
793 CIMInstance p = provider.provider;
|
794 thilo.boehm 1.25 PEG_TRACE((TRC_INDICATION_SERVICE,Tracer::LEVEL2,
|
795 thilo.boehm 1.23 "Provider %s not found in list for Subscription (%s) "
796 "in ActiveSubscriptionsTable",
797 (const char*)IndicationService::getProviderLogString(p)
798 .getCString(),
|
799 ashok.pathak 1.29.8.1 (const char*)
800 activeSubscriptionsKey.toString().getCString()));
|
801 carolann.graves 1.9 }
|
802 kumpf 1.1 }
803 }
804 else
805 {
|
806 thilo.boehm 1.25 PEG_TRACE((TRC_INDICATION_SERVICE, Tracer::LEVEL2,
|
807 thilo.boehm 1.23 "Subscription (%s) not found in ActiveSubscriptionsTable",
|
808 ashok.pathak 1.29.8.1 (const char*)activeSubscriptionsKey.toString().getCString()));
|
809 kumpf 1.14
|
810 carolann.graves 1.9 //
811 // The subscription may have been deleted in the mean time
812 // If so, no further update is required
813 //
|
814 kumpf 1.1 }
815 }
816
817 PEG_METHOD_EXIT ();
818 }
819
820 void SubscriptionTable::updateClasses (
821 const CIMObjectPath & subscriptionPath,
822 const CIMInstance & provider,
823 const CIMName & className)
824 {
825 PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
826 "SubscriptionTable::updateClasses");
827
|
828 ashok.pathak 1.29.8.1 SubscriptionKey activeSubscriptionsKey = SubscriptionKey(subscriptionPath);
|
829 kumpf 1.22 ActiveSubscriptionsTableEntry asTableValue;
|
830 kumpf 1.1
831 {
|
832 carolann.graves 1.9 //
833 // Acquire and hold the write lock during the entire
834 // lookup/remove/insert process, allowing competing threads to apply
835 // their logic over a consistent view of the data.
|
836 kumpf 1.14 // Do not call any other methods that need
|
837 carolann.graves 1.9 // _activeSubscriptionsTableLock.
838 //
839 WriteLock lock (_activeSubscriptionsTableLock);
|
840 kumpf 1.22 if (_activeSubscriptionsTable.lookup(
841 activeSubscriptionsKey, asTableValue))
|
842 kumpf 1.1 {
|
843 kumpf 1.22 Uint32 providerIndex = providerInList(provider, asTableValue);
|
844 carolann.graves 1.9 if (providerIndex != PEG_NOT_FOUND)
|
845 kumpf 1.1 {
|
846 kumpf 1.22 Uint32 classIndex = classInList(
847 className, asTableValue.providers[providerIndex]);
|
848 carolann.graves 1.9 if (classIndex == PEG_NOT_FOUND)
849 {
|
850 kumpf 1.22 asTableValue.providers[providerIndex].classList.append(
851 className);
|
852 carolann.graves 1.9 }
853 else // classIndex != PEG_NOT_FOUND
854 {
|
855 kumpf 1.22 asTableValue.providers[providerIndex].classList.remove(
856 classIndex);
|
857 carolann.graves 1.9 }
858
|
859 kumpf 1.22 _removeActiveSubscriptionsEntry(activeSubscriptionsKey);
860 _insertActiveSubscriptionsEntry(
861 asTableValue.subscription,
862 asTableValue.providers);
|
863 kumpf 1.1 }
|
864 carolann.graves 1.9 else
|
865 kumpf 1.1 {
|
866 thilo.boehm 1.25 PEG_TRACE((TRC_INDICATION_SERVICE,Tracer::LEVEL2,
|
867 thilo.boehm 1.23 "Provider (%s) not found in list for Subscription (%s) in "
868 "ActiveSubscriptionsTable",
869 (const char*)provider.getPath().toString().getCString(),
|
870 ashok.pathak 1.29.8.1 (const char*)
871 activeSubscriptionsKey.toString().getCString()));
|
872 kumpf 1.1 }
873 }
874 else
875 {
|
876 carolann.graves 1.9 //
877 // Subscription not found in Active Subscriptions table
878 //
|
879 kumpf 1.1 }
880 }
881
882 PEG_METHOD_EXIT ();
883 }
884
|
885 carolann.graves 1.6 void SubscriptionTable::removeSubscription (
|
886 kumpf 1.1 const CIMInstance & subscription,
887 const Array <CIMName> & indicationSubclassNames,
888 const CIMNamespaceName & sourceNamespaceName,
889 const Array <ProviderClassList> & providers)
890 {
891 PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
892 "SubscriptionTable::removeSubscription");
893
894 //
|
895 carolann.graves 1.9 // Remove entry from active subscriptions table
|
896 kumpf 1.1 //
897 {
898 WriteLock lock(_activeSubscriptionsTableLock);
|
899 ashok.pathak 1.29.8.1 _removeActiveSubscriptionsEntry(
900 SubscriptionKey(subscription.getPath()));
|
901 kumpf 1.1 }
902
903 //
|
904 carolann.graves 1.9 // Remove or update entries in subscription classes table
|
905 kumpf 1.1 //
906 {
|
907 carolann.graves 1.9 //
908 // Acquire and hold the write lock during the entire
909 // lookup/remove/insert process, allowing competing threads to apply
910 // their logic over a consistent view of the data.
|
911 kumpf 1.14 // Do not call any other methods that need
|
912 carolann.graves 1.9 // _subscriptionClassesTableLock.
913 //
914 WriteLock lock (_subscriptionClassesTableLock);
915 for (Uint32 i = 0; i < indicationSubclassNames.size (); i++)
|
916 kumpf 1.1 {
|
917 carolann.graves 1.9 String subscriptionClassesKey = _generateSubscriptionClassesKey
918 (indicationSubclassNames [i], sourceNamespaceName);
|
919 kumpf 1.22 SubscriptionClassesTableEntry scTableValue;
920 if (_subscriptionClassesTable.lookup(
921 subscriptionClassesKey, scTableValue))
|
922 carolann.graves 1.9 {
923 //
924 // If entry exists for this IndicationClassName-SourceNamespace
925 // pair, remove subscription from the list
926 //
|
927 kumpf 1.22 Array<CIMInstance> subscriptions = scTableValue.subscriptions;
|
928 carolann.graves 1.9 for (Uint32 j = 0; j < subscriptions.size (); j++)
929 {
930 if (subscriptions [j].getPath().identical
931 (subscription.getPath()))
932 {
933 subscriptions.remove (j);
934 }
935 }
|
936 kumpf 1.14
|
937 carolann.graves 1.9 //
938 // Remove the old entry
939 //
940 _removeSubscriptionClassesEntry (subscriptionClassesKey);
|
941 kumpf 1.14
|
942 carolann.graves 1.9 //
943 // If there are still subscriptions in the list, insert the
944 // new entry
945 //
946 if (subscriptions.size () > 0)
|
947 kumpf 1.1 {
|
948 carolann.graves 1.9 _insertSubscriptionClassesEntry (
949 indicationSubclassNames [i],
950 sourceNamespaceName, subscriptions);
|
951 kumpf 1.1 }
952 }
|
953 carolann.graves 1.9 else
|
954 kumpf 1.1 {
|
955 carolann.graves 1.9 //
956 // Entry not found in Subscription Classes table
957 //
|
958 thilo.boehm 1.25 PEG_TRACE((TRC_INDICATION_SERVICE,Tracer::LEVEL2,
|
959 thilo.boehm 1.23 "Indication subclass and namespace (%s) not found "
960 "in SubscriptionClassesTable",
961 (const char*)subscriptionClassesKey.getCString()));
|
962 kumpf 1.1 }
963 }
964 }
965
966 PEG_METHOD_EXIT ();
967 }
968
|
969 carolann.graves 1.9 Uint32 SubscriptionTable::providerInList
970 (const CIMInstance & provider,
|
971 kumpf 1.1 const ActiveSubscriptionsTableEntry & tableValue) const
972 {
973 PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
974 "SubscriptionTable::providerInList");
975
976 //
977 // Look for the provider in the list
978 //
979 for (Uint32 i = 0; i < tableValue.providers.size (); i++)
980 {
|
981 carolann.graves 1.9 if (tableValue.providers [i].provider.getPath ().identical
|
982 kumpf 1.1 (provider.getPath ()))
983 {
|
984 gs.keenan 1.4 PEG_METHOD_EXIT ();
|
985 kumpf 1.1 return i;
986 }
987 }
988
|
989 gs.keenan 1.4 PEG_METHOD_EXIT ();
|
990 kumpf 1.1 return PEG_NOT_FOUND;
991 }
992
993
|
994 carolann.graves 1.9 Uint32 SubscriptionTable::classInList
995 (const CIMName & className,
|
996 kumpf 1.1 const ProviderClassList & providerClasses) const
997 {
998 PEG_METHOD_ENTER (TRC_INDICATION_SERVICE, "SubscriptionTable::classInList");
999
1000 //
1001 // Look for the class in the list
1002 //
1003 for (Uint32 i = 0; i < providerClasses.classList.size (); i++)
1004 {
1005 if (providerClasses.classList [i].equal (className))
1006 {
|
1007 gs.keenan 1.4 PEG_METHOD_EXIT ();
|
1008 kumpf 1.1 return i;
1009 }
1010 }
1011
|
1012 gs.keenan 1.4 PEG_METHOD_EXIT ();
|
1013 kumpf 1.1 return PEG_NOT_FOUND;
1014 }
1015
|
1016 kumpf 1.2 void SubscriptionTable::clear ()
1017 {
1018 PEG_METHOD_ENTER (TRC_INDICATION_SERVICE, "SubscriptionTable::clear");
1019
1020 {
1021 WriteLock lock (_activeSubscriptionsTableLock);
1022 _activeSubscriptionsTable.clear ();
1023 }
1024 {
1025 WriteLock lock (_subscriptionClassesTableLock);
1026 _subscriptionClassesTable.clear ();
1027 }
1028
1029 PEG_METHOD_EXIT ();
1030 }
1031
|
1032 yi.zhou 1.17 void SubscriptionTable::getMatchingClassNamespaceSubscriptions(
|
1033 yi.zhou 1.16 const CIMName & supportedClass,
1034 const CIMNamespaceName & nameSpace,
|
1035 yi.zhou 1.17 const CIMInstance& provider,
1036 Array<CIMInstance>& matchingSubscriptions,
|
1037 ashok.pathak 1.29.8.1 Array<SubscriptionKey>& matchingSubscriptionKeys)
|
1038 yi.zhou 1.16 {
1039 PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
1040 "SubscriptionTable::getMatchingClassNamespaceSubscriptions");
1041
1042 Array <CIMInstance> subscriptions;
|
1043 yi.zhou 1.17 matchingSubscriptions.clear();
1044 matchingSubscriptionKeys.clear();
|
1045 yi.zhou 1.16
1046 //
1047 // Look up the indicationClass-sourceNamespace pair in the
1048 // Subscription Classes table
1049 //
|
1050 ashok.pathak 1.29.8.1 String subscriptionClassesKey =
1051 _generateSubscriptionClassesKey(supportedClass, nameSpace);
|
1052 kumpf 1.22 SubscriptionClassesTableEntry scTableValue;
1053 if (_lockedLookupSubscriptionClassesEntry(
1054 subscriptionClassesKey, scTableValue))
|
1055 yi.zhou 1.16 {
|
1056 kumpf 1.22 subscriptions = scTableValue.subscriptions;
|
1057 yi.zhou 1.16 for (Uint32 j = 0; j < subscriptions.size (); j++)
1058 {
1059 //
1060 // Check if the provider who generated this indication
1061 // accepted this subscription
1062 //
|
1063 ashok.pathak 1.29.8.1 SubscriptionKey activeSubscriptionsKey =
1064 SubscriptionKey(subscriptions [j].getPath ());
|
1065 kumpf 1.22 ActiveSubscriptionsTableEntry asTableValue;
1066 if (_lockedLookupActiveSubscriptionsEntry(
1067 activeSubscriptionsKey, asTableValue))
|
1068 yi.zhou 1.16 {
1069 //
|
1070 kumpf 1.28 // If provider is in list, the subscription is acceptted
|
1071 yi.zhou 1.16 //
|
1072 kumpf 1.22 if ((providerInList(provider, asTableValue)) != PEG_NOT_FOUND)
|
1073 yi.zhou 1.16 {
1074 //
1075 // Add current subscription to list
1076 //
|
1077 yi.zhou 1.17 matchingSubscriptions.append(subscriptions[j]);
1078 matchingSubscriptionKeys.append(activeSubscriptionsKey);
|
1079 yi.zhou 1.16 }
1080 }
1081 }
1082 }
1083
|
1084 yi.zhou 1.17 PEGASUS_ASSERT(
1085 matchingSubscriptions.size() == matchingSubscriptionKeys.size());
|
1086 yi.zhou 1.16 PEG_METHOD_EXIT ();
1087 }
1088
|
1089 venkat.puvvada 1.29 Array<ActiveSubscriptionsTableEntry>
1090 SubscriptionTable::getAllActiveSubscriptionEntries()
1091 {
1092 PEG_METHOD_ENTER(TRC_INDICATION_SERVICE,
1093 "SubscriptionTable::getAllActiveSubscriptionEntries");
1094
1095 Array <ActiveSubscriptionsTableEntry> subscriptionsEntries;
1096
1097 //
1098 // Iterate through the ActiveSubscriptions table to get all active
1099 // subscriptions table entries
1100 //
1101
1102 ReadLock lock(_activeSubscriptionsTableLock);
1103
1104 for (ActiveSubscriptionsTable::Iterator i =
1105 _activeSubscriptionsTable.start(); i; i++)
1106 {
1107 subscriptionsEntries.append(i.value());
1108 }
1109
1110 venkat.puvvada 1.29 PEG_METHOD_EXIT();
1111 return subscriptionsEntries;
1112 }
1113
|
1114 yi.zhou 1.17 #ifdef PEGASUS_ENABLE_INDICATION_COUNT
1115
1116 void SubscriptionTable::updateMatchedIndicationCounts(
1117 const CIMInstance & providerInstance,
|
1118 ashok.pathak 1.29.8.1 const Array<SubscriptionKey>& activeSubscriptionsKeys)
|
1119 yi.zhou 1.17 {
1120 PEG_METHOD_ENTER(TRC_INDICATION_SERVICE,
1121 "SubscriptionTable::updateMatchedIndicationCounts");
1122
1123 WriteLock lock(_activeSubscriptionsTableLock);
1124
1125 for (Uint32 i = 0; i < activeSubscriptionsKeys.size(); i++)
1126 {
1127 ActiveSubscriptionsTableEntry* entry = 0;
1128 if (_activeSubscriptionsTable.lookupReference(
1129 activeSubscriptionsKeys[i], entry))
1130 {
1131 Uint32 providerIndex = providerInList(providerInstance, *entry);
1132 if (providerIndex != PEG_NOT_FOUND)
1133 {
1134 entry->providers[providerIndex].
1135 matchedIndCountPerSubscription++;
1136 }
1137 }
1138 else
1139 {
1140 yi.zhou 1.17 // The subscription may have been deleted in the mean time.
1141 // If so, no further update is required.
|
1142 thilo.boehm 1.25 PEG_TRACE((TRC_INDICATION_SERVICE, Tracer::LEVEL2,
|
1143 yi.zhou 1.17 "Subscription %s not found in ActiveSubscriptionsTable",
|
1144 ashok.pathak 1.29.8.1 (const char *)
1145 activeSubscriptionsKeys[i].toString().getCString()));
|
1146 yi.zhou 1.17 }
1147 }
1148 PEG_METHOD_EXIT();
1149 }
1150
1151
1152 Array<CIMInstance>
1153 SubscriptionTable::enumerateSubscriptionIndicationDataInstances()
1154 {
1155 PEG_METHOD_ENTER(TRC_INDICATION_SERVICE,
1156 "SubscriptionTable::enumerateSubscriptionIndicationDataInstances");
1157
1158 Array<CIMInstance> instances;
1159
1160 //
1161 // Get all active subscriptions table entries
1162 //
1163 Array<ActiveSubscriptionsTableEntry> activeSubscriptionEntries =
|
1164 venkat.puvvada 1.29 getAllActiveSubscriptionEntries();
|
1165 yi.zhou 1.17
1166 for (Uint32 i = 0; i < activeSubscriptionEntries.size(); i++)
1167 {
1168 //
1169 // Gets filter name and handler name of the subscription
1170 //
1171 CIMInstance subscription = activeSubscriptionEntries[i].subscription;
1172 String sourceNS = subscription.getPath().getNameSpace().getString();
1173
1174 String filterName;
1175 String handlerName;
1176 _getFilterAndHandlerNames(subscription, filterName, handlerName);
1177
1178 Array<ProviderClassList> providers =
1179 activeSubscriptionEntries[i].providers;
1180
1181 for (Uint32 j = 0; j < providers.size(); j++)
1182 {
|
1183 yi.zhou 1.18 //
1184 // Gets provider name and provider module name
1185 //
1186 String providerName, providerModuleName;
1187 ProviderIndicationCountTable::getProviderKeys(
1188 providers[j].provider,
1189 providerModuleName,
1190 providerName);
1191
|
1192 kumpf 1.28 CIMInstance subscriptionIndDataInstance =
|
1193 yi.zhou 1.18 _buildSubscriptionIndDataInstance(
1194 filterName,
1195 handlerName,
1196 sourceNS,
1197 providerModuleName,
1198 providerName,
1199 providers[j].matchedIndCountPerSubscription);
1200
1201 instances.append(subscriptionIndDataInstance);
1202 }
1203 }
1204
1205 PEG_METHOD_EXIT();
1206 return instances;
1207 }
1208
1209 Array<CIMObjectPath>
1210 SubscriptionTable::enumerateSubscriptionIndicationDataInstanceNames()
1211 {
1212 PEG_METHOD_ENTER(TRC_INDICATION_SERVICE,
1213 "SubscriptionTable::enumerateSubscriptionIndicationDataInstanceNames");
1214 yi.zhou 1.18
1215 Array<CIMObjectPath> instanceNames;
1216
1217 //
1218 // Get all active subscriptions table entries
1219 //
1220 Array<ActiveSubscriptionsTableEntry> activeSubscriptionEntries =
|
1221 venkat.puvvada 1.29 getAllActiveSubscriptionEntries();
|
1222 yi.zhou 1.18
1223 for (Uint32 i = 0; i < activeSubscriptionEntries.size(); i++)
1224 {
1225 //
1226 // Gets filter name and handler name of the subscription
1227 //
1228 CIMInstance subscription = activeSubscriptionEntries[i].subscription;
1229 String sourceNS = subscription.getPath().getNameSpace().getString();
1230
1231 String filterName;
1232 String handlerName;
1233 _getFilterAndHandlerNames(subscription, filterName, handlerName);
|
1234 yi.zhou 1.17
|
1235 yi.zhou 1.18 Array<ProviderClassList> providers =
1236 activeSubscriptionEntries[i].providers;
|
1237 yi.zhou 1.17
|
1238 yi.zhou 1.18 for (Uint32 j = 0; j < providers.size(); j++)
1239 {
|
1240 yi.zhou 1.17 //
|
1241 yi.zhou 1.18 // Gets provider name and provider module name
|
1242 yi.zhou 1.17 //
1243 String providerName, providerModuleName;
1244 ProviderIndicationCountTable::getProviderKeys(
|
1245 yi.zhou 1.18 providers[j].provider,
1246 providerModuleName,
1247 providerName);
1248
1249 CIMObjectPath path = _buildSubscriptionIndDataInstanceName(
1250 filterName,
1251 handlerName,
1252 sourceNS,
|
1253 yi.zhou 1.17 providerModuleName,
1254 providerName);
1255
|
1256 yi.zhou 1.18 instanceNames.append(path);
1257 }
1258 }
|
1259 yi.zhou 1.17
|
1260 yi.zhou 1.18 PEG_METHOD_EXIT();
1261 return instanceNames;
1262 }
1263
1264 CIMInstance SubscriptionTable::getSubscriptionIndicationDataInstance(
1265 const CIMObjectPath& instanceName)
1266 {
1267 PEG_METHOD_ENTER(TRC_INDICATION_SERVICE,
1268 "SubscriptionTable::getSubscriptionIndicationDataInstance");
1269
1270 String filterName;
1271 String handlerName;
1272 String sourceNS;
1273 String specifiedProviderModuleName;
1274 String specifiedProviderName;
1275
1276 //
1277 // Gets handler name, filter name, source namespace, provider module name,
1278 // and provider name from a PG_SubscriptionIndicationData instanceName
1279 //
1280 _getSubscriptionIndicationDataKeys(
1281 yi.zhou 1.18 instanceName,
1282 filterName,
1283 handlerName,
1284 sourceNS,
1285 specifiedProviderModuleName,
1286 specifiedProviderName);
1287
1288 // Builds the PG_Provider object path
1289 CIMObjectPath providerName = _buildProviderPath(
1290 specifiedProviderModuleName, specifiedProviderName);
1291
1292 //
1293 // Builds subscription path by using the specified parameters
1294 //
1295 CIMObjectPath subscriptionPath = _buildSubscriptionPath(
1296 filterName, handlerName, sourceNS);
1297
1298 //
1299 // Look up the subscription in the active subscriptions table
1300 //
|
1301 kumpf 1.22 ActiveSubscriptionsTableEntry asTableValue;
1302 if (getSubscriptionEntry(subscriptionPath, asTableValue))
|
1303 yi.zhou 1.18 {
|
1304 kumpf 1.22 Array<ProviderClassList> providers = asTableValue.providers;
|
1305 yi.zhou 1.18 for (Uint32 i = 0; i < providers.size(); i++)
1306 {
1307 if (providerName.identical(providers[i].provider.getPath()))
1308 {
|
1309 kumpf 1.28 CIMInstance subIndDataInstance =
|
1310 yi.zhou 1.18 _buildSubscriptionIndDataInstance(
1311 filterName,
1312 handlerName,
1313 sourceNS,
1314 specifiedProviderModuleName,
1315 specifiedProviderName,
1316 providers[i].matchedIndCountPerSubscription);
1317
1318 PEG_METHOD_EXIT();
1319 return subIndDataInstance;
1320 }
|
1321 yi.zhou 1.17 }
1322 }
1323
1324 PEG_METHOD_EXIT();
|
1325 yi.zhou 1.18 throw CIMObjectNotFoundException(instanceName.toString());
|
1326 yi.zhou 1.17 }
1327
1328 void SubscriptionTable::_getFilterAndHandlerNames(
1329 const CIMInstance& subscription,
1330 String& filterName,
1331 String& handlerName)
1332 {
1333 PEG_METHOD_ENTER(TRC_INDICATION_SERVICE,
1334 "SubscriptionTable::_getFilterAndHandlerNames");
1335
1336 CIMObjectPath filterPath;
1337 CIMObjectPath handlerPath;
1338
1339 subscription.getProperty(subscription.findProperty(
1340 PEGASUS_PROPERTYNAME_FILTER)).getValue().get(filterPath);
1341 subscription.getProperty(subscription.findProperty(
1342 PEGASUS_PROPERTYNAME_HANDLER)).getValue().get(handlerPath);
1343
1344 //
1345 // Get Filter namespace - if not set in Filter reference property
1346 // value, namespace is the namespace of the subscription
1347 yi.zhou 1.17 //
1348 CIMNamespaceName filterNS = filterPath.getNameSpace();
1349 if (filterNS.isNull())
1350 {
1351 filterNS = subscription.getPath().getNameSpace();
1352 }
1353
1354 //
1355 // Get filter name
1356 //
1357 Array<CIMKeyBinding> filterKeyBindings = filterPath.getKeyBindings();
1358 for (Uint32 i = 0; i < filterKeyBindings.size(); i++)
1359 {
1360 if (filterKeyBindings[i].getName().equal(PEGASUS_PROPERTYNAME_NAME))
1361 {
1362 filterName.append(filterNS.getString());
1363 filterName.append(":");
1364 filterName.append(filterKeyBindings[i].getValue());
1365 break;
1366 }
1367 }
1368 yi.zhou 1.17
1369 //
1370 // Get handler namespace - if not set in handler reference property
1371 // value, namespace is the namespace of the subscription
1372 //
1373 CIMNamespaceName handlerNS = handlerPath.getNameSpace();
1374 if (handlerNS.isNull())
1375 {
1376 handlerNS = subscription.getPath().getNameSpace();
1377 }
1378
1379 //
1380 // Get handler name
1381 //
1382 Array<CIMKeyBinding> handlerKeyBindings = handlerPath.getKeyBindings();
1383 for (Uint32 i = 0; i < handlerKeyBindings.size(); i++)
1384 {
1385 if (handlerKeyBindings[i].getName().equal(PEGASUS_PROPERTYNAME_NAME))
1386 {
1387 handlerName.append(handlerNS.getString());
1388 handlerName.append(":");
1389 yi.zhou 1.17 handlerName.append(handlerPath.getClassName().getString());
1390 handlerName.append(".");
1391 handlerName.append(handlerKeyBindings[i].getValue());
1392 break;
1393 }
1394 }
1395
1396 PEG_METHOD_EXIT();
1397 }
1398
|
1399 yi.zhou 1.18 void SubscriptionTable::_getSubscriptionIndicationDataKeys(
1400 const CIMObjectPath& instanceName,
1401 String& filterName,
1402 String& handlerName,
1403 String& sourceNS,
1404 String& providerModuleName,
1405 String& providerName)
1406 {
1407 PEG_METHOD_ENTER(TRC_INDICATION_SERVICE,
1408 "SubscriptionTable::_getSubscriptionIndicationDataKeys");
1409
1410 Array<CIMKeyBinding> keys = instanceName.getKeyBindings();
1411 for (Uint32 i = 0; i < keys.size(); i++)
1412 {
1413 if (keys[i].getName() == "FilterName")
1414 {
1415 filterName = keys[i].getValue();
1416 }
1417 else if (keys[i].getName() == "HandlerName")
1418 {
1419 handlerName = keys[i].getValue();
1420 yi.zhou 1.18 }
1421 else if (keys[i].getName() == "SourceNamespace")
1422 {
1423 sourceNS = keys[i].getValue();
1424 }
1425 else if (keys[i].getName() == "ProviderModuleName")
1426 {
1427 providerModuleName = keys[i].getValue();
1428 }
1429 else if (keys[i].getName() == "ProviderName")
1430 {
1431 providerName = keys[i].getValue();
1432 }
1433 }
1434
1435 PEG_METHOD_EXIT();
1436 }
1437
1438
1439 CIMObjectPath SubscriptionTable::_buildFilterPath(const String& filterName)
1440 {
1441 yi.zhou 1.18 PEG_METHOD_ENTER(TRC_INDICATION_SERVICE,
1442 "SubscriptionTable::_buildFilterPath");
1443
1444 //
1445 // creates filter object path from input string filterName
1446 // (namespace:filtername)
1447 //
1448 String name;
1449 Uint32 colonIndex = filterName.find(':');
1450
1451 if (colonIndex != PEG_NOT_FOUND)
1452 {
1453 name = filterName.subString(colonIndex + 1);
1454 }
1455
1456 Array<CIMKeyBinding> filterKeys;
1457 filterKeys.append(CIMKeyBinding(
1458 "SystemCreationClassName",
1459 System::getSystemCreationClassName(),
1460 CIMKeyBinding::STRING));
1461 filterKeys.append(CIMKeyBinding(
1462 yi.zhou 1.18 "SystemName",
1463 System::getFullyQualifiedHostName(),
1464 CIMKeyBinding::STRING));
1465 filterKeys.append(CIMKeyBinding(
1466 "CreationClassName",
1467 PEGASUS_CLASSNAME_INDFILTER.getString(),
1468 CIMKeyBinding::STRING));
1469 filterKeys.append(CIMKeyBinding(
|
1470 marek 1.24 PEGASUS_PROPERTYNAME_NAME,
|
1471 yi.zhou 1.18 name,
1472 CIMKeyBinding::STRING));
1473
1474 CIMObjectPath filterPath = CIMObjectPath(
1475 String::EMPTY,
1476 CIMNamespaceName(),
1477 PEGASUS_CLASSNAME_INDFILTER,
1478 filterKeys);
1479
1480 PEG_METHOD_EXIT();
1481 return filterPath;
1482 }
1483
1484 CIMObjectPath SubscriptionTable::_buildHandlerPath(const String& handlerName)
1485 {
1486 PEG_METHOD_ENTER(TRC_INDICATION_SERVICE,
1487 "SubscriptionTable::_buildHandlerPath");
1488
1489 //
1490 // creates handler object path from input string handlerName
1491 // (namespace:classname.handlername)
1492 yi.zhou 1.18 //
1493 String name;
1494 String classname;
1495 Uint32 colonIndex = handlerName.find(':');
1496 Uint32 dotIndex = handlerName.find('.');
|
1497 kumpf 1.28
|
1498 yi.zhou 1.18 if (colonIndex != PEG_NOT_FOUND)
1499 {
1500 if ((dotIndex != PEG_NOT_FOUND) && (dotIndex > colonIndex))
|
1501 kumpf 1.28 {
|
1502 yi.zhou 1.18 classname = handlerName.subString(
1503 colonIndex + 1, dotIndex - 1 - colonIndex);
1504 name = handlerName.subString(dotIndex + 1);
1505 }
1506 }
1507
1508 Array<CIMKeyBinding> handlerKeys;
1509 handlerKeys.append(CIMKeyBinding(
1510 "SystemCreationClassName",
1511 System::getSystemCreationClassName(),
1512 CIMKeyBinding::STRING));
1513 handlerKeys.append(CIMKeyBinding(
1514 "SystemName",
1515 System::getFullyQualifiedHostName(),
1516 CIMKeyBinding::STRING));
1517 handlerKeys.append(CIMKeyBinding(
1518 "CreationClassName",
1519 classname,
1520 CIMKeyBinding::STRING));
1521 handlerKeys.append(CIMKeyBinding(
|
1522 marek 1.24 PEGASUS_PROPERTYNAME_NAME,
|
1523 yi.zhou 1.18 name,
1524 CIMKeyBinding::STRING));
1525
1526 CIMObjectPath handlerPath = CIMObjectPath(
1527 String::EMPTY,
1528 CIMNamespaceName(),
1529 classname,
1530 handlerKeys);
1531
1532 PEG_METHOD_EXIT();
1533 return handlerPath;
1534 }
1535
1536 CIMObjectPath SubscriptionTable::_buildSubscriptionPath(
1537 const String& filterName,
1538 const String& handlerName,
1539 const String& sourceNS)
1540 {
1541 CIMObjectPath filterPath = _buildFilterPath(filterName);
1542 CIMObjectPath handlerPath = _buildHandlerPath(handlerName);
1543
1544 yi.zhou 1.18 CIMObjectPath subscriptionPath;
1545 Array<CIMKeyBinding> keyBindings;
1546 keyBindings.append(CIMKeyBinding(
1547 PEGASUS_PROPERTYNAME_FILTER,
1548 filterPath.toString(),
1549 CIMKeyBinding::REFERENCE));
1550 keyBindings.append(CIMKeyBinding(
1551 PEGASUS_PROPERTYNAME_HANDLER,
1552 handlerPath.toString(),
1553 CIMKeyBinding::REFERENCE));
|
1554 kumpf 1.28
|
1555 yi.zhou 1.18 subscriptionPath.setClassName(PEGASUS_CLASSNAME_INDSUBSCRIPTION);
1556 subscriptionPath.setNameSpace(sourceNS);
1557 subscriptionPath.setKeyBindings(keyBindings);
1558
1559 return subscriptionPath;
1560 }
1561
1562 CIMInstance SubscriptionTable::_buildSubscriptionIndDataInstance(
1563 const String& filterName,
1564 const String& handlerName,
1565 const String& sourceNS,
1566 const String& providerModuleName,
1567 const String& providerName,
1568 Uint32 matchedIndicationCount)
1569 {
1570 CIMInstance subscriptionIndDataInstance(
1571 PEGASUS_CLASSNAME_SUBSCRIPTIONINDDATA);
1572 subscriptionIndDataInstance.addProperty(CIMProperty(
1573 CIMName("FilterName"), filterName));
1574 subscriptionIndDataInstance.addProperty(CIMProperty(
1575 CIMName("HandlerName"), handlerName));
1576 yi.zhou 1.18 subscriptionIndDataInstance.addProperty(CIMProperty(
1577 CIMName("SourceNamespace"), sourceNS));
1578 subscriptionIndDataInstance.addProperty(CIMProperty(
1579 CIMName("ProviderModuleName"), providerModuleName));
1580 subscriptionIndDataInstance.addProperty(CIMProperty(
1581 CIMName("ProviderName"), providerName));
1582 subscriptionIndDataInstance.addProperty(CIMProperty(
1583 CIMName("MatchedIndicationCount"),
1584 matchedIndicationCount));
1585
1586 CIMObjectPath path = _buildSubscriptionIndDataInstanceName(
1587 filterName,
1588 handlerName,
1589 sourceNS,
1590 providerModuleName,
1591 providerName);
1592 subscriptionIndDataInstance.setPath(path);
1593
1594 return subscriptionIndDataInstance;
1595 }
1596
1597 yi.zhou 1.18 CIMObjectPath SubscriptionTable::_buildSubscriptionIndDataInstanceName(
1598 const String& filterName,
1599 const String& handlerName,
1600 const String& sourceNS,
1601 const String& providerModuleName,
1602 const String& providerName)
1603 {
1604 CIMObjectPath path;
1605 Array<CIMKeyBinding> keyBindings;
1606 keyBindings.append(CIMKeyBinding(
1607 "FilterName",
1608 filterName,
1609 CIMKeyBinding::STRING));
1610 keyBindings.append(CIMKeyBinding(
1611 "HandlerName",
1612 handlerName,
1613 CIMKeyBinding::STRING));
1614 keyBindings.append(CIMKeyBinding(
1615 "SourceNamespace",
1616 sourceNS,
1617 CIMKeyBinding::STRING));
1618 yi.zhou 1.18 keyBindings.append(CIMKeyBinding(
1619 "ProviderModuleName",
1620 providerModuleName,
1621 CIMKeyBinding::STRING));
1622 keyBindings.append(CIMKeyBinding(
1623 "ProviderName",
1624 providerName,
1625 CIMKeyBinding::STRING));
1626
1627 path.setClassName(PEGASUS_CLASSNAME_SUBSCRIPTIONINDDATA);
1628 path.setKeyBindings(keyBindings);
1629
1630 return path;
1631 }
1632
1633 CIMObjectPath SubscriptionTable::_buildProviderPath(
1634 const String& providerModuleName,
1635 const String& providerName)
1636 {
1637 CIMObjectPath path;
1638 Array<CIMKeyBinding> keyBindings;
1639 yi.zhou 1.18 keyBindings.append(CIMKeyBinding(
1640 _PROPERTY_PROVIDERMODULENAME,
1641 providerModuleName,
1642 CIMKeyBinding::STRING));
1643 keyBindings.append(CIMKeyBinding(
1644 PEGASUS_PROPERTYNAME_NAME,
1645 providerName,
1646 CIMKeyBinding::STRING));
1647
1648 path.setClassName(PEGASUS_CLASSNAME_PROVIDER);
1649 path.setKeyBindings(keyBindings);
1650
1651 return path;
1652 }
1653
|
1654 yi.zhou 1.17 #endif
1655
|
1656 kumpf 1.1 PEGASUS_NAMESPACE_END
|