1 karl 1.5 //%2005////////////////////////////////////////////////////////////////////////
|
2 kumpf 1.1 //
|
3 karl 1.3 // 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.3 // 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 // Modified By:
|
34 gs.keenan 1.4 // Sean Keenan, Hewlett-Packard Company (sean.keenan@hp.com)
|
35 aruran.ms 1.7 // Aruran, IBM (ashanmug@in.ibm.com) for Bug# 3603
|
36 kumpf 1.1 //
37 //%/////////////////////////////////////////////////////////////////////////////
38
39 #include <Pegasus/Common/Config.h>
40 #include <Pegasus/Common/Constants.h>
41 #include <Pegasus/Common/Tracer.h>
42
43 #include "IndicationConstants.h"
44 #include "IndicationService.h"
45 #include "SubscriptionTable.h"
46
47 PEGASUS_USING_STD;
48
49 PEGASUS_NAMESPACE_BEGIN
50
51 SubscriptionTable::SubscriptionTable (
52 SubscriptionRepository * subscriptionRepository)
53 : _subscriptionRepository (subscriptionRepository)
54 {
55 }
56
57 kumpf 1.1 SubscriptionTable::~SubscriptionTable ()
58 {
59 }
60
|
61 aruran.ms 1.7 Array <CIMInstance> SubscriptionTable::getActiveSubscriptions () const
|
62 kumpf 1.1 {
63 PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
64 "SubscriptionTable::getActiveSubscriptions");
65
66 Array <CIMInstance> activeSubscriptions;
67
68 // Do not call any other methods that need _activeSubscriptionsTableLock
69 ReadLock lock(_activeSubscriptionsTableLock);
70
71 //
72 // Iterate through the subscription table
73 //
74 for (ActiveSubscriptionsTable::Iterator i =
75 _activeSubscriptionsTable.start (); i; i++)
76 {
77 //
78 // Append subscription to the list
79 //
80 activeSubscriptions.append (i.value ().subscription);
81 }
82
83 kumpf 1.1 PEG_METHOD_EXIT ();
84 return activeSubscriptions;
85 }
86
87 Boolean SubscriptionTable::getSubscriptionEntry (
88 const CIMObjectPath & subscriptionPath,
|
89 aruran.ms 1.7 ActiveSubscriptionsTableEntry & tableValue) const
|
90 kumpf 1.1 {
91 PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
92 "SubscriptionTable::getSubscriptionEntry");
93
94 Boolean succeeded = false;
95 String activeSubscriptionsKey = _generateActiveSubscriptionsKey
96 (subscriptionPath);
97 if (_lockedLookupActiveSubscriptionsEntry
98 (activeSubscriptionsKey, tableValue))
99 {
100 succeeded = true;
101 }
102 else
103 {
104 //
105 // Subscription not found in Active Subscriptions table
106 //
107 PEG_TRACE_STRING (TRC_INDICATION_SERVICE_INTERNAL, Tracer::LEVEL2,
108 "Subscription (" + activeSubscriptionsKey +
109 ") not found in ActiveSubscriptionsTable");
110 }
111 kumpf 1.1
112 PEG_METHOD_EXIT ();
113 return succeeded;
114 }
115
116 Array <CIMInstance> SubscriptionTable::getMatchingSubscriptions (
117 const CIMName & supportedClass,
118 const Array <CIMNamespaceName> nameSpaces,
119 const Boolean checkProvider,
|
120 aruran.ms 1.7 const CIMInstance & provider) const
|
121 kumpf 1.1 {
122 PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
123 "SubscriptionTable::getMatchingSubscriptions");
124
125 Array <CIMInstance> matchingSubscriptions;
126 Array <CIMInstance> subscriptions;
127
128 for (Uint32 i = 0; i < nameSpaces.size (); i++)
129 {
130 //
131 // Look up the indicationClass-sourceNamespace pair in the
132 // Subscription Classes table
133 //
134 String subscriptionClassesKey = _generateSubscriptionClassesKey
135 (supportedClass, nameSpaces [i]);
136 SubscriptionClassesTableEntry tableValue;
137 if (_lockedLookupSubscriptionClassesEntry (subscriptionClassesKey,
138 tableValue))
139 {
140 subscriptions = tableValue.subscriptions;
141 for (Uint32 j = 0; j < subscriptions.size (); j++)
142 kumpf 1.1 {
143 Boolean match = true;
144
145 if (checkProvider)
146 {
147 //
148 // Check if the provider who generated this indication
149 // accepted this subscription
150 //
151 String activeSubscriptionsKey =
152 _generateActiveSubscriptionsKey
153 (subscriptions [j].getPath ());
154 ActiveSubscriptionsTableEntry tableValue;
155 if (_lockedLookupActiveSubscriptionsEntry
156 (activeSubscriptionsKey, tableValue))
157 {
158 //
159 // If provider is not in list, it did not accept the
160 // subscription
161 //
162 if ((providerInList (provider, tableValue)) ==
163 kumpf 1.1 PEG_NOT_FOUND)
164 {
165 match = false;
166 break;
167 }
168 }
169 }
170
171 if (match)
172 {
173 //
174 // Add current subscription to list
175 //
176 matchingSubscriptions.append (subscriptions [j]);
177 }
178 }
179 }
180 }
181
182 PEG_METHOD_EXIT ();
183 return matchingSubscriptions;
184 kumpf 1.1 }
185
|
186 aruran.ms 1.8 Array <CIMInstance> SubscriptionTable::getAndUpdateProviderSubscriptions (
187 const CIMInstance & provider)
|
188 kumpf 1.1 {
189 PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
|
190 aruran.ms 1.8 "SubscriptionTable::getAndUpdateProviderSubscriptions");
|
191 kumpf 1.1
192 Array <CIMInstance> providerSubscriptions;
193
194 //
195 // Iterate through the subscription table to find subscriptions served by
196 // the provider
197 // NOTE: updating entries (remove and insert) while iterating through the
198 // table does not work reliably, and it is not clear if that is supposed to
199 // work; for now, the SubscriptionTable first iterates through the
200 // active subscriptions table to find subscriptions served by the
201 // provider, then looks up and updates each affected subscription
202 //
203 {
204 //
205 // Do not call any other methods that need _activeSubscriptionsTableLock
206 //
207 ReadLock lock (_activeSubscriptionsTableLock);
208
209 CIMClass providerClass = _subscriptionRepository->getClass
210 (PEGASUS_NAMESPACENAME_INTEROP, PEGASUS_CLASSNAME_PROVIDER);
211 for (ActiveSubscriptionsTable::Iterator i =
212 kumpf 1.1 _activeSubscriptionsTable.start (); i; i++)
213 {
214 //
215 // If provider matches, append subscription to the list
216 //
217 ActiveSubscriptionsTableEntry tableValue = i.value ();
218 for (Uint32 j = 0; j < tableValue.providers.size (); j++)
219 {
220 if (tableValue.providers [j].provider.getPath ().identical
221 (provider.getPath ()))
222 {
223 //
224 // Add the subscription to the list
225 //
226 providerSubscriptions.append (tableValue.subscription);
227 break;
228 }
229 }
230 }
231 }
232
233 kumpf 1.1 //
234 // Look up and update hash table entry for each affected subscription
235 //
236 for (Uint32 k = 0; k < providerSubscriptions.size (); k++)
237 {
238 //
239 // Update the entry in the active subscriptions hash table
240 //
241 String activeSubscriptionsKey = _generateActiveSubscriptionsKey
242 (providerSubscriptions [k].getPath ());
243 ActiveSubscriptionsTableEntry tableValue;
244 if (_lockedLookupActiveSubscriptionsEntry (activeSubscriptionsKey,
245 tableValue))
246 {
247 //
248 // Remove the provider from the list of providers serving the
249 // subscription
250 //
251 Uint32 providerIndex = providerInList (provider, tableValue);
252 if (providerIndex != PEG_NOT_FOUND)
253 {
254 kumpf 1.1 tableValue.providers.remove (providerIndex);
255 if (tableValue.providers.size () > 0)
256 {
257 //
258 // At least one provider is still serving the
259 // subscription
260 // Update entry in Active Subscriptions table
261 //
262 WriteLock lock (_activeSubscriptionsTableLock);
263 _removeActiveSubscriptionsEntry
264 (activeSubscriptionsKey);
265 _insertActiveSubscriptionsEntry
266 (tableValue.subscription, tableValue.providers);
267 }
268 else
269 {
270 //
271 // If the terminated provider was the only provider
272 // serving the subscription, implement the
273 // subscription's On Fatal Error Policy
274 //
275 kumpf 1.1 if (!_subscriptionRepository->reconcileFatalError
276 (tableValue.subscription))
277 {
278 //
279 // If subscription was not disabled or deleted
280 // Update entry in Active Subscriptions table
281 //
282 WriteLock lock (_activeSubscriptionsTableLock);
283 _removeActiveSubscriptionsEntry
284 (activeSubscriptionsKey);
285 _insertActiveSubscriptionsEntry
286 (tableValue.subscription, tableValue.providers);
287 }
288 }
289 }
290 else
291 {
292 PEG_TRACE_STRING (TRC_INDICATION_SERVICE_INTERNAL,
293 Tracer::LEVEL2,
294 "Provider (" + provider.getPath().toString() +
295 ") not found in list for Subscription (" +
296 kumpf 1.1 activeSubscriptionsKey +
297 ") in ActiveSubscriptionsTable");
298 }
299 }
300 else
301 {
302 PEG_TRACE_STRING (TRC_INDICATION_SERVICE_INTERNAL, Tracer::LEVEL2,
303 "Subscription (" + activeSubscriptionsKey +
304 ") not found in ActiveSubscriptionsTable");
305 //
306 // The subscription may have been deleted in the mean time
307 // If so, no further update is required
308 //
309 }
310 }
311
312 PEG_METHOD_EXIT ();
313 return providerSubscriptions;
314 }
315
316 Boolean SubscriptionTable::_providerInUse (
317 kumpf 1.1 const CIMInstance & provider) const
318 {
319 PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
320 "SubscriptionTable::_providerInUse");
321
322 //
323 // The caller must acquire a lock on the Active Subscriptions table
324 // before calling
325 //
326
327 //
328 // Iterate through the subscription table
329 //
330 CIMClass providerClass = _subscriptionRepository->getClass
331 (PEGASUS_NAMESPACENAME_INTEROP, PEGASUS_CLASSNAME_PROVIDER);
332 for (ActiveSubscriptionsTable::Iterator i =
333 _activeSubscriptionsTable.start (); i; i++)
334 {
335 //
336 // If provider matches, return true
337 //
338 kumpf 1.1 for (Uint32 j = 0; j < i.value ().providers.size (); j++)
339 {
340 ActiveSubscriptionsTableEntry tableValue = i.value ();
341 if (tableValue.providers [j].provider.getPath ().identical
342 (provider.getPath ()))
343 {
|
344 gs.keenan 1.4 PEG_METHOD_EXIT ();
|
345 kumpf 1.1 return true;
346 }
347 }
348 }
349
350 PEG_METHOD_EXIT ();
351 return false;
352 }
353
354 String SubscriptionTable::_generateActiveSubscriptionsKey (
355 const CIMObjectPath & subscription) const
356 {
357 String activeSubscriptionsKey;
358
359 //
360 // Append subscription namespace name to key
361 //
362 activeSubscriptionsKey.append
363 (subscription.getNameSpace ().getString());
364
365 //
366 kumpf 1.1 // Get filter and handler key bindings from subscription reference
367 //
368 Array<CIMKeyBinding> subscriptionKB = subscription.getKeyBindings ();
369 Array<CIMKeyBinding> filterKB;
370 Array<CIMKeyBinding> handlerKB;
371 for (Uint32 i = 0; i < subscriptionKB.size (); i++)
372 {
373 if ((subscriptionKB [i].getName () == _PROPERTY_FILTER) &&
374 (subscriptionKB [i].getType () == CIMKeyBinding::REFERENCE))
375 {
376 CIMObjectPath filterRef (subscriptionKB [i].getValue ());
377 filterKB = filterRef.getKeyBindings ();
378 }
379 if ((subscriptionKB [i].getName () == _PROPERTY_HANDLER) &&
380 (subscriptionKB [i].getType () == CIMKeyBinding::REFERENCE))
381 {
382 CIMObjectPath handlerRef (subscriptionKB [i].getValue ());
383 handlerKB = handlerRef.getKeyBindings ();
384 }
385 }
386
387 kumpf 1.1 //
388 // Append subscription filter key values to key
389 //
390 for (Uint32 j = 0; j < filterKB.size (); j++)
391 {
392 activeSubscriptionsKey.append (filterKB [j].getValue ());
393 }
394
395 //
396 // Append subscription handler key values to key
397 //
398 for (Uint32 k = 0; k < handlerKB.size (); k++)
399 {
400 activeSubscriptionsKey.append (handlerKB [k].getValue ());
401 }
402
403 return activeSubscriptionsKey;
404 }
405
406 Boolean SubscriptionTable::_lockedLookupActiveSubscriptionsEntry (
407 const String & key,
|
408 aruran.ms 1.7 ActiveSubscriptionsTableEntry & tableEntry) const
|
409 kumpf 1.1 {
410 ReadLock lock(_activeSubscriptionsTableLock);
411
412 return (_activeSubscriptionsTable.lookup (key, tableEntry));
413 }
414
415 void SubscriptionTable::_insertActiveSubscriptionsEntry (
416 const CIMInstance & subscription,
|
417 aruran.ms 1.8 const Array <ProviderClassList> & providers)
|
418 kumpf 1.1 {
419 PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
420 "SubscriptionTable::_insertActiveSubscriptionsEntry");
421
422 String activeSubscriptionsKey = _generateActiveSubscriptionsKey
423 (subscription.getPath ());
424 ActiveSubscriptionsTableEntry entry;
425 entry.subscription = subscription;
426 entry.providers = providers;
427
428 _activeSubscriptionsTable.insert (activeSubscriptionsKey, entry);
429
430 #ifdef PEGASUS_INDICATION_HASHTRACE
431 String traceString;
432 traceString.append (activeSubscriptionsKey);
433 traceString.append (" Providers: ");
434 for (Uint32 i = 0; i < providers.size (); i++)
435 {
436 String providerName = providers [i].provider.getProperty
437 (providers [i].provider.findProperty
438 (_PROPERTY_NAME)).getValue ().toString ();
439 kumpf 1.1 traceString.append (providerName);
440 traceString.append (" Classes: ");
441 for (Uint32 j = 0; j < providers[i].classList.size (); j++)
442 {
443 traceString.append (providers[i].classList[j].getString());
444 traceString.append (" ");
445 }
446 }
447
448 PEG_TRACE_STRING (TRC_INDICATION_SERVICE_INTERNAL, Tracer::LEVEL3,
449 "INSERTED _activeSubscriptionsTable entry: " + traceString);
450 #endif
451
452 PEG_METHOD_EXIT ();
453 }
454
455 void SubscriptionTable::_removeActiveSubscriptionsEntry (
|
456 aruran.ms 1.8 const String & key)
|
457 kumpf 1.1 {
458 PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
459 "SubscriptionTable::_removeActiveSubscriptionsEntry");
460
461 _activeSubscriptionsTable.remove (key);
462 #ifdef PEGASUS_INDICATION_HASHTRACE
463 PEG_TRACE_STRING (TRC_INDICATION_SERVICE_INTERNAL,
464 Tracer::LEVEL3,
465 "REMOVED _activeSubscriptionsTable entry: " + key);
466 #endif
467
468 PEG_METHOD_EXIT ();
469 }
470
471 String SubscriptionTable::_generateSubscriptionClassesKey (
472 const CIMName & indicationClassName,
473 const CIMNamespaceName & sourceNamespaceName) const
474 {
475 String subscriptionClassesKey;
476
477 //
478 kumpf 1.1 // Append indication class name to key
479 //
480 subscriptionClassesKey.append (indicationClassName.getString ());
481
482 //
483 // Append source namespace name to key
484 //
485 subscriptionClassesKey.append (sourceNamespaceName.getString ());
486
487 return subscriptionClassesKey;
488 }
489
490 Boolean SubscriptionTable::_lockedLookupSubscriptionClassesEntry (
491 const String & key,
|
492 aruran.ms 1.7 SubscriptionClassesTableEntry & tableEntry) const
|
493 kumpf 1.1 {
494 ReadLock lock(_subscriptionClassesTableLock);
495
496 return (_subscriptionClassesTable.lookup (key, tableEntry));
497 }
498
499 void SubscriptionTable::_lockedInsertSubscriptionClassesEntry (
500 const CIMName & indicationClassName,
501 const CIMNamespaceName & sourceNamespaceName,
502 const Array <CIMInstance> & subscriptions)
503 {
504 PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
505 "SubscriptionTable::_lockedInsertSubscriptionClassesEntry");
506
507 String subscriptionClassesKey = _generateSubscriptionClassesKey
508 (indicationClassName, sourceNamespaceName);
509 SubscriptionClassesTableEntry entry;
510 entry.indicationClassName = indicationClassName;
511 entry.sourceNamespaceName = sourceNamespaceName;
512 entry.subscriptions = subscriptions;
513 {
514 kumpf 1.1 WriteLock lock(_subscriptionClassesTableLock);
515 _subscriptionClassesTable.insert (subscriptionClassesKey, entry);
516 }
517
518 #ifdef PEGASUS_INDICATION_HASHTRACE
519 String traceString;
520 traceString.append (subscriptionClassesKey);
521 traceString.append (" Subscriptions: ");
522 for (Uint32 i = 0; i < subscriptions.size (); i++)
523 {
524 traceString.append (subscriptions [i].getPath ().toString());
525 traceString.append (" ");
526 }
527
528 PEG_TRACE_STRING (TRC_INDICATION_SERVICE_INTERNAL, Tracer::LEVEL3,
529 "INSERTED _subscriptionClassesTable entry: " + traceString);
530 #endif
531
532 PEG_METHOD_EXIT ();
533 }
534
535 kumpf 1.1 void SubscriptionTable::_lockedRemoveSubscriptionClassesEntry (
536 const String & key)
537 {
538 PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
539 "SubscriptionTable::_lockedRemoveSubscriptionClassesEntry");
540
541 WriteLock lock(_subscriptionClassesTableLock);
542
543 _subscriptionClassesTable.remove (key);
544
545 #ifdef PEGASUS_INDICATION_HASHTRACE
546 PEG_TRACE_STRING (TRC_INDICATION_SERVICE_INTERNAL, Tracer::LEVEL3,
547 "REMOVED _subscriptionClassesTable entry: " + key);
548 #endif
549
550 PEG_METHOD_EXIT ();
551 }
552
|
553 carolann.graves 1.6 void SubscriptionTable::insertSubscription (
|
554 kumpf 1.1 const CIMInstance & subscription,
555 const Array <ProviderClassList> & providers,
556 const Array <CIMName> & indicationSubclassNames,
557 const CIMNamespaceName & sourceNamespaceName)
558 {
559 PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
560 "SubscriptionTable::insertSubscription");
561
562 //
563 // Insert entry into active subscriptions table
564 //
565 {
566 WriteLock lock(_activeSubscriptionsTableLock);
567
568 _insertActiveSubscriptionsEntry (subscription, providers);
569 }
570
571 //
572 // Insert or update entries in subscription classes table
573 //
574 for (Uint32 i = 0; i < indicationSubclassNames.size (); i++)
575 kumpf 1.1 {
576 String subscriptionClassesKey = _generateSubscriptionClassesKey
577 (indicationSubclassNames [i], sourceNamespaceName);
578 SubscriptionClassesTableEntry tableValue;
579 if (_lockedLookupSubscriptionClassesEntry (subscriptionClassesKey,
580 tableValue))
581 {
582 //
583 // If entry exists for this IndicationClassName-SourceNamespace
584 // pair, remove old entry and insert new entry
585 //
586 Array <CIMInstance> subscriptions = tableValue.subscriptions;
587 subscriptions.append (subscription);
588 _lockedRemoveSubscriptionClassesEntry (subscriptionClassesKey);
589 _lockedInsertSubscriptionClassesEntry (indicationSubclassNames [i],
590 sourceNamespaceName, subscriptions);
591 }
592 else
593 {
594 //
595 // If no entry exists for this
596 kumpf 1.1 // IndicationClassName-SourceNamespace pair, insert new entry
597 //
598 Array <CIMInstance> subscriptions;
599 subscriptions.append (subscription);
600 _lockedInsertSubscriptionClassesEntry (indicationSubclassNames [i],
601 sourceNamespaceName, subscriptions);
602 }
603 }
604
605 PEG_METHOD_EXIT ();
606 }
607
|
608 carolann.graves 1.6 void SubscriptionTable::updateProviders (
|
609 kumpf 1.1 const CIMObjectPath & subscriptionPath,
610 const ProviderClassList & provider,
611 Boolean addProvider)
612 {
613 PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
614 "SubscriptionTable::updateProviders");
615
616 String activeSubscriptionsKey = _generateActiveSubscriptionsKey
617 (subscriptionPath);
618 ActiveSubscriptionsTableEntry tableValue;
619 if (_lockedLookupActiveSubscriptionsEntry (activeSubscriptionsKey,
620 tableValue))
621 {
622 Uint32 providerIndex = providerInList (provider.provider, tableValue);
623 if (addProvider)
624 {
625 if (providerIndex == PEG_NOT_FOUND)
626 {
627 tableValue.providers.append (provider);
628 }
629 else
630 kumpf 1.1 {
631 CIMInstance p = provider.provider;
632 PEG_TRACE_STRING (TRC_INDICATION_SERVICE_INTERNAL,
633 Tracer::LEVEL2,
634 "Provider " + IndicationService::getProviderLogString (p) +
635 " already in list for Subscription (" +
636 activeSubscriptionsKey +
637 ") in ActiveSubscriptionsTable");
638 }
639 }
640 else
641 {
642 if (providerIndex != PEG_NOT_FOUND)
643 {
644 tableValue.providers.remove (providerIndex);
645 }
646 else
647 {
648 CIMInstance p = provider.provider;
649 PEG_TRACE_STRING (TRC_INDICATION_SERVICE_INTERNAL,
650 Tracer::LEVEL2,
651 kumpf 1.1 "Provider " + IndicationService::getProviderLogString (p) +
652 " not found in list for Subscription (" +
653 activeSubscriptionsKey +
654 ") in ActiveSubscriptionsTable");
655 }
656 }
657 {
658 WriteLock lock (_activeSubscriptionsTableLock);
659 _removeActiveSubscriptionsEntry (activeSubscriptionsKey);
660 _insertActiveSubscriptionsEntry (tableValue.subscription,
661 tableValue.providers);
662 }
663 }
664 else
665 {
666 PEG_TRACE_STRING (TRC_INDICATION_SERVICE_INTERNAL, Tracer::LEVEL2,
667 "Subscription (" + activeSubscriptionsKey +
668 ") not found in ActiveSubscriptionsTable");
669
670 //
671 // The subscription may have been deleted in the mean time
672 kumpf 1.1 // If so, no further update is required
673 //
674 }
675
676 PEG_METHOD_EXIT ();
677 }
678
679 void SubscriptionTable::updateClasses (
680 const CIMObjectPath & subscriptionPath,
681 const CIMInstance & provider,
682 const CIMName & className)
683 {
684 PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
685 "SubscriptionTable::updateClasses");
686
687 String activeSubscriptionsKey = _generateActiveSubscriptionsKey
688 (subscriptionPath);
689 ActiveSubscriptionsTableEntry tableValue;
690
691 if (getSubscriptionEntry (subscriptionPath, tableValue))
692 {
693 kumpf 1.1 Uint32 providerIndex = providerInList (provider, tableValue);
694 if (providerIndex != PEG_NOT_FOUND)
695 {
696 Uint32 classIndex = classInList (className,
697 tableValue.providers [providerIndex]);
698 if (classIndex == PEG_NOT_FOUND)
699 {
700 tableValue.providers [providerIndex].classList.append
701 (className);
702 }
703 else // classIndex != PEG_NOT_FOUND
704 {
705 tableValue.providers [providerIndex].classList.remove
706 (classIndex);
707 }
708 }
709 else
710 {
711 PEG_TRACE_STRING (TRC_INDICATION_SERVICE_INTERNAL, Tracer::LEVEL2,
712 "Provider (" + provider.getPath ().toString () +
713 ") not found in list for Subscription (" +
714 kumpf 1.1 activeSubscriptionsKey +
715 ") in ActiveSubscriptionsTable");
716 }
717 }
718 else
719 {
720 //
721 // Subscription not found in Active Subscriptions table
722 //
723 }
724
725 {
726 WriteLock lock (_activeSubscriptionsTableLock);
727 _removeActiveSubscriptionsEntry (activeSubscriptionsKey);
728 _insertActiveSubscriptionsEntry (tableValue.subscription,
729 tableValue.providers);
730 }
731
732 PEG_METHOD_EXIT ();
733 }
734
|
735 carolann.graves 1.6 void SubscriptionTable::removeSubscription (
|
736 kumpf 1.1 const CIMInstance & subscription,
737 const Array <CIMName> & indicationSubclassNames,
738 const CIMNamespaceName & sourceNamespaceName,
739 const Array <ProviderClassList> & providers)
740 {
741 PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
742 "SubscriptionTable::removeSubscription");
743
744 //
745 // Remove entry from active subscriptions table
746 //
747 {
748 WriteLock lock(_activeSubscriptionsTableLock);
749
750 _removeActiveSubscriptionsEntry (
751 _generateActiveSubscriptionsKey (subscription.getPath ()));
752 }
753
754 //
755 // Remove or update entries in subscription classes table
756 //
757 kumpf 1.1 for (Uint32 i = 0; i < indicationSubclassNames.size (); i++)
758 {
759 String subscriptionClassesKey = _generateSubscriptionClassesKey
760 (indicationSubclassNames [i], sourceNamespaceName);
761 SubscriptionClassesTableEntry tableValue;
762 if (_lockedLookupSubscriptionClassesEntry (subscriptionClassesKey,
763 tableValue))
764 {
765 //
766 // If entry exists for this IndicationClassName-SourceNamespace
767 // pair, remove subscription from the list
768 //
769 Array <CIMInstance> subscriptions = tableValue.subscriptions;
770 for (Uint32 j = 0; j < subscriptions.size (); j++)
771 {
772 if (subscriptions [j].getPath().identical
773 (subscription.getPath()))
774 {
775 subscriptions.remove (j);
776 }
777 }
778 kumpf 1.1
779 //
780 // Remove the old entry
781 //
782 _lockedRemoveSubscriptionClassesEntry (subscriptionClassesKey);
783
784 //
785 // If there are still subscriptions in the list, insert the
786 // new entry
787 //
788 if (subscriptions.size () > 0)
789 {
790 _lockedInsertSubscriptionClassesEntry (
791 indicationSubclassNames [i],
792 sourceNamespaceName, subscriptions);
793 }
794 }
795 else
796 {
797 //
798 // Entry not found in Subscription Classes table
799 kumpf 1.1 //
800 PEG_TRACE_STRING (TRC_INDICATION_SERVICE_INTERNAL, Tracer::LEVEL2,
801 "Indication subclass and namespace (" + subscriptionClassesKey +
802 ") not found in SubscriptionClassesTable");
803 }
804 }
805
806 PEG_METHOD_EXIT ();
807 }
808
809 Uint32 SubscriptionTable::providerInList
810 (const CIMInstance & provider,
811 const ActiveSubscriptionsTableEntry & tableValue) const
812 {
813 PEG_METHOD_ENTER (TRC_INDICATION_SERVICE,
814 "SubscriptionTable::providerInList");
815
816 CIMClass providerClass = _subscriptionRepository->getClass
817 (PEGASUS_NAMESPACENAME_INTEROP, PEGASUS_CLASSNAME_PROVIDER);
818
819 //
820 kumpf 1.1 // Look for the provider in the list
821 //
822 for (Uint32 i = 0; i < tableValue.providers.size (); i++)
823 {
824 if (tableValue.providers [i].provider.getPath ().identical
825 (provider.getPath ()))
826 {
|
827 gs.keenan 1.4 PEG_METHOD_EXIT ();
|
828 kumpf 1.1 return i;
829 }
830 }
831
|
832 gs.keenan 1.4 PEG_METHOD_EXIT ();
|
833 kumpf 1.1 return PEG_NOT_FOUND;
834 }
835
836
837 Uint32 SubscriptionTable::classInList
838 (const CIMName & className,
839 const ProviderClassList & providerClasses) const
840 {
841 PEG_METHOD_ENTER (TRC_INDICATION_SERVICE, "SubscriptionTable::classInList");
842
843 //
844 // Look for the class in the list
845 //
846 for (Uint32 i = 0; i < providerClasses.classList.size (); i++)
847 {
848 if (providerClasses.classList [i].equal (className))
849 {
|
850 gs.keenan 1.4 PEG_METHOD_EXIT ();
|
851 kumpf 1.1 return i;
852 }
853 }
854
|
855 gs.keenan 1.4 PEG_METHOD_EXIT ();
|
856 kumpf 1.1 return PEG_NOT_FOUND;
857 }
858
|
859 kumpf 1.2 void SubscriptionTable::clear ()
860 {
861 PEG_METHOD_ENTER (TRC_INDICATION_SERVICE, "SubscriptionTable::clear");
862
863 {
864 WriteLock lock (_activeSubscriptionsTableLock);
865 _activeSubscriptionsTable.clear ();
866 }
867 {
868 WriteLock lock (_subscriptionClassesTableLock);
869 _subscriptionClassesTable.clear ();
870 }
871
872 PEG_METHOD_EXIT ();
873 }
874
|
875 kumpf 1.1 PEGASUS_NAMESPACE_END
|