From 54cf59ca438fe72eba6b6304f3fc4cf09ec80941 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Mon, 28 May 2007 22:20:25 +0000 Subject: [PATCH] Please to be testing new logdata interfaces! --- .../MySQLLogData.cs | 5 ++ .../OpenGrid.Framework.Data/ILogData.cs | 22 ++++++++ .../GridManager.cs | 54 +++++++++++++++++-- 3 files changed, 78 insertions(+), 3 deletions(-) diff --git a/OpenGridServices/OpenGrid.Framework.Data.MySQL/MySQLLogData.cs b/OpenGridServices/OpenGrid.Framework.Data.MySQL/MySQLLogData.cs index f1610ec9e7..8fff7939d9 100644 --- a/OpenGridServices/OpenGrid.Framework.Data.MySQL/MySQLLogData.cs +++ b/OpenGridServices/OpenGrid.Framework.Data.MySQL/MySQLLogData.cs @@ -31,6 +31,11 @@ namespace OpenGrid.Framework.Data.MySQL return "MySQL Logdata Interface"; } + public void Close() + { + // Do nothing. + } + public string getVersion() { return "0.1"; diff --git a/OpenGridServices/OpenGrid.Framework.Data/ILogData.cs b/OpenGridServices/OpenGrid.Framework.Data/ILogData.cs index 27b40cbbdc..7c6a2c542e 100644 --- a/OpenGridServices/OpenGrid.Framework.Data/ILogData.cs +++ b/OpenGridServices/OpenGrid.Framework.Data/ILogData.cs @@ -16,5 +16,27 @@ namespace OpenGrid.Framework.Data public interface ILogData { void saveLog(string serverDaemon, string target, string methodCall, string arguments, int priority,string logMessage); + /// + /// Initialises the interface + /// + void Initialise(); + + /// + /// Closes the interface + /// + void Close(); + + /// + /// The plugin being loaded + /// + /// A string containing the plugin name + string getName(); + + /// + /// The plugins version + /// + /// A string containing the plugin version + string getVersion(); } + } diff --git a/OpenGridServices/OpenGridServices.GridServer/GridManager.cs b/OpenGridServices/OpenGridServices.GridServer/GridManager.cs index 54e4bb79a6..b73f24d4a2 100644 --- a/OpenGridServices/OpenGridServices.GridServer/GridManager.cs +++ b/OpenGridServices/OpenGridServices.GridServer/GridManager.cs @@ -16,6 +16,8 @@ namespace OpenGridServices.GridServer class GridManager { Dictionary _plugins = new Dictionary(); + Dictionary _logplugins = new Dictionary(); + public OpenSim.Framework.Interfaces.GridConfig config; /// @@ -32,6 +34,7 @@ namespace OpenGridServices.GridServer { if (!pluginType.IsAbstract) { + // Regions go here Type typeInterface = pluginType.GetInterface("IGridData", true); if (typeInterface != null) @@ -43,12 +46,48 @@ namespace OpenGridServices.GridServer } typeInterface = null; + + // Logs go here + typeInterface = pluginType.GetInterface("ILogData", true); + + if (typeInterface != null) + { + ILogData plug = (ILogData)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); + plug.Initialise(); + this._logplugins.Add(plug.getName(), plug); + OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Storage: Added ILogData Interface"); + } + + typeInterface = null; } } pluginAssembly = null; } - + + /// + /// Logs a piece of information to the database + /// + /// What you were operating on (in grid server, this will likely be the region UUIDs) + /// Which method is being called? + /// What arguments are being passed? + /// How high priority is this? 1 = Max, 6 = Verbose + /// The message to log + private void logToDB(string target, string method, string args, int priority, string message) + { + foreach (KeyValuePair kvp in _logplugins) + { + try + { + kvp.Value.saveLog("Gridserver", target, method, args, priority, message); + } + catch (Exception e) + { + OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.NORMAL, "Storage: unable to write log via " + kvp.Key); + } + } + } + /// /// Returns a region by argument /// @@ -160,15 +199,23 @@ namespace OpenGridServices.GridServer if (requestData.ContainsKey("UUID")) { TheSim = getRegion(new LLUUID((string)requestData["UUID"])); + logToDB((new LLUUID((string)requestData["UUID"])).ToStringHyphenated(),"XmlRpcLoginToSimulatorMethod","", 5,"Region attempting login with UUID."); } else if (requestData.ContainsKey("region_handle")) { TheSim = getRegion((ulong)Convert.ToUInt64(requestData["region_handle"])); + logToDB((string)requestData["region_handle"], "XmlRpcLoginToSimulatorMethod", "", 5, "Region attempting login with regionHandle."); + } + else + { + responseData["error"] = "No UUID or region_handle passed to grid server - unable to connect you"; + return response; } if (TheSim == null) { responseData["error"] = "sim not found"; + return response; } else { @@ -366,7 +413,7 @@ namespace OpenGridServices.GridServer /// "OK" or an error public string RestSetSimMethod(string request, string path, string param) { - Console.WriteLine("SimProfiles.cs:RestSetSimMethod() - processing request......"); + Console.WriteLine("Processing region update"); SimProfileData TheSim; TheSim = getRegion(new LLUUID(param)); if ((TheSim) == null) @@ -449,13 +496,14 @@ namespace OpenGridServices.GridServer try { - OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW,"Attempting to add a new region to the grid - " + _plugins.Count + " storage provider(s) registered."); + OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW,"Updating / adding via " + _plugins.Count + " storage provider(s) registered."); foreach (KeyValuePair kvp in _plugins) { try { kvp.Value.AddProfile(TheSim); OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW,"New sim added to grid (" + TheSim.regionName + ")"); + logToDB(TheSim.UUID.ToStringHyphenated(), "RestSetSimMethod", "", 5, "Region successfully updated and connected to grid."); } catch (Exception e) {