(file) Return to ShutdownPropertyOwner.cpp CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / Config

  1 martin 1.25 //%LICENSE////////////////////////////////////////////////////////////////
  2 martin 1.26 //
  3 martin 1.25 // 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 martin 1.26 //
 10 martin 1.25 // 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 martin 1.26 //
 17 martin 1.25 // The above copyright notice and this permission notice shall be included
 18             // in all copies or substantial portions of the Software.
 19 martin 1.26 //
 20 martin 1.25 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 21 martin 1.26 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 22 martin 1.25 // 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 martin 1.26 //
 28 martin 1.25 //////////////////////////////////////////////////////////////////////////
 29 mike   1.2  //
 30             //%/////////////////////////////////////////////////////////////////////////////
 31             
 32             
 33             ///////////////////////////////////////////////////////////////////////////////
 34 kumpf  1.22 //
 35 mike   1.2  // This file has implementation for the timeout property owner class.
 36             //
 37             ///////////////////////////////////////////////////////////////////////////////
 38             
 39             #include <Pegasus/Common/FileSystem.h>
 40 kumpf  1.23 #include <Pegasus/Common/Constants.h>
 41 mike   1.2  #include "ShutdownPropertyOwner.h"
 42 marek  1.33 #include "ConfigExceptions.h"
 43 mike   1.2  
 44             
 45             PEGASUS_USING_STD;
 46             
 47             PEGASUS_NAMESPACE_BEGIN
 48             
 49             ///////////////////////////////////////////////////////////////////////////////
 50             //  ShutdownPropertyOwner
 51             //
 52 kumpf  1.3  //  The shutdownTimeout property is the timeout value in seconds that the
 53 kumpf  1.6  //  cimom uses to wait for all the outstanding CIM operations to complete
 54 carolann.graves 1.20 //  before shutting down the cimserver.  The default value is 30 seconds.
 55 kumpf           1.3  //
 56 mike            1.2  //  When a new timeout property is added, make sure to add the property name
 57                      //  and the default attributes of that property in the table below.
 58 kumpf           1.3  //
 59 mike            1.2  ///////////////////////////////////////////////////////////////////////////////
 60                      
 61                      static struct ConfigPropertyRow properties[] =
 62                      {
 63 kumpf           1.23     {"shutdownTimeout", PEGASUS_DEFAULT_SHUTDOWN_TIMEOUT_SECONDS_STRING,
 64 kumpf           1.27          IS_DYNAMIC, IS_VISIBLE},
 65 mike            1.2  };
 66                      
 67                      const Uint32 NUM_PROPERTIES = sizeof(properties) / sizeof(properties[0]);
 68                      
 69 kumpf           1.7  static long MIN_SHUTDOWN_TIMEOUT = 2;
 70 mike            1.2  
 71                      /** Constructor  */
 72                      ShutdownPropertyOwner::ShutdownPropertyOwner()
 73                      {
 74 a.arora         1.13     _shutdownTimeout.reset(new ConfigProperty);
 75 mike            1.2  }
 76                      
 77                      
 78                      /**
 79 kumpf           1.22     Initialize the config properties.
 80 mike            1.2  */
 81                      void ShutdownPropertyOwner::initialize()
 82                      {
 83 dl.meetei       1.34     for (Uint32 i = 0; i < NUM_PROPERTIES; ++i)
 84 mike            1.2      {
 85                              //
 86                              // Initialize the properties with default values
 87                              //
 88 kavita.gupta    1.28         if (String::equal(properties[i].propertyName, "shutdownTimeout"))
 89 mike            1.2          {
 90                                  _shutdownTimeout->propertyName = properties[i].propertyName;
 91                                  _shutdownTimeout->defaultValue = properties[i].defaultValue;
 92                                  _shutdownTimeout->currentValue = properties[i].defaultValue;
 93                                  _shutdownTimeout->plannedValue = properties[i].defaultValue;
 94                                  _shutdownTimeout->dynamic = properties[i].dynamic;
 95 kumpf           1.22             _shutdownTimeout->externallyVisible =
 96                                      properties[i].externallyVisible;
 97 mike            1.2          }
 98                          }
 99                      }
