aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Grid/GridServer/GridServerBase.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Grid/GridServer/GridServerBase.cs121
1 files changed, 80 insertions, 41 deletions
diff --git a/OpenSim/Grid/GridServer/GridServerBase.cs b/OpenSim/Grid/GridServer/GridServerBase.cs
index bcd1403..d4d268c 100644
--- a/OpenSim/Grid/GridServer/GridServerBase.cs
+++ b/OpenSim/Grid/GridServer/GridServerBase.cs
@@ -25,6 +25,7 @@
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28using System;
28using System.Collections.Generic; 29using System.Collections.Generic;
29using System.IO; 30using System.IO;
30using System.Reflection; 31using System.Reflection;
@@ -38,12 +39,18 @@ namespace OpenSim.Grid.GridServer
38{ 39{
39 /// <summary> 40 /// <summary>
40 /// </summary> 41 /// </summary>
41 public class GridServerBase : BaseOpenSimServer 42 public class GridServerBase : BaseOpenSimServer, IGridCore
42 { 43 {
43 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 44 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
44 45
45 protected GridConfig m_config; 46 protected GridConfig m_config;
46 protected GridManager m_gridManager; 47
48 protected GridXmlRpcModule m_gridXmlRpcModule;
49 protected GridMessagingModule m_gridMessageModule;
50 protected GridRestModule m_gridRestModule;
51
52 protected GridDBService m_gridDBService;
53
47 protected List<IGridPlugin> m_plugins = new List<IGridPlugin>(); 54 protected List<IGridPlugin> m_plugins = new List<IGridPlugin>();
48 55
49 public void Work() 56 public void Work()
@@ -66,14 +73,14 @@ namespace OpenSim.Grid.GridServer
66 { 73 {
67 switch (cmd[0]) 74 switch (cmd[0])
68 { 75 {
69 case "enable": 76 case "enable":
70 m_config.AllowRegionRegistration = true; 77 m_config.AllowRegionRegistration = true;
71 m_log.Info("Region registration enabled"); 78 m_log.Info("Region registration enabled");
72 break; 79 break;
73 case "disable": 80 case "disable":
74 m_config.AllowRegionRegistration = false; 81 m_config.AllowRegionRegistration = false;
75 m_log.Info("Region registration disabled"); 82 m_log.Info("Region registration disabled");
76 break; 83 break;
77 } 84 }
78 } 85 }
79 86
@@ -84,32 +91,32 @@ namespace OpenSim.Grid.GridServer
84 m_log.Info("Region registration enabled."); 91 m_log.Info("Region registration enabled.");
85 } 92 }
86 else 93 else
87 { 94 {
88 m_log.Info("Region registration disabled."); 95 m_log.Info("Region registration disabled.");
89 } 96 }
90 } 97 }
91 98
92 99
93 protected override void StartupSpecific() 100 protected override void StartupSpecific()
94 { 101 {
95 m_config = new GridConfig("GRID SERVER", (Path.Combine(Util.configDir(), "GridServer_Config.xml"))); 102 m_config = new GridConfig("GRID SERVER", (Path.Combine(Util.configDir(), "GridServer_Config.xml")));
96 103
97 SetupGridManager();
98
99 m_log.Info("[GRID]: Starting HTTP process"); 104 m_log.Info("[GRID]: Starting HTTP process");
100 m_httpServer = new BaseHttpServer(m_config.HttpPort); 105 m_httpServer = new BaseHttpServer(m_config.HttpPort);
101 106
107 SetupGridServices();
108
102 AddHttpHandlers(); 109 AddHttpHandlers();
103 110
104 LoadPlugins(); 111 LoadPlugins();
105 112
106 m_httpServer.Start(); 113 m_httpServer.Start();
107 114
108// m_log.Info("[GRID]: Starting sim status checker"); 115 // m_log.Info("[GRID]: Starting sim status checker");
109// 116 //
110// Timer simCheckTimer = new Timer(3600000 * 3); // 3 Hours between updates. 117 // Timer simCheckTimer = new Timer(3600000 * 3); // 3 Hours between updates.
111// simCheckTimer.Elapsed += new ElapsedEventHandler(CheckSims); 118 // simCheckTimer.Elapsed += new ElapsedEventHandler(CheckSims);
112// simCheckTimer.Enabled = true; 119 // simCheckTimer.Enabled = true;
113 120
114 base.StartupSpecific(); 121 base.StartupSpecific();
115 122
@@ -130,38 +137,32 @@ namespace OpenSim.Grid.GridServer
130 137
131 protected void AddHttpHandlers() 138 protected void AddHttpHandlers()
132 { 139 {
133 m_httpServer.AddXmlRPCHandler("simulator_login", m_gridManager.XmlRpcSimulatorLoginMethod); 140 // Registering Handlers is now done in the components/modules
134 m_httpServer.AddXmlRPCHandler("simulator_data_request", m_gridManager.XmlRpcSimulatorDataRequestMethod);
135 m_httpServer.AddXmlRPCHandler("simulator_after_region_moved", m_gridManager.XmlRpcDeleteRegionMethod);
136 m_httpServer.AddXmlRPCHandler("map_block", m_gridManager.XmlRpcMapBlockMethod);
137 m_httpServer.AddXmlRPCHandler("search_for_region_by_name", m_gridManager.XmlRpcSearchForRegionMethod);
138
139 // Message Server ---> Grid Server
140 m_httpServer.AddXmlRPCHandler("register_messageserver", m_gridManager.XmlRPCRegisterMessageServer);
141 m_httpServer.AddXmlRPCHandler("deregister_messageserver", m_gridManager.XmlRPCDeRegisterMessageServer);
142
143 m_httpServer.AddStreamHandler(new RestStreamHandler("GET", "/sims/", m_gridManager.RestGetSimMethod));
144 m_httpServer.AddStreamHandler(new RestStreamHandler("POST", "/sims/", m_gridManager.RestSetSimMethod));
145
146 m_httpServer.AddStreamHandler(new RestStreamHandler("GET", "/regions/", m_gridManager.RestGetRegionMethod));
147 m_httpServer.AddStreamHandler(new RestStreamHandler("POST", "/regions/", m_gridManager.RestSetRegionMethod));
148 } 141 }
149 142
150 protected void LoadPlugins() 143 protected void LoadPlugins()
151 { 144 {
152 PluginLoader<IGridPlugin> loader = 145 PluginLoader<IGridPlugin> loader =
153 new PluginLoader<IGridPlugin> (new GridPluginInitialiser (this)); 146 new PluginLoader<IGridPlugin>(new GridPluginInitialiser(this));
154 147
155 loader.Load ("/OpenSim/GridServer"); 148 loader.Load("/OpenSim/GridServer");
156 m_plugins = loader.Plugins; 149 m_plugins = loader.Plugins;
157 } 150 }
158 151
159 protected virtual void SetupGridManager() 152 protected virtual void SetupGridServices()
160 { 153 {
161 m_log.Info("[DATA]: Connecting to Storage Server"); 154 m_log.Info("[DATA]: Connecting to Storage Server");
162 m_gridManager = new GridManager(m_version); 155 m_gridDBService = new GridDBService();
163 m_gridManager.AddPlugin(m_config.DatabaseProvider, m_config.DatabaseConnect); 156 m_gridDBService.AddPlugin(m_config.DatabaseProvider, m_config.DatabaseConnect);
164 m_gridManager.Config = m_config; 157
158 m_gridMessageModule = new GridMessagingModule(m_version, m_gridDBService, this, m_config);
159 m_gridMessageModule.Initialise();
160
161 m_gridXmlRpcModule = new GridXmlRpcModule(m_version, m_gridDBService, this, m_config);
162 m_gridXmlRpcModule.Initialise();
163
164 m_gridRestModule = new GridRestModule(m_version, m_gridDBService, this, m_config);
165 m_gridRestModule.Initialise();
165 } 166 }
166 167
167 public void CheckSims(object sender, ElapsedEventArgs e) 168 public void CheckSims(object sender, ElapsedEventArgs e)
@@ -205,5 +206,43 @@ namespace OpenSim.Grid.GridServer
205 { 206 {
206 foreach (IGridPlugin plugin in m_plugins) plugin.Dispose(); 207 foreach (IGridPlugin plugin in m_plugins) plugin.Dispose();
207 } 208 }
209
210 #region IGridCore
211 private readonly Dictionary<Type, object> m_gridInterfaces = new Dictionary<Type, object>();
212
213 /// <summary>
214 /// Register an interface on this client, should only be called in the constructor.
215 /// </summary>
216 /// <typeparam name="T"></typeparam>
217 /// <param name="iface"></param>
218 public void RegisterInterface<T>(T iface)
219 {
220 lock (m_gridInterfaces)
221 {
222 m_gridInterfaces.Add(typeof(T), iface);
223 }
224 }
225
226 public bool TryGet<T>(out T iface)
227 {
228 if (m_gridInterfaces.ContainsKey(typeof(T)))
229 {
230 iface = (T)m_gridInterfaces[typeof(T)];
231 return true;
232 }
233 iface = default(T);
234 return false;
235 }
236
237 public T Get<T>()
238 {
239 return (T)m_gridInterfaces[typeof(T)];
240 }
241
242 public BaseHttpServer GetHttpServer()
243 {
244 return m_httpServer;
245 }
246 #endregion
208 } 247 }
209} 248}