(file) Return to CMPIProvider.h CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / ProviderManager2 / CMPI

  1 karl  1.12 //%2006////////////////////////////////////////////////////////////////////////
  2 schuur 1.1  //
  3 karl   1.6  // 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 karl   1.7  // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
 10             // EMC Corporation; VERITAS Software Corporation; The Open Group.
 11 karl   1.12 // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;
 12             // EMC Corporation; Symantec Corporation; The Open Group.
 13 schuur 1.1  //
 14             // Permission is hereby granted, free of charge, to any person obtaining a copy
 15             // of this software and associated documentation files (the "Software"), to
 16             // deal in the Software without restriction, including without limitation the
 17             // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
 18             // sell copies of the Software, and to permit persons to whom the Software is
 19             // furnished to do so, subject to the following conditions:
 20 karl   1.6  // 
 21 schuur 1.1  // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
 22             // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
 23             // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
 24             // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
 25             // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 26             // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
 27 karl   1.6  // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 28 schuur 1.1  // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 29             //
 30             //==============================================================================
 31             //
 32             // Author: Chip Vincent (cvincent@us.ibm.com)
 33             //
 34             // Modified By: Yi Zhou, Hewlett-Packard Company(yi_zhou@hp.com)
 35             //              Mike Day, IBM (mdday@us.ibm.com)
 36             //              Adrian Schuur, schuur@de.ibm.com
 37 dj.gorey 1.3  //              Dan Gorey, IBM djgorey@us.ibm.com
 38 schuur   1.1  //
 39               //%/////////////////////////////////////////////////////////////////////////////
 40               
 41               #ifndef Pegasus_CMPIProvider_h
 42               #define Pegasus_CMPIProvider_h
 43               
 44               #include "CMPI_Object.h"
 45               #include "CMPI_Broker.h"
 46 konrad.r 1.9  #include "CMPI_Version.h"
 47 schuur   1.1  #include <Pegasus/Common/Config.h>
 48               #include <Pegasus/Common/IPC.h>
 49 konrad.r 1.11 #include <Pegasus/Common/Thread.h>
 50 mike     1.13 #include <Pegasus/Common/List.h>
 51               #include <Pegasus/Common/RecursiveMutex.h>
 52 konrad.r 1.11 #include <Pegasus/Provider/CIMOMHandle.h>
 53 schuur   1.1  #include <Pegasus/Provider/CIMOMHandle.h>
 54               #include <Pegasus/Provider/CIMInstanceProvider.h>
 55               #include <Pegasus/Provider/CIMAssociationProvider.h>
 56               #include <Pegasus/Provider/CIMMethodProvider.h>
 57               #include <Pegasus/ProviderManager2/CMPI/CMPIResolverModule.h>
 58               
 59 schuur   1.4  #include <Pegasus/ProviderManager2/CMPI/Linkage.h>
 60 schuur   1.1  
 61               PEGASUS_NAMESPACE_BEGIN
 62               
 63               class CMPIProviderModule;
 64               class CMPIResolverModule;
 65               
 66 konrad.r 1.11 #ifndef _CMPI_Broker_H_
 67               struct CMPI_Broker;
 68               #endif
 69               
 70 schuur   1.1  #define CMPI_MIType_Instance    1
 71               #define CMPI_MIType_Association 2
 72               #define CMPI_MIType_Method      4
 73               #define CMPI_MIType_Property    8
 74               #define CMPI_MIType_Indication 16
 75               
 76 konrad.r 1.9  /* Ver 1.00 CMPI spec - which added a new parameter. */
 77               #ifdef CMPI_VER_100
 78               
 79               typedef CMPIInstanceMI* 	(*CREATE_INST_MI)(const CMPIBroker*,const CMPIContext*,  CMPIStatus *rc);
 80               typedef CMPIAssociationMI* 	(*CREATE_ASSOC_MI)(const CMPIBroker*,const CMPIContext*,  CMPIStatus *rc);
 81               typedef CMPIMethodMI* 		(*CREATE_METH_MI)(const CMPIBroker*,const CMPIContext*,  CMPIStatus *rc);
 82               typedef CMPIPropertyMI* 	(*CREATE_PROP_MI)(const CMPIBroker*,const CMPIContext*,  CMPIStatus *rc);
 83               typedef CMPIIndicationMI* 	(*CREATE_IND_MI)(const CMPIBroker*,const CMPIContext*,  CMPIStatus *rc);
 84               
 85               typedef CMPIInstanceMI*    (*CREATE_GEN_INST_MI)(const CMPIBroker*,const CMPIContext*,const char*,  CMPIStatus *rc);
 86               typedef CMPIAssociationMI* (*CREATE_GEN_ASSOC_MI)(const CMPIBroker*,const CMPIContext*,const char*, CMPIStatus *rc);
 87               typedef CMPIMethodMI* 	    (*CREATE_GEN_METH_MI)(const CMPIBroker*,const CMPIContext*,const char*, CMPIStatus *rc);
 88               typedef CMPIPropertyMI*    (*CREATE_GEN_PROP_MI)(const CMPIBroker*,const CMPIContext*,const char*, CMPIStatus *rc);
 89               typedef CMPIIndicationMI*  (*CREATE_GEN_IND_MI)(const CMPIBroker*,const CMPIContext*,const char*,  CMPIStatus *rc);
 90 schuur   1.1  
 91 konrad.r 1.9  #else
 92 schuur   1.1  typedef CMPIInstanceMI* 	(*CREATE_INST_MI)(CMPIBroker*,CMPIContext*);
 93               typedef CMPIAssociationMI* 	(*CREATE_ASSOC_MI)(CMPIBroker*,CMPIContext*);
 94               typedef CMPIMethodMI* 		(*CREATE_METH_MI)(CMPIBroker*,CMPIContext*);
 95               typedef CMPIPropertyMI* 	(*CREATE_PROP_MI)(CMPIBroker*,CMPIContext*);
 96               typedef CMPIIndicationMI* 	(*CREATE_IND_MI)(CMPIBroker*,CMPIContext*);
 97               
 98               typedef CMPIInstanceMI*    (*CREATE_GEN_INST_MI)(CMPIBroker*,CMPIContext*,const char*);
 99               typedef CMPIAssociationMI* (*CREATE_GEN_ASSOC_MI)(CMPIBroker*,CMPIContext*,const char*);
