aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2011-03-29 23:08:44 +0100
committerJustin Clark-Casey (justincc)2011-03-29 23:08:44 +0100
commitf754dedbef45097910f3977ca22e9afaaaed9196 (patch)
tree88f2119ec41194436baae80c974795f4083f0944 /OpenSim/Region/CoreModules
parentImprovement over 2 commits ago: make the hyperlink check understand port 80. (diff)
parentdisable prim count debug logging temporarily (diff)
downloadopensim-SC-f754dedbef45097910f3977ca22e9afaaaed9196.zip
opensim-SC-f754dedbef45097910f3977ca22e9afaaaed9196.tar.gz
opensim-SC-f754dedbef45097910f3977ca22e9afaaaed9196.tar.bz2
opensim-SC-f754dedbef45097910f3977ca22e9afaaaed9196.tar.xz
Merge branch 'primcounts'
Diffstat (limited to 'OpenSim/Region/CoreModules')
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Combat/CombatModule.cs1
-rw-r--r--OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs2
-rw-r--r--OpenSim/Region/CoreModules/World/Land/LandObject.cs2
-rw-r--r--OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs118
-rw-r--r--OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs55
5 files changed, 160 insertions, 18 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Combat/CombatModule.cs b/OpenSim/Region/CoreModules/Avatar/Combat/CombatModule.cs
index a5fcb49..0babeb5 100644
--- a/OpenSim/Region/CoreModules/Avatar/Combat/CombatModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Combat/CombatModule.cs
@@ -28,6 +28,7 @@
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using Nini.Config; 30using Nini.Config;
31using OpenSim.Framework;
31using OpenSim.Region.Framework.Interfaces; 32using OpenSim.Region.Framework.Interfaces;
32using OpenSim.Region.Framework.Scenes; 33using OpenSim.Region.Framework.Scenes;
33using OpenMetaverse; 34using OpenMetaverse;
diff --git a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
index d0727d9..52e3718 100644
--- a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
+++ b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
@@ -805,7 +805,7 @@ namespace OpenSim.Region.CoreModules.World.Land
805 ILandObject landUnderPrim = GetLandObject(position.X, position.Y); 805 ILandObject landUnderPrim = GetLandObject(position.X, position.Y);
806 if (landUnderPrim != null) 806 if (landUnderPrim != null)
807 { 807 {
808 landUnderPrim.AddPrimToCount(obj); 808 ((LandObject)landUnderPrim).AddPrimToCount(obj);
809 } 809 }
810 } 810 }
811 811
diff --git a/OpenSim/Region/CoreModules/World/Land/LandObject.cs b/OpenSim/Region/CoreModules/World/Land/LandObject.cs
index 749bb3d..e7bdb19 100644
--- a/OpenSim/Region/CoreModules/World/Land/LandObject.cs
+++ b/OpenSim/Region/CoreModules/World/Land/LandObject.cs
@@ -243,7 +243,7 @@ namespace OpenSim.Region.CoreModules.World.Land
243 } 243 }
244 244
245 remote_client.SendLandProperties(seq_id, 245 remote_client.SendLandProperties(seq_id,
246 snap_selection, request_result, LandData, 246 snap_selection, request_result, this,
247 (float)m_scene.RegionInfo.RegionSettings.ObjectBonus, 247 (float)m_scene.RegionInfo.RegionSettings.ObjectBonus,
248 GetParcelMaxPrimCount(this), 248 GetParcelMaxPrimCount(this),
249 GetSimulatorMaxPrimCount(this), regionFlags); 249 GetSimulatorMaxPrimCount(this), regionFlags);
diff --git a/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs b/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs
index 9fd347e..d126b26 100644
--- a/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs
+++ b/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs
@@ -51,8 +51,7 @@ namespace OpenSim.Region.CoreModules.World.Land
51 51
52 public class PrimCountModule : IPrimCountModule, INonSharedRegionModule 52 public class PrimCountModule : IPrimCountModule, INonSharedRegionModule
53 { 53 {
54// private static readonly ILog m_log = 54 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
55// LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
56 55
57 private Scene m_Scene; 56 private Scene m_Scene;
58 private Dictionary<UUID, PrimCounts> m_PrimCounts = 57 private Dictionary<UUID, PrimCounts> m_PrimCounts =
@@ -123,6 +122,11 @@ namespace OpenSim.Region.CoreModules.World.Land
123 { 122 {
124 if (!m_Tainted) 123 if (!m_Tainted)
125 AddObject(obj); 124 AddObject(obj);
125// else
126// m_log.DebugFormat(
127// "[PRIM COUNT MODULE]: Ignoring OnParcelPrimCountAdd() for {0} on {1} since count is tainted",
128// obj.Name, m_Scene.RegionInfo.RegionName);
129
126 } 130 }
127 } 131 }
128 132
@@ -133,11 +137,18 @@ namespace OpenSim.Region.CoreModules.World.Land
133 { 137 {
134 if (!m_Tainted) 138 if (!m_Tainted)
135 RemoveObject(obj); 139 RemoveObject(obj);
140// else
141// m_log.DebugFormat(
142// "[PRIM COUNT MODULE]: Ignoring OnObjectBeingRemovedFromScene() for {0} on {1} since count is tainted",
143// obj.Name, m_Scene.RegionInfo.RegionName);
136 } 144 }
137 } 145 }
138 146
139 private void OnParcelPrimCountTainted() 147 private void OnParcelPrimCountTainted()
140 { 148 {
149// m_log.DebugFormat(
150// "[PRIM COUNT MODULE]: OnParcelPrimCountTainted() called on {0}", m_Scene.RegionInfo.RegionName);
151
141 lock (m_TaintLock) 152 lock (m_TaintLock)
142 m_Tainted = true; 153 m_Tainted = true;
143 } 154 }
@@ -163,7 +174,7 @@ namespace OpenSim.Region.CoreModules.World.Land
163 // NOTE: Call under Taint Lock 174 // NOTE: Call under Taint Lock
164 private void AddObject(SceneObjectGroup obj) 175 private void AddObject(SceneObjectGroup obj)
165 { 176 {
166// m_log.DebugFormat("[PRIM COUNT MODULE]: Adding object {0} to prim count", obj.Name); 177// m_log.DebugFormat("[PRIM COUNT MODULE]: Adding object {0} {1} to prim count", obj.Name, obj.UUID);
167 178
168 if (obj.IsAttachment) 179 if (obj.IsAttachment)
169 return; 180 return;
@@ -214,10 +225,16 @@ namespace OpenSim.Region.CoreModules.World.Land
214 // NOTE: Call under Taint Lock 225 // NOTE: Call under Taint Lock
215 private void RemoveObject(SceneObjectGroup obj) 226 private void RemoveObject(SceneObjectGroup obj)
216 { 227 {
228// m_log.DebugFormat("[PRIM COUNT MODULE]: Removing object {0} {1} from prim count", obj.Name, obj.UUID);
229
230 // Currently this is being done by tainting the count instead.
217 } 231 }
218 232
219 public IPrimCounts GetPrimCounts(UUID parcelID) 233 public IPrimCounts GetPrimCounts(UUID parcelID)
220 { 234 {
235// m_log.DebugFormat(
236// "[PRIM COUNT MODULE]: GetPrimCounts for parcel {0} in {1}", parcelID, m_Scene.RegionInfo.RegionName);
237
221 PrimCounts primCounts; 238 PrimCounts primCounts;
222 239
223 lock (m_PrimCounts) 240 lock (m_PrimCounts)
@@ -239,7 +256,7 @@ namespace OpenSim.Region.CoreModules.World.Land
239 /// <returns></returns> 256 /// <returns></returns>
240 public int GetOwnerCount(UUID parcelID) 257 public int GetOwnerCount(UUID parcelID)
241 { 258 {
242// m_log.DebugFormat("[PRIM COUNT MODULE]: GetOwnerCount for {0}", parcelID); 259 int count = 0;
243 260
244 lock (m_TaintLock) 261 lock (m_TaintLock)
245 { 262 {
@@ -248,9 +265,14 @@ namespace OpenSim.Region.CoreModules.World.Land
248 265
249 ParcelCounts counts; 266 ParcelCounts counts;
250 if (m_ParcelCounts.TryGetValue(parcelID, out counts)) 267 if (m_ParcelCounts.TryGetValue(parcelID, out counts))
251 return counts.Owner; 268 count = counts.Owner;
252 } 269 }
253 return 0; 270
271// m_log.DebugFormat(
272// "[PRIM COUNT MODULE]: GetOwnerCount for parcel {0} in {1} returning {2}",
273// parcelID, m_Scene.RegionInfo.RegionName, count);
274
275 return count;
254 } 276 }
255 277
256 /// <summary> 278 /// <summary>
@@ -260,6 +282,8 @@ namespace OpenSim.Region.CoreModules.World.Land
260 /// <returns></returns> 282 /// <returns></returns>
261 public int GetGroupCount(UUID parcelID) 283 public int GetGroupCount(UUID parcelID)
262 { 284 {
285 int count = 0;
286
263 lock (m_TaintLock) 287 lock (m_TaintLock)
264 { 288 {
265 if (m_Tainted) 289 if (m_Tainted)
@@ -267,9 +291,14 @@ namespace OpenSim.Region.CoreModules.World.Land
267 291
268 ParcelCounts counts; 292 ParcelCounts counts;
269 if (m_ParcelCounts.TryGetValue(parcelID, out counts)) 293 if (m_ParcelCounts.TryGetValue(parcelID, out counts))
270 return counts.Group; 294 count = counts.Group;
271 } 295 }
272 return 0; 296
297// m_log.DebugFormat(
298// "[PRIM COUNT MODULE]: GetGroupCount for parcel {0} in {1} returning {2}",
299// parcelID, m_Scene.RegionInfo.RegionName, count);
300
301 return count;
273 } 302 }
274 303
275 /// <summary> 304 /// <summary>
@@ -279,6 +308,35 @@ namespace OpenSim.Region.CoreModules.World.Land
279 /// <returns></returns> 308 /// <returns></returns>
280 public int GetOthersCount(UUID parcelID) 309 public int GetOthersCount(UUID parcelID)
281 { 310 {
311 int count = 0;
312
313 lock (m_TaintLock)
314 {
315 if (m_Tainted)
316 Recount();
317
318 ParcelCounts counts;
319 if (m_ParcelCounts.TryGetValue(parcelID, out counts))
320 count = counts.Others;
321 }
322
323// m_log.DebugFormat(
324// "[PRIM COUNT MODULE]: GetOthersCount for parcel {0} in {1} returning {2}",
325// parcelID, m_Scene.RegionInfo.RegionName, count);
326
327 return count;
328 }
329
330 /// <summary>
331 /// Get the total count of owner, group and others prims on the parcel.
332 /// FIXME: Need to do selected prims once this is reimplemented.
333 /// </summary>
334 /// <param name="parcelID"></param>
335 /// <returns></returns>
336 public int GetTotalCount(UUID parcelID)
337 {
338 int count = 0;
339
282 lock (m_TaintLock) 340 lock (m_TaintLock)
283 { 341 {
284 if (m_Tainted) 342 if (m_Tainted)
@@ -286,9 +344,18 @@ namespace OpenSim.Region.CoreModules.World.Land
286 344
287 ParcelCounts counts; 345 ParcelCounts counts;
288 if (m_ParcelCounts.TryGetValue(parcelID, out counts)) 346 if (m_ParcelCounts.TryGetValue(parcelID, out counts))
289 return counts.Others; 347 {
348 count = counts.Owner;
349 count += counts.Group;
350 count += counts.Others;
351 }
290 } 352 }
291 return 0; 353
354// m_log.DebugFormat(
355// "[PRIM COUNT MODULE]: GetTotalCount for parcel {0} in {1} returning {2}",
356// parcelID, m_Scene.RegionInfo.RegionName, count);
357
358 return count;
292 } 359 }
293 360
294 /// <summary> 361 /// <summary>
@@ -298,6 +365,8 @@ namespace OpenSim.Region.CoreModules.World.Land
298 /// <returns></returns> 365 /// <returns></returns>
299 public int GetSimulatorCount(UUID parcelID) 366 public int GetSimulatorCount(UUID parcelID)
300 { 367 {
368 int count = 0;
369
301 lock (m_TaintLock) 370 lock (m_TaintLock)
302 { 371 {
303 if (m_Tainted) 372 if (m_Tainted)
@@ -308,10 +377,15 @@ namespace OpenSim.Region.CoreModules.World.Land
308 { 377 {
309 int val; 378 int val;
310 if (m_SimwideCounts.TryGetValue(owner, out val)) 379 if (m_SimwideCounts.TryGetValue(owner, out val))
311 return val; 380 count = val;
312 } 381 }
313 } 382 }
314 return 0; 383
384// m_log.DebugFormat(
385// "[PRIM COUNT MODULE]: GetOthersCount for parcel {0} in {1} returning {2}",
386// parcelID, m_Scene.RegionInfo.RegionName, count);
387
388 return count;
315 } 389 }
316 390
317 /// <summary> 391 /// <summary>
@@ -322,6 +396,8 @@ namespace OpenSim.Region.CoreModules.World.Land
322 /// <returns></returns> 396 /// <returns></returns>
323 public int GetUserCount(UUID parcelID, UUID userID) 397 public int GetUserCount(UUID parcelID, UUID userID)
324 { 398 {
399 int count = 0;
400
325 lock (m_TaintLock) 401 lock (m_TaintLock)
326 { 402 {
327 if (m_Tainted) 403 if (m_Tainted)
@@ -332,10 +408,15 @@ namespace OpenSim.Region.CoreModules.World.Land
332 { 408 {
333 int val; 409 int val;
334 if (counts.Users.TryGetValue(userID, out val)) 410 if (counts.Users.TryGetValue(userID, out val))
335 return val; 411 count = val;
336 } 412 }
337 } 413 }
338 return 0; 414
415// m_log.DebugFormat(
416// "[PRIM COUNT MODULE]: GetUserCount for user {0} in parcel {1} in region {2} returning {3}",
417// userID, parcelID, m_Scene.RegionInfo.RegionName, count);
418
419 return count;
339 } 420 }
340 421
341 // NOTE: This method MUST be called while holding the taint lock! 422 // NOTE: This method MUST be called while holding the taint lock!
@@ -367,6 +448,7 @@ namespace OpenSim.Region.CoreModules.World.Land
367 if (!m_OwnerMap.ContainsKey(k)) 448 if (!m_OwnerMap.ContainsKey(k))
368 m_PrimCounts.Remove(k); 449 m_PrimCounts.Remove(k);
369 } 450 }
451
370 m_Tainted = false; 452 m_Tainted = false;
371 } 453 }
372 } 454 }
@@ -408,6 +490,14 @@ namespace OpenSim.Region.CoreModules.World.Land
408 return m_Parent.GetOthersCount(m_ParcelID); 490 return m_Parent.GetOthersCount(m_ParcelID);
409 } 491 }
410 } 492 }
493
494 public int Total
495 {
496 get
497 {
498 return m_Parent.GetTotalCount(m_ParcelID);
499 }
500 }
411 501
412 public int Simulator 502 public int Simulator
413 { 503 {
diff --git a/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs b/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs
index c9d393f..58bd841 100644
--- a/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs
+++ b/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs
@@ -78,9 +78,10 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests
78 Assert.That(pc.Owner, Is.EqualTo(0)); 78 Assert.That(pc.Owner, Is.EqualTo(0));
79 Assert.That(pc.Group, Is.EqualTo(0)); 79 Assert.That(pc.Group, Is.EqualTo(0));
80 Assert.That(pc.Others, Is.EqualTo(0)); 80 Assert.That(pc.Others, Is.EqualTo(0));
81 Assert.That(pc.Total, Is.EqualTo(0));
81 Assert.That(pc.Users[m_userId], Is.EqualTo(0)); 82 Assert.That(pc.Users[m_userId], Is.EqualTo(0));
82 Assert.That(pc.Users[m_dummyUserId], Is.EqualTo(0)); 83 Assert.That(pc.Users[m_dummyUserId], Is.EqualTo(0));
83 Assert.That(pc.Simulator, Is.EqualTo(0)); 84 Assert.That(pc.Simulator, Is.EqualTo(0));
84 85
85 SceneObjectGroup sog = SceneSetupHelpers.CreateSceneObject(3, m_userId, 0x01); 86 SceneObjectGroup sog = SceneSetupHelpers.CreateSceneObject(3, m_userId, 0x01);
86 m_scene.AddNewSceneObject(sog, false); 87 m_scene.AddNewSceneObject(sog, false);
@@ -88,6 +89,7 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests
88 Assert.That(pc.Owner, Is.EqualTo(3)); 89 Assert.That(pc.Owner, Is.EqualTo(3));
89 Assert.That(pc.Group, Is.EqualTo(0)); 90 Assert.That(pc.Group, Is.EqualTo(0));
90 Assert.That(pc.Others, Is.EqualTo(0)); 91 Assert.That(pc.Others, Is.EqualTo(0));
92 Assert.That(pc.Total, Is.EqualTo(3));
91 Assert.That(pc.Users[m_userId], Is.EqualTo(3)); 93 Assert.That(pc.Users[m_userId], Is.EqualTo(3));
92 Assert.That(pc.Users[m_dummyUserId], Is.EqualTo(0)); 94 Assert.That(pc.Users[m_dummyUserId], Is.EqualTo(0));
93 Assert.That(pc.Simulator, Is.EqualTo(3)); 95 Assert.That(pc.Simulator, Is.EqualTo(3));
@@ -99,12 +101,37 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests
99 Assert.That(pc.Owner, Is.EqualTo(5)); 101 Assert.That(pc.Owner, Is.EqualTo(5));
100 Assert.That(pc.Group, Is.EqualTo(0)); 102 Assert.That(pc.Group, Is.EqualTo(0));
101 Assert.That(pc.Others, Is.EqualTo(0)); 103 Assert.That(pc.Others, Is.EqualTo(0));
104 Assert.That(pc.Total, Is.EqualTo(5));
102 Assert.That(pc.Users[m_userId], Is.EqualTo(5)); 105 Assert.That(pc.Users[m_userId], Is.EqualTo(5));
103 Assert.That(pc.Users[m_dummyUserId], Is.EqualTo(0)); 106 Assert.That(pc.Users[m_dummyUserId], Is.EqualTo(0));
104 Assert.That(pc.Simulator, Is.EqualTo(5)); 107 Assert.That(pc.Simulator, Is.EqualTo(5));
105 } 108 }
106 109
107 /// <summary> 110 /// <summary>
111 /// Test count after a parcel owner owned copied object is added.
112 /// </summary>
113 [Test]
114 public void TestCopiedOwnerObject()
115 {
116 TestHelper.InMethod();
117// log4net.Config.XmlConfigurator.Configure();
118
119 IPrimCounts pc = m_lo.PrimCounts;
120
121 SceneObjectGroup sog = SceneSetupHelpers.CreateSceneObject(3, m_userId, 0x01);
122 m_scene.AddNewSceneObject(sog, false);
123 m_scene.SceneGraph.DuplicateObject(sog.LocalId, Vector3.Zero, 0, m_userId, UUID.Zero, Quaternion.Identity);
124
125 Assert.That(pc.Owner, Is.EqualTo(6));
126 Assert.That(pc.Group, Is.EqualTo(0));
127 Assert.That(pc.Others, Is.EqualTo(0));
128 Assert.That(pc.Total, Is.EqualTo(6));
129 Assert.That(pc.Users[m_userId], Is.EqualTo(6));
130 Assert.That(pc.Users[m_dummyUserId], Is.EqualTo(0));
131 Assert.That(pc.Simulator, Is.EqualTo(6));
132 }
133
134 /// <summary>
108 /// Test count after a parcel owner owned object is removed. 135 /// Test count after a parcel owner owned object is removed.
109 /// </summary> 136 /// </summary>
110 [Test] 137 [Test]
@@ -123,9 +150,33 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests
123 Assert.That(pc.Owner, Is.EqualTo(1)); 150 Assert.That(pc.Owner, Is.EqualTo(1));
124 Assert.That(pc.Group, Is.EqualTo(0)); 151 Assert.That(pc.Group, Is.EqualTo(0));
125 Assert.That(pc.Others, Is.EqualTo(0)); 152 Assert.That(pc.Others, Is.EqualTo(0));
153 Assert.That(pc.Total, Is.EqualTo(1));
126 Assert.That(pc.Users[m_userId], Is.EqualTo(1)); 154 Assert.That(pc.Users[m_userId], Is.EqualTo(1));
127 Assert.That(pc.Users[m_dummyUserId], Is.EqualTo(0)); 155 Assert.That(pc.Users[m_dummyUserId], Is.EqualTo(0));
128 Assert.That(pc.Simulator, Is.EqualTo(1)); 156 Assert.That(pc.Simulator, Is.EqualTo(1));
129 } 157 }
158
159 /// <summary>
160 /// Test the count is correct after is has been tainted.
161 /// </summary>
162 [Test]
163 public void TestTaint()
164 {
165 TestHelper.InMethod();
166 IPrimCounts pc = m_lo.PrimCounts;
167
168 SceneObjectGroup sog = SceneSetupHelpers.CreateSceneObject(3, m_userId, 0x01);
169 m_scene.AddNewSceneObject(sog, false);
170
171 m_pcm.TaintPrimCount();
172
173 Assert.That(pc.Owner, Is.EqualTo(3));
174 Assert.That(pc.Group, Is.EqualTo(0));
175 Assert.That(pc.Others, Is.EqualTo(0));
176 Assert.That(pc.Total, Is.EqualTo(3));
177 Assert.That(pc.Users[m_userId], Is.EqualTo(3));
178 Assert.That(pc.Users[m_dummyUserId], Is.EqualTo(0));
179 Assert.That(pc.Simulator, Is.EqualTo(3));
180 }
130 } 181 }
131} \ No newline at end of file 182} \ No newline at end of file