(file) Return to Provider.h CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / ProviderManager

  1 karl  1.21 //%2004////////////////////////////////////////////////////////////////////////
  2 chip  1.1  //
  3 karl  1.21 // 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 karl  1.19 // IBM Corp.; EMC Corporation, The Open Group.
  7 karl  1.21 // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
  8            // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
  9 chip  1.1  //
 10            // Permission is hereby granted, free of charge, to any person obtaining a copy
 11            // of this software and associated documentation files (the "Software"), to
 12            // deal in the Software without restriction, including without limitation the
 13            // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
 14            // sell copies of the Software, and to permit persons to whom the Software is
 15            // furnished to do so, subject to the following conditions:
 16 karl  1.19 // 
 17 chip  1.1  // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
 18            // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
 19            // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
 20            // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
 21            // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 22            // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
 23            // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 24            // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 25            //
 26            //==============================================================================
 27            //
 28            // Author: Chip Vincent (cvincent@us.ibm.com)
 29            //
 30 kumpf 1.3  // Modified By: Yi Zhou, Hewlett-Packard Company(yi_zhou@hp.com)
 31 mday  1.12 //              Mike Day, IBM (mdday@us.ibm.com)
 32 kumpf 1.18 //              Jenny Yu, Hewlett-Packard Company (jenny_yu@hp.com)
 33 a.arora 1.20 //              Amit K Arora, IBM (amita@in.ibm.com) for PEP101
 34 chip    1.1  //
 35              //%/////////////////////////////////////////////////////////////////////////////
 36              
 37              #ifndef Pegasus_Provider_h
 38              #define Pegasus_Provider_h
 39              
 40              #include <Pegasus/Common/Config.h>
 41 kumpf   1.17 #include <Pegasus/Common/IPC.h>
 42 mday    1.12 #include <Pegasus/Provider/CIMOMHandle.h>
 43 chip    1.1  #include <Pegasus/ProviderManager/ProviderModule.h>
 44              #include <Pegasus/ProviderManager/ProviderFacade.h>
 45 kumpf   1.11 #include <Pegasus/Server/Linkage.h>
 46 chip    1.1  
 47              PEGASUS_NAMESPACE_BEGIN
 48              
 49 kumpf   1.18 /**
 50                 The Provider class represents the logical provider extracted from a
 51                 provider module. It is wrapped in a facade to stabalize the interface
 52                 and is directly tied to a module.
 53                
 54                 A provider's status is either INITIALIZED or UNITIALIZED.
 55                 
 56                 A provider's status is set to UNINITIALZED when it is created by the
 57                 ProviderManager and has not yet been loaded/initialized.  Its status 
 58                 is also set to UNINITIALIZED after the provider has been terminated/unloaded.
 59                
 60                 A provider's status is set to INITIALIZED after it has been successfully
 61                 loaded and initialized.
 62                
 63                 To prevent multiple threads from attempting to load/initialize/terminate
 64                 the same provider at the same time, a mutex is used to synchronize access
 65                 to the status of a provider.  This mutex MUST be locked before any
 66                 attempt to change the status of a provider.
 67              */
 68                
 69 chip    1.1  class PEGASUS_SERVER_LINKAGE Provider : public ProviderFacade
 70              {
 71              public:
 72 chip    1.7      enum Status {
 73 kumpf   1.18 	UNINITIALIZED,
 74              	INITIALIZED
 75 chip    1.7      };
 76              
 77              public:
 78 mday    1.12     typedef ProviderFacade Base;
 79 chip    1.16 
 80 mday    1.12     Provider(const String & name,
 81              	     ProviderModule *module,
 82              	     CIMProvider *pr);
 83 chip    1.16 
 84 chip    1.2      virtual ~Provider(void);
 85 chip    1.1  
 86 kumpf   1.18     /**
 87                     Initializes the provider.
 88                     Caller must lock the _statusMutex before calling this method.
 89                  */
 90                    
 91 chip    1.2      virtual void initialize(CIMOMHandle & cimom);
 92 kumpf   1.18 
 93                  /**
 94                     Terminates the provider.
 95                     Caller must lock the _statusMutex before calling this method.
 96                  */
 97 mday    1.14     virtual Boolean tryTerminate(void);
 98 chip    1.16 
 99 kumpf   1.18     /**
100                     Terminates the provider.
101                     Caller must lock the _statusMutex before calling this method.
102                  */
103 chip    1.2      virtual void terminate(void);
104 chip    1.1  
105 kumpf   1.18     Status getStatus(void);
106 chip    1.2      String getName(void) const;
107 kumpf   1.9  
108 mday    1.12     ProviderModule *getModule(void) const;
109 chip    1.16 
110 kumpf   1.18     /**
111                     Sets the provider module, CIMProvider and CIMOM handle 
112                  */
113                  void set(ProviderModule *module, 
114                           CIMProvider *base, 
115                           CIMOMHandle *cimomHandle);
116              
117                  /**
118                     Resets the provider after termination.  
119                     Caller must lock the _statusMutex before calling this method.
120                  */
121                  void reset();
122              
123 mday    1.12       // << Mon Oct 14 15:42:24 2002 mdd >> for use with DQueue template
124 chip    1.16       // to allow conversion from using Array<>
125 mday    1.12       Boolean operator == (const void *key) const;
126                    Boolean operator == (const Provider & prov) const;
127              
128                    virtual void get_idle_timer(struct timeval *);
129                    virtual void update_idle_timer(void);
130                    virtual Boolean pending_operation(void);
131                    virtual Boolean unload_ok(void);
132              
133              //   force provider manager to keep in memory
134                    virtual void protect(void);
135 chip    1.16 // allow provider manager to unload when idle
136 mday    1.12       virtual void unprotect(void);
137              
138                 protected:
139                    Status _status;
140                    ProviderModule *_module;
141                 private:
142                    friend class ProviderManager;
143                    friend class ProviderManagerService;
144 konrad.r 1.15       friend class OpProviderHolder;
145 mday     1.12       CIMOMHandle *_cimom_handle;
146                     String _name;
147 mday     1.14       AtomicInt _no_unload;
148                     Uint32 _quantum;
149 kumpf    1.18 
150                     /**
151                        A mutex to synchronize access to the status of a provider.
152                        In order to prevent deadlocks, one should never attempt to 
153                        lock the ProviderTable mutex kept by the ProviderManager
154                        while holding a Provider's _statusMutex.
155                     */
156                     Mutex  _statusMutex;
157 konrad.r 1.15 };
158               
159               
160               //
161               // Used to encapsulate the incrementing/decrementing of the _current_operations
162               // for a Provider so it won't be unloaded during operations.
163               //
164               
165               class OpProviderHolder
166               {
167               private:
168 a.arora  1.20 	AutoPtr<Provider> _provider; //PEP101
169 konrad.r 1.15 
170               public:
171               	OpProviderHolder(): _provider( NULL )
172               	{
173               	}
174               	OpProviderHolder( const OpProviderHolder& p ): _provider( NULL )
175               	{
176 a.arora  1.20 		SetProvider( p._provider.get() );
177 konrad.r 1.15 	}
178               	OpProviderHolder( Provider* p ): _provider( NULL )
179               	{
180               		SetProvider( p );
181               	}
182               	~OpProviderHolder()
183               	{
184               		UnSetProvider();
185               	}
186               
187 a.arora  1.20 	Provider& GetProvider() { return *_provider.get(); }
188 konrad.r 1.15 
189               	OpProviderHolder& operator=( const OpProviderHolder& x )
190               	{
191               		if( this == &x )
192               			return *this;
193 a.arora  1.20 		SetProvider( x._provider.get() );
194 chip     1.16 
195                       return(*this);
196 konrad.r 1.15 	}
197               
198               	void SetProvider( Provider* p )
199               	{
200               		UnSetProvider();
201               		if( p )
202               		{
203 a.arora  1.20             _provider.release();
204               			_provider.reset(p);
205 konrad.r 1.15 			_provider->_current_operations++;
206               		}
207               	}
208               
209               	void UnSetProvider()
210               	{
211 a.arora  1.20 		if( _provider.get() )
212 konrad.r 1.15 		{
213               			_provider->_current_operations--;
214 a.arora  1.20 			_provider.release();
215 konrad.r 1.15 		}
216               	}
217 chip     1.1  };
218               
219               PEGASUS_NAMESPACE_END
220               
221               #endif

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2