From b34743e5fe6b0783caa62c014ff86e2ec76c8184 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 22 Mar 2011 23:47:36 +0000 Subject: Add an initial confidence-building TestAddObject() for prim counts. --- .../CoreModules/World/Land/PrimCountModule.cs | 23 ++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs') diff --git a/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs b/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs index 34ef67f..c71264c 100644 --- a/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs +++ b/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs @@ -51,8 +51,8 @@ namespace OpenSim.Region.CoreModules.World.Land public class PrimCountModule : IPrimCountModule, INonSharedRegionModule { - private static readonly ILog m_log = - LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); +// private static readonly ILog m_log = +// LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private Scene m_Scene; private Dictionary m_PrimCounts = @@ -64,10 +64,16 @@ namespace OpenSim.Region.CoreModules.World.Land private Dictionary m_ParcelCounts = new Dictionary(); - // For now, a simple simwide taint to get this up. Later parcel based - // taint to allow recounting a parcel if only ownership has changed - // without recounting the whole sim. + + /// + /// For now, a simple simwide taint to get this up. Later parcel based + /// taint to allow recounting a parcel if only ownership has changed + /// without recounting the whole sim. + /// + /// We start out tainted so that the first get call resets the various prim counts. + /// private bool m_Tainted = true; + private Object m_TaintLock = new Object(); public Type ReplaceableInterface @@ -156,6 +162,8 @@ namespace OpenSim.Region.CoreModules.World.Land // NOTE: Call under Taint Lock private void AddObject(SceneObjectGroup obj) { +// m_log.DebugFormat("[PRIM COUNT MODULE]: Adding object {0} to prim count", obj.Name); + if (obj.IsAttachment) return; if (((obj.RootPart.Flags & PrimFlags.TemporaryOnRez) != 0)) @@ -299,18 +307,21 @@ namespace OpenSim.Region.CoreModules.World.Land // NOTE: This method MUST be called while holding the taint lock! private void Recount() { +// m_log.DebugFormat("[PRIM COUNT MODULE]: Recounting prims on {0}", m_Scene.RegionInfo.RegionName); + m_OwnerMap.Clear(); m_SimwideCounts.Clear(); m_ParcelCounts.Clear(); List land = m_Scene.LandChannel.AllParcels(); - + foreach (ILandObject l in land) { LandData landData = l.LandData; m_OwnerMap[landData.GlobalID] = landData.OwnerID; m_SimwideCounts[landData.OwnerID] = 0; +// m_log.DebugFormat("[PRIM COUNT MODULE]: Adding parcel count for {0}", landData.GlobalID); m_ParcelCounts[landData.GlobalID] = new ParcelCounts(); } -- cgit v1.1 From d011896341d09ce6c10a801264e663b6a19f0b48 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 23 Mar 2011 21:50:56 +0000 Subject: Add generic EventManager.OnObjectAddedToScene and get PrimCountModule to listen for that rather than EventManager.OnParcelPrimCountAdd OnParcelPrimCountAdd had the wrong semantics for the PrimCountModule - it was invoked for every entity in the scene, not just new ones, which would screw up the untainted count. Extend automated test for this scenario. --- OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs') diff --git a/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs b/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs index c71264c..5371aaf 100644 --- a/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs +++ b/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs @@ -89,8 +89,7 @@ namespace OpenSim.Region.CoreModules.World.Land { m_Scene = scene; - m_Scene.EventManager.OnParcelPrimCountAdd += - OnParcelPrimCountAdd; + m_Scene.EventManager.OnObjectAddedToScene += OnParcelPrimCountAdd; m_Scene.EventManager.OnObjectBeingRemovedFromScene += OnObjectBeingRemovedFromScene; m_Scene.EventManager.OnParcelPrimCountTainted += @@ -116,6 +115,7 @@ namespace OpenSim.Region.CoreModules.World.Land private void OnParcelPrimCountAdd(SceneObjectGroup obj) { + Console.WriteLine("WIBBLE"); // If we're tainted already, don't bother to add. The next // access will cause a recount anyway lock (m_TaintLock) @@ -172,6 +172,10 @@ namespace OpenSim.Region.CoreModules.World.Land Vector3 pos = obj.AbsolutePosition; ILandObject landObject = m_Scene.LandChannel.GetLandObject(pos.X, pos.Y); LandData landData = landObject.LandData; + +// m_log.DebugFormat( +// "[PRIM COUNT MODULE]: Object {0} is owned by {1} over land owned by {2}", +// obj.Name, obj.OwnerID, landData.OwnerID); ParcelCounts parcelCounts; if (m_ParcelCounts.TryGetValue(landData.GlobalID, out parcelCounts)) @@ -228,6 +232,8 @@ namespace OpenSim.Region.CoreModules.World.Land public int GetOwnerCount(UUID parcelID) { +// m_log.DebugFormat("[PRIM COUNT MODULE]: GetOwnerCount for {0}", parcelID); + lock (m_TaintLock) { if (m_Tainted) -- cgit v1.1 From 67cafbd33aeb1038f22aa775cbde96b4c89dd770 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 23 Mar 2011 21:54:02 +0000 Subject: remove a rogue Console.WriteLine() from the last commit. --- OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs | 1 - 1 file changed, 1 deletion(-) (limited to 'OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs') diff --git a/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs b/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs index 5371aaf..46c7eed 100644 --- a/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs +++ b/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs @@ -115,7 +115,6 @@ namespace OpenSim.Region.CoreModules.World.Land private void OnParcelPrimCountAdd(SceneObjectGroup obj) { - Console.WriteLine("WIBBLE"); // If we're tainted already, don't bother to add. The next // access will cause a recount anyway lock (m_TaintLock) -- cgit v1.1 From 08c3cd6b369e2bb8dfa08709c2ffddaea4cdbaa5 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 23 Mar 2011 22:04:14 +0000 Subject: Add method doc to the Get*() methods on PrimCountModule --- .../CoreModules/World/Land/PrimCountModule.cs | 27 ++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs') diff --git a/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs b/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs index 46c7eed..ae85798 100644 --- a/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs +++ b/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs @@ -229,6 +229,12 @@ namespace OpenSim.Region.CoreModules.World.Land return primCounts; } + + /// + /// Get the number of prims on the parcel that are owned by the parcel owner. + /// + /// + /// public int GetOwnerCount(UUID parcelID) { // m_log.DebugFormat("[PRIM COUNT MODULE]: GetOwnerCount for {0}", parcelID); @@ -245,6 +251,11 @@ namespace OpenSim.Region.CoreModules.World.Land return 0; } + /// + /// Get the number of prims on the parcel that have been set to the group that owns the parcel. + /// + /// + /// public int GetGroupCount(UUID parcelID) { lock (m_TaintLock) @@ -259,6 +270,11 @@ namespace OpenSim.Region.CoreModules.World.Land return 0; } + /// + /// Get the number of prims on the parcel that are not owned by the parcel owner or set to the parcel group. + /// + /// + /// public int GetOthersCount(UUID parcelID) { lock (m_TaintLock) @@ -273,6 +289,11 @@ namespace OpenSim.Region.CoreModules.World.Land return 0; } + /// + /// Get the number of prims that are in the entire simulator for the owner of this parcel. + /// + /// + /// public int GetSimulatorCount(UUID parcelID) { lock (m_TaintLock) @@ -291,6 +312,12 @@ namespace OpenSim.Region.CoreModules.World.Land return 0; } + /// + /// Get the number of prims that a particular user owns on this parcel. + /// + /// + /// + /// public int GetUserCount(UUID parcelID, UUID userID) { lock (m_TaintLock) -- cgit v1.1 From 7f5019b0f23959ca049f87b596bc2bd47725eb0d Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 25 Mar 2011 21:47:54 +0000 Subject: Add ILandObject.IPrimCounts for the new prim count module. Not functional yet, but tests now act against this object rather than interrogating the module directly --- OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs | 2 ++ 1 file changed, 2 insertions(+) (limited to 'OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs') diff --git a/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs b/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs index ae85798..9fd347e 100644 --- a/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs +++ b/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs @@ -88,6 +88,8 @@ namespace OpenSim.Region.CoreModules.World.Land public void AddRegion(Scene scene) { m_Scene = scene; + + m_Scene.RegisterModuleInterface(this); m_Scene.EventManager.OnObjectAddedToScene += OnParcelPrimCountAdd; m_Scene.EventManager.OnObjectBeingRemovedFromScene += -- cgit v1.1