Merge branch 'master' into primcounts

0.7.1-dev
Justin Clark-Casey (justincc) 2011-03-26 00:57:52 +00:00
commit 3d0e072d50
5 changed files with 84 additions and 49 deletions

View File

@ -68,7 +68,7 @@ namespace OpenSim.ApplicationPlugins.LoadRegions
public void Initialise() public void Initialise()
{ {
m_log.Error("[LOADREGIONS]: " + Name + " cannot be default-initialized!"); m_log.Error("[LOAD REGIONS PLUGIN]: " + Name + " cannot be default-initialized!");
throw new PluginNotInitialisedException(Name); throw new PluginNotInitialisedException(Name);
} }
@ -85,7 +85,7 @@ namespace OpenSim.ApplicationPlugins.LoadRegions
IRegionLoader regionLoader; IRegionLoader regionLoader;
if (m_openSim.ConfigSource.Source.Configs["Startup"].GetString("region_info_source", "filesystem") == "filesystem") if (m_openSim.ConfigSource.Source.Configs["Startup"].GetString("region_info_source", "filesystem") == "filesystem")
{ {
m_log.Info("[LOADREGIONS]: Loading region configurations from filesystem"); m_log.Info("[LOAD REGIONS PLUGIN]: Loading region configurations from filesystem");
regionLoader = new RegionLoaderFileSystem(); regionLoader = new RegionLoaderFileSystem();
} }
else else
@ -94,8 +94,6 @@ namespace OpenSim.ApplicationPlugins.LoadRegions
regionLoader = new RegionLoaderWebServer(); regionLoader = new RegionLoaderWebServer();
} }
m_log.Info("[LOADREGIONSPLUGIN]: Loading region configurations...");
regionLoader.SetIniConfigSource(m_openSim.ConfigSource.Source); regionLoader.SetIniConfigSource(m_openSim.ConfigSource.Source);
RegionInfo[] regionsToLoad = regionLoader.LoadRegions(); RegionInfo[] regionsToLoad = regionLoader.LoadRegions();
@ -112,14 +110,14 @@ namespace OpenSim.ApplicationPlugins.LoadRegions
if (!CheckRegionsForSanity(regionsToLoad)) if (!CheckRegionsForSanity(regionsToLoad))
{ {
m_log.Error("[LOADREGIONS]: Halting startup due to conflicts in region configurations"); m_log.Error("[LOAD REGIONS PLUGIN]: Halting startup due to conflicts in region configurations");
Environment.Exit(1); Environment.Exit(1);
} }
for (int i = 0; i < regionsToLoad.Length; i++) for (int i = 0; i < regionsToLoad.Length; i++)
{ {
IScene scene; IScene scene;
m_log.Debug("[LOADREGIONS]: Creating Region: " + regionsToLoad[i].RegionName + " (ThreadID: " + m_log.Debug("[LOAD REGIONS PLUGIN]: Creating Region: " + regionsToLoad[i].RegionName + " (ThreadID: " +
Thread.CurrentThread.ManagedThreadId.ToString() + Thread.CurrentThread.ManagedThreadId.ToString() +
")"); ")");
@ -164,7 +162,7 @@ namespace OpenSim.ApplicationPlugins.LoadRegions
if (regions[i].RegionID == regions[j].RegionID) if (regions[i].RegionID == regions[j].RegionID)
{ {
m_log.ErrorFormat( m_log.ErrorFormat(
"[LOADREGIONS]: Regions {0} and {1} have the same UUID {2}", "[LOAD REGIONS PLUGIN]: Regions {0} and {1} have the same UUID {2}",
regions[i].RegionName, regions[j].RegionName, regions[i].RegionID); regions[i].RegionName, regions[j].RegionName, regions[i].RegionID);
return false; return false;
} }
@ -172,14 +170,14 @@ namespace OpenSim.ApplicationPlugins.LoadRegions
regions[i].RegionLocX == regions[j].RegionLocX && regions[i].RegionLocY == regions[j].RegionLocY) regions[i].RegionLocX == regions[j].RegionLocX && regions[i].RegionLocY == regions[j].RegionLocY)
{ {
m_log.ErrorFormat( m_log.ErrorFormat(
"[LOADREGIONS]: Regions {0} and {1} have the same grid location ({2}, {3})", "[LOAD REGIONS PLUGIN]: Regions {0} and {1} have the same grid location ({2}, {3})",
regions[i].RegionName, regions[j].RegionName, regions[i].RegionLocX, regions[i].RegionLocY); regions[i].RegionName, regions[j].RegionName, regions[i].RegionLocX, regions[i].RegionLocY);
return false; return false;
} }
else if (regions[i].InternalEndPoint.Port == regions[j].InternalEndPoint.Port) else if (regions[i].InternalEndPoint.Port == regions[j].InternalEndPoint.Port)
{ {
m_log.ErrorFormat( m_log.ErrorFormat(
"[LOADREGIONS]: Regions {0} and {1} have the same internal IP port {2}", "[LOAD REGIONS PLUGIN]: Regions {0} and {1} have the same internal IP port {2}",
regions[i].RegionName, regions[j].RegionName, regions[i].InternalEndPoint.Port); regions[i].RegionName, regions[j].RegionName, regions[i].InternalEndPoint.Port);
return false; return false;
} }