100                      
101 kumpf           1.5  struct ConfigProperty* ShutdownPropertyOwner::_lookupConfigProperty(
102 aruran.ms       1.19     const String& name) const
103 kumpf           1.5  {
104 kavita.gupta    1.28     if (String::equal(_shutdownTimeout->propertyName, name))
105 kumpf           1.5      {
106 a.arora         1.13         return _shutdownTimeout.get();
107 kumpf           1.5      }
108                          else
109                          {
110                              throw UnrecognizedConfigProperty(name);
111                          }
112                      }
113                      
114 kumpf           1.22 /**
115                          Get information about the specified property.
116 mike            1.2  */
117                      void ShutdownPropertyOwner::getPropertyInfo(
118 kumpf           1.22     const String& name,
119 vijay.eli       1.18     Array<String>& propertyInfo) const
120 mike            1.2  {
121 aruran.ms       1.19     struct ConfigProperty * configProperty = _lookupConfigProperty(name);
122 kumpf           1.5  
123 karl            1.32     buildPropertyInfo(name, configProperty, propertyInfo);
124 mike            1.2  }
125                      
126 kumpf           1.22 /**
127                          Get default value of the specified property.
128 mike            1.2  */
129 vijay.eli       1.18 String ShutdownPropertyOwner::getDefaultValue(const String& name) const
130 mike            1.2  {
131 aruran.ms       1.19     struct ConfigProperty * configProperty = _lookupConfigProperty(name);
132 kumpf           1.5      return configProperty->defaultValue;
133 mike            1.2  }
134                      
135 kumpf           1.22 /**
136                          Get current value of the specified property.
137 mike            1.2  */
138 vijay.eli       1.18 String ShutdownPropertyOwner::getCurrentValue(const String& name) const
139 mike            1.2  {
140 aruran.ms       1.19     struct ConfigProperty * configProperty = _lookupConfigProperty(name);
141 kumpf           1.5      return configProperty->currentValue;
142 mike            1.2  }
143                      
144 kumpf           1.22 /**
145                          Get planned value of the specified property.
146 mike            1.2  */
147 vijay.eli       1.18 String ShutdownPropertyOwner::getPlannedValue(const String& name) const
148 mike            1.2  {
149 aruran.ms       1.19     struct ConfigProperty * configProperty = _lookupConfigProperty(name);
150 kumpf           1.5      return configProperty->plannedValue;
151 mike            1.2  }
152                      
153 kumpf           1.22 /**
154                          Init current value of the specified property to the specified value.
155 mike            1.2  */
156                      void ShutdownPropertyOwner::initCurrentValue(
157 kumpf           1.22     const String& name,
158 mike            1.2      const String& value)
159                      {
160 kumpf           1.5      struct ConfigProperty* configProperty = _lookupConfigProperty(name);
161                          configProperty->currentValue = value;
162 mike            1.2  }
163                      
164                      
165 kumpf           1.22 /**
166                          Init planned value of the specified property to the specified value.
167 mike            1.2  */
168                      void ShutdownPropertyOwner::initPlannedValue(
169 kumpf           1.22     const String& name,
170 mike            1.2      const String& value)
171                      {
172 kumpf           1.5      struct ConfigProperty* configProperty = _lookupConfigProperty(name);
173                          configProperty->plannedValue = value;
174 mike            1.2  }
175                      
176 kumpf           1.22 /**
177                          Update current value of the specified property to the specified value.
178 mike            1.2  */
179                      void ShutdownPropertyOwner::updateCurrentValue(
180 kumpf           1.22     const String& name,
181 venkat.puvvada  1.29     const String& value,
182 venkat.puvvada  1.30     const String& userName,
183                          Uint32 timeoutSeconds)
184 mike            1.2  {
185 ashok.pathak    1.31     struct ConfigProperty* configProperty = _lookupConfigProperty(name);
186                      
187 mike            1.2      //
188                          // make sure the property is dynamic before updating the value.
189                          //
190 ashok.pathak    1.31     if (configProperty->dynamic != IS_DYNAMIC)
191 mike            1.2      {
192 kumpf           1.22         throw NonDynamicConfigProperty(name);
193 mike            1.2      }
194 karl            1.32 
195 ashok.pathak    1.31     configProperty->currentValue = value;
196 mike            1.2  }
197                      
198                      
199 kumpf           1.22 /**
200                          Update planned value of the specified property to the specified value.
201 mike            1.2  */
202                      void ShutdownPropertyOwner::updatePlannedValue(
203 kumpf           1.22     const String& name,
204 mike            1.2      const String& value)
205                      {
206                          //
207                          // Since the validations done in initPlannedValue are sufficient and
208                          // no additional validations required for update, we will call
209                          // initPlannedValue.
210                          //
211                          initPlannedValue(name, value);
212                      }
213                      
214 kumpf           1.22 /**
215                          Checks to see if the given value is valid or not.
216 mike            1.2  */
217 kumpf           1.22 Boolean ShutdownPropertyOwner::isValid(
218                          const String& name,
219                          const String& value) const
220 mike            1.2  {
221                          //
222                          // convert timeout string to integer
223                          //
224 kumpf           1.10     long timeoutValue = strtol(value.getCString(), (char **)0, 10);
225 mike            1.2  
226 kavita.gupta    1.28     if (String::equal(_shutdownTimeout->propertyName, name))
227 mike            1.2      {
228                              // Check if the timeout value is greater than the minimum allowed
229                              //
230 dl.meetei       1.34         return  timeoutValue >= MIN_SHUTDOWN_TIMEOUT;
231 mike            1.2      }
232                          else
233                          {
234                              throw UnrecognizedConfigProperty(name);
235                          }
236                      }
237                      
238 kumpf           1.22 /**
239                          Checks to see if the specified property is dynamic or not.
240 mike            1.2  */
241 vijay.eli       1.18 Boolean ShutdownPropertyOwner::isDynamic(const String& name) const
242 mike            1.2  {
243 kumpf           1.22     struct ConfigProperty* configProperty = _lookupConfigProperty(name);
244                          return (configProperty->dynamic == IS_DYNAMIC);
245 mike            1.2  }
246                      
247                      PEGASUS_NAMESPACE_END

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2