diff options
author | Diva Canto | 2013-02-21 17:27:03 -0800 |
---|---|---|
committer | Diva Canto | 2013-02-21 17:27:03 -0800 |
commit | 56c979afe8cfc563b9fd0ecfcf39495de20a5f24 (patch) | |
tree | 28f3f63bb7e465bbb1892f54aba1ad15fb9c5c65 | |
parent | Minor formatting cleanup. No changes. (diff) | |
parent | Add a virtual ToOSDMap() function to Monitoring.Stat for future (diff) | |
download | opensim-SC_OLD-56c979afe8cfc563b9fd0ecfcf39495de20a5f24.zip opensim-SC_OLD-56c979afe8cfc563b9fd0ecfcf39495de20a5f24.tar.gz opensim-SC_OLD-56c979afe8cfc563b9fd0ecfcf39495de20a5f24.tar.bz2 opensim-SC_OLD-56c979afe8cfc563b9fd0ecfcf39495de20a5f24.tar.xz |
Merge branch 'master' of ssh://opensimulator.org/var/git/opensim
4 files changed, 236 insertions, 3 deletions
diff --git a/OpenSim/Framework/Monitoring/Stats/CounterStat.cs b/OpenSim/Framework/Monitoring/Stats/CounterStat.cs new file mode 100755 index 0000000..d81f182 --- /dev/null +++ b/OpenSim/Framework/Monitoring/Stats/CounterStat.cs | |||
@@ -0,0 +1,211 @@ | |||
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 OpenSimulator 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 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Linq; | ||
31 | using System.Text; | ||
32 | |||
33 | using OpenMetaverse.StructuredData; | ||
34 | |||
35 | namespace OpenSim.Framework.Monitoring | ||
36 | { | ||
37 | // Create a time histogram of events. The histogram is built in a wrap-around | ||
38 | // array of equally distributed buckets. | ||
39 | // For instance, a minute long histogram of second sized buckets would be: | ||
40 | // new EventHistogram(60, 1000) | ||
41 | public class EventHistogram | ||
42 | { | ||
43 | private int m_timeBase; | ||
44 | private int m_numBuckets; | ||
45 | private int m_bucketMilliseconds; | ||
46 | private int m_lastBucket; | ||
47 | private int m_totalHistogramMilliseconds; | ||
48 | private long[] m_histogram; | ||
49 | private object histoLock = new object(); | ||
50 | |||
51 | public EventHistogram(int numberOfBuckets, int millisecondsPerBucket) | ||
52 | { | ||
53 | m_numBuckets = numberOfBuckets; | ||
54 | m_bucketMilliseconds = millisecondsPerBucket; | ||
55 | m_totalHistogramMilliseconds = m_numBuckets * m_bucketMilliseconds; | ||
56 | |||
57 | m_histogram = new long[m_numBuckets]; | ||
58 | Zero(); | ||
59 | m_lastBucket = 0; | ||
60 | m_timeBase = Util.EnvironmentTickCount(); | ||
61 | } | ||
62 | |||
63 | public void Event() | ||
64 | { | ||
65 | this.Event(1); | ||
66 | } | ||
67 | |||
68 | // Record an event at time 'now' in the histogram. | ||
69 | public void Event(int cnt) | ||
70 | { | ||
71 | lock (histoLock) | ||
72 | { | ||
73 | // The time as displaced from the base of the histogram | ||
74 | int bucketTime = Util.EnvironmentTickCountSubtract(m_timeBase); | ||
75 | |||
76 | // If more than the total time of the histogram, we just start over | ||
77 | if (bucketTime > m_totalHistogramMilliseconds) | ||
78 | { | ||
79 | Zero(); | ||
80 | m_lastBucket = 0; | ||
81 | m_timeBase = Util.EnvironmentTickCount(); | ||
82 | } | ||
83 | else | ||
84 | { | ||
85 | // To which bucket should we add this event? | ||
86 | int bucket = bucketTime / m_bucketMilliseconds; | ||
87 | |||
88 | // Advance m_lastBucket to the new bucket. Zero any buckets skipped over. | ||
89 | while (bucket != m_lastBucket) | ||
90 | { | ||
91 | // Zero from just after the last bucket to the new bucket or the end | ||
92 | for (int jj = m_lastBucket + 1; jj <= Math.Min(bucket, m_numBuckets - 1); jj++) | ||
93 | { | ||
94 | m_histogram[jj] = 0; | ||
95 | } | ||
96 | m_lastBucket = bucket; | ||
97 | // If the new bucket is off the end, wrap around to the beginning | ||
98 | if (bucket > m_numBuckets) | ||
99 | { | ||
100 | bucket -= m_numBuckets; | ||
101 | m_lastBucket = 0; | ||
102 | m_histogram[m_lastBucket] = 0; | ||
103 | m_timeBase += m_totalHistogramMilliseconds; | ||
104 | } | ||
105 | } | ||
106 | } | ||
107 | m_histogram[m_lastBucket] += cnt; | ||
108 | } | ||
109 | } | ||
110 | |||
111 | // Get a copy of the current histogram | ||
112 | public long[] GetHistogram() | ||
113 | { | ||
114 | long[] ret = new long[m_numBuckets]; | ||
115 | lock (histoLock) | ||
116 | { | ||
117 | int indx = m_lastBucket + 1; | ||
118 | for (int ii = 0; ii < m_numBuckets; ii++, indx++) | ||
119 | { | ||
120 | if (indx >= m_numBuckets) | ||
121 | indx = 0; | ||
122 | ret[ii] = m_histogram[indx]; | ||
123 | } | ||
124 | } | ||
125 | return ret; | ||
126 | } | ||
127 | |||
128 | // Get a copy of the current histogram | ||
129 | public OSDArray GetHistogramAsOSDArray() | ||
130 | { | ||
131 | OSDArray ret = new OSDArray(m_numBuckets); | ||
132 | lock (histoLock) | ||
133 | { | ||
134 | int indx = m_lastBucket + 1; | ||
135 | for (int ii = 0; ii < m_numBuckets; ii++, indx++) | ||
136 | { | ||
137 | if (indx >= m_numBuckets) | ||
138 | indx = 0; | ||
139 | ret[ii] = OSD.FromLong(m_histogram[indx]); | ||
140 | } | ||
141 | } | ||
142 | return ret; | ||
143 | } | ||
144 | |||
145 | // Zero out the histogram | ||
146 | public void Zero() | ||
147 | { | ||
148 | lock (histoLock) | ||
149 | { | ||
150 | for (int ii = 0; ii < m_numBuckets; ii++) | ||
151 | m_histogram[ii] = 0; | ||
152 | } | ||
153 | } | ||
154 | } | ||
155 | |||
156 | // A statistic that wraps a counter. | ||
157 | // Built this way mostly so histograms and history can be created. | ||
158 | public class CounterStat : Stat | ||
159 | { | ||
160 | private SortedDictionary<string, EventHistogram> m_histograms; | ||
161 | private object counterLock = new object(); | ||
162 | |||
163 | public CounterStat( | ||
164 | string shortName, | ||
165 | string name, | ||
166 | string description, | ||
167 | string unitName, | ||
168 | string category, | ||
169 | string container, | ||
170 | StatVerbosity verbosity) | ||
171 | : base(shortName, name, description, unitName, category, container, StatType.Push, null, verbosity) | ||
172 | { | ||
173 | m_histograms = new SortedDictionary<string, EventHistogram>(); | ||
174 | } | ||
175 | |||
176 | // Histograms are presumably added at intialization time and the list does not change thereafter. | ||
177 | // Thus no locking of the histogram list. | ||
178 | public void AddHistogram(string histoName, EventHistogram histo) | ||
179 | { | ||
180 | m_histograms.Add(histoName, histo); | ||
181 | } | ||
182 | |||
183 | public delegate void ProcessHistogram(string name, EventHistogram histo); | ||
184 | public void ForEachHistogram(ProcessHistogram process) | ||
185 | { | ||
186 | foreach (KeyValuePair<string, EventHistogram> kvp in m_histograms) | ||
187 | { | ||
188 | process(kvp.Key, kvp.Value); | ||
189 | } | ||
190 | } | ||
191 | |||
192 | public void Event() | ||
193 | { | ||
194 | this.Event(1); | ||
195 | } | ||
196 | |||
197 | // Count the underlying counter. | ||
198 | public void Event(int cnt) | ||
199 | { | ||
200 | lock (counterLock) | ||
201 | { | ||
202 | base.Value += cnt; | ||
203 | |||
204 | foreach (EventHistogram histo in m_histograms.Values) | ||
205 | { | ||
206 | histo.Event(cnt); | ||
207 | } | ||
208 | } | ||
209 | } | ||
210 | } | ||
211 | } | ||
diff --git a/OpenSim/Framework/Monitoring/Stats/Stat.cs b/OpenSim/Framework/Monitoring/Stats/Stat.cs index f91251b..c8d9174 100644 --- a/OpenSim/Framework/Monitoring/Stats/Stat.cs +++ b/OpenSim/Framework/Monitoring/Stats/Stat.cs | |||
@@ -29,12 +29,14 @@ using System; | |||
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Text; | 30 | using System.Text; |
31 | 31 | ||
32 | using OpenMetaverse.StructuredData; | ||
33 | |||
32 | namespace OpenSim.Framework.Monitoring | 34 | namespace OpenSim.Framework.Monitoring |
33 | { | 35 | { |
34 | /// <summary> | 36 | /// <summary> |
35 | /// Holds individual statistic details | 37 | /// Holds individual statistic details |
36 | /// </summary> | 38 | /// </summary> |
37 | public class Stat | 39 | public class Stat : IDisposable |
38 | { | 40 | { |
39 | /// <summary> | 41 | /// <summary> |
40 | /// Category of this stat (e.g. cache, scene, etc). | 42 | /// Category of this stat (e.g. cache, scene, etc). |
@@ -181,6 +183,12 @@ namespace OpenSim.Framework.Monitoring | |||
181 | Verbosity = verbosity; | 183 | Verbosity = verbosity; |
182 | } | 184 | } |
183 | 185 | ||
186 | // IDisposable.Dispose() | ||
187 | public virtual void Dispose() | ||
188 | { | ||
189 | return; | ||
190 | } | ||
191 | |||
184 | /// <summary> | 192 | /// <summary> |
185 | /// Record a value in the sample set. | 193 | /// Record a value in the sample set. |
186 | /// </summary> | 194 | /// </summary> |
@@ -210,6 +218,20 @@ namespace OpenSim.Framework.Monitoring | |||
210 | return sb.ToString(); | 218 | return sb.ToString(); |
211 | } | 219 | } |
212 | 220 | ||
221 | public virtual OSDMap ToOSDMap() | ||
222 | { | ||
223 | OSDMap ret = new OSDMap(); | ||
224 | ret.Add("Category", OSD.FromString(Category)); | ||
225 | ret.Add("Container", OSD.FromString(Container)); | ||
226 | ret.Add("ShortName", OSD.FromString(ShortName)); | ||
227 | ret.Add("Name", OSD.FromString(Name)); | ||
228 | ret.Add("Description", OSD.FromString(Description)); | ||
229 | ret.Add("UnitName", OSD.FromString(UnitName)); | ||
230 | ret.Add("Value", OSD.FromReal(Value)); | ||
231 | |||
232 | return ret; | ||
233 | } | ||
234 | |||
213 | protected void AppendMeasuresOfInterest(StringBuilder sb) | 235 | protected void AppendMeasuresOfInterest(StringBuilder sb) |
214 | { | 236 | { |
215 | if ((MeasuresOfInterest & MeasuresOfInterest.AverageChangeOverTime) | 237 | if ((MeasuresOfInterest & MeasuresOfInterest.AverageChangeOverTime) |
diff --git a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs index ce79f07..00d1fd8 100644 --- a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs | |||
@@ -693,7 +693,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
693 | } | 693 | } |
694 | 694 | ||
695 | bool bakedTextureValid = m_scene.AvatarFactory.ValidateBakedTextureCache(sp); | 695 | bool bakedTextureValid = m_scene.AvatarFactory.ValidateBakedTextureCache(sp); |
696 | outputAction("{0} baked appearance texture is {1}", sp.Name, bakedTextureValid ? "OK" : "corrupt"); | 696 | outputAction("{0} baked appearance texture is {1}", sp.Name, bakedTextureValid ? "OK" : "incomplete"); |
697 | } | 697 | } |
698 | } | 698 | } |
699 | } | 699 | } |
diff --git a/OpenSim/Region/OptionalModules/Avatar/Appearance/AppearanceInfoModule.cs b/OpenSim/Region/OptionalModules/Avatar/Appearance/AppearanceInfoModule.cs index d718a2f..fa35f0f 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Appearance/AppearanceInfoModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Appearance/AppearanceInfoModule.cs | |||
@@ -222,7 +222,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Appearance | |||
222 | { | 222 | { |
223 | bool bakedTextureValid = scene.AvatarFactory.ValidateBakedTextureCache(sp); | 223 | bool bakedTextureValid = scene.AvatarFactory.ValidateBakedTextureCache(sp); |
224 | MainConsole.Instance.OutputFormat( | 224 | MainConsole.Instance.OutputFormat( |
225 | "{0} baked appearance texture is {1}", sp.Name, bakedTextureValid ? "OK" : "corrupt"); | 225 | "{0} baked appearance texture is {1}", sp.Name, bakedTextureValid ? "OK" : "incomplete"); |
226 | } | 226 | } |
227 | ); | 227 | ); |
228 | } | 228 | } |