View File

@ -25,15 +25,19 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
using log4net;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Reflection;
using Nini.Config; using Nini.Config;
namespace OpenSim.Framework.RegionLoader.Filesystem namespace OpenSim.Framework.RegionLoader.Filesystem
{ {
public class RegionLoaderFileSystem : IRegionLoader public class RegionLoaderFileSystem : IRegionLoader
{ {
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private IConfigSource m_configSource; private IConfigSource m_configSource;
public void SetIniConfigSource(IConfigSource configSource) public void SetIniConfigSource(IConfigSource configSource)
@ -63,32 +67,44 @@ namespace OpenSim.Framework.RegionLoader.Filesystem
string[] configFiles = Directory.GetFiles(regionConfigPath, "*.xml"); string[] configFiles = Directory.GetFiles(regionConfigPath, "*.xml");
string[] iniFiles = Directory.GetFiles(regionConfigPath, "*.ini"); string[] iniFiles = Directory.GetFiles(regionConfigPath, "*.ini");
// Create an empty Regions.ini if there are no existing config files.
if (configFiles.Length == 0 && iniFiles.Length == 0) if (configFiles.Length == 0 && iniFiles.Length == 0)
{ {
new RegionInfo("DEFAULT REGION CONFIG", Path.Combine(regionConfigPath, "Regions.ini"), false, m_configSource); new RegionInfo("DEFAULT REGION CONFIG", Path.Combine(regionConfigPath, "Regions.ini"), false, m_configSource);
iniFiles = Directory.GetFiles(regionConfigPath, "*.ini"); iniFiles = Directory.GetFiles(regionConfigPath, "*.ini");
} }
m_log.InfoFormat("[REGION LOADER FILE SYSTEM]: Loading config files from {0}", regionConfigPath);
List<RegionInfo> regionInfos = new List<RegionInfo>(); List<RegionInfo> regionInfos = new List<RegionInfo>();
int i = 0; int i = 0;
foreach (string file in iniFiles) foreach (string file in iniFiles)
{ {
m_log.InfoFormat("[REGION LOADER FILE SYSTEM]: Loading config file {0}", file);
IConfigSource source = new IniConfigSource(file); IConfigSource source = new IniConfigSource(file);
foreach (IConfig config in source.Configs) foreach (IConfig config in source.Configs)
{ {
//m_log.Info("[REGIONLOADERFILESYSTEM]: Creating RegionInfo for " + config.Name);
RegionInfo regionInfo = new RegionInfo("REGION CONFIG #" + (i + 1), file, false, m_configSource, config.Name); RegionInfo regionInfo = new RegionInfo("REGION CONFIG #" + (i + 1), file, false, m_configSource, config.Name);
regionInfos.Add(regionInfo); regionInfos.Add(regionInfo);
m_log.InfoFormat("[REGION LOADER FILE SYSTEM]: Loaded config for region {0}", regionInfo.RegionName);
i++; i++;
} }
} }
foreach (string file in configFiles) foreach (string file in configFiles)
{ {
m_log.InfoFormat("[REGION LOADER FILE SYSTEM]: Loading config file {0}", file);
RegionInfo regionInfo = new RegionInfo("REGION CONFIG #" + (i + 1), file, false, m_configSource); RegionInfo regionInfo = new RegionInfo("REGION CONFIG #" + (i + 1), file, false, m_configSource);
regionInfos.Add(regionInfo); regionInfos.Add(regionInfo);
m_log.InfoFormat("[REGION LOADER FILE SYSTEM]: Loaded config for region {0}", regionInfo.RegionName);
i++; i++;
} }

View File

@ -66,9 +66,9 @@ namespace OpenSim.Framework.RegionLoader.Web
{ {
HttpWebRequest webRequest = (HttpWebRequest) WebRequest.Create(url); HttpWebRequest webRequest = (HttpWebRequest) WebRequest.Create(url);
webRequest.Timeout = 30000; //30 Second Timeout webRequest.Timeout = 30000; //30 Second Timeout
m_log.Debug("[WEBLOADER]: Sending Download Request..."); m_log.DebugFormat("[WEBLOADER]: Sending download request to {0}", url);
HttpWebResponse webResponse = (HttpWebResponse) webRequest.GetResponse(); HttpWebResponse webResponse = (HttpWebResponse) webRequest.GetResponse();
m_log.Debug("[WEBLOADER]: Downloading Region Information From Remote Server..."); m_log.Debug("[WEBLOADER]: Downloading region information...");
StreamReader reader = new StreamReader(webResponse.GetResponseStream()); StreamReader reader = new StreamReader(webResponse.GetResponseStream());
string xmlSource = String.Empty; string xmlSource = String.Empty;
string tempStr = reader.ReadLine(); string tempStr = reader.ReadLine();

View File

@ -89,9 +89,21 @@ namespace OpenSim.Region.Framework.Scenes
protected internal PhysicsScene _PhyScene; protected internal PhysicsScene _PhyScene;
protected internal Dictionary<uint, SceneObjectGroup> SceneObjectGroupsByLocalID = new Dictionary<uint, SceneObjectGroup>(); /// <summary>
/// Index the SceneObjectGroup for each part by the root part's UUID.
/// </summary>
protected internal Dictionary<UUID, SceneObjectGroup> SceneObjectGroupsByFullID = new Dictionary<UUID, SceneObjectGroup>(); protected internal Dictionary<UUID, SceneObjectGroup> SceneObjectGroupsByFullID = new Dictionary<UUID, SceneObjectGroup>();
/// <summary>
/// Index the SceneObjectGroup for each part by that part's UUID.
/// </summary>
protected internal Dictionary<UUID, SceneObjectGroup> SceneObjectGroupsByFullPartID = new Dictionary<UUID, SceneObjectGroup>();
/// <summary>
/// Index the SceneObjectGroup for each part by that part's local ID.
/// </summary>
protected internal Dictionary<uint, SceneObjectGroup> SceneObjectGroupsByLocalPartID = new Dictionary<uint, SceneObjectGroup>();
private Object m_updateLock = new Object(); private Object m_updateLock = new Object();
#endregion #endregion
@ -133,8 +145,10 @@ namespace OpenSim.Region.Framework.Scenes
lock (SceneObjectGroupsByFullID) lock (SceneObjectGroupsByFullID)
SceneObjectGroupsByFullID.Clear(); SceneObjectGroupsByFullID.Clear();
lock (SceneObjectGroupsByLocalID) lock (SceneObjectGroupsByFullPartID)
SceneObjectGroupsByLocalID.Clear(); SceneObjectGroupsByFullPartID.Clear();
lock (SceneObjectGroupsByLocalPartID)
SceneObjectGroupsByLocalPartID.Clear();
Entities.Clear(); Entities.Clear();
} }
@ -385,17 +399,20 @@ namespace OpenSim.Region.Framework.Scenes
OnObjectCreate(sceneObject); OnObjectCreate(sceneObject);
lock (SceneObjectGroupsByFullID) lock (SceneObjectGroupsByFullID)
{
SceneObjectGroupsByFullID[sceneObject.UUID] = sceneObject; SceneObjectGroupsByFullID[sceneObject.UUID] = sceneObject;
lock (SceneObjectGroupsByFullPartID)
{
SceneObjectGroupsByFullPartID[sceneObject.UUID] = sceneObject;
foreach (SceneObjectPart part in children) foreach (SceneObjectPart part in children)
SceneObjectGroupsByFullID[part.UUID] = sceneObject; SceneObjectGroupsByFullPartID[part.UUID] = sceneObject;
} }
lock (SceneObjectGroupsByLocalID) lock (SceneObjectGroupsByLocalPartID)
{ {
SceneObjectGroupsByLocalID[sceneObject.LocalId] = sceneObject; SceneObjectGroupsByLocalPartID[sceneObject.LocalId] = sceneObject;
foreach (SceneObjectPart part in children) foreach (SceneObjectPart part in children)
SceneObjectGroupsByLocalID[part.LocalId] = sceneObject; SceneObjectGroupsByLocalPartID[part.LocalId] = sceneObject;
} }
return true; return true;
@ -428,19 +445,22 @@ namespace OpenSim.Region.Framework.Scenes
OnObjectRemove(Entities[uuid]); OnObjectRemove(Entities[uuid]);
lock (SceneObjectGroupsByFullID) lock (SceneObjectGroupsByFullID)
SceneObjectGroupsByFullID.Remove(grp.UUID);
lock (SceneObjectGroupsByFullPartID)
{ {
SceneObjectPart[] parts = grp.Parts; SceneObjectPart[] parts = grp.Parts;
for (int i = 0; i < parts.Length; i++) for (int i = 0; i < parts.Length; i++)
SceneObjectGroupsByFullID.Remove(parts[i].UUID); SceneObjectGroupsByFullPartID.Remove(parts[i].UUID);
SceneObjectGroupsByFullID.Remove(grp.RootPart.UUID); SceneObjectGroupsByFullPartID.Remove(grp.RootPart.UUID);
} }
lock (SceneObjectGroupsByLocalID) lock (SceneObjectGroupsByLocalPartID)
{ {
SceneObjectPart[] parts = grp.Parts; SceneObjectPart[] parts = grp.Parts;
for (int i = 0; i < parts.Length; i++) for (int i = 0; i < parts.Length; i++)
SceneObjectGroupsByLocalID.Remove(parts[i].LocalId); SceneObjectGroupsByLocalPartID.Remove(parts[i].LocalId);
SceneObjectGroupsByLocalID.Remove(grp.RootPart.LocalId); SceneObjectGroupsByLocalPartID.Remove(grp.RootPart.LocalId);
} }
return Entities.Remove(uuid); return Entities.Remove(uuid);
@ -854,14 +874,14 @@ namespace OpenSim.Region.Framework.Scenes
//m_log.DebugFormat("Entered GetGroupByPrim with localID {0}", localID); //m_log.DebugFormat("Entered GetGroupByPrim with localID {0}", localID);
SceneObjectGroup sog; SceneObjectGroup sog;
lock (SceneObjectGroupsByLocalID) lock (SceneObjectGroupsByLocalPartID)
SceneObjectGroupsByLocalID.TryGetValue(localID, out sog); SceneObjectGroupsByLocalPartID.TryGetValue(localID, out sog);
if (sog != null) if (sog != null)
{ {
if (sog.HasChildPrim(localID)) if (sog.HasChildPrim(localID))
return sog; return sog;
SceneObjectGroupsByLocalID.Remove(localID); SceneObjectGroupsByLocalPartID.Remove(localID);
} }
EntityBase[] entityList = GetEntities(); EntityBase[] entityList = GetEntities();
@ -873,8 +893,8 @@ namespace OpenSim.Region.Framework.Scenes
sog = (SceneObjectGroup)ent; sog = (SceneObjectGroup)ent;
if (sog.HasChildPrim(localID)) if (sog.HasChildPrim(localID))
{ {
lock (SceneObjectGroupsByLocalID) lock (SceneObjectGroupsByLocalPartID)
SceneObjectGroupsByLocalID[localID] = sog; SceneObjectGroupsByLocalPartID[localID] = sog;
return sog; return sog;
} }
} }
@ -891,16 +911,16 @@ namespace OpenSim.Region.Framework.Scenes
private SceneObjectGroup GetGroupByPrim(UUID fullID) private SceneObjectGroup GetGroupByPrim(UUID fullID)
{ {
SceneObjectGroup sog; SceneObjectGroup sog;
lock (SceneObjectGroupsByFullID) lock (SceneObjectGroupsByFullPartID)
SceneObjectGroupsByFullID.TryGetValue(fullID, out sog); SceneObjectGroupsByFullPartID.TryGetValue(fullID, out sog);
if (sog != null) if (sog != null)
{ {
if (sog.ContainsPart(fullID)) if (sog.ContainsPart(fullID))
return sog; return sog;
lock (SceneObjectGroupsByFullID) lock (SceneObjectGroupsByFullPartID)
SceneObjectGroupsByFullID.Remove(fullID); SceneObjectGroupsByFullPartID.Remove(fullID);
} }
EntityBase[] entityList = GetEntities(); EntityBase[] entityList = GetEntities();
@ -911,8 +931,8 @@ namespace OpenSim.Region.Framework.Scenes
sog = (SceneObjectGroup)ent; sog = (SceneObjectGroup)ent;
if (sog.HasChildPrim(fullID)) if (sog.HasChildPrim(fullID))
{ {
lock (SceneObjectGroupsByFullID) lock (SceneObjectGroupsByFullPartID)
SceneObjectGroupsByFullID[fullID] = sog; SceneObjectGroupsByFullPartID[fullID] = sog;
return sog; return sog;
} }
} }
@ -1064,11 +1084,12 @@ namespace OpenSim.Region.Framework.Scenes
} }
/// <summary> /// <summary>
/// Performs action on all scene object groups. /// Performs action once on all scene object groups.
/// </summary> /// </summary>
/// <param name="action"></param> /// <param name="action"></param>
protected internal void ForEachSOG(Action<SceneObjectGroup> action) protected internal void ForEachSOG(Action<SceneObjectGroup> action)
{ {
// FIXME: Need to lock here, really.
List<SceneObjectGroup> objlist = new List<SceneObjectGroup>(SceneObjectGroupsByFullID.Values); List<SceneObjectGroup> objlist = new List<SceneObjectGroup>(SceneObjectGroupsByFullID.Values);
foreach (SceneObjectGroup obj in objlist) foreach (SceneObjectGroup obj in objlist)
{ {
@ -1085,7 +1106,6 @@ namespace OpenSim.Region.Framework.Scenes
} }
} }
/// <summary> /// <summary>
/// Performs action on all scene presences. This can ultimately run the actions in parallel but /// Performs action on all scene presences. This can ultimately run the actions in parallel but
/// any delegates passed in will need to implement their own locking on data they reference and /// any delegates passed in will need to implement their own locking on data they reference and

View File

@ -402,6 +402,7 @@
<Reference name="System"/> <Reference name="System"/>
<Reference name="System.Xml"/> <Reference name="System.Xml"/>
<Reference name="OpenMetaverseTypes" path="../../../../bin/"/> <Reference name="OpenMetaverseTypes" path="../../../../bin/"/>
<Reference name="log4net" path="../../../../bin/"/>
<Reference name="XMLRPC" path="../../../../bin/"/> <Reference name="XMLRPC" path="../../../../bin/"/>
<Reference name="OpenSim.Framework"/> <Reference name="OpenSim.Framework"/>
<Reference name="OpenSim.Framework.Console"/> <Reference name="OpenSim.Framework.Console"/>