aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Statistics
diff options
context:
space:
mode:
authorJustin Clarke Casey2008-01-28 19:49:07 +0000
committerJustin Clarke Casey2008-01-28 19:49:07 +0000
commitfa5fe6b7f6f187817ad166799f99fe2e5699fbf1 (patch)
treecad7d66b148ea366edb13b69059fbc11d6085414 /OpenSim/Framework/Statistics
parent* ODE Going to Time Step 0.020 = (1000\20) - ((1000\20) * .09) = ~45 pfps (diff)
downloadopensim-SC-fa5fe6b7f6f187817ad166799f99fe2e5699fbf1.zip
opensim-SC-fa5fe6b7f6f187817ad166799f99fe2e5699fbf1.tar.gz
opensim-SC-fa5fe6b7f6f187817ad166799f99fe2e5699fbf1.tar.bz2
opensim-SC-fa5fe6b7f6f187817ad166799f99fe2e5699fbf1.tar.xz
* Move AssetStatsReporter to Framework.Statistics
* The hooks are still plugged in too high at the asset server, but then next layer down is the database and this may be refactored soon. * This change will requires a prebuild
Diffstat (limited to 'OpenSim/Framework/Statistics')
-rw-r--r--OpenSim/Framework/Statistics/AssetStatsReporter.cs82
1 files changed, 82 insertions, 0 deletions
diff --git a/OpenSim/Framework/Statistics/AssetStatsReporter.cs b/OpenSim/Framework/Statistics/AssetStatsReporter.cs
new file mode 100644
index 0000000..ea5add5
--- /dev/null
+++ b/OpenSim/Framework/Statistics/AssetStatsReporter.cs
@@ -0,0 +1,82 @@
1/*
2* Copyright (c) Contributors, http://opensimulator.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28
29using System.Text;
30using System.Timers;
31
32namespace OpenSim.Grid.AssetServer
33{
34 /// <summary>
35 /// Collects and reports information on the requests made to the asset server
36 /// </summary>
37 public class AssetStatsReporter
38 {
39 private Timer ageStatsTimer = new Timer(24 * 60 * 60 * 1000);
40
41 private long assetRequestsToday;
42 public long AssetRequestsToday { get { return assetRequestsToday; } }
43
44 private long assetRequestsYesterday;
45 public long AssetRequestsYesterday { get { return assetRequestsYesterday; } }
46
47 public AssetStatsReporter()
48 {
49 ageStatsTimer.Elapsed += new ElapsedEventHandler(OnAgeing);
50 ageStatsTimer.Enabled = true;
51 }
52
53 private void OnAgeing(object source, ElapsedEventArgs e)
54 {
55 assetRequestsYesterday = assetRequestsToday;
56
57 // There is a possibility that an asset request could occur between the execution of these
58 // two statements. But we're better off without the synchronization overhead.
59 assetRequestsToday = 0;
60 }
61
62 /// <summary>
63 /// Record that a request was made to the asset server
64 /// </summary>
65 public void AddRequest()
66 {
67 assetRequestsToday++;
68 }
69
70 /// <summary>
71 /// Report back collected statistical information.
72 /// </summary>
73 /// <returns></returns>
74 public string Report()
75 {
76 return string.Format(
77@"Asset requests today : {0}
78Asset requests yesterday : {1}",
79 AssetRequestsToday, AssetRequestsYesterday);
80 }
81 }
82}