diff options
author | Justin Clark-Casey (justincc) | 2012-10-23 01:50:05 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2012-10-23 01:52:10 +0100 |
commit | 4578ff74fec7500902f58fbdee6ce5a6b39601fb (patch) | |
tree | 5058ada18085a83ae8a76a791ba1052c7025b6d6 /OpenSim/Framework | |
parent | minor: Get content type handler logger to log "unset" for the content type in... (diff) | |
download | opensim-SC-4578ff74fec7500902f58fbdee6ce5a6b39601fb.zip opensim-SC-4578ff74fec7500902f58fbdee6ce5a6b39601fb.tar.gz opensim-SC-4578ff74fec7500902f58fbdee6ce5a6b39601fb.tar.bz2 opensim-SC-4578ff74fec7500902f58fbdee6ce5a6b39601fb.tar.xz |
Add object count stats for new IncomingPacket and UDPPacketBuffer pools if they are enabled. Add count stats for existing LLUDP pool.
This introduces a pull stat type in addition to the push stat type.
A pull stat takes a method on construction which knows how to update the stat on request.
In this way, special interfaces for pull stat collection are not necessary.
Diffstat (limited to 'OpenSim/Framework')
-rw-r--r-- | OpenSim/Framework/Monitoring/StatsManager.cs | 75 | ||||
-rw-r--r-- | OpenSim/Framework/Pool.cs | 15 |
2 files changed, 84 insertions, 6 deletions
diff --git a/OpenSim/Framework/Monitoring/StatsManager.cs b/OpenSim/Framework/Monitoring/StatsManager.cs index 31989e5..116b2c0 100644 --- a/OpenSim/Framework/Monitoring/StatsManager.cs +++ b/OpenSim/Framework/Monitoring/StatsManager.cs | |||
@@ -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> |
@@ -285,29 +298,65 @@ namespace OpenSim.Framework.Monitoring | |||
285 | /// </value> | 298 | /// </value> |
286 | public string Container { get; private set; } | 299 | public string Container { get; private set; } |
287 | 300 | ||
301 | public StatType StatType { get; private set; } | ||
302 | |||
303 | /// <summary> | ||
304 | /// Action used to update this stat when the value is requested if it's a pull type. | ||
305 | /// </summary> | ||
306 | public Action<Stat> PullAction { get; private set; } | ||
307 | |||
288 | public StatVerbosity Verbosity { get; private set; } | 308 | public StatVerbosity Verbosity { get; private set; } |
289 | public string ShortName { get; private set; } | 309 | public string ShortName { get; private set; } |
290 | public string Name { get; private set; } | 310 | public string Name { get; private set; } |
291 | public string Description { get; private set; } | 311 | public string Description { get; private set; } |
292 | public virtual string UnitName { get; private set; } | 312 | public virtual string UnitName { get; private set; } |
293 | 313 | ||
294 | public virtual double Value { get; set; } | 314 | public virtual double Value |
315 | { | ||
316 | get | ||
317 | { | ||
318 | // Asking for an update here means that the updater cannot access this value without infinite recursion. | ||
319 | // XXX: A slightly messy but simple solution may be to flick a flag so we can tell if this is being | ||
320 | // called by the pull action and just return the value. | ||
321 | if (StatType == StatType.Pull) | ||
322 | PullAction(this); | ||
323 | |||
324 | return m_value; | ||
325 | } | ||
326 | |||
327 | set | ||
328 | { | ||
329 | m_value = value; | ||
330 | } | ||
331 | } | ||
332 | |||
333 | private double m_value; | ||
295 | 334 | ||
296 | /// <summary> | 335 | /// <summary> |
297 | /// Constructor | 336 | /// Constructor |
298 | /// </summary> | 337 | /// </summary> |
299 | /// <param name='shortName'>Short name for the stat. Must not contain spaces. e.g. "LongFrames"</param> | 338 | /// <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> | 339 | /// <param name='name'>Human readable name for the stat. e.g. "Long frames"</param> |
340 | /// <param name='description'>Description of stat</param> | ||
301 | /// <param name='unitName'> | 341 | /// <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. | 342 | /// 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" | 343 | /// e.g. " frames" |
304 | /// </param> | 344 | /// </param> |
305 | /// <param name='category'>Category under which this stat should appear, e.g. "scene". Do not capitalize.</param> | 345 | /// <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> | 346 | /// <param name='container'>Entity to which this stat relates. e.g. scene name if this is a per scene stat.</param> |
347 | /// <param name='type'>Push or pull</param> | ||
348 | /// <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> | 349 | /// <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( | 350 | public Stat( |
310 | string shortName, string name, string unitName, string category, string container, StatVerbosity verbosity, string description) | 351 | string shortName, |
352 | string name, | ||
353 | string description, | ||
354 | string unitName, | ||
355 | string category, | ||
356 | string container, | ||
357 | StatType type, | ||
358 | Action<Stat> pullAction, | ||
359 | StatVerbosity verbosity) | ||
311 | { | 360 | { |
312 | if (StatsManager.SubCommands.Contains(category)) | 361 | if (StatsManager.SubCommands.Contains(category)) |
313 | throw new Exception( | 362 | throw new Exception( |
@@ -315,11 +364,18 @@ namespace OpenSim.Framework.Monitoring | |||
315 | 364 | ||
316 | ShortName = shortName; | 365 | ShortName = shortName; |
317 | Name = name; | 366 | Name = name; |
367 | Description = description; | ||
318 | UnitName = unitName; | 368 | UnitName = unitName; |
319 | Category = category; | 369 | Category = category; |
320 | Container = container; | 370 | Container = container; |
371 | StatType = type; | ||
372 | |||
373 | if (StatType == StatType.Push && pullAction != null) | ||
374 | throw new Exception("A push stat cannot have a pull action"); | ||
375 | else | ||
376 | PullAction = pullAction; | ||
377 | |||
321 | Verbosity = verbosity; | 378 | Verbosity = verbosity; |
322 | Description = description; | ||
323 | 379 | ||
324 | UniqueName = GenUniqueName(Container, Category, ShortName); | 380 | UniqueName = GenUniqueName(Container, Category, ShortName); |
325 | } | 381 | } |
@@ -361,8 +417,15 @@ namespace OpenSim.Framework.Monitoring | |||
361 | } | 417 | } |
362 | 418 | ||
363 | public PercentageStat( | 419 | public PercentageStat( |
364 | string shortName, string name, string category, string container, StatVerbosity verbosity, string description) | 420 | string shortName, |
365 | : base(shortName, name, "%", category, container, verbosity, description) {} | 421 | string name, |
422 | string description, | ||
423 | string category, | ||
424 | string container, | ||
425 | StatType type, | ||
426 | Action<Stat> pullAction, | ||
427 | StatVerbosity verbosity) | ||
428 | : base(shortName, name, description, "%", category, container, type, pullAction, verbosity) {} | ||
366 | 429 | ||
367 | public override string ToConsoleString() | 430 | public override string ToConsoleString() |
368 | { | 431 | { |
diff --git a/OpenSim/Framework/Pool.cs b/OpenSim/Framework/Pool.cs index 1ca06c3..5484f5c 100644 --- a/OpenSim/Framework/Pool.cs +++ b/OpenSim/Framework/Pool.cs | |||
@@ -38,8 +38,23 @@ namespace OpenSim.Framework | |||
38 | /// </remarks> | 38 | /// </remarks> |
39 | public class Pool<T> | 39 | public class Pool<T> |
40 | { | 40 | { |
41 | /// <summary> | ||
42 | /// Number of objects in the pool. | ||
43 | /// </summary> | ||
44 | public int Count | ||
45 | { | ||
46 | get | ||
47 | { | ||
48 | lock (m_pool) | ||
49 | return m_pool.Count; | ||
50 | } | ||
51 | } | ||
52 | |||
41 | private Stack<T> m_pool; | 53 | private Stack<T> m_pool; |
42 | 54 | ||
55 | /// <summary> | ||
56 | /// Maximum pool size. Beyond this, any returned objects are not pooled. | ||
57 | /// </summary> | ||
43 | private int m_maxPoolSize; | 58 | private int m_maxPoolSize; |
44 | 59 | ||
45 | private Func<T> m_createFunction; | 60 | private Func<T> m_createFunction; |