aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenGridServices/OpenGrid.Framework.Manager
diff options
context:
space:
mode:
Diffstat (limited to 'OpenGridServices/OpenGrid.Framework.Manager')
-rw-r--r--OpenGridServices/OpenGrid.Framework.Manager/GridManagementAgent.cs67
-rw-r--r--OpenGridServices/OpenGrid.Framework.Manager/GridServerManager.cs53
2 files changed, 113 insertions, 7 deletions
diff --git a/OpenGridServices/OpenGrid.Framework.Manager/GridManagementAgent.cs b/OpenGridServices/OpenGrid.Framework.Manager/GridManagementAgent.cs
index f4483fb..0ee0e3d 100644
--- a/OpenGridServices/OpenGrid.Framework.Manager/GridManagementAgent.cs
+++ b/OpenGridServices/OpenGrid.Framework.Manager/GridManagementAgent.cs
@@ -1,3 +1,29 @@
1/*
2* Copyright (c) OpenSim project, http://sim.opensecondlife.org/
3*
4* Redistribution and use in source and binary forms, with or without
5* modification, are permitted provided that the following conditions are met:
6* * Redistributions of source code must retain the above copyright
7* notice, this list of conditions and the following disclaimer.
8* * Redistributions in binary form must reproduce the above copyright
9* notice, this list of conditions and the following disclaimer in the
10* documentation and/or other materials provided with the distribution.
11* * Neither the name of the <organization> nor the
12* names of its contributors may be used to endorse or promote products
13* derived from this software without specific prior written permission.
14*
15* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
16* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
19* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25*
26*/
1using Nwc.XmlRpc; 27using Nwc.XmlRpc;
2using OpenSim.Framework; 28using OpenSim.Framework;
3using OpenSim.Servers; 29using OpenSim.Servers;
@@ -7,19 +33,46 @@ using libsecondlife;
7 33
8namespace OpenGrid.Framework.Manager 34namespace OpenGrid.Framework.Manager
9{ 35{
10 36 /// <summary>
37 /// Used to pass messages to the gridserver
38 /// </summary>
39 /// <param name="param">Pass this argument</param>
11 public delegate void GridManagerCallback(string param); 40 public delegate void GridManagerCallback(string param);
12 41
42 /// <summary>
43 /// Serverside listener for grid commands
44 /// </summary>
13 public class GridManagementAgent 45 public class GridManagementAgent
14 { 46 {
15 47 /// <summary>
48 /// Passes grid server messages
49 /// </summary>
16 private GridManagerCallback thecallback; 50 private GridManagerCallback thecallback;
51
52 /// <summary>
53 /// Security keys
54 /// </summary>
17 private string sendkey; 55 private string sendkey;
18 private string recvkey; 56 private string recvkey;
57
58 /// <summary>
59 /// Our component type
60 /// </summary>
19 private string component_type; 61 private string component_type;
20 62
63 /// <summary>
64 /// List of active sessions
65 /// </summary>
21 private static ArrayList Sessions; 66 private static ArrayList Sessions;
22 67
68 /// <summary>
69 /// Initialises a new GridManagementAgent
70 /// </summary>
71 /// <param name="app_httpd">HTTP Daemon for this server</param>
72 /// <param name="component_type">What component type are we?</param>
73 /// <param name="sendkey">Security send key</param>
74 /// <param name="recvkey">Security recieve key</param>
75 /// <param name="thecallback">Message callback</param>
23 public GridManagementAgent(BaseHttpServer app_httpd, string component_type, string sendkey, string recvkey, GridManagerCallback thecallback) 76 public GridManagementAgent(BaseHttpServer app_httpd, string component_type, string sendkey, string recvkey, GridManagerCallback thecallback)
24 { 77 {
25 this.sendkey = sendkey; 78 this.sendkey = sendkey;
@@ -41,11 +94,21 @@ namespace OpenGrid.Framework.Manager
41 } 94 }
42 } 95 }
43 96
97 /// <summary>
98 /// Checks if a session exists
99 /// </summary>
100 /// <param name="sessionID">The session ID</param>
101 /// <returns>Exists?</returns>
44 public static bool SessionExists(LLUUID sessionID) 102 public static bool SessionExists(LLUUID sessionID)
45 { 103 {
46 return Sessions.Contains(sessionID); 104 return Sessions.Contains(sessionID);
47 } 105 }
48 106
107 /// <summary>
108 /// Logs a new session to the grid manager
109 /// </summary>
110 /// <param name="request">the XMLRPC request</param>
111 /// <returns>An XMLRPC reply</returns>
49 public static XmlRpcResponse XmlRpcLoginMethod(XmlRpcRequest request) 112 public static XmlRpcResponse XmlRpcLoginMethod(XmlRpcRequest request)
50 { 113 {
51 XmlRpcResponse response = new XmlRpcResponse(); 114 XmlRpcResponse response = new XmlRpcResponse();
diff --git a/OpenGridServices/OpenGrid.Framework.Manager/GridServerManager.cs b/OpenGridServices/OpenGrid.Framework.Manager/GridServerManager.cs
index 7ebf66a..e1d25a6 100644
--- a/OpenGridServices/OpenGrid.Framework.Manager/GridServerManager.cs
+++ b/OpenGridServices/OpenGrid.Framework.Manager/GridServerManager.cs
@@ -1,3 +1,30 @@
1/*
2* Copyright (c) OpenSim project, http://sim.opensecondlife.org/
3*
4* Redistribution and use in source and binary forms, with or without
5* modification, are permitted provided that the following conditions are met:
6* * Redistributions of source code must retain the above copyright
7* notice, this list of conditions and the following disclaimer.
8* * Redistributions in binary form must reproduce the above copyright
9* notice, this list of conditions and the following disclaimer in the
10* documentation and/or other materials provided with the distribution.
11* * Neither the name of the <organization> nor the
12* names of its contributors may be used to endorse or promote products
13* derived from this software without specific prior written permission.
14*
15* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
16* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
19* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25*
26*/
27
1using System; 28using System;
2using System.Collections; 29using System.Collections;
3using System.Collections.Generic; 30using System.Collections.Generic;
@@ -7,13 +34,27 @@ using libsecondlife;
7 34
8namespace OpenGrid.Framework.Manager { 35namespace OpenGrid.Framework.Manager {
9 36
37 /// <summary>
38 /// A remote management system for the grid server
39 /// </summary>
10 public class GridServerManager 40 public class GridServerManager
11 { 41 {
42 /// <summary>
43 /// Triggers events from the grid manager
44 /// </summary>
12 public static GridManagerCallback thecallback; 45 public static GridManagerCallback thecallback;
13 46
47 /// <summary>
48 /// Security keys
49 /// </summary>
14 public static string sendkey; 50 public static string sendkey;
15 public static string recvkey; 51 public static string recvkey;
16 52
53 /// <summary>
54 /// Disconnects the grid server and shuts it down
55 /// </summary>
56 /// <param name="request">XmlRpc Request</param>
57 /// <returns>An XmlRpc response containing either a "msg" or an "error"</returns>
17 public static XmlRpcResponse XmlRpcShutdownMethod(XmlRpcRequest request) 58 public static XmlRpcResponse XmlRpcShutdownMethod(XmlRpcRequest request)
18 { 59 {
19 XmlRpcResponse response = new XmlRpcResponse(); 60 XmlRpcResponse response = new XmlRpcResponse();
@@ -23,7 +64,7 @@ namespace OpenGrid.Framework.Manager {
23 if(requestData.ContainsKey("session_id")) { 64 if(requestData.ContainsKey("session_id")) {
24 if(GridManagementAgent.SessionExists(new LLUUID((string)requestData["session_id"]))) { 65 if(GridManagementAgent.SessionExists(new LLUUID((string)requestData["session_id"]))) {
25 responseData["msg"]="Shutdown command accepted"; 66 responseData["msg"]="Shutdown command accepted";
26 (new Thread(new ThreadStart(ZOMGServerIsNowTerminallyIll))).Start(); 67 (new Thread(new ThreadStart(ShutdownServer))).Start();
27 } else { 68 } else {
28 response.IsFault=true; 69 response.IsFault=true;
29 responseData["error"]="bad session ID"; 70 responseData["error"]="bad session ID";
@@ -37,11 +78,13 @@ namespace OpenGrid.Framework.Manager {
37 return response; 78 return response;
38 } 79 }
39 80
40 // Brought to by late-night coding 81 /// <summary>
41 public static void ZOMGServerIsNowTerminallyIll() 82 /// Shuts down the grid server
83 /// </summary>
84 public static void ShutdownServer()
42 { 85 {
43 Console.WriteLine("ZOMG! THIS SERVER IS TERMINALLY ILL - WE GOT A SHUTDOWN REQUEST FROM A GRID MANAGER!!!!"); 86 Console.WriteLine("Shutting down the grid server - recieved a grid manager request");
44 Console.WriteLine("We have 3 seconds to live..."); 87 Console.WriteLine("Terminating in three seconds...");
45 Thread.Sleep(3000); 88 Thread.Sleep(3000);
46 thecallback("shutdown"); 89 thecallback("shutdown");
47 } 90 }