(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.12.12.1 #include <Pegasus/Common/List.h>
 51                    #include <Pegasus/Common/RMutex.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                        Boolean operator == (const void *key) const;
228                        Boolean operator == (const CMPIProvider & prov) const;
229                    
230                        virtual void get_idle_timer(struct timeval *);
231                        virtual void update_idle_timer(void);
232                        virtual Boolean pending_operation(void);
233                        virtual Boolean unload_ok(void);
234                    
235                    //   force provider manager to keep in memory
236                        virtual void protect(void);
237                    // allow provider manager to unload when idle
238                        virtual void unprotect(void);
239                    
240 carolann.graves 1.8           /**
241                                   Increments the count of current subscriptions for this provider, and
242                                   determines if there were no current subscriptions before the increment.
243                                   If there were no current subscriptions before the increment, the first
244                                   subscription has been created, and the provider's enableIndications
245                                   method should be called.
246                           
247                                   @return  True, if before the increment there were no current
248                                                  subscriptions for this provider;
249                                            False, otherwise
250                                */
251                               Boolean testIfZeroAndIncrementSubscriptions ();
252                           
253                               /**
254                                   Decrements the count of current subscriptions for this provider, and
255                                   determines if there are no current subscriptions after the decrement.
256                                   If there are no current subscriptions after the decrement, the last
257                                   subscription has been deleted, and the provider's disableIndications
258                                   method should be called.
259                           
260                                   @return  True, if after the decrement there are no current subscriptions
261 carolann.graves 1.8                              for this provider;
262                                            False, otherwise
263                                */
264                               Boolean decrementSubscriptionsAndTestIfZero ();
265                           
266                               /**
267                                   Determines if there are current subscriptions for this provider.
268                           
269                                   @return  True, if there is at least one current subscription
270                                                  for this provider;
271                                            False, otherwise
272                                */
273                               Boolean testSubscriptions ();
274                           
275                               /**
276                                   Resets the count of current subscriptions for the indication provider.
277                                */
278                               void resetSubscriptions ();
279                           
280                               /**
281                                   Sets the provider instance for the provider.
282 carolann.graves 1.8       
283                                   Note: the provider instance is set only for an indication provider, and
284                                   is set when a Create Subscription request is processed for the provider.
285                           
286                                   @param  instance  the Provider CIMInstance for the provider
287                                */
288                               void setProviderInstance (const CIMInstance & instance);
289                           
290                               /**
291                                   Gets the provider instance for the provider.
292                           
293                                   Note: the provider instance is set only for an indication provider, and
294                                   only if a Create Subscription request has been processed for the
295                                   provider.
296                           
297                                   @return  the Provider CIMInstance for the provider
298                                */
299                               CIMInstance getProviderInstance ();
300                           
301 schuur          1.1       protected:
302 schuur          1.5           String _location;
303 schuur          1.1           Status _status;
304                               CMPIProviderModule *_module;
305                               ProviderVector miVector;
306                               CMPI_Broker broker;
307                               Boolean noUnload;
308                           
309                           private:
310 konrad.r        1.9           virtual void _terminate(Boolean term);
311                               CMPIProvider(const String & name,
312                                   CMPIProviderModule *module,
313                                   ProviderVector *mv);
314                           
315                               static void initialize(CIMOMHandle & cimom,
316                                                      ProviderVector & miVector,
317 konrad.r        1.11      			   			   String & name,
318 konrad.r        1.9                                  CMPI_Broker & broker);
319 konrad.r        1.11      	
320                              /*
321                            	* Wait until all finished provider threads have been cleaned and deleted.
322                            	* Note: This should NEVER be called from the thread that IS the Thread object that was
323                            	* is finished and called 'removeThreadFromWatch()' . If you do it, you will
324                            	* wait forever.
325                            	*/
326                               void waitUntilThreadsDone();
327 konrad.r        1.9       
328                               void set(CMPIProviderModule *&module,
329                                       ProviderVector base,
330                                       CIMOMHandle *&cimomHandle);
331 konrad.r        1.11      
332 schuur          1.1           friend class CMPILocalProviderManager;
333                               friend class CMPIProviderManager;
334                               friend class ProviderManagerService;
335 kumpf           1.2           class OpProviderHolder;
336                               friend class OpProviderHolder;
337 schuur          1.1           CIMOMHandle *_cimom_handle;
338                               String _name;
339                               AtomicInt _no_unload;
340                               CMPIResolverModule *_rm;
341                               Uint32 _quantum;
342                               AtomicInt _current_operations;
343 dj.gorey        1.3           Mutex _statusMutex;
344 carolann.graves 1.8       
345 konrad.r        1.11      	/*
346                            		List of threads which are monitored and cleaned.
347                            	*/
348 mike            1.12.12.1     List<Thread,RMutex> _threadWatchList;
349                               List<Thread,RMutex> _cleanedThreads;
350 konrad.r        1.11      
351                           
352 carolann.graves 1.8           /**
353                                   Count of current subscriptions for this provider.  Access to this
354                                   data member is controlled by the _currentSubscriptionsLock.
355                                */
356                               Uint32 _currentSubscriptions;
357                           
358                               /**
359                                   A mutex to control access to the _currentSubscriptions member variable.
360                                   Before any access (test, increment, decrement or reset) of the
361                                   _currentSubscriptions member variable, the _currentSubscriptionsMutex is
362                                   first locked.
363                                */
364                               Mutex _currentSubscriptionsMutex;
365                           
366                               /**
367                                   The Provider CIMInstance for the provider.
368                                   The Provider CIMInstance is set only for indication providers, and only
369                                   if a Create Subscription request has been processed for the provider.
370                                   The Provider CIMInstance is needed in order to construct the
371                                   EnableIndicationsResponseHandler to send to the indication provider
372                                   when the provider's enableIndications() method is called.
373 carolann.graves 1.8               The Provider CIMInstance is needed in the
374                                   EnableIndicationsResponseHandler in order to construct the Process
375                                   Indication request when an indication is delivered by the provider.
376                                   The Provider CIMInstance is needed in the Process Indication request
377                                   to enable the Indication Service to determine if the provider that
378                                   generated the indication accepted a matching subscription.
379                                */
380                               CIMInstance _providerInstance;
381 schuur          1.1       //};
382                           
383                           
384                           //
385                           // Used to encapsulate the incrementing/decrementing of the _current_operations
386                           // for a CMPIProvider so it won't be unloaded during operations.
387                           //
388                           
389                              class OpProviderHolder
390                              {
391                              private:
392                                  CMPIProvider* _provider;
393                           
394                              public:
395                                  OpProviderHolder(): _provider( NULL )
396                                  {
397                                  }
398                                  OpProviderHolder( const OpProviderHolder& p ): _provider( NULL )
399                                  {
400                                      SetProvider( p._provider );
401                                  }
402 schuur          1.1              OpProviderHolder( CMPIProvider* p ): _provider( NULL )
403                                  {
404                                      SetProvider( p );
405                                  }
406                                  ~OpProviderHolder()
407                                  {
408                                      UnSetProvider();
409                                  }
410                                  CMPIProvider& GetProvider()
411                                  {
412                                      return(*_provider);
413                                  }
414                           
415                                  OpProviderHolder& operator=( const OpProviderHolder& x )
416                                  {
417                                      if(this == &x)
418                                          return(*this);
419                                      SetProvider( x._provider );
420                           
421                                      return(*this);
422                                  }
423 schuur          1.1       
424                                  void SetProvider( CMPIProvider* p )
425                                  {
426                                      UnSetProvider();
427                                      if(p)
428                                      {
429                                          _provider = p;
430                                          _provider->_current_operations++;
431                                      }
432                                  }
433                           
434                                  void UnSetProvider()
435                                  {
436                                      if(_provider)
437                                      {
438                                          _provider->_current_operations--;
439                                          _provider = NULL;
440                                      }
441                                  }
442                              };
443                           };
444 schuur          1.1       
445                           PEGASUS_NAMESPACE_END
446                           
447                           #endif

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2