aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2011-03-22 23:47:36 +0000
committerJustin Clark-Casey (justincc)2011-03-22 23:47:36 +0000
commitb34743e5fe6b0783caa62c014ff86e2ec76c8184 (patch)
treef8f8acbff4265321ea3919b635fa925583d7b445
parentTypo fix (diff)
downloadopensim-SC_OLD-b34743e5fe6b0783caa62c014ff86e2ec76c8184.zip
opensim-SC_OLD-b34743e5fe6b0783caa62c014ff86e2ec76c8184.tar.gz
opensim-SC_OLD-b34743e5fe6b0783caa62c014ff86e2ec76c8184.tar.bz2
opensim-SC_OLD-b34743e5fe6b0783caa62c014ff86e2ec76c8184.tar.xz
Add an initial confidence-building TestAddObject() for prim counts.
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs29
-rw-r--r--OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs23
-rw-r--r--OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs75
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneGraph.cs13
-rw-r--r--prebuild.xml1
5 files changed, 116 insertions, 25 deletions
diff --git a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
index 98ba8c3..514be4f 100644
--- a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
+++ b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
@@ -306,6 +306,9 @@ namespace OpenSim.Region.CoreModules.World.Land
306 /// <returns>The parcel created.</returns> 306 /// <returns>The parcel created.</returns>
307 protected ILandObject CreateDefaultParcel() 307 protected ILandObject CreateDefaultParcel()
308 { 308 {
309// m_log.DebugFormat(
310// "[LAND MANAGEMENT MODULE]: Creating default parcel for region {0}", m_scene.RegionInfo.RegionName);
311
309 ILandObject fullSimParcel = new LandObject(UUID.Zero, false, m_scene); 312 ILandObject fullSimParcel = new LandObject(UUID.Zero, false, m_scene);
310 fullSimParcel.SetLandBitmap(fullSimParcel.GetSquareLandBitmap(0, 0, (int)Constants.RegionSize, (int)Constants.RegionSize)); 313 fullSimParcel.SetLandBitmap(fullSimParcel.GetSquareLandBitmap(0, 0, (int)Constants.RegionSize, (int)Constants.RegionSize));
311 fullSimParcel.LandData.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner; 314 fullSimParcel.LandData.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner;
@@ -579,7 +582,7 @@ namespace OpenSim.Region.CoreModules.World.Land
579 } 582 }
580 else 583 else
581 { 584 {
582 m_log.WarnFormat("[LAND]: Invalid local land ID {0}", landLocalID); 585 m_log.WarnFormat("[LAND MANAGEMENT MODULE]: Invalid local land ID {0}", landLocalID);
583 } 586 }
584 } 587 }
585 588
@@ -630,7 +633,7 @@ namespace OpenSim.Region.CoreModules.World.Land
630 { 633 {
631 if (m_landIDList[x, y] == local_id) 634 if (m_landIDList[x, y] == local_id)
632 { 635 {
633 m_log.WarnFormat("[LAND]: Not removing land object {0}; still being used at {1}, {2}", 636 m_log.WarnFormat("[LAND MANAGEMENT MODULE]: Not removing land object {0}; still being used at {1}, {2}",
634 local_id, x, y); 637 local_id, x, y);
635 return; 638 return;
636 //throw new Exception("Could not remove land object. Still being used at " + x + ", " + y); 639 //throw new Exception("Could not remove land object. Still being used at " + x + ", " + y);
@@ -1198,7 +1201,7 @@ namespace OpenSim.Region.CoreModules.World.Land
1198 } 1201 }
1199 else 1202 else
1200 { 1203 {
1201 m_log.WarnFormat("[PARCEL]: Invalid land object {0} passed for parcel object owner request", local_id); 1204 m_log.WarnFormat("[LAND MANAGEMENT MODULE]: Invalid land object {0} passed for parcel object owner request", local_id);
1202 } 1205 }
1203 } 1206 }
1204 1207
@@ -1426,7 +1429,7 @@ namespace OpenSim.Region.CoreModules.World.Land
1426 { 1429 {
1427 IClientAPI client; 1430 IClientAPI client;
1428 if (! m_scene.TryGetClient(agentID, out client)) { 1431 if (! m_scene.TryGetClient(agentID, out client)) {
1429 m_log.WarnFormat("[LAND] unable to retrieve IClientAPI for {0}", agentID.ToString()); 1432 m_log.WarnFormat("[LAND MANAGEMENT MODULE]: Unable to retrieve IClientAPI for {0}", agentID);
1430 return LLSDHelpers.SerialiseLLSDReply(new LLSDEmpty()); 1433 return LLSDHelpers.SerialiseLLSDReply(new LLSDEmpty());
1431 } 1434 }
1432 1435
@@ -1475,7 +1478,7 @@ namespace OpenSim.Region.CoreModules.World.Land
1475 } 1478 }
1476 else 1479 else
1477 { 1480 {
1478 m_log.WarnFormat("[LAND] unable to find parcelID {0}", parcelID); 1481 m_log.WarnFormat("[LAND MANAGEMENT MODULE]: Unable to find parcelID {0}", parcelID);
1479 } 1482 }
1480 return LLSDHelpers.SerialiseLLSDReply(new LLSDEmpty()); 1483 return LLSDHelpers.SerialiseLLSDReply(new LLSDEmpty());
1481 } 1484 }
@@ -1533,17 +1536,17 @@ namespace OpenSim.Region.CoreModules.World.Land
1533 } 1536 }
1534 catch (LLSD.LLSDParseException e) 1537 catch (LLSD.LLSDParseException e)
1535 { 1538 {
1536 m_log.ErrorFormat("[LAND] Fetch error: {0}", e.Message); 1539 m_log.ErrorFormat("[LAND MANAGEMENT MODULE]: Fetch error: {0}", e.Message);
1537 m_log.ErrorFormat("[LAND] ... in request {0}", request); 1540 m_log.ErrorFormat("[LAND MANAGEMENT MODULE]: ... in request {0}", request);
1538 } 1541 }
1539 catch(InvalidCastException) 1542 catch (InvalidCastException)
1540 { 1543 {
1541 m_log.ErrorFormat("[LAND] Wrong type in request {0}", request); 1544 m_log.ErrorFormat("[LAND MANAGEMENT MODULE]: Wrong type in request {0}", request);
1542 } 1545 }
1543 1546
1544 LLSDRemoteParcelResponse response = new LLSDRemoteParcelResponse(); 1547 LLSDRemoteParcelResponse response = new LLSDRemoteParcelResponse();
1545 response.parcel_id = parcelID; 1548 response.parcel_id = parcelID;
1546 m_log.DebugFormat("[LAND] got parcelID {0}", parcelID); 1549 m_log.DebugFormat("[LAND MANAGEMENT MODULE]: Got parcelID {0}", parcelID);
1547 1550
1548 return LLSDHelpers.SerialiseLLSDReply(response); 1551 return LLSDHelpers.SerialiseLLSDReply(response);
1549 } 1552 }
@@ -1564,7 +1567,7 @@ namespace OpenSim.Region.CoreModules.World.Land
1564 ExtendedLandData extLandData = new ExtendedLandData(); 1567 ExtendedLandData extLandData = new ExtendedLandData();
1565 Util.ParseFakeParcelID(parcel, out extLandData.RegionHandle, 1568 Util.ParseFakeParcelID(parcel, out extLandData.RegionHandle,
1566 out extLandData.X, out extLandData.Y); 1569 out extLandData.X, out extLandData.Y);
1567 m_log.DebugFormat("[LAND] got parcelinfo request for regionHandle {0}, x/y {1}/{2}", 1570 m_log.DebugFormat("[LAND MANAGEMENT MODULE]: Got parcelinfo request for regionHandle {0}, x/y {1}/{2}",
1568 extLandData.RegionHandle, extLandData.X, extLandData.Y); 1571 extLandData.RegionHandle, extLandData.X, extLandData.Y);
1569 1572
1570 // for this region or for somewhere else? 1573 // for this region or for somewhere else?
@@ -1605,7 +1608,7 @@ namespace OpenSim.Region.CoreModules.World.Land
1605 info = m_scene.GridService.GetRegionByPosition(m_scene.RegionInfo.ScopeID, (int)x, (int)y); 1608 info = m_scene.GridService.GetRegionByPosition(m_scene.RegionInfo.ScopeID, (int)x, (int)y);
1606 } 1609 }
1607 // we need to transfer the fake parcelID, not the one in landData, so the viewer can match it to the landmark. 1610 // we need to transfer the fake parcelID, not the one in landData, so the viewer can match it to the landmark.
1608 m_log.DebugFormat("[LAND] got parcelinfo for parcel {0} in region {1}; sending...", 1611 m_log.DebugFormat("[LAND MANAGEMENT MODULE]: got parcelinfo for parcel {0} in region {1}; sending...",
1609 data.LandData.Name, data.RegionHandle); 1612 data.LandData.Name, data.RegionHandle);
1610 // HACK for now 1613 // HACK for now
1611 RegionInfo r = new RegionInfo(); 1614 RegionInfo r = new RegionInfo();
@@ -1616,7 +1619,7 @@ namespace OpenSim.Region.CoreModules.World.Land
1616 remoteClient.SendParcelInfo(r, data.LandData, parcelID, data.X, data.Y); 1619 remoteClient.SendParcelInfo(r, data.LandData, parcelID, data.X, data.Y);
1617 } 1620 }
1618 else 1621 else
1619 m_log.Debug("[LAND] got no parcelinfo; not sending"); 1622 m_log.Debug("[LAND MANAGEMENT MODULE]: got no parcelinfo; not sending");
1620 } 1623 }
1621 1624
1622 public void setParcelOtherCleanTime(IClientAPI remoteClient, int localID, int otherCleanTime) 1625 public void setParcelOtherCleanTime(IClientAPI remoteClient, int localID, int otherCleanTime)
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
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 =
55 LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 55// LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
56 56
57 private Scene m_Scene; 57 private Scene m_Scene;
58 private Dictionary<UUID, PrimCounts> m_PrimCounts = 58 private Dictionary<UUID, PrimCounts> m_PrimCounts =
@@ -64,10 +64,16 @@ namespace OpenSim.Region.CoreModules.World.Land
64 private Dictionary<UUID, ParcelCounts> m_ParcelCounts = 64 private Dictionary<UUID, ParcelCounts> m_ParcelCounts =
65 new Dictionary<UUID, ParcelCounts>(); 65 new Dictionary<UUID, ParcelCounts>();
66 66
67 // For now, a simple simwide taint to get this up. Later parcel based 67
68 // taint to allow recounting a parcel if only ownership has changed 68 /// <value>
69 // without recounting the whole sim. 69 /// For now, a simple simwide taint to get this up. Later parcel based
70 /// taint to allow recounting a parcel if only ownership has changed
71 /// without recounting the whole sim.
72 ///
73 /// We start out tainted so that the first get call resets the various prim counts.
74 /// <value>
70 private bool m_Tainted = true; 75 private bool m_Tainted = true;
76
71 private Object m_TaintLock = new Object(); 77 private Object m_TaintLock = new Object();
72 78
73 public Type ReplaceableInterface 79 public Type ReplaceableInterface
@@ -156,6 +162,8 @@ namespace OpenSim.Region.CoreModules.World.Land
156 // NOTE: Call under Taint Lock 162 // NOTE: Call under Taint Lock
157 private void AddObject(SceneObjectGroup obj) 163 private void AddObject(SceneObjectGroup obj)
158 { 164 {
165// m_log.DebugFormat("[PRIM COUNT MODULE]: Adding object {0} to prim count", obj.Name);
166
159 if (obj.IsAttachment) 167 if (obj.IsAttachment)
160 return; 168 return;
161 if (((obj.RootPart.Flags & PrimFlags.TemporaryOnRez) != 0)) 169 if (((obj.RootPart.Flags & PrimFlags.TemporaryOnRez) != 0))
@@ -299,18 +307,21 @@ namespace OpenSim.Region.CoreModules.World.Land
299 // NOTE: This method MUST be called while holding the taint lock! 307 // NOTE: This method MUST be called while holding the taint lock!
300 private void Recount() 308 private void Recount()
301 { 309 {
310// m_log.DebugFormat("[PRIM COUNT MODULE]: Recounting prims on {0}", m_Scene.RegionInfo.RegionName);
311
302 m_OwnerMap.Clear(); 312 m_OwnerMap.Clear();
303 m_SimwideCounts.Clear(); 313 m_SimwideCounts.Clear();
304 m_ParcelCounts.Clear(); 314 m_ParcelCounts.Clear();
305 315
306 List<ILandObject> land = m_Scene.LandChannel.AllParcels(); 316 List<ILandObject> land = m_Scene.LandChannel.AllParcels();
307 317
308 foreach (ILandObject l in land) 318 foreach (ILandObject l in land)
309 { 319 {
310 LandData landData = l.LandData; 320 LandData landData = l.LandData;
311 321
312 m_OwnerMap[landData.GlobalID] = landData.OwnerID; 322 m_OwnerMap[landData.GlobalID] = landData.OwnerID;
313 m_SimwideCounts[landData.OwnerID] = 0; 323 m_SimwideCounts[landData.OwnerID] = 0;
324// m_log.DebugFormat("[PRIM COUNT MODULE]: Adding parcel count for {0}", landData.GlobalID);
314 m_ParcelCounts[landData.GlobalID] = new ParcelCounts(); 325 m_ParcelCounts[landData.GlobalID] = new ParcelCounts();
315 } 326 }
316 327
diff --git a/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs b/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs
new file mode 100644
index 0000000..402965f
--- /dev/null
+++ b/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs
@@ -0,0 +1,75 @@
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
28using System;
29using System.Collections.Generic;
30using System.Reflection;
31using log4net.Config;
32using NUnit.Framework;
33using OpenMetaverse;
34using OpenMetaverse.Assets;
35using OpenSim.Framework;
36using OpenSim.Region.Framework.Interfaces;
37using OpenSim.Region.Framework.Scenes;
38using OpenSim.Tests.Common;
39using OpenSim.Tests.Common.Mock;
40using OpenSim.Tests.Common.Setup;
41
42namespace OpenSim.Region.CoreModules.World.Land.Tests
43{
44 [TestFixture]
45 public class PrimCountModuleTests
46 {
47 [Test]
48 public void TestAddObject()
49 {
50 TestHelper.InMethod();
51// log4net.Config.XmlConfigurator.Configure();
52
53 PrimCountModule pcm = new PrimCountModule();
54 LandManagementModule lmm = new LandManagementModule();
55 Scene scene = SceneSetupHelpers.SetupScene();
56 SceneSetupHelpers.SetupSceneModules(scene, lmm, pcm);
57
58 ILandObject lo = new LandObject(UUID.Zero, false, scene);
59 lo.SetLandBitmap(lo.GetSquareLandBitmap(0, 0, (int)Constants.RegionSize, (int)Constants.RegionSize));
60 lmm.AddLandObject(lo);
61 //scene.loadAllLandObjectsFromStorage(scene.RegionInfo.originRegionID);
62
63 string objName = "obj1";
64 UUID objUuid = new UUID("00000000-0000-0000-0000-000000000001");
65
66 SceneObjectPart part
67 = new SceneObjectPart(UUID.Zero, PrimitiveBaseShape.Default, Vector3.Zero, Quaternion.Identity, Vector3.Zero)
68 { Name = objName, UUID = objUuid };
69
70 scene.AddNewSceneObject(new SceneObjectGroup(part), false);
71
72 Assert.That(pcm.GetOwnerCount(lo.LandData.GlobalID), Is.EqualTo(1));
73 }
74 }
75} \ No newline at end of file
diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
index 734ba22..eca2786 100644
--- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
@@ -627,7 +627,7 @@ namespace OpenSim.Region.Framework.Scenes
627 if (!Entities.Remove(agentID)) 627 if (!Entities.Remove(agentID))
628 { 628 {
629 m_log.WarnFormat( 629 m_log.WarnFormat(
630 "[SCENE]: Tried to remove non-existent scene presence with agent ID {0} from scene Entities list", 630 "[SCENEGRAPH]: Tried to remove non-existent scene presence with agent ID {0} from scene Entities list",
631 agentID); 631 agentID);
632 } 632 }
633 633
@@ -650,7 +650,7 @@ namespace OpenSim.Region.Framework.Scenes
650 } 650 }
651 else 651 else
652 { 652 {
653 m_log.WarnFormat("[SCENE]: Tried to remove non-existent scene presence with agent ID {0} from scene ScenePresences list", agentID); 653 m_log.WarnFormat("[SCENEGRAPH]: Tried to remove non-existent scene presence with agent ID {0} from scene ScenePresences list", agentID);
654 } 654 }
655 } 655 }
656 } 656 }
@@ -1079,7 +1079,8 @@ namespace OpenSim.Region.Framework.Scenes
1079 catch (Exception e) 1079 catch (Exception e)
1080 { 1080 {
1081 // Catch it and move on. This includes situations where splist has inconsistent info 1081 // Catch it and move on. This includes situations where splist has inconsistent info
1082 m_log.WarnFormat("[SCENE]: Problem processing action in ForEachSOG: ", e.ToString()); 1082 m_log.WarnFormat(
1083 "[SCENEGRAPH]: Problem processing action in ForEachSOG: {0} {1}", e.Message, e.StackTrace);
1083 } 1084 }
1084 } 1085 }
1085 } 1086 }
@@ -1103,8 +1104,8 @@ namespace OpenSim.Region.Framework.Scenes
1103 } 1104 }
1104 catch (Exception e) 1105 catch (Exception e)
1105 { 1106 {
1106 m_log.Info("[BUG] in " + m_parentScene.RegionInfo.RegionName + ": " + e.ToString()); 1107 m_log.Info("[SCENEGRAPH]: Error in " + m_parentScene.RegionInfo.RegionName + ": " + e.ToString());
1107 m_log.Info("[BUG] Stack Trace: " + e.StackTrace); 1108 m_log.Info("[SCENEGRAPH]: Stack Trace: " + e.StackTrace);
1108 } 1109 }
1109 }); 1110 });
1110 Parallel.ForEach<ScenePresence>(GetScenePresences(), protectedAction); 1111 Parallel.ForEach<ScenePresence>(GetScenePresences(), protectedAction);
@@ -1119,7 +1120,7 @@ namespace OpenSim.Region.Framework.Scenes
1119 } 1120 }
1120 catch (Exception e) 1121 catch (Exception e)
1121 { 1122 {
1122 m_log.Info("[BUG] in " + m_parentScene.RegionInfo.RegionName + ": " + e.ToString()); 1123 m_log.Error("[SCENEGRAPH]: Error in " + m_parentScene.RegionInfo.RegionName + ": " + e.ToString());
1123 } 1124 }
1124 } 1125 }
1125 } 1126 }
diff --git a/prebuild.xml b/prebuild.xml
index 910cb31..d564341 100644
--- a/prebuild.xml
+++ b/prebuild.xml
@@ -2927,6 +2927,7 @@
2927 <Match path="Avatar/Inventory/Archiver/Tests" pattern="*.cs" recurse="true"/> 2927 <Match path="Avatar/Inventory/Archiver/Tests" pattern="*.cs" recurse="true"/>
2928 <Match path="World/Archiver/Tests" pattern="*.cs" recurse="true"/> 2928 <Match path="World/Archiver/Tests" pattern="*.cs" recurse="true"/>
2929 <Match buildAction="EmbeddedResource" path="World/Archiver/Tests/Resources" pattern="*"/> 2929 <Match buildAction="EmbeddedResource" path="World/Archiver/Tests/Resources" pattern="*"/>
2930 <Match path="World/Land/Tests" pattern="*.cs" recurse="true"/>
2930 <Match path="World/Media/Moap/Tests" pattern="*.cs" recurse="true"/> 2931 <Match path="World/Media/Moap/Tests" pattern="*.cs" recurse="true"/>
2931 <Match path="World/Serialiser/Tests" pattern="*.cs" recurse="true"/> 2932 <Match path="World/Serialiser/Tests" pattern="*.cs" recurse="true"/>
2932 <Match path="World/Terrain/Tests" pattern="*.cs" recurse="true"/> 2933 <Match path="World/Terrain/Tests" pattern="*.cs" recurse="true"/>