100               typedef CMPIMethodMI* 	    (*CREATE_GEN_METH_MI)(CMPIBroker*,CMPIContext*,const char*);
101               typedef CMPIPropertyMI*    (*CREATE_GEN_PROP_MI)(CMPIBroker*,CMPIContext*,const char*);
102               typedef CMPIIndicationMI*  (*CREATE_GEN_IND_MI)(CMPIBroker*,CMPIContext*,const char*);
103 konrad.r 1.9  #endif
104 schuur   1.1  
105 konrad.r 1.10 #define _Generic_Create_InstanceMI "_Generic_Create_InstanceMI"
106               #define _Generic_Create_AssociationMI "_Generic_Create_AssociationMI"
107               #define _Generic_Create_MethodMI "_Generic_Create_MethodMI"
108               #define _Generic_Create_PropertyMI "_Generic_Create_PropertyMI"
109               #define _Generic_Create_IndicationMI "_Generic_Create_IndicationMI"
110               
111               #define _Create_InstanceMI "_Create_InstanceMI"
112               #define _Create_AssociationMI "_Create_AssociationMI"
113               #define _Create_MethodMI "_Create_MethodMI"
114               #define _Create_PropertyMI "_Create_PropertyMI"
115               #define _Create_IndicationMI "_Create_IndicationMI"
116               
117 schuur   1.1  struct ProviderVector {
118                  int			miTypes;
119                  int			genericMode;
120                  CMPIInstanceMI 	*instMI;
121                  CMPIAssociationMI 	*assocMI;
122                  CMPIMethodMI 	*methMI;
123                  CMPIPropertyMI 	*propMI;
124                  CMPIIndicationMI 	*indMI;
125                  CREATE_INST_MI 	createInstMI;
126                  CREATE_ASSOC_MI 	createAssocMI;
127                  CREATE_METH_MI 	createMethMI;
128                  CREATE_PROP_MI 	createPropMI;
129                  CREATE_IND_MI 	createIndMI;
130                  CREATE_GEN_INST_MI 	createGenInstMI;
131                  CREATE_GEN_ASSOC_MI 	createGenAssocMI;
132                  CREATE_GEN_METH_MI 	createGenMethMI;
133                  CREATE_GEN_PROP_MI 	createGenPropMI;
134                  CREATE_GEN_IND_MI 	createGenIndMI;
135               };
136               
137               // The CMPIProvider class represents the logical provider extracted from a
138 schuur   1.1  // provider module. It is wrapped in a facade to stabalize the interface
139               // and is directly tied to a module.
140               
141 schuur   1.4  class PEGASUS_CMPIPM_LINKAGE CMPIProvider :
142 schuur   1.1                         public virtual CIMProvider
143               {
144               public:
145               
146                   enum Status
147                   {
148 dj.gorey 1.3          UNINITIALIZED,
149                       INITIALIZED
150 schuur   1.1      };
151               
152               public:
153               
154               
155                   class pm_service_op_lock {
156                   private:
157                      pm_service_op_lock(void);
158                   public:
159                      pm_service_op_lock(CMPIProvider *provider) : _provider(provider)
160                         { _provider->protect(); }
161                      ~pm_service_op_lock(void)
162                         { _provider->unprotect(); }
163                      CMPIProvider * _provider;
164                   };
165               
166                //  typedef CMPIProviderFacade Base;
167               
168                   CMPIProvider(CMPIProvider*);
169               
170                   virtual ~CMPIProvider(void);
171 schuur   1.1  
172                   virtual void initialize(CIMOMHandle & cimom);
173 konrad.r 1.9  
174 schuur   1.5      void setLocation(String loc) { _location=loc; }
175 schuur   1.1  
176                   virtual Boolean tryTerminate(void);
177                   virtual void terminate(void);
178               
179 dj.gorey 1.3      Status getStatus(void);
180 schuur   1.1      String getName(void) const;
181                   void setResolver(CMPIResolverModule *rm) { _rm=rm; }
182               
183 dj.gorey 1.3      void reset();
184               
185 konrad.r 1.11     // Monitors threads that the provider has allocated.
186               
187               	/* 
188                    * Adds the thread to the watch list. The watch list is monitored when the
189                    * provider is terminated and if any of the threads have not cleaned up by
190                    * that time, they are forcifully terminated and cleaned up.
191                    *
192                    * @argument t Thread is not NULL.
193                    */
194                   void addThreadToWatch(Thread *t);
195                 /*
196                 // Removes the thread from the watch list and schedule the CMPILocalProviderManager
197                 // to delete the thread. The CMPILocalProviderManager after deleting the thread calls
198                 // the CMPIProvider' "cleanupThread". The CMPILocalProviderManager notifies this
199                 // CMPIProvider object when the thread is truly dead by calling "threadDeleted" function.
200                 //
201                 // Note that this function is called from the thread that finished with
202                 // running the providers function, and returns immediately while scheduling the
203                 // a cleanup procedure. If you want to wait until the thread is truly deleted,
204                 // call 'waitUntilThreadsDone' - but DO NOT do it in the the thread that
205                 // the Thread owns - you will wait forever.
206 konrad.r 1.11   //
207                 // @argument t Thread that is not NULL and finished with running the provider function.
208                 */
209                   void removeThreadFromWatch(Thread *t);
210               
211               	/*
212                	* Remove the thread from the list of threads that are being deleted
213                	* by the CMPILocalProviderManager.
214                	*
215                	* @argument t Thread which has been previously provided to 'removeThreadFromWatch' function.
216                	*/
217               	void threadDelete(Thread *t);
218               	/*
219                	* Check if the Thread is owner by this CMPIProvider object	.
220                	*
221                	* @argument t Thread that is not NULL.
222                	*/
223               	Boolean isThreadOwner( Thread *t); 
224               
225 schuur   1.1      CMPIProviderModule *getModule(void) const;
226               
227                   virtual void get_idle_timer(struct timeval *);
228                   virtual void update_idle_timer(void);
229                   virtual Boolean pending_operation(void);
230                   virtual Boolean unload_ok(void);
231               
232               //   force provider manager to keep in memory
233                   virtual void protect(void);
234               // allow provider manager to unload when idle
235                   virtual void unprotect(void);
236               
237 carolann.graves 1.8      /**
238                              Increments the count of current subscriptions for this provider, and
239                              determines if there were no current subscriptions before the increment.
240                              If there were no current subscriptions before the increment, the first
241                              subscription has been created, and the provider's enableIndications
242                              method should be called.
243                      
244                              @return  True, if before the increment there were no current
245                                             subscriptions for this provider;
246                                       False, otherwise
247                           */
248                          Boolean testIfZeroAndIncrementSubscriptions ();
249                      
250                          /**
251                              Decrements the count of current subscriptions for this provider, and
252                              determines if there are no current subscriptions after the decrement.
253                              If there are no current subscriptions after the decrement, the last
254                              subscription has been deleted, and the provider's disableIndications
255                              method should be called.
256                      
257                              @return  True, if after the decrement there are no current subscriptions
258 carolann.graves 1.8                         for this provider;
259                                       False, otherwise
260                           */
261                          Boolean decrementSubscriptionsAndTestIfZero ();
262                      
263                          /**
264                              Determines if there are current subscriptions for this provider.
265                      
266                              @return  True, if there is at least one current subscription
267                                             for this provider;
268                                       False, otherwise
269                           */
270                          Boolean testSubscriptions ();
271                      
272                          /**
273                              Resets the count of current subscriptions for the indication provider.
274                           */
275                          void resetSubscriptions ();
276                      
277                          /**
278                              Sets the provider instance for the provider.
279 carolann.graves 1.8  
280                              Note: the provider instance is set only for an indication provider, and
281                              is set when a Create Subscription request is processed for the provider.
282                      
283                              @param  instance  the Provider CIMInstance for the provider
284                           */
285                          void setProviderInstance (const CIMInstance & instance);
286                      
287                          /**
288                              Gets the provider instance for the provider.
289                      
290                              Note: the provider instance is set only for an indication provider, and
291                              only if a Create Subscription request has been processed for the
292                              provider.
293                      
294                              @return  the Provider CIMInstance for the provider
295                           */
296                          CIMInstance getProviderInstance ();
297                      
298 schuur          1.1  protected:
299 schuur          1.5      String _location;
300 schuur          1.1      Status _status;
301                          CMPIProviderModule *_module;
302                          ProviderVector miVector;
303                          CMPI_Broker broker;
304                          Boolean noUnload;
305                      
306                      private:
307 konrad.r        1.9      virtual void _terminate(Boolean term);
308                          CMPIProvider(const String & name,
309                              CMPIProviderModule *module,
310                              ProviderVector *mv);
311                      
312                          static void initialize(CIMOMHandle & cimom,
313                                                 ProviderVector & miVector,
314 konrad.r        1.11 			   			   String & name,
315 konrad.r        1.9                             CMPI_Broker & broker);
316 konrad.r        1.11 	
317                         /*
318                       	* Wait until all finished provider threads have been cleaned and deleted.
319                       	* Note: This should NEVER be called from the thread that IS the Thread object that was
320                       	* is finished and called 'removeThreadFromWatch()' . If you do it, you will
321                       	* wait forever.
322                       	*/
323                          void waitUntilThreadsDone();
324 konrad.r        1.9  
325                          void set(CMPIProviderModule *&module,
326                                  ProviderVector base,
327                                  CIMOMHandle *&cimomHandle);
328 konrad.r        1.11 
329 schuur          1.1      friend class CMPILocalProviderManager;
330                          friend class CMPIProviderManager;
331                          friend class ProviderManagerService;
332 kumpf           1.2      class OpProviderHolder;
333                          friend class OpProviderHolder;
334 schuur          1.1      CIMOMHandle *_cimom_handle;
335                          String _name;
336                          AtomicInt _no_unload;
337                          CMPIResolverModule *_rm;
338                          Uint32 _quantum;
339                          AtomicInt _current_operations;
340 dj.gorey        1.3      Mutex _statusMutex;
341 carolann.graves 1.8  
342 konrad.r        1.11 	/*
343                       		List of threads which are monitored and cleaned.
344                       	*/
345 mike            1.13     List<Thread,RecursiveMutex> _threadWatchList;
346                          List<Thread,RecursiveMutex> _cleanedThreads;
347 konrad.r        1.11 
348                      
349 carolann.graves 1.8      /**
350                              Count of current subscriptions for this provider.  Access to this
351                              data member is controlled by the _currentSubscriptionsLock.
352                           */
353                          Uint32 _currentSubscriptions;
354                      
355                          /**
356                              A mutex to control access to the _currentSubscriptions member variable.
357                              Before any access (test, increment, decrement or reset) of the
358                              _currentSubscriptions member variable, the _currentSubscriptionsMutex is
359                              first locked.
360                           */
361                          Mutex _currentSubscriptionsMutex;
362                      
363                          /**
364                              The Provider CIMInstance for the provider.
365                              The Provider CIMInstance is set only for indication providers, and only
366                              if a Create Subscription request has been processed for the provider.
367                              The Provider CIMInstance is needed in order to construct the
368                              EnableIndicationsResponseHandler to send to the indication provider
369                              when the provider's enableIndications() method is called.
370 carolann.graves 1.8          The Provider CIMInstance is needed in the
371                              EnableIndicationsResponseHandler in order to construct the Process
372                              Indication request when an indication is delivered by the provider.
373                              The Provider CIMInstance is needed in the Process Indication request
374                              to enable the Indication Service to determine if the provider that
375                              generated the indication accepted a matching subscription.
376                           */
377                          CIMInstance _providerInstance;
378 schuur          1.1  //};
379                      
380                      
381                      //
382                      // Used to encapsulate the incrementing/decrementing of the _current_operations
383                      // for a CMPIProvider so it won't be unloaded during operations.
384                      //
385                      
386                         class OpProviderHolder
387                         {
388                         private:
389                             CMPIProvider* _provider;
390                      
391                         public:
392                             OpProviderHolder(): _provider( NULL )
393                             {
394                             }
395                             OpProviderHolder( const OpProviderHolder& p ): _provider( NULL )
396                             {
397                                 SetProvider( p._provider );
398                             }
399 schuur          1.1         OpProviderHolder( CMPIProvider* p ): _provider( NULL )
400                             {
401                                 SetProvider( p );
402                             }
403                             ~OpProviderHolder()
404                             {
405                                 UnSetProvider();
406                             }
407                             CMPIProvider& GetProvider()
408                             {
409                                 return(*_provider);
410                             }
411                      
412                             OpProviderHolder& operator=( const OpProviderHolder& x )
413                             {
414                                 if(this == &x)
415                                     return(*this);
416                                 SetProvider( x._provider );
417                      
418                                 return(*this);
419                             }
420 schuur          1.1  
421                             void SetProvider( CMPIProvider* p )
422                             {
423                                 UnSetProvider();
424                                 if(p)
425                                 {
426                                     _provider = p;
427                                     _provider->_current_operations++;
428                                 }
429                             }
430                      
431                             void UnSetProvider()
432                             {
433                                 if(_provider)
434                                 {
435                                     _provider->_current_operations--;
436                                     _provider = NULL;
437                                 }
438                             }
439                         };
440                      };
441 schuur          1.1  
442                      PEGASUS_NAMESPACE_END
443                      
444                      #endif

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2