From 47ea453b32fe8122ed2eb0d62607f65d3dbdddb8 Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Tue, 17 Jul 2007 00:07:26 +0000 Subject: * debugged quite a lot of db-related strangeness and various refactoring goofs --- OpenSim/Region/Environment/Scenes/Scene.cs | 13 +- OpenSim/Region/Environment/Scenes/SceneBase.cs | 55 ++--- OpenSim/Region/Examples/SimpleApp/Program.cs | 17 +- .../GridInterfaces/Local/LocalAssetServer.cs | 249 ++++++++++----------- 4 files changed, 150 insertions(+), 184 deletions(-) diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index 671b222..5bba87a 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs @@ -89,7 +89,7 @@ namespace OpenSim.Region.Environment.Scenes return (this.phyScene); } } - + private LandManager m_LandManager; public LandManager LandManager { @@ -441,15 +441,8 @@ namespace OpenSim.Region.Environment.Scenes /// public void LoadPrimsFromStorage() { - try - { - MainLog.Instance.Verbose("World.cs: LoadPrimsFromStorage() - Loading primitives"); - this.localStorage.LoadPrimitives(this); - } - catch (Exception e) - { - MainLog.Instance.Warn("World.cs: LoadPrimsFromStorage() - Failed with exception " + e.ToString()); - } + MainLog.Instance.Verbose("World.cs: LoadPrimsFromStorage() - Loading primitives"); + this.localStorage.LoadPrimitives(this); } /// diff --git a/OpenSim/Region/Environment/Scenes/SceneBase.cs b/OpenSim/Region/Environment/Scenes/SceneBase.cs index cbf69ac..4326553 100644 --- a/OpenSim/Region/Environment/Scenes/SceneBase.cs +++ b/OpenSim/Region/Environment/Scenes/SceneBase.cs @@ -38,7 +38,7 @@ using OpenSim.Framework; namespace OpenSim.Region.Environment.Scenes { - public abstract class SceneBase : IWorld + public abstract class SceneBase : IWorld { public Dictionary Entities; protected ulong m_regionHandle; @@ -47,7 +47,7 @@ namespace OpenSim.Region.Environment.Scenes public TerrainEngine Terrain; - public string m_datastore; + protected string m_datastore; public ILocalStorage localStorage; protected object m_syncRoot = new object(); @@ -76,44 +76,37 @@ namespace OpenSim.Region.Environment.Scenes /// Successful or not public bool LoadStorageDLL(string dllName) { - try - { - Assembly pluginAssembly = Assembly.LoadFrom(dllName); - ILocalStorage store = null; + Assembly pluginAssembly = Assembly.LoadFrom(dllName); + ILocalStorage store = null; - foreach (Type pluginType in pluginAssembly.GetTypes()) + foreach (Type pluginType in pluginAssembly.GetTypes()) + { + if (pluginType.IsPublic) { - if (pluginType.IsPublic) + if (!pluginType.IsAbstract) { - if (!pluginType.IsAbstract) - { - Type typeInterface = pluginType.GetInterface("ILocalStorage", true); + Type typeInterface = pluginType.GetInterface("ILocalStorage", true); - if (typeInterface != null) - { - ILocalStorage plug = (ILocalStorage)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); - store = plug; - - store.Initialise(this.m_datastore); - break; - } + if (typeInterface != null) + { + ILocalStorage plug = (ILocalStorage)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); + store = plug; - typeInterface = null; + store.Initialise(this.m_datastore); + break; } + + typeInterface = null; } } - pluginAssembly = null; - this.localStorage = store; - return (store == null); - } - catch (Exception e) - { - MainLog.Instance.Warn("World.cs: LoadStorageDLL() - Failed with exception " + e.ToString()); - return false; } + pluginAssembly = null; + this.localStorage = store; + return (store == null); + } - + /// /// Send the region heightmap to the client /// @@ -150,7 +143,7 @@ namespace OpenSim.Region.Environment.Scenes /// /// public abstract void RemoveClient(LLUUID agentID); - + #endregion /// @@ -190,6 +183,6 @@ namespace OpenSim.Region.Environment.Scenes #endregion - + } } diff --git a/OpenSim/Region/Examples/SimpleApp/Program.cs b/OpenSim/Region/Examples/SimpleApp/Program.cs index c945d39..322db2c 100644 --- a/OpenSim/Region/Examples/SimpleApp/Program.cs +++ b/OpenSim/Region/Examples/SimpleApp/Program.cs @@ -22,10 +22,6 @@ namespace SimpleApp { class Program : RegionApplicationBase, conscmd_callback { - public MyWorld m_scene; - private SceneObject m_sceneObject; - public MyNpcCharacter m_character; - protected override LogBase CreateLog() { return new LogBase(null, "SimpleApp", this, false); @@ -40,20 +36,21 @@ namespace SimpleApp LocalAssetServer assetServer = new LocalAssetServer(); assetServer.SetServerInfo("http://localhost:8003/", ""); - AssetCache m_assetCache = new AssetCache(assetServer); + m_assetCache = new AssetCache(assetServer); } public void Run() { base.StartUp(); - CommunicationsLocal m_commsManager = new CommunicationsLocal(m_networkServersInfo, m_httpServer); + m_commsManager = new CommunicationsLocal(m_networkServersInfo, m_httpServer); ScenePresence.PhysicsEngineFlying = true; IPEndPoint internalEndPoint = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 9000); RegionInfo regionInfo = new RegionInfo(1000, 1000, internalEndPoint, "localhost"); - + regionInfo.DataStore = "simpleapp_datastore.yap"; + UDPServer udpServer; Scene scene = SetupScene(regionInfo, out udpServer); @@ -64,10 +61,10 @@ namespace SimpleApp shape.Scale = new LLVector3(0.5f, 0.5f, 0.5f); LLVector3 pos = new LLVector3(138, 129, 27); - m_sceneObject = new MySceneObject(scene, scene.EventManager, LLUUID.Zero, scene.PrimIDAllocate(), pos, shape); + SceneObject m_sceneObject = new MySceneObject(scene, scene.EventManager, LLUUID.Zero, scene.PrimIDAllocate(), pos, shape); scene.AddEntity(m_sceneObject); - m_character = new MyNpcCharacter(); + MyNpcCharacter m_character = new MyNpcCharacter(); scene.AddNewClient(m_character, false); m_log.WriteLine(LogPriority.NORMAL, "Press enter to quit."); @@ -107,7 +104,7 @@ namespace SimpleApp { Program app = new Program(); - app.StartUp(); + app.Run(); } } } diff --git a/OpenSim/Region/GridInterfaces/Local/LocalAssetServer.cs b/OpenSim/Region/GridInterfaces/Local/LocalAssetServer.cs index f3d7a2c..2f827cf 100644 --- a/OpenSim/Region/GridInterfaces/Local/LocalAssetServer.cs +++ b/OpenSim/Region/GridInterfaces/Local/LocalAssetServer.cs @@ -64,22 +64,15 @@ namespace OpenSim.Region.GridInterfaces.Local this._assetRequests = new BlockingQueue(); yapfile = File.Exists("regionassets.yap"); - MainLog.Instance.Verbose( "Local Asset Server class created"); - try - { - db = Db4oFactory.OpenFile("regionassets.yap"); - MainLog.Instance.Verbose( "Db4 Asset database creation"); - } - catch (Exception e) - { - db.Close(); - MainLog.Instance.WriteLine(LogPriority.MEDIUM, "Db4 Asset server :Constructor - Exception occured"); - MainLog.Instance.Warn(e.ToString()); - } + MainLog.Instance.Verbose("Local Asset Server class created"); + db = Db4oFactory.OpenFile("regionassets.yap"); + MainLog.Instance.Verbose("Db4 Asset database creation"); + if (!yapfile) { this.SetUpAssetDatabase(); } + this._localAssetServerThread = new Thread(new ThreadStart(RunRequests)); this._localAssetServerThread.IsBackground = true; this._localAssetServerThread.Start(); @@ -122,7 +115,7 @@ namespace OpenSim.Region.GridInterfaces.Local { if (db != null) { - MainLog.Instance.Verbose( "Closing local asset server database"); + MainLog.Instance.Verbose("Closing local asset server database"); db.Close(); } } @@ -163,116 +156,106 @@ namespace OpenSim.Region.GridInterfaces.Local private void SetUpAssetDatabase() { - try - { + MainLog.Instance.Verbose("Setting up asset database"); - MainLog.Instance.Verbose( "Setting up asset database"); - - AssetBase Image = new AssetBase(); - Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000001"); - Image.Name = "Bricks"; - this.LoadAsset(Image, true, "bricks.jp2"); - AssetStorage store = new AssetStorage(); - store.Data = Image.Data; - store.Name = Image.Name; - store.UUID = Image.FullID; - db.Set(store); - db.Commit(); - - Image = new AssetBase(); - Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000002"); - Image.Name = "Plywood"; - this.LoadAsset(Image, true, "plywood.jp2"); - store = new AssetStorage(); - store.Data = Image.Data; - store.Name = Image.Name; - store.UUID = Image.FullID; - db.Set(store); - db.Commit(); - - Image = new AssetBase(); - Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000003"); - Image.Name = "Rocks"; - this.LoadAsset(Image, true, "rocks.jp2"); - store = new AssetStorage(); - store.Data = Image.Data; - store.Name = Image.Name; - store.UUID = Image.FullID; - db.Set(store); - db.Commit(); - - Image = new AssetBase(); - Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000004"); - Image.Name = "Granite"; - this.LoadAsset(Image, true, "granite.jp2"); - store = new AssetStorage(); - store.Data = Image.Data; - store.Name = Image.Name; - store.UUID = Image.FullID; - db.Set(store); - db.Commit(); - - Image = new AssetBase(); - Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000005"); - Image.Name = "Hardwood"; - this.LoadAsset(Image, true, "hardwood.jp2"); - store = new AssetStorage(); - store.Data = Image.Data; - store.Name = Image.Name; - store.UUID = Image.FullID; - db.Set(store); - db.Commit(); - - Image = new AssetBase(); - Image.FullID = new LLUUID("00000000-0000-0000-5005-000000000005"); - Image.Name = "Prim Base Texture"; - this.LoadAsset(Image, true, "plywood.jp2"); - store = new AssetStorage(); - store.Data = Image.Data; - store.Name = Image.Name; - store.UUID = Image.FullID; - db.Set(store); - db.Commit(); - - Image = new AssetBase(); - Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000006"); - Image.Name = "Map Base Texture"; - this.LoadAsset(Image, true, "map_base.jp2"); - store = new AssetStorage(); - store.Data = Image.Data; - store.Name = Image.Name; - store.UUID = Image.FullID; - db.Set(store); - db.Commit(); - - Image = new AssetBase(); - Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000007"); - Image.Name = "Map Texture"; - this.LoadAsset(Image, true, "map1.jp2"); - store = new AssetStorage(); - store.Data = Image.Data; - store.Name = Image.Name; - store.UUID = Image.FullID; - db.Set(store); - db.Commit(); - - Image = new AssetBase(); - Image.FullID = new LLUUID("66c41e39-38f9-f75a-024e-585989bfab73"); - Image.Name = "Shape"; - this.LoadAsset(Image, false, "base_shape.dat"); - store = new AssetStorage(); - store.Data = Image.Data; - store.Name = Image.Name; - store.UUID = Image.FullID; - db.Set(store); - db.Commit(); - } - catch (Exception e) - { - Console.WriteLine("exception loading default assets into database"); - Console.WriteLine(e.Message); - } + AssetBase Image = new AssetBase(); + Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000001"); + Image.Name = "Bricks"; + this.LoadAsset(Image, true, "bricks.jp2"); + AssetStorage store = new AssetStorage(); + store.Data = Image.Data; + store.Name = Image.Name; + store.UUID = Image.FullID; + db.Set(store); + db.Commit(); + + Image = new AssetBase(); + Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000002"); + Image.Name = "Plywood"; + this.LoadAsset(Image, true, "plywood.jp2"); + store = new AssetStorage(); + store.Data = Image.Data; + store.Name = Image.Name; + store.UUID = Image.FullID; + db.Set(store); + db.Commit(); + + Image = new AssetBase(); + Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000003"); + Image.Name = "Rocks"; + this.LoadAsset(Image, true, "rocks.jp2"); + store = new AssetStorage(); + store.Data = Image.Data; + store.Name = Image.Name; + store.UUID = Image.FullID; + db.Set(store); + db.Commit(); + + Image = new AssetBase(); + Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000004"); + Image.Name = "Granite"; + this.LoadAsset(Image, true, "granite.jp2"); + store = new AssetStorage(); + store.Data = Image.Data; + store.Name = Image.Name; + store.UUID = Image.FullID; + db.Set(store); + db.Commit(); + Image = new AssetBase(); + Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000005"); + Image.Name = "Hardwood"; + this.LoadAsset(Image, true, "hardwood.jp2"); + store = new AssetStorage(); + store.Data = Image.Data; + store.Name = Image.Name; + store.UUID = Image.FullID; + db.Set(store); + db.Commit(); + + Image = new AssetBase(); + Image.FullID = new LLUUID("00000000-0000-0000-5005-000000000005"); + Image.Name = "Prim Base Texture"; + this.LoadAsset(Image, true, "plywood.jp2"); + store = new AssetStorage(); + store.Data = Image.Data; + store.Name = Image.Name; + store.UUID = Image.FullID; + db.Set(store); + db.Commit(); + + Image = new AssetBase(); + Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000006"); + Image.Name = "Map Base Texture"; + this.LoadAsset(Image, true, "map_base.jp2"); + store = new AssetStorage(); + store.Data = Image.Data; + store.Name = Image.Name; + store.UUID = Image.FullID; + db.Set(store); + db.Commit(); + + Image = new AssetBase(); + Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000007"); + Image.Name = "Map Texture"; + this.LoadAsset(Image, true, "map1.jp2"); + store = new AssetStorage(); + store.Data = Image.Data; + store.Name = Image.Name; + store.UUID = Image.FullID; + db.Set(store); + db.Commit(); + + Image = new AssetBase(); + Image.FullID = new LLUUID("66c41e39-38f9-f75a-024e-585989bfab73"); + Image.Name = "Shape"; + this.LoadAsset(Image, false, "base_shape.dat"); + store = new AssetStorage(); + store.Data = Image.Data; + store.Name = Image.Name; + store.UUID = Image.FullID; + db.Set(store); + db.Commit(); } private void LoadAsset(AssetBase info, bool image, string filename) @@ -294,18 +277,18 @@ namespace OpenSim.Region.GridInterfaces.Local //info.loaded=true; } } - public class AssetUUIDQuery : Predicate - { - private LLUUID _findID; + public class AssetUUIDQuery : Predicate + { + private LLUUID _findID; - public AssetUUIDQuery(LLUUID find) - { - _findID = find; - } - public bool Match(AssetStorage asset) - { - return (asset.UUID == _findID); - } + public AssetUUIDQuery(LLUUID find) + { + _findID = find; + } + public bool Match(AssetStorage asset) + { + return (asset.UUID == _findID); } - + } + } -- cgit v1.1