(file) Return to ProviderStatus.cpp CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / ProviderManager2 / Default

  1 kumpf 1.1 //%2006////////////////////////////////////////////////////////////////////////
  2           //
  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.
 11           // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;
 12           // EMC Corporation; Symantec Corporation; The Open Group.
 13           //
 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           // 
 21           // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
 22 kumpf 1.1 // 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           // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 28           // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 29           //
 30           //==============================================================================
 31           //
 32           //%/////////////////////////////////////////////////////////////////////////////
 33           
 34           #include "ProviderStatus.h"
 35 kumpf 1.3 #include <Pegasus/Common/Time.h>
 36           #include <Pegasus/Common/PegasusAssert.h>
 37 kumpf 1.1 
 38           PEGASUS_NAMESPACE_BEGIN
 39           
 40           ProviderStatus::ProviderStatus()
 41           {
 42 kumpf 1.3     setInitialized(false);
 43 kumpf 1.1 }
 44           
 45           ProviderStatus::~ProviderStatus()
 46           {
 47           }
 48           
 49           Boolean ProviderStatus::isInitialized()
 50           {
 51               AutoMutex lock(_statusMutex);
 52               return _isInitialized;
 53           }
 54           
 55           void ProviderStatus::setInitialized(Boolean initialized)
 56           {
 57               AutoMutex lock(_statusMutex);
 58               _isInitialized = initialized;
 59 kumpf 1.3 
 60               if (!_isInitialized)
 61               {
 62                   _module = 0;
 63                   _cimomHandle = 0;
 64                   _currentOperations = 0;
 65                   _indicationsEnabled = false;
 66                   _currentSubscriptions = 0;
 67               }
 68           
 69               Time::gettimeofday(&_lastOperationEndTime);
 70 kumpf 1.1 }
 71           
 72           ProviderModule* ProviderStatus::getModule() const
 73           {
 74               return _module;
 75           }
 76           
 77           void ProviderStatus::setModule(ProviderModule* module)
 78           {
 79               _module = module;
 80           }
 81           
 82 kumpf 1.3 CIMOMHandle* ProviderStatus::getCIMOMHandle()
 83 kumpf 1.1 {
 84 kumpf 1.3     return _cimomHandle;
 85 kumpf 1.1 }
 86           
 87 kumpf 1.3 void ProviderStatus::setCIMOMHandle(CIMOMHandle* cimomHandle)
 88 kumpf 1.1 {
 89 kumpf 1.3     _cimomHandle = cimomHandle;
 90 kumpf 1.1 }
 91           
 92 kumpf 1.3 void ProviderStatus::getLastOperationEndTime(struct timeval* t)
 93 kumpf 1.1 {
 94 kumpf 1.3     PEGASUS_ASSERT(t != 0);
 95               AutoMutex lock(_lastOperationEndTimeMutex);
 96               memcpy(t, &_lastOperationEndTime, sizeof(struct timeval));
 97 kumpf 1.1 }
 98           
 99 kumpf 1.3 Boolean ProviderStatus::isIdle()
100 kumpf 1.1 {
101 kumpf 1.3     if (!_isInitialized ||
102                   (_currentOperations.get() > 0) ||
103                   _indicationsEnabled)
104 kumpf 1.1     {
105 kumpf 1.3         return false;
106 kumpf 1.1     }
107           
108 kumpf 1.3     if (_cimomHandle)
109 kumpf 1.1     {
110 kumpf 1.3         return _cimomHandle->unload_ok();
111 kumpf 1.1     }
112           
113 kumpf 1.3     return true;
114 kumpf 1.1 }
115           
116 kumpf 1.3 void ProviderStatus::operationBegin()
117           {
118               _currentOperations++;
119           }
120 kumpf 1.1 
121 kumpf 1.3 void ProviderStatus::operationEnd()
122 kumpf 1.1 {
123 kumpf 1.3     _currentOperations--;
124 kumpf 1.1 
125 kumpf 1.3     // Update the timer used to detect idle providers
126               AutoMutex lock(_lastOperationEndTimeMutex);
127               Time::gettimeofday(&_lastOperationEndTime);
128           }
129 kumpf 1.1 
130 kumpf 1.3 Uint32 ProviderStatus::numCurrentOperations() const
131           {
132               return _currentOperations.get();
133 kumpf 1.1 }
134           
135 kumpf 1.3 Boolean ProviderStatus::getIndicationsEnabled() const
136 kumpf 1.1 {
137 kumpf 1.3     return _indicationsEnabled;
138 kumpf 1.1 }
139           
140 kumpf 1.3 void ProviderStatus::setIndicationsEnabled(Boolean indicationsEnabled)
141 kumpf 1.1 {
142 kumpf 1.3     _indicationsEnabled = indicationsEnabled;
143 kumpf 1.1 }
144           
145           Boolean ProviderStatus::testIfZeroAndIncrementSubscriptions()
146           {
147               AutoMutex lock(_currentSubscriptionsMutex);
148               return (_currentSubscriptions++ == 0);
149           }
150           
151           Boolean ProviderStatus::decrementSubscriptionsAndTestIfZero()
152           {
153               AutoMutex lock(_currentSubscriptionsMutex);
154               return (--_currentSubscriptions == 0);
155           }
156           
157           Boolean ProviderStatus::testSubscriptions()
158           {
159               AutoMutex lock(_currentSubscriptionsMutex);
160               return (_currentSubscriptions > 0);
161           }
162           
163           void ProviderStatus::resetSubscriptions()
164 kumpf 1.1 {
165               AutoMutex lock(_currentSubscriptionsMutex);
166               _currentSubscriptions = 0;
167           }
168           
169           void ProviderStatus::setProviderInstance(const CIMInstance& instance)
170           {
171               _providerInstance = instance;
172           }
173           
174           CIMInstance ProviderStatus::getProviderInstance()
175           {
176               return _providerInstance;
177           }
178           
179 kumpf 1.3 Mutex& ProviderStatus::getStatusMutex()
180           {
181               return _statusMutex;
182           }
183           
184 kumpf 1.1 PEGASUS_NAMESPACE_END

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2