diff --git a/OpenGrid.Framework.Data.DB4o/DB4oGridData.cs b/OpenGrid.Framework.Data.DB4o/DB4oGridData.cs index c853b50d05..caf7eb07f9 100644 --- a/OpenGrid.Framework.Data.DB4o/DB4oGridData.cs +++ b/OpenGrid.Framework.Data.DB4o/DB4oGridData.cs @@ -9,20 +9,20 @@ namespace OpenGrid.Framework.Data.DB4o { class DB4oGridData : IGridData { - DB4oManager manager; + DB4oGridManager manager; public void Initialise() { - manager = new DB4oManager("gridserver.yap"); + manager = new DB4oGridManager("gridserver.yap"); } public SimProfileData GetProfileByHandle(ulong handle) { - lock (manager.profiles) + lock (manager.simProfiles) { - foreach (LLUUID UUID in manager.profiles.Keys) + foreach (LLUUID UUID in manager.simProfiles.Keys) { - if (manager.profiles[UUID].regionHandle == handle) + if (manager.simProfiles[UUID].regionHandle == handle) { - return manager.profiles[UUID]; + return manager.simProfiles[UUID]; } } } @@ -31,17 +31,17 @@ namespace OpenGrid.Framework.Data.DB4o public SimProfileData GetProfileByLLUUID(LLUUID uuid) { - lock (manager.profiles) + lock (manager.simProfiles) { - if (manager.profiles.ContainsKey(uuid)) - return manager.profiles[uuid]; + if (manager.simProfiles.ContainsKey(uuid)) + return manager.simProfiles[uuid]; } throw new Exception("Unable to find profile with UUID (" + uuid.ToStringHyphenated() + ")"); } public DataResponse AddProfile(SimProfileData profile) { - lock (manager.profiles) + lock (manager.simProfiles) { if (manager.AddRow(profile)) { @@ -55,7 +55,7 @@ namespace OpenGrid.Framework.Data.DB4o } public bool AuthenticateSim(LLUUID uuid, ulong handle, string key) { - if (manager.profiles[uuid].regionRecvKey == key) + if (manager.simProfiles[uuid].regionRecvKey == key) return true; return false; } diff --git a/OpenGrid.Framework.Data.DB4o/DB4oManager.cs b/OpenGrid.Framework.Data.DB4o/DB4oManager.cs index 3ebcee2c1b..aaa6e916be 100644 --- a/OpenGrid.Framework.Data.DB4o/DB4oManager.cs +++ b/OpenGrid.Framework.Data.DB4o/DB4oManager.cs @@ -7,19 +7,19 @@ using libsecondlife; namespace OpenGrid.Framework.Data.DB4o { - class DB4oManager + class DB4oGridManager { - public Dictionary profiles = new Dictionary(); + public Dictionary simProfiles = new Dictionary(); string dbfl; - public DB4oManager(string db4odb) + public DB4oGridManager(string db4odb) { dbfl = db4odb; IObjectContainer database; database = Db4oFactory.OpenFile(dbfl); IObjectSet result = database.Get(typeof(SimProfileData)); foreach(SimProfileData row in result) { - profiles.Add(row.UUID, row); + simProfiles.Add(row.UUID, row); } database.Close(); } @@ -31,7 +31,65 @@ namespace OpenGrid.Framework.Data.DB4o /// Successful? public bool AddRow(SimProfileData row) { - profiles.Add(row.UUID, row); + if (simProfiles.ContainsKey(row.UUID)) + { + simProfiles[row.UUID] = row; + } + else + { + simProfiles.Add(row.UUID, row); + } + + try + { + IObjectContainer database; + database = Db4oFactory.OpenFile(dbfl); + database.Set(row); + database.Close(); + return true; + } + catch (Exception e) + { + return false; + } + } + + + } + + class DB4oUserManager + { + public Dictionary userProfiles = new Dictionary(); + string dbfl; + + public DB4oUserManager(string db4odb) + { + dbfl = db4odb; + IObjectContainer database; + database = Db4oFactory.OpenFile(dbfl); + IObjectSet result = database.Get(typeof(UserProfileData)); + foreach (UserProfileData row in result) + { + userProfiles.Add(row.UUID, row); + } + database.Close(); + } + + /// + /// Adds a new profile to the database (Warning: Probably slow.) + /// + /// The profile to add + /// Successful? + public bool AddRow(UserProfileData row) + { + if (userProfiles.ContainsKey(row.UUID)) + { + userProfiles[row.UUID] = row; + } + else + { + userProfiles.Add(row.UUID, row); + } try { diff --git a/OpenGrid.Framework.Data.DB4o/OpenGrid.Framework.Data.DB4o.csproj b/OpenGrid.Framework.Data.DB4o/OpenGrid.Framework.Data.DB4o.csproj index 45a2d44c45..6ef93c2b47 100644 --- a/OpenGrid.Framework.Data.DB4o/OpenGrid.Framework.Data.DB4o.csproj +++ b/OpenGrid.Framework.Data.DB4o/OpenGrid.Framework.Data.DB4o.csproj @@ -1,4 +1,4 @@ - + Local 8.0.50727 @@ -6,7 +6,8 @@ {39BD9497-0000-0000-0000-000000000000} Debug AnyCPU - + + OpenGrid.Framework.Data.DB4o @@ -15,9 +16,11 @@ IE50 false Library - + + OpenGrid.Framework.Data.DB4o - + + @@ -28,7 +31,8 @@ TRACE;DEBUG - + + True 4096 False @@ -37,7 +41,8 @@ False False 4 - + + False @@ -46,7 +51,8 @@ TRACE - + + False 4096 True @@ -55,26 +61,27 @@ False False 4 - + + - + System.dll False - + System.Xml.dll False - + System.Data.dll False - + ..\bin\libsecondlife.dll False - + ..\bin\Db4objects.Db4o.dll False @@ -84,7 +91,7 @@ OpenGrid.Framework.Data {62CDF671-0000-0000-0000-000000000000} {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - False + False @@ -94,6 +101,7 @@ Code + Code @@ -105,4 +113,4 @@ - + \ No newline at end of file diff --git a/OpenGrid.Framework.Data/OpenGrid.Framework.Data.csproj b/OpenGrid.Framework.Data/OpenGrid.Framework.Data.csproj index bba672068d..e64663ddd3 100644 --- a/OpenGrid.Framework.Data/OpenGrid.Framework.Data.csproj +++ b/OpenGrid.Framework.Data/OpenGrid.Framework.Data.csproj @@ -1,4 +1,4 @@ - + Local 8.0.50727 @@ -6,7 +6,8 @@ {62CDF671-0000-0000-0000-000000000000} Debug AnyCPU - + + OpenGrid.Framework.Data @@ -15,9 +16,11 @@ IE50 false Library - + + OpenGrid.Framework.Data - + + @@ -28,7 +31,8 @@ TRACE;DEBUG - + + True 4096 False @@ -37,7 +41,8 @@ False False 4 - + + False @@ -46,7 +51,8 @@ TRACE - + + False 4096 True @@ -55,22 +61,23 @@ False False 4 - + + - + System.dll False - + System.Xml.dll False - + System.Data.dll False - + ..\bin\libsecondlife.dll False @@ -84,6 +91,7 @@ Code + Code @@ -98,4 +106,4 @@ - + \ No newline at end of file diff --git a/OpenGrid.Framework.Data/UserProfileData.cs b/OpenGrid.Framework.Data/UserProfileData.cs index d99394e791..3a5482889f 100644 --- a/OpenGrid.Framework.Data/UserProfileData.cs +++ b/OpenGrid.Framework.Data/UserProfileData.cs @@ -7,27 +7,42 @@ namespace OpenGrid.Framework.Data { public class UserProfileData { - string username; // The configurable part of the users username - string surname; // The users surname (can be used to indicate user class - eg 'Test User' or 'Test Admin') + public LLUUID UUID; + public string username; // The configurable part of the users username + public string surname; // The users surname (can be used to indicate user class - eg 'Test User' or 'Test Admin') - ulong homeRegion; // RegionHandle of home - LLVector3 homeLocation; // Home Location inside the sim + public string passwordHash; // Hash of the users password - int created; // UNIX Epoch Timestamp (User Creation) - int lastLogin; // UNIX Epoch Timestamp (Last Login Time) + public ulong homeRegion; // RegionHandle of home + public LLVector3 homeLocation; // Home Location inside the sim - string userInventoryURI; // URI to inventory server for this user - string userAssetURI; // URI to asset server for this user + public int created; // UNIX Epoch Timestamp (User Creation) + public int lastLogin; // UNIX Epoch Timestamp (Last Login Time) - uint profileCanDoMask; // Profile window "I can do" mask - uint profileWantDoMask; // Profile window "I want to" mask + public string userInventoryURI; // URI to inventory server for this user + public string userAssetURI; // URI to asset server for this user - string profileAboutText; // My about window text - string profileFirstText; // First Life Text + public uint profileCanDoMask; // Profile window "I can do" mask + public uint profileWantDoMask; // Profile window "I want to" mask - LLUUID profileImage; // My avatars profile image - LLUUID profileFirstImage; // First-life image + public string profileAboutText; // My about window text + public string profileFirstText; // First Life Text + public LLUUID profileImage; // My avatars profile image + public LLUUID profileFirstImage; // First-life image + public UserAgentData currentAgent; // The users last agent + } + + public class UserAgentData + { + public string agentIP; // The IP of the agent + public uint agentPort; // The port of the agent + public bool agentOnline; // The online status of the agent + public LLUUID sessionID; // The session ID for the agent + public LLUUID secureSessionID; // The secure session ID for the agent + public LLUUID regionID; // The region ID the agent occupies + public uint loginTime; // EPOCH based Timestamp + public uint logoutTime; // Timestamp or 0 if N/A } } diff --git a/OpenGridServices.GridServer/GridManager.cs b/OpenGridServices.GridServer/GridManager.cs index 8cff0d3fca..e41f3d50c0 100644 --- a/OpenGridServices.GridServer/GridManager.cs +++ b/OpenGridServices.GridServer/GridManager.cs @@ -16,6 +16,7 @@ namespace OpenGridServices.GridServer class GridManager { Dictionary _plugins = new Dictionary(); + public string defaultRecvKey; /// /// Adds a new grid server plugin - grid servers will be requested in the order they were loaded. @@ -23,27 +24,26 @@ namespace OpenGridServices.GridServer /// The filename to the grid server plugin DLL public void AddPlugin(string FileName) { + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Storage: Attempting to load " + FileName); Assembly pluginAssembly = Assembly.LoadFrom(FileName); - + + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Storage: Found " + pluginAssembly.GetTypes().Length + " interfaces."); foreach (Type pluginType in pluginAssembly.GetTypes()) { - if (pluginType.IsPublic) - { - if (!pluginType.IsAbstract) - { - Type typeInterface = pluginType.GetInterface("IGridData", true); - - if (typeInterface != null) - { - IGridData plug = (IGridData)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); - plug.Initialise(); - this._plugins.Add(plug.getName(),plug); - - } - - typeInterface = null; - } - } + if (!pluginType.IsAbstract) + { + Type typeInterface = pluginType.GetInterface("IGridData", true); + + if (typeInterface != null) + { + IGridData plug = (IGridData)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); + plug.Initialise(); + this._plugins.Add(plug.getName(), plug); + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Storage: Added IGridData Interface"); + } + + typeInterface = null; + } } pluginAssembly = null; @@ -63,7 +63,7 @@ namespace OpenGridServices.GridServer } catch (Exception e) { - OpenSim.Framework.Console.MainConsole.Instance.WriteLine("getRegionPlugin UUID " + kvp.Key + " is made of fail: " + e.ToString()); + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Storage: Unable to find region " + uuid.ToStringHyphenated() + " via " + kvp.Key); } } return null; @@ -84,7 +84,7 @@ namespace OpenGridServices.GridServer } catch (Exception e) { - OpenSim.Framework.Console.MainConsole.Instance.WriteLine("getRegionPlugin Handle " + kvp.Key + " is made of fail: " + e.ToString()); + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Storage: Unable to find region " + handle.ToString() + " via " + kvp.Key); } } return null; @@ -269,6 +269,7 @@ namespace OpenGridServices.GridServer TheSim = new SimProfileData(); LLUUID UUID = new LLUUID(param); TheSim.UUID = UUID; + TheSim.regionRecvKey = defaultRecvKey; } XmlDocument doc = new XmlDocument(); @@ -320,11 +321,13 @@ namespace OpenGridServices.GridServer try { + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Attempting to add a new region to the grid - " + _plugins.Count + " storage provider(s) registered."); foreach (KeyValuePair kvp in _plugins) { try { kvp.Value.AddProfile(TheSim); + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("New sim added to grid (" + TheSim.regionName + ")"); } catch (Exception e) { diff --git a/OpenGridServices.GridServer/Main.cs b/OpenGridServices.GridServer/Main.cs index f7cfe71981..ba6c60d90f 100644 --- a/OpenGridServices.GridServer/Main.cs +++ b/OpenGridServices.GridServer/Main.cs @@ -47,6 +47,7 @@ namespace OpenGridServices.GridServer public class OpenGrid_Main : BaseServer, conscmd_callback { private string ConfigDll = "OpenGrid.Config.GridConfigDb4o.dll"; + private string GridDll = "OpenGrid.Framework.Data.DB4o.dll"; public GridConfig Cfg; public static OpenGrid_Main thegrid; @@ -94,9 +95,10 @@ namespace OpenGridServices.GridServer Cfg = this.LoadConfigDll(this.ConfigDll); Cfg.InitConfig(); - m_console.WriteLine("Main.cs:Startup() - Connecting to MySql Server"); + m_console.WriteLine("Main.cs:Startup() - Connecting to Storage Server"); m_gridManager = new GridManager(); - m_gridManager.AddPlugin("OpenGrid.Framework.Data.MySQL.dll"); // Made of win + m_gridManager.AddPlugin(GridDll); // Made of win + m_gridManager.defaultRecvKey = Cfg.SimRecvKey; m_console.WriteLine("Main.cs:Startup() - Starting HTTP process"); BaseHttpServer httpServer = new BaseHttpServer(8001); diff --git a/OpenSim.Framework.Console/ConsoleBase.cs b/OpenSim.Framework.Console/ConsoleBase.cs index 39d2b28057..dd8054a483 100644 --- a/OpenSim.Framework.Console/ConsoleBase.cs +++ b/OpenSim.Framework.Console/ConsoleBase.cs @@ -43,6 +43,7 @@ namespace OpenSim.Framework.Console public void Write(string format, params object[] args) { Log.Write(format, args); + Log.Flush(); if(!disableOutput) { System.Console.Write(format, args); @@ -53,7 +54,8 @@ namespace OpenSim.Framework.Console public void WriteLine(string format, params object[] args) { Log.WriteLine(format, args); - if(!disableOutput) + Log.Flush(); + if(!disableOutput) { System.Console.WriteLine(format, args); } diff --git a/OpenSim.Framework/OpenSim.Framework.dll.build b/OpenSim.Framework/OpenSim.Framework.dll.build index aa405fb290..69ea10a393 100644 --- a/OpenSim.Framework/OpenSim.Framework.dll.build +++ b/OpenSim.Framework/OpenSim.Framework.dll.build @@ -22,7 +22,6 @@ - diff --git a/OpenSim.RegionServer/OpenSim.RegionServer.dll.build b/OpenSim.RegionServer/OpenSim.RegionServer.dll.build index d41d6643bb..871d639d3a 100644 --- a/OpenSim.RegionServer/OpenSim.RegionServer.dll.build +++ b/OpenSim.RegionServer/OpenSim.RegionServer.dll.build @@ -19,6 +19,7 @@ + diff --git a/OpenSim.RegionServer/OpenSimMain.cs b/OpenSim.RegionServer/OpenSimMain.cs index 61441b2f4d..1fd24b78d3 100644 --- a/OpenSim.RegionServer/OpenSimMain.cs +++ b/OpenSim.RegionServer/OpenSimMain.cs @@ -150,12 +150,28 @@ namespace OpenSim m_console.WriteLine("Starting in Grid mode"); } - GridServers.Initialise(); + try + { + GridServers.Initialise(); + } + catch (Exception e) + { + m_console.WriteLine(e.Message + "\nSorry, could not setup the grid interface"); + Environment.Exit(1); + } startuptime = DateTime.Now; - AssetCache = new AssetCache(GridServers.AssetServer); - InventoryCache = new InventoryCache(); + try + { + AssetCache = new AssetCache(GridServers.AssetServer); + InventoryCache = new InventoryCache(); + } + catch (Exception e) + { + m_console.WriteLine(e.Message + "\nSorry, could not setup local cache"); + Environment.Exit(1); + } PacketServer packetServer = new PacketServer(this); @@ -189,9 +205,17 @@ namespace OpenSim { // The grid server has told us who we are // We must obey the grid server. - regionData.RegionLocX = Convert.ToUInt32(((RemoteGridBase)(GridServers.GridServer)).GridData["region_locx"].ToString()); - regionData.RegionLocY = Convert.ToUInt32(((RemoteGridBase)(GridServers.GridServer)).GridData["region_locy"].ToString()); - regionData.RegionName = ((RemoteGridBase)(GridServers.GridServer)).GridData["regionname"].ToString(); + try + { + regionData.RegionLocX = Convert.ToUInt32(((RemoteGridBase)(GridServers.GridServer)).GridData["region_locx"].ToString()); + regionData.RegionLocY = Convert.ToUInt32(((RemoteGridBase)(GridServers.GridServer)).GridData["region_locy"].ToString()); + regionData.RegionName = ((RemoteGridBase)(GridServers.GridServer)).GridData["regionname"].ToString(); + } + catch (Exception e) + { + m_console.WriteLine(e.Message + "\nBAD ERROR! THIS SHOULD NOT HAPPEN! Bad GridData from the grid interface!!!! ZOMG!!!"); + Environment.Exit(1); + } } } @@ -234,6 +258,7 @@ namespace OpenSim if (gridServer.GetName() == "Remote") { // should startup the OGS protocol server here + // Are we actually using this? OGSServer = new OpenGridProtocolServer(this.regionData.IPListenPort - 500); // Changed so we can have more than one OGSServer per machine. // we are in Grid mode so set a XmlRpc handler to handle "expect_user" calls from the user server @@ -347,7 +372,7 @@ namespace OpenSim // SandBoxMode string attri = ""; attri = configData.GetAttribute("SandBox"); - if (attri == "") + if ((attri == "") || ((attri != "false") && (attri != "true"))) { this.m_sandbox = false; configData.SetAttribute("SandBox", "false"); @@ -360,7 +385,7 @@ namespace OpenSim // LoginServer attri = ""; attri = configData.GetAttribute("LoginServer"); - if (attri == "") + if ((attri == "") || ((attri != "false") && (attri != "true"))) { this.m_loginserver = false; configData.SetAttribute("LoginServer", "false"); @@ -373,12 +398,12 @@ namespace OpenSim // Sandbox User accounts attri = ""; attri = configData.GetAttribute("UserAccount"); - if (attri == "") + if ((attri == "") || ((attri != "false") && (attri != "true"))) { this.user_accounts = false; configData.SetAttribute("UserAccounts", "false"); } - else + else if (attri == "true") { this.user_accounts = Convert.ToBoolean(attri); } @@ -386,70 +411,96 @@ namespace OpenSim // Grid mode hack to use local asset server attri = ""; attri = configData.GetAttribute("LocalAssets"); - if (attri == "") + if ((attri == "") || ((attri != "false") && (attri != "true"))) { this.gridLocalAsset = false; configData.SetAttribute("LocalAssets", "false"); } - else + else if (attri == "true") { this.gridLocalAsset = Convert.ToBoolean(attri); } - // Grid mode hack to use local asset server + attri = ""; attri = configData.GetAttribute("PhysicsEngine"); - if (attri == "") + switch (attri) { - this.m_physicsEngine = "basicphysics"; - configData.SetAttribute("PhysicsEngine", "basicphysics"); - } - else - { - this.m_physicsEngine = attri; - if ((attri == "RealPhysX") || (attri == "OpenDynamicsEngine")) - { - OpenSim.world.Avatar.PhysicsEngineFlying = true; - } - else - { + default: + m_console.WriteLine("Main.cs: SetupFromConfig() - Invalid value for PhysicsEngine attribute, terminating"); + Environment.Exit(1); + break; + + case "": + this.m_physicsEngine = "basicphysics"; + configData.SetAttribute("PhysicsEngine", "basicphysics"); OpenSim.world.Avatar.PhysicsEngineFlying = false; - } + break; + + case "basicphysics": + this.m_physicsEngine = "basicphysics"; + configData.SetAttribute("PhysicsEngine", "basicphysics"); + OpenSim.world.Avatar.PhysicsEngineFlying = false; + break; + + case "RealPhysX": + this.m_physicsEngine = "RealPhysX"; + OpenSim.world.Avatar.PhysicsEngineFlying = true; + break; + + case "OpenDynamicsEngine": + this.m_physicsEngine = "OpenDynamicsEngine"; + OpenSim.world.Avatar.PhysicsEngineFlying = true; + break; } + configData.Commit(); } catch (Exception e) { Console.WriteLine(e.Message); + Console.WriteLine("\nSorry, a fatal error occurred while trying to initialise the configuration data"); + Console.WriteLine("Can not continue starting up"); + Environment.Exit(1); } } private SimConfig LoadConfigDll(string dllName) { - Assembly pluginAssembly = Assembly.LoadFrom(dllName); - SimConfig config = null; - - foreach (Type pluginType in pluginAssembly.GetTypes()) + try { - if (pluginType.IsPublic) + Assembly pluginAssembly = Assembly.LoadFrom(dllName); + SimConfig config = null; + + foreach (Type pluginType in pluginAssembly.GetTypes()) { - if (!pluginType.IsAbstract) + if (pluginType.IsPublic) { - Type typeInterface = pluginType.GetInterface("ISimConfig", true); - - if (typeInterface != null) + if (!pluginType.IsAbstract) { - ISimConfig plug = (ISimConfig)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); - config = plug.GetConfigObject(); - break; - } + Type typeInterface = pluginType.GetInterface("ISimConfig", true); - typeInterface = null; + if (typeInterface != null) + { + ISimConfig plug = (ISimConfig)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); + config = plug.GetConfigObject(); + break; + } + + typeInterface = null; + } } } + pluginAssembly = null; + return config; + } + catch (Exception e) + { + m_console.WriteLine(e.Message + "\nSorry, a fatal error occurred while trying to load the config DLL"); + m_console.WriteLine("Can not continue starting up"); + Environment.Exit(1); + return null; } - pluginAssembly = null; - return config; } private void OnReceivedData(IAsyncResult result) diff --git a/OpenSim.build b/OpenSim.build index 67b2120da1..e9ba612519 100644 --- a/OpenSim.build +++ b/OpenSim.build @@ -46,31 +46,34 @@ - - - - - - - - - - - - - - - - - - - + + + + - - + + + + + + + + + + + + + + + + + + + + @@ -85,6 +88,9 @@ + + + @@ -109,31 +115,34 @@ - - - - - - - - - - - - - - - - - - - + + + + - - + + + + + + + + + + + + + + + + + + + + diff --git a/releng/makerel.sh b/releng/makerel.sh index 75d1f8c17f..bf87543f6c 100755 --- a/releng/makerel.sh +++ b/releng/makerel.sh @@ -5,8 +5,8 @@ export OPENSIMMAJOR=0 export OPENSIMMINOR=1 export BUILD=`date +%s` -export BRANCH=DEVEL -export SVNURL=svn://openmetaverse.org/opensim/trunk +export BRANCH=PRESTABLE +export SVNURL=svn://openmetaverse.org/opensim/branches/0.1-prestable