aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Monitoring/Checks
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Framework/Monitoring/Checks/Check.cs8
-rw-r--r--OpenSim/Framework/Monitoring/ChecksManager.cs45
2 files changed, 25 insertions, 28 deletions
diff --git a/OpenSim/Framework/Monitoring/Checks/Check.cs b/OpenSim/Framework/Monitoring/Checks/Check.cs
index 594386a..9a1bd45 100644
--- a/OpenSim/Framework/Monitoring/Checks/Check.cs
+++ b/OpenSim/Framework/Monitoring/Checks/Check.cs
@@ -79,7 +79,7 @@ namespace OpenSim.Framework.Monitoring
79 string category, 79 string category,
80 string container, 80 string container,
81 Func<Check, bool> checkFunc, 81 Func<Check, bool> checkFunc,
82 StatVerbosity verbosity) 82 StatVerbosity verbosity)
83 { 83 {
84 if (ChecksManager.SubCommands.Contains(category)) 84 if (ChecksManager.SubCommands.Contains(category))
85 throw new Exception( 85 throw new Exception(
@@ -108,9 +108,9 @@ namespace OpenSim.Framework.Monitoring
108 public virtual string ToConsoleString() 108 public virtual string ToConsoleString()
109 { 109 {
110 return string.Format( 110 return string.Format(
111 "{0}.{1}.{2} - {3}", 111 "{0}.{1}.{2} - {3}",
112 Category, 112 Category,
113 Container, 113 Container,
114 ShortName, 114 ShortName,
115 Description); 115 Description);
116 } 116 }
diff --git a/OpenSim/Framework/Monitoring/ChecksManager.cs b/OpenSim/Framework/Monitoring/ChecksManager.cs
index e4a7f8c..ff3b041 100644
--- a/OpenSim/Framework/Monitoring/ChecksManager.cs
+++ b/OpenSim/Framework/Monitoring/ChecksManager.cs
@@ -132,8 +132,8 @@ namespace OpenSim.Framework.Monitoring
132 /// <returns></returns> 132 /// <returns></returns>
133 public static bool RegisterCheck(Check check) 133 public static bool RegisterCheck(Check check)
134 { 134 {
135 SortedDictionary<string, SortedDictionary<string, Check>> category = null, newCategory; 135 SortedDictionary<string, SortedDictionary<string, Check>> category = null;
136 SortedDictionary<string, Check> container = null, newContainer; 136 SortedDictionary<string, Check> container = null;
137 137
138 lock (RegisteredChecks) 138 lock (RegisteredChecks)
139 { 139 {
@@ -146,19 +146,15 @@ namespace OpenSim.Framework.Monitoring
146 // We take a copy-on-write approach here of replacing dictionaries when keys are added or removed. 146 // We take a copy-on-write approach here of replacing dictionaries when keys are added or removed.
147 // This means that we don't need to lock or copy them on iteration, which will be a much more 147 // This means that we don't need to lock or copy them on iteration, which will be a much more
148 // common operation after startup. 148 // common operation after startup.
149 if (container != null) 149 if (container == null)
150 newContainer = new SortedDictionary<string, Check>(container); 150 container = new SortedDictionary<string, Check>();
151 else
152 newContainer = new SortedDictionary<string, Check>();
153 151
154 if (category != null) 152 if (category == null)
155 newCategory = new SortedDictionary<string, SortedDictionary<string, Check>>(category); 153 category = new SortedDictionary<string, SortedDictionary<string, Check>>();
156 else
157 newCategory = new SortedDictionary<string, SortedDictionary<string, Check>>();
158 154
159 newContainer[check.ShortName] = check; 155 container[check.ShortName] = check;
160 newCategory[check.Container] = newContainer; 156 category[check.Container] = container;
161 RegisteredChecks[check.Category] = newCategory; 157 RegisteredChecks[check.Category] = category;
162 } 158 }
163 159
164 return true; 160 return true;
@@ -171,23 +167,24 @@ namespace OpenSim.Framework.Monitoring
171 /// <returns></returns> 167 /// <returns></returns>
172 public static bool DeregisterCheck(Check check) 168 public static bool DeregisterCheck(Check check)
173 { 169 {
174 SortedDictionary<string, SortedDictionary<string, Check>> category = null, newCategory; 170 SortedDictionary<string, SortedDictionary<string, Check>> category = null;
175 SortedDictionary<string, Check> container = null, newContainer; 171 SortedDictionary<string, Check> container = null;
176 172
177 lock (RegisteredChecks) 173 lock (RegisteredChecks)
178 { 174 {
179 if (!TryGetCheckParents(check, out category, out container)) 175 if (!TryGetCheckParents(check, out category, out container))
180 return false; 176 return false;
181 177
182 newContainer = new SortedDictionary<string, Check>(container); 178 if(container != null)
183 newContainer.Remove(check.ShortName); 179 {
184 180 container.Remove(check.ShortName);
185 newCategory = new SortedDictionary<string, SortedDictionary<string, Check>>(category); 181 if(category != null && container.Count == 0)
186 newCategory.Remove(check.Container); 182 {
187 183 category.Remove(check.Container);
188 newCategory[check.Container] = newContainer; 184 if(category.Count == 0)
189 RegisteredChecks[check.Category] = newCategory; 185 RegisteredChecks.Remove(check.Category);
190 186 }
187 }
191 return true; 188 return true;
192 } 189 }
193 } 190 }