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

  1 karl  1.1.2.1 //%LICENSE////////////////////////////////////////////////////////////////
  2               //
  3               // Licensed to The Open Group (TOG) under one or more contributor license
  4               // agreements.  Refer to the OpenPegasusNOTICE.txt file distributed with
  5               // this work for additional information regarding copyright ownership.
  6               // Each contributor licenses this file to you under the OpenPegasus Open
  7               // Source License; you may not use this file except in compliance with the
  8               // License.
  9               //
 10               // Permission is hereby granted, free of charge, to any person obtaining a
 11               // copy of this software and associated documentation files (the "Software"),
 12               // to deal in the Software without restriction, including without limitation
 13               // the rights to use, copy, modify, merge, publish, distribute, sublicense,
 14               // and/or sell copies of the Software, and to permit persons to whom the
 15               // Software is furnished to do so, subject to the following conditions:
 16               //
 17               // The above copyright notice and this permission notice shall be included
 18               // in all copies or substantial portions of the Software.
 19               //
 20               // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 21               // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 22 karl  1.1.2.1 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 23               // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
 24               // CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
 25               // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 26               // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 27               //
 28               //////////////////////////////////////////////////////////////////////////
 29               //
 30               //%////////////////////////////////////////////////////////////////////////////
 31               
 32 karl  1.1.2.4 #ifndef PegasusEnumerationContextTable_h
 33               #define PegasusEnumerationContextTable_h
 34 karl  1.1.2.1 
 35               #include <Pegasus/Common/Config.h>
 36               #include <Pegasus/Common/String.h>
 37               #include <Pegasus/Common/Thread.h>
 38               #include <Pegasus/Common/AutoPtr.h>
 39               #include <Pegasus/Common/CIMName.h>
 40               #include <Pegasus/Common/HashTable.h>
 41               #include <Pegasus/Common/List.h>
 42               #include <Pegasus/Common/NumericArg.h>
 43               #include <Pegasus/Server/Linkage.h>
 44               #include <Pegasus/Common/Tracer.h>
 45               #include <Pegasus/Common/CIMInstance.h>
 46               #include <Pegasus/Common/CIMResponseData.h>
 47               #include <Pegasus/Common/CIMMessage.h>
 48               #include <Pegasus/Common/Magic.h>
 49               #include <Pegasus/Common/Condition.h>
 50               #include <Pegasus/Common/AtomicInt.h>
 51               
 52               PEGASUS_NAMESPACE_BEGIN
 53               /****************************************************************************
 54               **
 55 karl  1.1.2.4 **   EnumerationContextTable Class
 56               **
 57 karl  1.1.2.2 **  This Class defines a table that contains all active EnumerationContext
 58               **  class objects. It is organized as a hash table and includes
 59 karl  1.1.2.1 **  methods to create new contexts, find a context by name, manage
 60 karl  1.1.2.2 **  the information in a context and remove a context.
 61               **  Each context object is represented by the EnumerationContext
 62               **  class.
 63               **  This class is expected to be used only with the Operation
 64 karl  1.1.2.5 **  Dispatcher.
 65               **  This class includes functions to time out inactive enumeration context
 66               **  entries in the table
 67 karl  1.1.2.1 *****************************************************************************/
 68               
 69 karl  1.1.2.2 class EnumerationContext;
 70               
 71 karl  1.1.2.4 class PEGASUS_SERVER_LINKAGE EnumerationContextTable
 72 karl  1.1.2.1 {
 73               public:
 74               
 75                   /**
 76 karl  1.1.2.5        Create a new Enumeration Table defining the defaults for
 77                      operation Timeout and response Cache Maximum Size.
 78 karl  1.1.2.1      */
 79 karl  1.1.2.4     EnumerationContextTable(Uint32 defaultInteroperationTimeoutValue,
 80 karl  1.1.2.1         Uint32 reponseCacheDefaultMaximumSize);
 81               
 82 karl  1.1.2.4     ~EnumerationContextTable();
 83 karl  1.1.2.1 
 84                   /**
 85                       Create a new EnumerationContext object and return a pointer to
 86 karl  1.1.2.5         the object.
 87 karl  1.1.2.1         @param nameSpace - Namespace for this sequence.
 88                       @param Uint32 value of operation timeout.
 89 karl  1.1.2.5         @param continueOnError Boolean containing the continueOnError flag for
 90                        this context.  (CURRENTLY MUST BE FALSE)
 91                       @param pullOpenRequestType - Type for the Pull request message so
 92 karl  1.1.2.1          tests can be made when pull received.  Used to prevent trying
 93                        to pull paths when instances required, etc.
 94                       @param contentType - Content type for the CIMResponseData cache
 95                        container
 96 karl  1.1.2.5         @param enumerationContextName  - Output parameter containing the
 97 karl  1.1.2.1          string which is the enumerationContext name that is used with
 98                        the find command and as the context in the operations
 99 karl  1.1.2.5         @return EnumerationContext*
100 karl  1.1.2.1      */
101                   EnumerationContext* createContext(
102                       const CIMNamespaceName& nameSpace,
103                       Uint32Arg&  operationTimeOutParam,
104                       Boolean continueOnError,
105                       MessageType pullRequestType,
106                       CIMResponseData::ResponseDataContent contentType,
107                       String& enumerationContextName);
108               
109                   /** Find and remove the enumeration context from the table
110                   */
111                   Boolean remove(const String& enumerationContextName);
112               
113                   Boolean remove(EnumerationContext* en);
114               
115                   /**
116 karl  1.1.2.5        Return the number of enumeration context entries in the
117                      enumeration context table
118                      @return Uint32
119 karl  1.1.2.1      */
120                   Uint32 size();
121               
122                   /**
123                      Remove any contexts that have expired inteoperation timers
124                   */
125                   void removeExpiredContexts();
126               
127                   EnumerationContext* find(const String& enumerationContextName);
128               
129                   /**
130                      Diagnostic to output info on all entries in table to trace log
131                   */
132                   void trace();
133               
134                   /**
135 karl  1.1.2.5        Dispatch the Timer thread if it is not already dispatched.
136 karl  1.1.2.1 
137 karl  1.1.2.5        @param interval Uint32 interval defines the interval for this context
138                             in seconds.
139 karl  1.1.2.1     */
140                   void dispatchTimerThread(Uint32 interval);
141               
142                   Uint32 getMinPullDefaultTimeout() const;
143               
144                   /**
145                      Return true if the Timer Thread is idle (i.e. not running)
146                    */
147 karl  1.1.2.4     Boolean timerThreadIdle();
148 karl  1.1.2.1 
149                   /**
150                      Set the Timer Thread Idle (i.e. Not running)
151                   */
152 karl  1.1.2.4     void setTimerThreadIdle();
153               
154                   /**
155                    * Update table timeout timer to next timeout
156                    */
157                   void updateNextTimeout();
158               
159                   // KS_TODO think some of these are overkill
160                   Uint32 timoutInterval();
161 karl  1.1.2.1 
162                   // Test if the timeout thread next timeout has passed.
163                   Boolean isTimedOut() const;
164               
165                   // diagnostic tests magic number in context to see if valid
166                   // Diagnostic tool
167                   Boolean valid();
168               
169 karl  1.1.2.3     // KS_TEMP TODO This diagnostic should be removed
170                   void tableValidate();
171               
172 karl  1.1.2.1 protected:
173               
174                   // timers for timer thread in seconds
175                   // Current minimum timeout time for active pull sequences
176                   Uint32 _timeoutInterval;
177               
178                   // next time the test for timed out pull sequences will be activated.
179                   // KS_TODO - This is incorrect since it will be the minimum for all
180                   // time.  How can we keep minimum for the active ones?
181                   Uint64 _nextTimeout;
182               
183               private:
184               
185                   // Enumeration Context objects are maintained in the following
186                   // Pegasus hash table
187                   typedef HashTable<String,
188                       EnumerationContext* ,
189                       EqualFunc<String>,
190                       HashFunc<String> > HT;
191                   HT ht;
192               
193 karl  1.1.2.1     // Private remove.  This is function that actually executes the remove
194                   // Not protected by mutex.
195                   Boolean _remove(EnumerationContext* en);
196               
197                   // monolithic increasing counter forms part of context id string
198                   AtomicInt _enumContextCounter;
199               
200                   Mutex tableLock;
201               
202                   // Maximum number of objects allowed in the ResponseData cache in
203                   // the enumerationContextObject. This sets the maximum number of
204                   // of objects that will be placed in this cache before we start
205                   // sitting on responses.
206                   Uint32 _responseCacheDefaultMaximumSize;
207               
208                   // systemwide highwater mark of number of objects in context cache
209                   // maintained from max of each context close/removal.
210                   Uint32 _cacheHighWaterMark;
211               
212                   // default interoperationTimeout
213                   Uint32 _pullOperationDefaultTimeout;
214 karl  1.1.2.1 
215                   Magic<0x57D11474> _magic;
216               };
217               
218 karl  1.1.2.4 //
219               //  inline EnumerationContextTable functions
220 karl  1.1.2.5 //
221 karl  1.1.2.4 inline Boolean EnumerationContextTable::timerThreadIdle()
222               {
223                   return _nextTimeout == 0;
224               }
225               
226               inline void EnumerationContextTable::setTimerThreadIdle()
227               {
228                   _nextTimeout = 0;
229               }
230               
231               inline void EnumerationContextTable::updateNextTimeout()
232               {
233                   _nextTimeout += _timeoutInterval;
234               }
235               
236               inline Uint32 EnumerationContextTable::timoutInterval()
237               {
238                   return _timeoutInterval;
239               }
240               
241 karl  1.1.2.1 PEGASUS_NAMESPACE_END
242               
243 karl  1.1.2.4 #endif /* PegasusEnumerationContextTable_h */

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2