1 martin 1.45 //%LICENSE////////////////////////////////////////////////////////////////
|
2 martin 1.46 //
|
3 martin 1.45 // 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.46 //
|
10 martin 1.45 // 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.46 //
|
17 martin 1.45 // The above copyright notice and this permission notice shall be included
18 // in all copies or substantial portions of the Software.
|
19 martin 1.46 //
|
20 martin 1.45 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
21 martin 1.46 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
22 martin 1.45 // 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.46 //
|
28 martin 1.45 //////////////////////////////////////////////////////////////////////////
|
29 mike 1.2 //
30 //%/////////////////////////////////////////////////////////////////////////////
31
32
33 ///////////////////////////////////////////////////////////////////////////////
|
34 kumpf 1.29 //
|
35 mike 1.2 // This file has implementation for the trace property owner class.
36 //
37 ///////////////////////////////////////////////////////////////////////////////
38
39 #include <Pegasus/Common/Tracer.h>
|
40 thilo.boehm 1.40 #include <Pegasus/Common/Logger.h>
|
41 mike 1.2 #include <Pegasus/Common/FileSystem.h>
|
42 kumpf 1.29 #include <Pegasus/Common/MessageLoader.h>
|
43 thilo.boehm 1.38 #include <Pegasus/Common/StringConversion.h>
|
44 kumpf 1.3 #include "ConfigManager.h"
|
45 mike 1.2 #include "TracePropertyOwner.h"
|
46 marek 1.54 #include "ConfigExceptions.h"
|
47 mike 1.2
48 PEGASUS_USING_STD;
49
50 PEGASUS_NAMESPACE_BEGIN
51
52 ///////////////////////////////////////////////////////////////////////////////
53 // TracePropertyOwner
54 //
55 // When a new trace property is added, make sure to add the property name
56 // and the default attributes of that property in the table below.
57 ///////////////////////////////////////////////////////////////////////////////
58
59 static struct ConfigPropertyRow properties[] =
60 {
|
61 kumpf 1.12 #ifdef PEGASUS_OS_HPUX
|
62 kumpf 1.48 {"traceLevel", "0", IS_DYNAMIC, IS_HIDDEN},
63 {"traceComponents", "", IS_DYNAMIC, IS_HIDDEN},
64 {"traceMemoryBufferKbytes", "10240", IS_STATIC, IS_HIDDEN},
65 {"traceFacility", "File", IS_DYNAMIC, IS_HIDDEN},
|
66 amit99shah 1.55 {"traceFileSizeKBytes", "1048576", IS_DYNAMIC, IS_HIDDEN},
67 {"numberOfTraceFiles", "3", IS_DYNAMIC, IS_HIDDEN},
|
68 ouyang.jian 1.33 #elif defined(PEGASUS_OS_PASE)
|
69 kumpf 1.48 {"traceLevel", "0", IS_DYNAMIC, IS_VISIBLE},
70 {"traceComponents", "", IS_DYNAMIC, IS_VISIBLE},
71 {"traceMemoryBufferKbytes", "10240", IS_STATIC, IS_VISIBLE},
72 {"traceFacility", "File", IS_DYNAMIC, IS_VISIBLE},
|
73 amit99shah 1.55 {"traceFileSizeKBytes", "1048576", IS_DYNAMIC, IS_VISIBLE},
74 {"numberOfTraceFiles", "3", IS_DYNAMIC, IS_VISIBLE},
|
75 thilo.boehm 1.44 #elif defined(PEGASUS_OS_ZOS)
|
76 kumpf 1.48 {"traceLevel", "2", IS_DYNAMIC, IS_VISIBLE},
77 {"traceComponents", "All", IS_DYNAMIC, IS_VISIBLE},
78 {"traceMemoryBufferKbytes", "10240", IS_STATIC, IS_VISIBLE},
79 {"traceFacility", "Memory", IS_DYNAMIC, IS_VISIBLE},
|
80 amit99shah 1.55 {"traceFileSizeKBytes", "1048576", IS_DYNAMIC, IS_VISIBLE},
81 {"numberOfTraceFiles", "3", IS_DYNAMIC, IS_VISIBLE},
|
82 kumpf 1.12 #else
|
83 thilo.boehm 1.42 # if defined (PEGASUS_USE_RELEASE_CONFIG_OPTIONS)
|
84 kumpf 1.48 {"traceLevel", "0", IS_DYNAMIC, IS_HIDDEN},
85 {"traceComponents", "", IS_DYNAMIC, IS_HIDDEN},
86 {"traceMemoryBufferKbytes", "10240", IS_STATIC, IS_HIDDEN},
87 {"traceFacility", "File", IS_DYNAMIC, IS_HIDDEN},
|
88 amit99shah 1.55 {"traceFileSizeKBytes", "1048576", IS_DYNAMIC, IS_HIDDEN},
89 {"numberOfTraceFiles", "3", IS_DYNAMIC, IS_HIDDEN},
|
90 thilo.boehm 1.42 # else
|
91 kumpf 1.48 {"traceLevel", "0", IS_DYNAMIC, IS_VISIBLE},
92 {"traceComponents", "", IS_DYNAMIC, IS_VISIBLE},
93 {"traceMemoryBufferKbytes", "10240", IS_STATIC, IS_VISIBLE},
94 {"traceFacility", "File", IS_DYNAMIC, IS_VISIBLE},
|
95 amit99shah 1.55 {"traceFileSizeKBytes", "1048576", IS_DYNAMIC, IS_VISIBLE},
96 {"numberOfTraceFiles", "3", IS_DYNAMIC, IS_VISIBLE},
|
97 thilo.boehm 1.42 # endif
|
98 kumpf 1.12 #endif
|
99 r.kieninger 1.41 #if defined(PEGASUS_OS_ZOS)
|
100 kumpf 1.31 # if defined(PEGASUS_USE_RELEASE_DIRS)
|
101 kumpf 1.48 {"traceFilePath", "/tmp/cimserver.trc", IS_DYNAMIC, IS_VISIBLE},
|
102 kumpf 1.31 # else
|
103 kumpf 1.48 {"traceFilePath", "cimserver.trc", IS_DYNAMIC, IS_VISIBLE},
|
104 kumpf 1.31 # endif
|
105 ouyang.jian 1.33 #elif defined(PEGASUS_OS_PASE)
|
106 kumpf 1.48 {"traceFilePath", "/tmp/cimserver.trc", IS_DYNAMIC, IS_VISIBLE},
|
107 david 1.26 #else
|
108 kumpf 1.48 {"traceFilePath", "trace/cimserver.trc", IS_DYNAMIC, IS_VISIBLE},
|
109 david 1.26 #endif
|
110 mike 1.2 };
111
112 const Uint32 NUM_PROPERTIES = sizeof(properties) / sizeof(properties[0]);
113
|
114 karl 1.52 static const char TRACE_POSSIBLE_VALUE [] =
115 "Possible Values: ";
|
116 mike 1.2
|
117 kumpf 1.29 //
|
118 mike 1.2 // Checks if the trace level is valid
119 //
|
120 marek 1.35 Boolean TracePropertyOwner::isLevelValid(const String& traceLevel) const
|
121 mike 1.2 {
122 //
123 // Check if the level is valid
124 //
|
125 marek 1.35 return (traceLevel == "0" || traceLevel == "1" ||
126 traceLevel == "2" || traceLevel == "3" ||
127 traceLevel == "4" || traceLevel == "5");
|
128 mike 1.2 }
129
|
130 thilo.boehm 1.38 //
|
131 kumpf 1.47 // Converts the trace memory buffer size string into a Uint32 value.
|
132 thilo.boehm 1.38 // It returns false and the bufferSize is set to 0 if the string was not valid.
|
133 martin 1.46 //
|
134 kumpf 1.47 Boolean TracePropertyOwner::toUint32TraceMemoryBufferSize(
|
135 thilo.boehm 1.38 const String& traceBufferSize, Uint32& bufferSize ) const
136 {
137 Boolean retCode = false;
138 Uint64 uInt64BufferSize;
|
139 kumpf 1.47
|
140 thilo.boehm 1.38 bufferSize = 0;
141 CString stringBufferSize = traceBufferSize.getCString();
142
143
144 retCode = StringConversion::decimalStringToUint64(stringBufferSize,
145 uInt64BufferSize);
146
147 if (retCode )
148 {
|
149 kumpf 1.47 retCode = StringConversion::checkUintBounds(uInt64BufferSize,
|
150 thilo.boehm 1.38 CIMTYPE_UINT32);
151 }
152
153 if (retCode )
154 {
155 bufferSize = (Uint32)uInt64BufferSize;
156 }
157
158 return retCode;
159 }
160
|
161 mike 1.2 //
162 // Get the appropriate trace level
163 //
|
164 marek 1.35 Uint32 TracePropertyOwner::getTraceLevel(const String& traceLevel)
|
165 mike 1.2 {
|
166 thilo.boehm 1.42 if ( traceLevel == "0")
|
167 marek 1.35 {
168 return Tracer::LEVEL0;
169 }
170 else if ( traceLevel == "1" )
|
171 mike 1.2 {
|
172 kumpf 1.29 return Tracer::LEVEL1;
|
173 mike 1.2 }
174 else if ( traceLevel == "2" )
175 {
|
176 kumpf 1.29 return Tracer::LEVEL2;
|
177 mike 1.2 }
178 else if ( traceLevel == "3" )
179 {
|
180 kumpf 1.29 return Tracer::LEVEL3;
|
181 mike 1.2 }
|
182 marek 1.35 else if ( traceLevel == "4" )
183 {
184 return Tracer::LEVEL4;
185 }
|
186 thilo.boehm 1.42 else if ( traceLevel == "5" )
|
187 mike 1.2 {
|
188 marek 1.35 return Tracer::LEVEL5;
|
189 mike 1.2 }
|
190 kumpf 1.47 else
|
191 thilo.boehm 1.42 {
192 return Tracer::LEVEL0;
193 }
|
194 mike 1.2 }
195
196 /** Constructors */
|
197 thilo.boehm 1.42 TracePropertyOwner::TracePropertyOwner():
198 _initialized(false)
|
199 mike 1.2 {
|
200 a.arora 1.16 _traceLevel.reset(new ConfigProperty);
201 _traceFilePath.reset(new ConfigProperty);
202 _traceComponents.reset(new ConfigProperty);
|
203 r.kieninger 1.36 _traceFacility.reset(new ConfigProperty);
|
204 thilo.boehm 1.38 _traceMemoryBufferKbytes.reset(new ConfigProperty);
|
205 amit99shah 1.55 _traceFileSizeKBytes.reset(new ConfigProperty);
206 _numberOfTraceFiles.reset(new ConfigProperty);
|
207 mike 1.2 }
208
209 /**
|
210 kumpf 1.29 Initialize the config properties.
|
211 mike 1.2 */
212 void TracePropertyOwner::initialize()
213 {
|
214 thilo.boehm 1.42 //
215 // Initialize the properties with default values only once !
216 //
217 if (_initialized)
218 {
219 return;
220 }
221
|
222 mike 1.2 for (Uint32 i = 0; i < NUM_PROPERTIES; i++)
223 {
|
224 kavita.gupta 1.49 if (String::equal(properties[i].propertyName, "traceComponents"))
|
225 mike 1.2 {
226 _traceComponents->propertyName = properties[i].propertyName;
227 _traceComponents->defaultValue = properties[i].defaultValue;
228 _traceComponents->currentValue = properties[i].defaultValue;
229 _traceComponents->plannedValue = properties[i].defaultValue;
230 _traceComponents->dynamic = properties[i].dynamic;
|
231 kumpf 1.29 _traceComponents->externallyVisible =
232 properties[i].externallyVisible;
|
233 thilo.boehm 1.42
234 Tracer::setTraceComponents(_traceComponents->defaultValue);
|
235 mike 1.2 }
|
236 kavita.gupta 1.49 else if (String::equal(properties[i].propertyName, "traceLevel"))
|
237 mike 1.2 {
238 _traceLevel->propertyName = properties[i].propertyName;
239 _traceLevel->defaultValue = properties[i].defaultValue;
240 _traceLevel->currentValue = properties[i].defaultValue;
241 _traceLevel->plannedValue = properties[i].defaultValue;
242 _traceLevel->dynamic = properties[i].dynamic;
|
243 kumpf 1.29 _traceLevel->externallyVisible =
244 properties[i].externallyVisible;
|
245 thilo.boehm 1.42
246 PEGASUS_ASSERT(_traceLevel->defaultValue.size()!= 0);
247
248 Tracer::setTraceLevel(getTraceLevel(_traceLevel->defaultValue));
|
249 kumpf 1.47
|
250 mike 1.2 }
|
251 kavita.gupta 1.49 else if (String::equal(
|
252 kumpf 1.29 properties[i].propertyName, "traceFilePath"))
|
253 mike 1.2 {
254 _traceFilePath->propertyName = properties[i].propertyName;
255 _traceFilePath->defaultValue = properties[i].defaultValue;
256 _traceFilePath->currentValue = properties[i].defaultValue;
257 _traceFilePath->plannedValue = properties[i].defaultValue;
258 _traceFilePath->dynamic = properties[i].dynamic;
|
259 kumpf 1.29 _traceFilePath->externallyVisible =
260 properties[i].externallyVisible;
|
261 thilo.boehm 1.39
262 // set the default value in the Trace
|
263 thilo.boehm 1.40 Uint32 retCode = Tracer::setTraceFile(ConfigManager::getHomedPath(
|
264 thilo.boehm 1.39 _traceFilePath->defaultValue).getCString());
|
265 thilo.boehm 1.40 if ( retCode == 1 )
266 {
267 Logger::put_l(
268 Logger::ERROR_LOG,System::CIMSERVER,Logger::WARNING,
269 MessageLoaderParms(
270 "Config.TracePropertyOwner.UNABLE_TO_WRITE_TRACE_FILE",
271 "Unable to write to trace file $0",
272 _traceFilePath->defaultValue));
273 _traceFilePath->currentValue.clear();
274 }
|
275 thilo.boehm 1.42
|
276 r.kieninger 1.36 }
|
277 kavita.gupta 1.49 else if (String::equal(
|
278 thilo.boehm 1.38 properties[i].propertyName, "traceMemoryBufferKbytes"))
279 {
280 _traceMemoryBufferKbytes->propertyName = properties[i].propertyName;
281 _traceMemoryBufferKbytes->defaultValue = properties[i].defaultValue;
282 _traceMemoryBufferKbytes->currentValue = properties[i].defaultValue;
283 _traceMemoryBufferKbytes->plannedValue = properties[i].defaultValue;
284 _traceMemoryBufferKbytes->dynamic = properties[i].dynamic;
285 _traceMemoryBufferKbytes->externallyVisible =
286 properties[i].externallyVisible;
|
287 mike 1.2
|
288 thilo.boehm 1.42 PEGASUS_ASSERT(_traceMemoryBufferKbytes->defaultValue.size()!= 0);
|
289 r.kieninger 1.36
|
290 thilo.boehm 1.42 Uint32 bufferSize;
|
291 kumpf 1.47 toUint32TraceMemoryBufferSize(
|
292 thilo.boehm 1.42 _traceMemoryBufferKbytes->defaultValue, bufferSize );
|
293 kumpf 1.47 Tracer::setTraceMemoryBufferSize(bufferSize);
294
|
295 marek 1.35 }
|
296 kavita.gupta 1.49 else if (String::equal(
|
297 thilo.boehm 1.42 properties[i].propertyName, "traceFacility"))
|
298 mike 1.2 {
|
299 thilo.boehm 1.42 _traceFacility->propertyName = properties[i].propertyName;
300 _traceFacility->defaultValue = properties[i].defaultValue;
301 _traceFacility->currentValue = properties[i].defaultValue;
302 _traceFacility->plannedValue = properties[i].defaultValue;
303 _traceFacility->dynamic = properties[i].dynamic;
304 _traceFacility->externallyVisible =
305 properties[i].externallyVisible;
306
307 PEGASUS_ASSERT(_traceFacility->defaultValue.size()!= 0);
308
309 Tracer::setTraceFacility(_traceFacility->defaultValue);
|
310 marek 1.35 }
|
311 amit99shah 1.55 else if (String::equalNoCase(
312 properties[i].propertyName, "traceFileSizeKBytes"))
313 {
314 _traceFileSizeKBytes->propertyName = properties[i].propertyName;
315 _traceFileSizeKBytes->defaultValue = properties[i].defaultValue;
316 _traceFileSizeKBytes->currentValue = properties[i].defaultValue;
317 _traceFileSizeKBytes->plannedValue = properties[i].defaultValue;
318 _traceFileSizeKBytes->dynamic = properties[i].dynamic;
319 _traceFileSizeKBytes->externallyVisible =
320 properties[i].externallyVisible;
321
322 PEGASUS_ASSERT(_traceFileSizeKBytes->defaultValue.size()!= 0);
323
324 Uint32 traceFileSize;
325 toUint32TraceMemoryBufferSize(
326 _traceFileSizeKBytes->currentValue,
327 traceFileSize);
328 Tracer::setMaxTraceFileSize(traceFileSize *1024);
329 }
330 else if (String::equalNoCase(
331 properties[i].propertyName, "numberOfTraceFiles"))
332 amit99shah 1.55 {
333 _numberOfTraceFiles->propertyName = properties[i].propertyName;
334 _numberOfTraceFiles->defaultValue = properties[i].defaultValue;
335 _numberOfTraceFiles->currentValue = properties[i].defaultValue;
336 _numberOfTraceFiles->plannedValue = properties[i].defaultValue;
337 _numberOfTraceFiles->dynamic = properties[i].dynamic;
338 _numberOfTraceFiles->externallyVisible =
339 properties[i].externallyVisible;
340
341 PEGASUS_ASSERT(_numberOfTraceFiles->defaultValue.size()!= 0);
342
343 Uint32 traceFileNumber;
344 toUint32TraceMemoryBufferSize(
345 _numberOfTraceFiles->currentValue,
346 traceFileNumber);
347 Tracer::setMaxTraceFileNumber(traceFileNumber);
348
349 }
|
350 mike 1.2 }
|
351 thilo.boehm 1.42 _initialized = true;
|
352 mike 1.2 }
353
|
354 kumpf 1.6 struct ConfigProperty* TracePropertyOwner::_lookupConfigProperty(
|
355 aruran.ms 1.25 const String& name) const
|
356 mike 1.2 {
|
357 kavita.gupta 1.49 if (String::equal(_traceComponents->propertyName, name))
|
358 mike 1.2 {
|
359 a.arora 1.16 return _traceComponents.get();
|
360 mike 1.2 }
|
361 kavita.gupta 1.49 else if (String::equal(_traceLevel->propertyName, name))
|
362 mike 1.2 {
|
363 a.arora 1.16 return _traceLevel.get();
|
364 mike 1.2 }
|
365 kavita.gupta 1.49 else if (String::equal(_traceFilePath->propertyName, name))
|
366 mike 1.2 {
|
367 a.arora 1.16 return _traceFilePath.get();
|
368 mike 1.2 }
|
369 kavita.gupta 1.49 else if (String::equal(_traceFacility->propertyName, name))
|
370 r.kieninger 1.36 {
371 return _traceFacility.get();
372 }
|
373 kavita.gupta 1.49 else if (String::equal(_traceMemoryBufferKbytes->propertyName, name))
|
374 thilo.boehm 1.38 {
375 return _traceMemoryBufferKbytes.get();
376 }
|
377 amit99shah 1.55 else if (String::equalNoCase(_traceFileSizeKBytes->propertyName, name))
378 {
379 return _traceFileSizeKBytes.get();
380 }
381 else if (String::equalNoCase(_numberOfTraceFiles->propertyName, name))
382 {
383 return _numberOfTraceFiles.get();
384 }
|
385 mike 1.2 else
386 {
387 throw UnrecognizedConfigProperty(name);
388 }
389 }
390
|
391 kumpf 1.29 /**
392 Get information about the specified property.
|
393 mike 1.2 */
|
394 kumpf 1.6 void TracePropertyOwner::getPropertyInfo(
|
395 kumpf 1.29 const String& name,
|
396 vijay.eli 1.24 Array<String>& propertyInfo) const
|
397 mike 1.2 {
|
398 karl 1.52 struct ConfigProperty * configProperty = _lookupConfigProperty(name);
|
399 kumpf 1.6
|
400 karl 1.52 buildPropertyInfo(name, configProperty, propertyInfo);
401 }
|
402 kumpf 1.6
|
403 karl 1.52 /*
404 Get supplementary help information.
405 */
406 String TracePropertyOwner::getPropertyHelpSupplement(
407 const String& name) const
408 {
409 String localPropertyInfo;
410 if (String::equalNoCase(_traceComponents->propertyName, name))
|
411 kumpf 1.12 {
|
412 karl 1.52 // Set list of possible traceComponent Strings
413 const Uint32 _NUM_COMPONENTS = Tracer::_NUM_COMPONENTS;
414 localPropertyInfo.append("\n");
|
415 karl 1.53
416 localPropertyInfo.append(loadMessage(
|
417 karl 1.52 "Config.TracePropertyOwner.TRACECOMPONENTS_POSSIBLE_VALUE",
|
418 karl 1.53 TRACE_POSSIBLE_VALUE));
|
419 karl 1.52
420 String possibleValues = "\n ALL ";
421 Uint32 lineSize = possibleValues.size();
422 // Get the list of traceComponents from Tracer and append to formatted
423 // string
424 for ( Uint32 index = 0;index < _NUM_COMPONENTS; index++)
425 {
426 if ((strlen(Tracer::TRACE_COMPONENT_LIST[index]) + lineSize) >= 79)
427 {
428 possibleValues.append("\n ");
429 lineSize = 5;
430 }
431 possibleValues.append(Tracer::TRACE_COMPONENT_LIST[index]);
432 possibleValues.append(" ");
433
434 lineSize += (strlen(Tracer::TRACE_COMPONENT_LIST[index]) + 1);
435 }
436 possibleValues = possibleValues.subString(0, possibleValues.size() - 1);
437 localPropertyInfo.append(possibleValues);
|
438 mike 1.2 }
|
439 karl 1.52 return localPropertyInfo;
|
440 mike 1.2 }
441
|
442 kumpf 1.29 /**
443 Get default value of the specified property.
|
444 kumpf 1.6 */
|
445 vijay.eli 1.24 String TracePropertyOwner::getDefaultValue(const String& name) const
|
446 kumpf 1.6 {
|
447 aruran.ms 1.25 struct ConfigProperty * configProperty = _lookupConfigProperty(name);
|
448 kumpf 1.6 return configProperty->defaultValue;
449 }
450
|
451 kumpf 1.29 /**
452 Get current value of the specified property.
|
453 mike 1.2 */
|
454 vijay.eli 1.24 String TracePropertyOwner::getCurrentValue(const String& name) const
|
455 mike 1.2 {
|
456 aruran.ms 1.25 struct ConfigProperty * configProperty = _lookupConfigProperty(name);
|
457 kumpf 1.6 return configProperty->currentValue;
|
458 mike 1.2 }
459
|
460 kumpf 1.29 /**
461 Get planned value of the specified property.
|
462 mike 1.2 */
|
463 vijay.eli 1.24 String TracePropertyOwner::getPlannedValue(const String& name) const
|
464 mike 1.2 {
|
465 aruran.ms 1.25 struct ConfigProperty * configProperty = _lookupConfigProperty(name);
|
466 kumpf 1.6 return configProperty->plannedValue;
|
467 mike 1.2 }
468
|
469 kumpf 1.29 /**
470 Init current value of the specified property to the specified value.
|
471 mike 1.2 */
472 void TracePropertyOwner::initCurrentValue(
|
473 kumpf 1.29 const String& name,
|
474 mike 1.2 const String& value)
475 {
|
476 kavita.gupta 1.49 if (String::equal(_traceComponents->propertyName, name))
|
477 mike 1.2 {
|
478 kumpf 1.14 _traceComponents->currentValue = value;
|
479 kumpf 1.29 Tracer::setTraceComponents(_traceComponents->currentValue);
|
480 mike 1.2 }
|
481 kavita.gupta 1.49 else if (String::equal(_traceLevel->propertyName, name))
|
482 mike 1.2 {
|
483 kumpf 1.5 _traceLevel->currentValue = value;
|
484 kumpf 1.29 Uint32 traceLevel = getTraceLevel(_traceLevel->currentValue);
|
485 mike 1.2 Tracer::setTraceLevel(traceLevel);
486 }
|
487 kavita.gupta 1.49 else if (String::equal(_traceFilePath->propertyName, name))
|
488 mike 1.2 {
|
489 kumpf 1.5 _traceFilePath->currentValue = value;
|
490 thilo.boehm 1.40 Uint32 retCode = Tracer::setTraceFile(ConfigManager::getHomedPath(
|
491 thilo.boehm 1.39 _traceFilePath->currentValue).getCString());
|
492 thilo.boehm 1.40 if ( retCode == 1 )
493 {
494 Logger::put_l(
495 Logger::ERROR_LOG,System::CIMSERVER,Logger::WARNING,
496 MessageLoaderParms(
497 "Config.TracePropertyOwner.UNABLE_TO_WRITE_TRACE_FILE",
498 "Unable to write to trace file $0",
499 _traceFilePath->currentValue));
500 _traceFilePath->currentValue.clear();
501 }
|
502 r.kieninger 1.36 }
|
503 kavita.gupta 1.49 else if (String::equal(_traceFacility->propertyName, name))
|
504 r.kieninger 1.36 {
505 _traceFacility->currentValue = value;
|
506 kumpf 1.47 Tracer::setTraceFacility(value);
|
507 mike 1.2 }
|
508 kavita.gupta 1.49 else if (String::equal(_traceMemoryBufferKbytes->propertyName, name))
|
509 thilo.boehm 1.38 {
510 Uint32 bufferSize;
511
512 _traceMemoryBufferKbytes->currentValue = value;
513
|
514 thilo.boehm 1.39 toUint32TraceMemoryBufferSize( value, bufferSize );
|
515 kumpf 1.47 Tracer::setTraceMemoryBufferSize(bufferSize);
|
516 thilo.boehm 1.38 }
|
517 amit99shah 1.55 else if (String::equalNoCase(_traceFileSizeKBytes->propertyName,name))
518 {
519 Boolean status = false;
520 Uint32 traceFileSizeKBytes=0;
521
522 status = toUint32TraceMemoryBufferSize(
523 value, traceFileSizeKBytes);
524
525 if(!status)
526 throw InvalidPropertyValue(name, value);
527
528 _traceFileSizeKBytes->currentValue = value;
529 Tracer::setMaxTraceFileSize(traceFileSizeKBytes*1024);
530
531 }
532 else if (String::equalNoCase(_numberOfTraceFiles->propertyName,name))
533 {
534 Boolean status = false;
535 Uint32 numberOfTraceFiles=0;
536
537 status = toUint32TraceMemoryBufferSize(
538 amit99shah 1.55 value, numberOfTraceFiles);
539
540 if(!status)
541 throw InvalidPropertyValue(name, value);
542
543 _numberOfTraceFiles->currentValue = value;
544 Tracer::setMaxTraceFileNumber(numberOfTraceFiles);
545 }
|
546 mike 1.2 else
547 {
548 throw UnrecognizedConfigProperty(name);
549 }
550 }
551
552
|
553 kumpf 1.29 /**
554 Init planned value of the specified property to the specified value.
|
555 mike 1.2 */
556 void TracePropertyOwner::initPlannedValue(
|
557 kumpf 1.29 const String& name,
|
558 mike 1.2 const String& value)
559 {
|
560 kumpf 1.6 struct ConfigProperty* configProperty = _lookupConfigProperty(name);
561 configProperty->plannedValue = value;
|
562 mike 1.2 }
563
|
564 kumpf 1.29 /**
565 Update current value of the specified property to the specified value.
|
566 mike 1.2 */
567 void TracePropertyOwner::updateCurrentValue(
|
568 kumpf 1.29 const String& name,
|
569 venkat.puvvada 1.50 const String& value,
|
570 venkat.puvvada 1.51 const String& userName,
571 Uint32 timeoutSeconds)
|
572 mike 1.2 {
573 //
574 // make sure the property is dynamic before updating the value.
575 //
576 if (!isDynamic(name))
577 {
|
578 kumpf 1.29 throw NonDynamicConfigProperty(name);
|
579 mike 1.2 }
580
581 //
|
582 kumpf 1.6 // Update does the same thing as initialization
|
583 mike 1.2 //
|
584 kumpf 1.6 initCurrentValue(name, value);
|
585 mike 1.2 }
586
587
|
588 kumpf 1.29 /**
589 Update planned value of the specified property to the specified value.
|
590 mike 1.2 */
591 void TracePropertyOwner::updatePlannedValue(
|
592 kumpf 1.29 const String& name,
|
593 mike 1.2 const String& value)
594 {
|
595 kumpf 1.6 struct ConfigProperty* configProperty = _lookupConfigProperty(name);
596 configProperty->plannedValue = value;
|
597 mike 1.2 }
598
|
599 kumpf 1.29 /**
600 Checks to see if the given value is valid or not.
|
601 mike 1.2 */
|
602 kumpf 1.29 Boolean TracePropertyOwner::isValid(
603 const String& name,
604 const String& value) const
|
605 mike 1.2 {
|
606 kavita.gupta 1.49 if (String::equal(_traceComponents->propertyName, name))
|
607 mike 1.2 {
|
608 kumpf 1.29 String newValue = value;
|
609 kumpf 1.30 String invalidComponents;
|
610 mike 1.2
|
611 kumpf 1.29 //
612 // Check if the trace components are valid
613 //
614 if (!Tracer::isValidComponents(newValue,invalidComponents))
615 {
616 throw InvalidPropertyValue(name, invalidComponents);
|
617 mike 1.2 }
618
|
619 kumpf 1.6 return true;
|
620 mike 1.2 }
|
621 kavita.gupta 1.49 else if (String::equal(_traceLevel->propertyName, name))
|
622 mike 1.2 {
|
623 kumpf 1.29 //
|
624 mike 1.2 // Check if the level is valid
|
625 kumpf 1.29 //
|
626 mike 1.2 if ( isLevelValid( value ) )
627 {
|
628 kumpf 1.6 return true;
|
629 mike 1.2 }
|
630 kumpf 1.29 else
631 {
632 throw InvalidPropertyValue(name, value);
|
633 mike 1.2 }
634 }
|
635 kavita.gupta 1.49 else if (String::equal(_traceFilePath->propertyName, name))
|
636 mike 1.2 {
|
637 kumpf 1.29 //
|
638 kumpf 1.20 // Check if the file path is valid. An empty string is currently
639 // considered a valid value; the traceFilePath is set to the empty
640 // string when a trace file cannot be opened successfully.
|
641 kumpf 1.29 //
|
642 kumpf 1.20 if ((value != String::EMPTY) &&
|
643 thilo.boehm 1.39 !Tracer::isValidFileName((const char*)value.getCString()))
|
644 kumpf 1.29 {
645 throw InvalidPropertyValue(name, value);
646 }
|
647 kumpf 1.6 return true;
|
648 mike 1.2 }
|
649 kavita.gupta 1.49 else if (String::equal(_traceFacility->propertyName, name))
|
650 r.kieninger 1.36 {
651 //
652 // Check if the trace facility is valid
653 //
654 if (!Tracer::isValidTraceFacility(value))
655 {
656 throw InvalidPropertyValue(name, value);
657 }
658 return true;
659 }
|
660 kavita.gupta 1.49 else if (String::equal(_traceMemoryBufferKbytes->propertyName, name))
|
661 thilo.boehm 1.38 {
662 Boolean retCode = false;
663 Uint32 size = 0;
664
665 //
666 // Ckeck if the trace memeory buffer size is valid
667 //
668 retCode = toUint32TraceMemoryBufferSize(value ,size);
|
669 kumpf 1.47 if (!retCode || (size > PEGASUS_TRC_BUFFER_MAX_SIZE_KB) ||
|
670 thilo.boehm 1.38 (size < PEGASUS_TRC_BUFFER_MIN_SIZE_KB))
671 {
672 throw InvalidPropertyValue(name, value);
673 }
674 return true;
675 }
|
676 amit99shah 1.55 else if (String::equalNoCase(_traceFileSizeKBytes->propertyName,name))
677 {
678 Boolean status = false;
679 Uint32 traceFileSizeKBytes=0;
680 const Uint32 minimumFileSizeKBytes=10240;
681 const Uint32 maximumFileSizeKBytes=2097152;
682
683 status = toUint32TraceMemoryBufferSize(
684 value, traceFileSizeKBytes);
685
686 if(!status)
687 throw InvalidPropertyValue(name, value);
688
689 /* checking File size greater than 10MB
690 and less than 2GB */
691 if (traceFileSizeKBytes < minimumFileSizeKBytes ||
692 traceFileSizeKBytes > maximumFileSizeKBytes)
693 {
694 throw InvalidPropertyValue(name, value);
695 }
696
697 amit99shah 1.55 return true;
698 }
699 else if (String::equalNoCase(_numberOfTraceFiles->propertyName,name))
700 {
701 Boolean status = false;
702 Uint32 numberOfTraceFiles=0;
703 const Uint32 minimumNumberOfTraceFiles=3;
704 const Uint32 maximumNumberOfTraceFiles=20;
705
706 status = toUint32TraceMemoryBufferSize(
707 value, numberOfTraceFiles);
708
709 if(!status)
710 throw InvalidPropertyValue(name, value);
711
712 /* checking number of files greater 3
713 and less than 20 */
714 if(numberOfTraceFiles < minimumNumberOfTraceFiles ||
715 numberOfTraceFiles > maximumNumberOfTraceFiles)
716 {
717 throw InvalidPropertyValue(name, value);
718 amit99shah 1.55 }
719
720 return true;
721 }
|
722 mike 1.2 else
723 {
724 throw UnrecognizedConfigProperty(name);
725 }
726 }
727
|
728 kumpf 1.29 /**
729 Checks to see if the specified property is dynamic or not.
|
730 mike 1.2 */
|
731 vijay.eli 1.24 Boolean TracePropertyOwner::isDynamic(const String& name) const
|
732 mike 1.2 {
|
733 kumpf 1.29 struct ConfigProperty* configProperty = _lookupConfigProperty(name);
734 return (configProperty->dynamic == IS_DYNAMIC);
|
735 mike 1.2 }
736
737 PEGASUS_NAMESPACE_END
|