diff options
author | Melanie | 2012-10-23 17:25:40 +0100 |
---|---|---|
committer | Melanie | 2012-10-23 17:25:40 +0100 |
commit | 484eca323b0e89b2da0c8c9404c1b9bf3a99945b (patch) | |
tree | c34f9cb43efd64fa26ac1ab2f676f0dc6f86fe8a /OpenSim/Framework/Monitoring | |
parent | Merge branch 'master' into careminster (diff) | |
parent | BulletSim: remove chatty debug message. (diff) | |
download | opensim-SC_OLD-484eca323b0e89b2da0c8c9404c1b9bf3a99945b.zip opensim-SC_OLD-484eca323b0e89b2da0c8c9404c1b9bf3a99945b.tar.gz opensim-SC_OLD-484eca323b0e89b2da0c8c9404c1b9bf3a99945b.tar.bz2 opensim-SC_OLD-484eca323b0e89b2da0c8c9404c1b9bf3a99945b.tar.xz |
Merge branch 'master' into careminster
Diffstat (limited to 'OpenSim/Framework/Monitoring')
-rw-r--r-- | OpenSim/Framework/Monitoring/StatsManager.cs | 87 |
1 files changed, 69 insertions, 18 deletions
diff --git a/OpenSim/Framework/Monitoring/StatsManager.cs b/OpenSim/Framework/Monitoring/StatsManager.cs index 31989e5..4844336 100644 --- a/OpenSim/Framework/Monitoring/StatsManager.cs +++ b/OpenSim/Framework/Monitoring/StatsManager.cs | |||
@@ -207,7 +207,7 @@ namespace OpenSim.Framework.Monitoring | |||
207 | return false; | 207 | return false; |
208 | 208 | ||
209 | newContainer = new Dictionary<string, Stat>(container); | 209 | newContainer = new Dictionary<string, Stat>(container); |
210 | newContainer.Remove(stat.UniqueName); | 210 | newContainer.Remove(stat.ShortName); |
211 | 211 | ||
212 | newCategory = new Dictionary<string, Dictionary<string, Stat>>(category); | 212 | newCategory = new Dictionary<string, Dictionary<string, Stat>>(category); |
213 | newCategory.Remove(stat.Container); | 213 | newCategory.Remove(stat.Container); |
@@ -249,6 +249,19 @@ namespace OpenSim.Framework.Monitoring | |||
249 | } | 249 | } |
250 | 250 | ||
251 | /// <summary> | 251 | /// <summary> |
252 | /// Stat type. | ||
253 | /// </summary> | ||
254 | /// <remarks> | ||
255 | /// A push stat is one which is continually updated and so it's value can simply by read. | ||
256 | /// A pull stat is one where reading the value triggers a collection method - the stat is not continually updated. | ||
257 | /// </remarks> | ||
258 | public enum StatType | ||
259 | { | ||
260 | Push, | ||
261 | Pull | ||
262 | } | ||
263 | |||
264 | /// <summary> | ||
252 | /// Verbosity of stat. | 265 | /// Verbosity of stat. |
253 | /// </summary> | 266 | /// </summary> |
254 | /// <remarks> | 267 | /// <remarks> |
@@ -266,11 +279,6 @@ namespace OpenSim.Framework.Monitoring | |||
266 | public class Stat | 279 | public class Stat |
267 | { | 280 | { |
268 | /// <summary> | 281 | /// <summary> |
269 | /// Unique stat name used for indexing. Each ShortName in a Category must be unique. | ||
270 | /// </summary> | ||
271 | public string UniqueName { get; private set; } | ||
272 | |||
273 | /// <summary> | ||
274 | /// Category of this stat (e.g. cache, scene, etc). | 282 | /// Category of this stat (e.g. cache, scene, etc). |
275 | /// </summary> | 283 | /// </summary> |
276 | public string Category { get; private set; } | 284 | public string Category { get; private set; } |
@@ -285,29 +293,65 @@ namespace OpenSim.Framework.Monitoring | |||
285 | /// </value> | 293 | /// </value> |
286 | public string Container { get; private set; } | 294 | public string Container { get; private set; } |
287 | 295 | ||
296 | public StatType StatType { get; private set; } | ||
297 | |||
298 | /// <summary> | ||
299 | /// Action used to update this stat when the value is requested if it's a pull type. | ||
300 | /// </summary> | ||
301 | public Action<Stat> PullAction { get; private set; } | ||
302 | |||
288 | public StatVerbosity Verbosity { get; private set; } | 303 | public StatVerbosity Verbosity { get; private set; } |
289 | public string ShortName { get; private set; } | 304 | public string ShortName { get; private set; } |
290 | public string Name { get; private set; } | 305 | public string Name { get; private set; } |
291 | public string Description { get; private set; } | 306 | public string Description { get; private set; } |
292 | public virtual string UnitName { get; private set; } | 307 | public virtual string UnitName { get; private set; } |
293 | 308 | ||
294 | public virtual double Value { get; set; } | 309 | public virtual double Value |
310 | { | ||
311 | get | ||
312 | { | ||
313 | // Asking for an update here means that the updater cannot access this value without infinite recursion. | ||
314 | // XXX: A slightly messy but simple solution may be to flick a flag so we can tell if this is being | ||
315 | // called by the pull action and just return the value. | ||
316 | if (StatType == StatType.Pull) | ||
317 | PullAction(this); | ||
318 | |||
319 | return m_value; | ||
320 | } | ||
321 | |||
322 | set | ||
323 | { | ||
324 | m_value = value; | ||
325 | } | ||
326 | } | ||
327 | |||
328 | private double m_value; | ||
295 | 329 | ||
296 | /// <summary> | 330 | /// <summary> |
297 | /// Constructor | 331 | /// Constructor |
298 | /// </summary> | 332 | /// </summary> |
299 | /// <param name='shortName'>Short name for the stat. Must not contain spaces. e.g. "LongFrames"</param> | 333 | /// <param name='shortName'>Short name for the stat. Must not contain spaces. e.g. "LongFrames"</param> |
300 | /// <param name='name'>Human readable name for the stat. e.g. "Long frames"</param> | 334 | /// <param name='name'>Human readable name for the stat. e.g. "Long frames"</param> |
335 | /// <param name='description'>Description of stat</param> | ||
301 | /// <param name='unitName'> | 336 | /// <param name='unitName'> |
302 | /// Unit name for the stat. Should be preceeded by a space if the unit name isn't normally appeneded immediately to the value. | 337 | /// Unit name for the stat. Should be preceeded by a space if the unit name isn't normally appeneded immediately to the value. |
303 | /// e.g. " frames" | 338 | /// e.g. " frames" |
304 | /// </param> | 339 | /// </param> |
305 | /// <param name='category'>Category under which this stat should appear, e.g. "scene". Do not capitalize.</param> | 340 | /// <param name='category'>Category under which this stat should appear, e.g. "scene". Do not capitalize.</param> |
306 | /// <param name='container'>Entity to which this stat relates. e.g. scene name if this is a per scene stat.</param> | 341 | /// <param name='container'>Entity to which this stat relates. e.g. scene name if this is a per scene stat.</param> |
342 | /// <param name='type'>Push or pull</param> | ||
343 | /// <param name='pullAction'>Pull stats need an action to update the stat on request. Push stats should set null here.</param> | ||
307 | /// <param name='verbosity'>Verbosity of stat. Controls whether it will appear in short stat display or only full display.</param> | 344 | /// <param name='verbosity'>Verbosity of stat. Controls whether it will appear in short stat display or only full display.</param> |
308 | /// <param name='description'>Description of stat</param> | ||
309 | public Stat( | 345 | public Stat( |
310 | string shortName, string name, string unitName, string category, string container, StatVerbosity verbosity, string description) | 346 | string shortName, |
347 | string name, | ||
348 | string description, | ||
349 | string unitName, | ||
350 | string category, | ||
351 | string container, | ||
352 | StatType type, | ||
353 | Action<Stat> pullAction, | ||
354 | StatVerbosity verbosity) | ||
311 | { | 355 | { |
312 | if (StatsManager.SubCommands.Contains(category)) | 356 | if (StatsManager.SubCommands.Contains(category)) |
313 | throw new Exception( | 357 | throw new Exception( |
@@ -315,18 +359,18 @@ namespace OpenSim.Framework.Monitoring | |||
315 | 359 | ||
316 | ShortName = shortName; | 360 | ShortName = shortName; |
317 | Name = name; | 361 | Name = name; |
362 | Description = description; | ||
318 | UnitName = unitName; | 363 | UnitName = unitName; |
319 | Category = category; | 364 | Category = category; |
320 | Container = container; | 365 | Container = container; |
321 | Verbosity = verbosity; | 366 | StatType = type; |
322 | Description = description; | ||
323 | 367 | ||
324 | UniqueName = GenUniqueName(Container, Category, ShortName); | 368 | if (StatType == StatType.Push && pullAction != null) |
325 | } | 369 | throw new Exception("A push stat cannot have a pull action"); |
370 | else | ||
371 | PullAction = pullAction; | ||
326 | 372 | ||
327 | public static string GenUniqueName(string container, string category, string shortName) | 373 | Verbosity = verbosity; |
328 | { | ||
329 | return string.Format("{0}+{1}+{2}", container, category, shortName); | ||
330 | } | 374 | } |
331 | 375 | ||
332 | public virtual string ToConsoleString() | 376 | public virtual string ToConsoleString() |
@@ -361,8 +405,15 @@ namespace OpenSim.Framework.Monitoring | |||
361 | } | 405 | } |
362 | 406 | ||
363 | public PercentageStat( | 407 | public PercentageStat( |
364 | string shortName, string name, string category, string container, StatVerbosity verbosity, string description) | 408 | string shortName, |
365 | : base(shortName, name, "%", category, container, verbosity, description) {} | 409 | string name, |
410 | string description, | ||
411 | string category, | ||
412 | string container, | ||
413 | StatType type, | ||
414 | Action<Stat> pullAction, | ||
415 | StatVerbosity verbosity) | ||
416 | : base(shortName, name, description, "%", category, container, type, pullAction, verbosity) {} | ||
366 | 417 | ||
367 | public override string ToConsoleString() | 418 | public override string ToConsoleString() |
368 | { | 419 | { |