From 3376b82501000692d6dac24b051af738cdaf2737 Mon Sep 17 00:00:00 2001 From: MW Date: Thu, 24 May 2007 12:16:50 +0000 Subject: Some more code refactoring, plus a restructuring of the directories so that the Grid servers can be a separate solution to the region server. --- .../GridManagementAgent.cs | 71 ++++++++++++++ .../GridServerManager.cs | 50 ++++++++++ .../OpenGrid.Framework.Manager.csproj | 105 +++++++++++++++++++++ .../OpenGrid.Framework.Manager.csproj.user | 12 +++ .../OpenGrid.Framework.Manager.dll.build | 44 +++++++++ 5 files changed, 282 insertions(+) create mode 100644 OpenGridServices-Source/OpenGrid.Framework.Manager/GridManagementAgent.cs create mode 100644 OpenGridServices-Source/OpenGrid.Framework.Manager/GridServerManager.cs create mode 100644 OpenGridServices-Source/OpenGrid.Framework.Manager/OpenGrid.Framework.Manager.csproj create mode 100644 OpenGridServices-Source/OpenGrid.Framework.Manager/OpenGrid.Framework.Manager.csproj.user create mode 100644 OpenGridServices-Source/OpenGrid.Framework.Manager/OpenGrid.Framework.Manager.dll.build (limited to 'OpenGridServices-Source/OpenGrid.Framework.Manager') diff --git a/OpenGridServices-Source/OpenGrid.Framework.Manager/GridManagementAgent.cs b/OpenGridServices-Source/OpenGrid.Framework.Manager/GridManagementAgent.cs new file mode 100644 index 0000000..e43ce87 --- /dev/null +++ b/OpenGridServices-Source/OpenGrid.Framework.Manager/GridManagementAgent.cs @@ -0,0 +1,71 @@ +using Nwc.XmlRpc; +using OpenSim.Framework; +using OpenSim.Servers; +using System.Collections; +using System.Collections.Generic; +using libsecondlife; + +namespace OpenGrid.Framework.Manager { + + public delegate void GridManagerCallback(string param); + + public class GridManagementAgent { + + private GridManagerCallback thecallback; + private string sendkey; + private string recvkey; + private string component_type; + + private static ArrayList Sessions; + + public GridManagementAgent(BaseHttpServer app_httpd, string component_type, string sendkey, string recvkey, GridManagerCallback thecallback) + { + this.sendkey=sendkey; + this.recvkey=recvkey; + this.component_type=component_type; + this.thecallback=thecallback; + Sessions = new ArrayList(); + + app_httpd.AddXmlRPCHandler("manager_login",XmlRpcLoginMethod); + + switch(component_type) + { + case "gridserver": + GridServerManager.sendkey=this.sendkey; + GridServerManager.recvkey=this.recvkey; + GridServerManager.thecallback=thecallback; + app_httpd.AddXmlRPCHandler("shutdown", GridServerManager.XmlRpcShutdownMethod); + break; + } + } + + public static bool SessionExists(LLUUID sessionID) + { + return Sessions.Contains(sessionID); + } + + public static XmlRpcResponse XmlRpcLoginMethod(XmlRpcRequest request) + { + XmlRpcResponse response = new XmlRpcResponse(); + Hashtable requestData = (Hashtable)request.Params[0]; + Hashtable responseData = new Hashtable(); + + // TODO: Switch this over to using OpenGrid.Framework.Data + if( requestData["username"].Equals("admin") && requestData["password"].Equals("supersecret")) { + response.IsFault=false; + LLUUID new_session=LLUUID.Random(); + Sessions.Add(new_session); + responseData["session_id"]=new_session.ToString(); + responseData["msg"]="Login OK"; + } else { + response.IsFault=true; + responseData["error"]="Invalid username or password"; + } + + response.Value = responseData; + return response; + + } + + } +} diff --git a/OpenGridServices-Source/OpenGrid.Framework.Manager/GridServerManager.cs b/OpenGridServices-Source/OpenGrid.Framework.Manager/GridServerManager.cs new file mode 100644 index 0000000..7ebf66a --- /dev/null +++ b/OpenGridServices-Source/OpenGrid.Framework.Manager/GridServerManager.cs @@ -0,0 +1,50 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using Nwc.XmlRpc; +using System.Threading; +using libsecondlife; + +namespace OpenGrid.Framework.Manager { + + public class GridServerManager + { + public static GridManagerCallback thecallback; + + public static string sendkey; + public static string recvkey; + + public static XmlRpcResponse XmlRpcShutdownMethod(XmlRpcRequest request) + { + XmlRpcResponse response = new XmlRpcResponse(); + Hashtable requestData = (Hashtable)request.Params[0]; + Hashtable responseData = new Hashtable(); + + if(requestData.ContainsKey("session_id")) { + if(GridManagementAgent.SessionExists(new LLUUID((string)requestData["session_id"]))) { + responseData["msg"]="Shutdown command accepted"; + (new Thread(new ThreadStart(ZOMGServerIsNowTerminallyIll))).Start(); + } else { + response.IsFault=true; + responseData["error"]="bad session ID"; + } + } else { + response.IsFault=true; + responseData["error"]="no session ID"; + } + + response.Value = responseData; + return response; + } + + // Brought to by late-night coding + public static void ZOMGServerIsNowTerminallyIll() + { + Console.WriteLine("ZOMG! THIS SERVER IS TERMINALLY ILL - WE GOT A SHUTDOWN REQUEST FROM A GRID MANAGER!!!!"); + Console.WriteLine("We have 3 seconds to live..."); + Thread.Sleep(3000); + thecallback("shutdown"); + } + } +} + diff --git a/OpenGridServices-Source/OpenGrid.Framework.Manager/OpenGrid.Framework.Manager.csproj b/OpenGridServices-Source/OpenGrid.Framework.Manager/OpenGrid.Framework.Manager.csproj new file mode 100644 index 0000000..3122633 --- /dev/null +++ b/OpenGridServices-Source/OpenGrid.Framework.Manager/OpenGrid.Framework.Manager.csproj @@ -0,0 +1,105 @@ + + + Local + 8.0.50727 + 2.0 + {7924FD35-0000-0000-0000-000000000000} + Debug + AnyCPU + + + + OpenGrid.Framework.Manager + JScript + Grid + IE50 + false + Library + + OpenGrid.Framework.Manager + + + + + + False + 285212672 + False + + + TRACE;DEBUG + + True + 4096 + False + ..\bin\ + False + False + False + 4 + + + + False + 285212672 + False + + + TRACE + + False + 4096 + True + ..\bin\ + False + False + False + 4 + + + + + System.dll + False + + + ..\bin\libsecondlife.dll + False + + + + + OpenSim.Framework + {8ACA2445-0000-0000-0000-000000000000} + {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + False + + + OpenSim.Servers + {8BB20F0A-0000-0000-0000-000000000000} + {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + False + + + XMLRPC + {8E81D43C-0000-0000-0000-000000000000} + {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + False + + + + + Code + + + Code + + + + + + + + + + diff --git a/OpenGridServices-Source/OpenGrid.Framework.Manager/OpenGrid.Framework.Manager.csproj.user b/OpenGridServices-Source/OpenGrid.Framework.Manager/OpenGrid.Framework.Manager.csproj.user new file mode 100644 index 0000000..d47d65d --- /dev/null +++ b/OpenGridServices-Source/OpenGrid.Framework.Manager/OpenGrid.Framework.Manager.csproj.user @@ -0,0 +1,12 @@ + + + Debug + AnyCPU + C:\New Folder\second-life-viewer\opensim-dailys2\opensim15-07\bin\ + 8.0.50727 + ProjectFiles + 0 + + + + diff --git a/OpenGridServices-Source/OpenGrid.Framework.Manager/OpenGrid.Framework.Manager.dll.build b/OpenGridServices-Source/OpenGrid.Framework.Manager/OpenGrid.Framework.Manager.dll.build new file mode 100644 index 0000000..daee3bf --- /dev/null +++ b/OpenGridServices-Source/OpenGrid.Framework.Manager/OpenGrid.Framework.Manager.dll.build @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- cgit v1.1