aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenGridServices/OpenGrid.Framework.Manager/GridServerManager.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenGridServices/OpenGrid.Framework.Manager/GridServerManager.cs53
1 files changed, 48 insertions, 5 deletions
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 }