1 //%2005////////////////////////////////////////////////////////////////////////
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 // IBM Corp.; EMC Corporation, The Open Group.
7 // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
8 // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
9 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
10 // EMC Corporation; VERITAS Software Corporation; The Open Group.
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:
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.
28 //==============================================================================
30 // Author: Heather Sterling (hsterl@us.ibm.com)
34 //%/////////////////////////////////////////////////////////////////////////////
36 #ifndef Pegasus_ConsumerManager_h
37 #define Pegasus_ConsumerManager_h
39 #include <Pegasus/Common/Config.h>
40 #include <Pegasus/Common/HashTable.h>
41 #include <Pegasus/Common/OptionManager.h>
42 #include <Pegasus/Common/ArrayInternal.h>
43 #include <Pegasus/Common/CIMInstance.h>
44 #include <Pegasus/Consumer/CIMIndicationConsumer.h>
45 #include <Pegasus/Common/System.h>
46 #include <Pegasus/DynListener/Linkage.h>
48 #include "ConsumerModule.h"
49 #include "DynamicConsumer.h"
51 PEGASUS_NAMESPACE_BEGIN
53 /** The ConsumerManager class is responsible for managing all of the consumers. It is also responsible for
54 * synchronizing consumer operations.
57 class PEGASUS_DYNLISTENER_LINKAGE ConsumerManager
61 ConsumerManager(const String& consumerDir, const String& consumerConfigDir, Boolean enableConsumerUnload, Uint32 idleTimeout);
63 virtual ~ConsumerManager();
65 String getConsumerDir();
67 String getConsumerConfigDir();
69 Boolean getEnableConsumerUnload();
71 Uint32 getIdleTimeout();
73 Boolean hasLoadedConsumers();
75 Boolean hasActiveConsumers();
77 DynamicConsumer* getConsumer(const String& consumerName);
79 void unloadConsumer(const String& consumerName);
81 void unloadAllConsumers();
83 void unloadIdleConsumers();
87 typedef HashTable<String, DynamicConsumer *, EqualFunc<String>, HashFunc<String> > ConsumerTable;
89 typedef HashTable<String, ConsumerModule *, EqualFunc<String>, HashFunc<String> > ModuleTable;
92 ConsumerTable _consumers;
93 Mutex _consumerTableMutex;
95 //consumer module queue
97 Mutex _moduleTableMutex;
101 String _consumerConfigDir;
102 Boolean _enableConsumerUnload;
103 Uint32 _idleTimeout; //ms
104 Boolean _forceShutdown;
106 //ATTN: Bugzilla 3765 - Uncomment when OptionManager has a reset capability
107 //OptionManager _optionMgr;
110 ThreadPool* _thread_pool;
113 static PEGASUS_THREAD_RETURN PEGASUS_THREAD_CDECL _worker_routine(void *param);
118 ConsumerModule* _lookupModule(const String & moduleFileName);
120 String _getConsumerLibraryName(const String & consumerName);
122 void _initConsumer(const String& consumerName, DynamicConsumer* consumer);
124 void _unloadConsumers(Array<DynamicConsumer*> consumersToUnload);
128 Array<IndicationDispatchEvent> _deserializeOutstandingIndications(const String& consumerName);
130 void _serializeOutstandingIndications(const String& consumerName, Array<IndicationDispatchEvent> indications);
134 PEGASUS_NAMESPACE_END
136 #endif /* Pegasus_ConsumerManager_h */