* debugged quite a lot of db-related strangeness and various refactoring goofs

afrisby
lbsa71 2007-07-17 00:07:26 +00:00
parent 497ab5d7ab
commit 47ea453b32
4 changed files with 143 additions and 177 deletions

View File

@ -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
/// </summary>
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);
}
/// <summary>

View File

@ -38,7 +38,7 @@ using OpenSim.Framework;
namespace OpenSim.Region.Environment.Scenes
{
public abstract class SceneBase : IWorld
public abstract class SceneBase : IWorld
{
public Dictionary<LLUUID, EntityBase> 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
/// <returns>Successful or not</returns>
public bool LoadStorageDLL(string dllName)
{
try
Assembly pluginAssembly = Assembly.LoadFrom(dllName);
ILocalStorage store = null;
foreach (Type pluginType in pluginAssembly.GetTypes())
{
Assembly pluginAssembly = Assembly.LoadFrom(dllName);
ILocalStorage store = null;
foreach (Type pluginType in pluginAssembly.GetTypes())
if (pluginType.IsPublic)
{
if (pluginType.IsPublic)
if (!pluginType.IsAbstract)
{
if (!pluginType.IsAbstract)
Type typeInterface = pluginType.GetInterface("ILocalStorage", true);
if (typeInterface != null)
{
Type typeInterface = pluginType.GetInterface("ILocalStorage", true);
ILocalStorage plug = (ILocalStorage)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
store = plug;
if (typeInterface != null)
{
ILocalStorage plug = (ILocalStorage)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
store = plug;
store.Initialise(this.m_datastore);
break;
}
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);
}
/// <summary>
/// Send the region heightmap to the client
/// </summary>
@ -150,7 +143,7 @@ namespace OpenSim.Region.Environment.Scenes
/// </summary>
/// <param name="agentID"></param>
public abstract void RemoveClient(LLUUID agentID);
#endregion
/// <summary>
@ -190,6 +183,6 @@ namespace OpenSim.Region.Environment.Scenes
#endregion
}
}

View File

@ -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();
}
}
}

View File

@ -64,22 +64,15 @@ namespace OpenSim.Region.GridInterfaces.Local
this._assetRequests = new BlockingQueue<ARequest>();
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();
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-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-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-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-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-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-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);
}
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);
}
}
}