aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Grid/GridServer/Main.cs
diff options
context:
space:
mode:
authorSean Dague2007-07-16 15:40:11 +0000
committerSean Dague2007-07-16 15:40:11 +0000
commit2a3c79df83e800d5dfe75a1a3b140ed81da2b1d6 (patch)
treee3f80ad51736cf17e856547b1bcf956010927434 /OpenSim/Grid/GridServer/Main.cs
parent*Trunk compiles now (diff)
downloadopensim-SC_OLD-2a3c79df83e800d5dfe75a1a3b140ed81da2b1d6.zip
opensim-SC_OLD-2a3c79df83e800d5dfe75a1a3b140ed81da2b1d6.tar.gz
opensim-SC_OLD-2a3c79df83e800d5dfe75a1a3b140ed81da2b1d6.tar.bz2
opensim-SC_OLD-2a3c79df83e800d5dfe75a1a3b140ed81da2b1d6.tar.xz
changed to native line ending encoding
Diffstat (limited to 'OpenSim/Grid/GridServer/Main.cs')
-rw-r--r--OpenSim/Grid/GridServer/Main.cs516
1 files changed, 258 insertions, 258 deletions
diff --git a/OpenSim/Grid/GridServer/Main.cs b/OpenSim/Grid/GridServer/Main.cs
index dc5e4fa..09aeab5 100644
--- a/OpenSim/Grid/GridServer/Main.cs
+++ b/OpenSim/Grid/GridServer/Main.cs
@@ -1,258 +1,258 @@
1/* 1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/ 2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders. 3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4* 4*
5* Redistribution and use in source and binary forms, with or without 5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met: 6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright 7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer. 8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright 9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the 10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution. 11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the 12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products 13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission. 14* derived from this software without specific prior written permission.
15* 15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY 16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
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*/
28 28
29using System; 29using System;
30using System.Reflection; 30using System.Reflection;
31using System.Threading; 31using System.Threading;
32using System.Timers; 32using System.Timers;
33using OpenSim.Framework.Console; 33using OpenSim.Framework.Console;
34using OpenSim.Framework.Interfaces; 34using OpenSim.Framework.Interfaces;
35using OpenSim.Framework.Servers; 35using OpenSim.Framework.Servers;
36using OpenSim.GenericConfig; 36using OpenSim.GenericConfig;
37using Timer=System.Timers.Timer; 37using Timer=System.Timers.Timer;
38 38
39namespace OpenSim.Grid.GridServer 39namespace OpenSim.Grid.GridServer
40{ 40{
41 /// <summary> 41 /// <summary>
42 /// </summary> 42 /// </summary>
43 public class OpenGrid_Main : conscmd_callback 43 public class OpenGrid_Main : conscmd_callback
44 { 44 {
45 private string ConfigDll = "OpenSim.Grid.GridServer.Config.dll"; 45 private string ConfigDll = "OpenSim.Grid.GridServer.Config.dll";
46 private string GridDll = "OpenSim.Framework.Data.MySQL.dll"; 46 private string GridDll = "OpenSim.Framework.Data.MySQL.dll";
47 public GridConfig Cfg; 47 public GridConfig Cfg;
48 48
49 public static OpenGrid_Main thegrid; 49 public static OpenGrid_Main thegrid;
50 protected IGenericConfig localXMLConfig; 50 protected IGenericConfig localXMLConfig;
51 51
52 public static bool setuponly; 52 public static bool setuponly;
53 53
54 //public LLUUID highestUUID; 54 //public LLUUID highestUUID;
55 55
56 // private SimProfileManager m_simProfileManager; 56 // private SimProfileManager m_simProfileManager;
57 57
58 private GridManager m_gridManager; 58 private GridManager m_gridManager;
59 59
60 private LogBase m_console; 60 private LogBase m_console;
61 61
62 [STAThread] 62 [STAThread]
63 public static void Main(string[] args) 63 public static void Main(string[] args)
64 { 64 {
65 if (args.Length > 0) 65 if (args.Length > 0)
66 { 66 {
67 if (args[0] == "-setuponly") setuponly = true; 67 if (args[0] == "-setuponly") setuponly = true;
68 } 68 }
69 Console.WriteLine("Starting...\n"); 69 Console.WriteLine("Starting...\n");
70 70
71 thegrid = new OpenGrid_Main(); 71 thegrid = new OpenGrid_Main();
72 thegrid.Startup(); 72 thegrid.Startup();
73 73
74 thegrid.Work(); 74 thegrid.Work();
75 } 75 }
76 76
77 private void Work() 77 private void Work()
78 { 78 {
79 m_console.Notice("Enter help for a list of commands\n"); 79 m_console.Notice("Enter help for a list of commands\n");
80 80
81 while (true) 81 while (true)
82 { 82 {
83 m_console.MainLogPrompt(); 83 m_console.MainLogPrompt();
84 } 84 }
85 } 85 }
86 86
87 private OpenGrid_Main() 87 private OpenGrid_Main()
88 { 88 {
89 m_console = new LogBase("opengrid-gridserver-console.log", "OpenGrid", this, false); 89 m_console = new LogBase("opengrid-gridserver-console.log", "OpenGrid", this, false);
90 MainLog.Instance = m_console; 90 MainLog.Instance = m_console;
91 91
92 92
93 } 93 }
94 94
95 public void managercallback(string cmd) 95 public void managercallback(string cmd)
96 { 96 {
97 switch (cmd) 97 switch (cmd)
98 { 98 {
99 case "shutdown": 99 case "shutdown":
100 RunCmd("shutdown", new string[0]); 100 RunCmd("shutdown", new string[0]);
101 break; 101 break;
102 } 102 }
103 } 103 }
104 104
105 105
106 public void Startup() 106 public void Startup()
107 { 107 {
108 this.localXMLConfig = new XmlConfig("GridServerConfig.xml"); 108 this.localXMLConfig = new XmlConfig("GridServerConfig.xml");
109 this.localXMLConfig.LoadData(); 109 this.localXMLConfig.LoadData();
110 this.ConfigDB(this.localXMLConfig); 110 this.ConfigDB(this.localXMLConfig);
111 this.localXMLConfig.Close(); 111 this.localXMLConfig.Close();
112 112
113 m_console.Verbose( "Main.cs:Startup() - Loading configuration"); 113 m_console.Verbose( "Main.cs:Startup() - Loading configuration");
114 Cfg = this.LoadConfigDll(this.ConfigDll); 114 Cfg = this.LoadConfigDll(this.ConfigDll);
115 Cfg.InitConfig(); 115 Cfg.InitConfig();
116 if (setuponly) Environment.Exit(0); 116 if (setuponly) Environment.Exit(0);
117 117
118 m_console.Verbose( "Main.cs:Startup() - Connecting to Storage Server"); 118 m_console.Verbose( "Main.cs:Startup() - Connecting to Storage Server");
119 m_gridManager = new GridManager(); 119 m_gridManager = new GridManager();
120 m_gridManager.AddPlugin(GridDll); // Made of win 120 m_gridManager.AddPlugin(GridDll); // Made of win
121 m_gridManager.config = Cfg; 121 m_gridManager.config = Cfg;
122 122
123 m_console.Verbose( "Main.cs:Startup() - Starting HTTP process"); 123 m_console.Verbose( "Main.cs:Startup() - Starting HTTP process");
124 BaseHttpServer httpServer = new BaseHttpServer(8001); 124 BaseHttpServer httpServer = new BaseHttpServer(8001);
125 //GridManagementAgent GridManagerAgent = new GridManagementAgent(httpServer, "gridserver", Cfg.SimSendKey, Cfg.SimRecvKey, managercallback); 125 //GridManagementAgent GridManagerAgent = new GridManagementAgent(httpServer, "gridserver", Cfg.SimSendKey, Cfg.SimRecvKey, managercallback);
126 126
127 httpServer.AddXmlRPCHandler("simulator_login", m_gridManager.XmlRpcSimulatorLoginMethod); 127 httpServer.AddXmlRPCHandler("simulator_login", m_gridManager.XmlRpcSimulatorLoginMethod);
128 httpServer.AddXmlRPCHandler("simulator_data_request", m_gridManager.XmlRpcSimulatorDataRequestMethod); 128 httpServer.AddXmlRPCHandler("simulator_data_request", m_gridManager.XmlRpcSimulatorDataRequestMethod);
129 httpServer.AddXmlRPCHandler("map_block", m_gridManager.XmlRpcMapBlockMethod); 129 httpServer.AddXmlRPCHandler("map_block", m_gridManager.XmlRpcMapBlockMethod);
130 130
131 httpServer.AddStreamHandler(new RestStreamHandler("GET", "/sims/", m_gridManager.RestGetSimMethod )); 131 httpServer.AddStreamHandler(new RestStreamHandler("GET", "/sims/", m_gridManager.RestGetSimMethod ));
132 httpServer.AddStreamHandler(new RestStreamHandler("POST", "/sims/", m_gridManager.RestSetSimMethod )); 132 httpServer.AddStreamHandler(new RestStreamHandler("POST", "/sims/", m_gridManager.RestSetSimMethod ));
133 133
134 httpServer.AddStreamHandler( new RestStreamHandler("GET", "/regions/", m_gridManager.RestGetRegionMethod )); 134 httpServer.AddStreamHandler( new RestStreamHandler("GET", "/regions/", m_gridManager.RestGetRegionMethod ));
135 httpServer.AddStreamHandler( new RestStreamHandler("POST","/regions/", m_gridManager.RestSetRegionMethod )); 135 httpServer.AddStreamHandler( new RestStreamHandler("POST","/regions/", m_gridManager.RestSetRegionMethod ));
136 136
137 //httpServer.AddRestHandler("GET", "/sims/", m_gridManager.RestGetSimMethod); 137 //httpServer.AddRestHandler("GET", "/sims/", m_gridManager.RestGetSimMethod);
138 //httpServer.AddRestHandler("POST", "/sims/", m_gridManager.RestSetSimMethod); 138 //httpServer.AddRestHandler("POST", "/sims/", m_gridManager.RestSetSimMethod);
139 //httpServer.AddRestHandler("GET", "/regions/", m_gridManager.RestGetRegionMethod); 139 //httpServer.AddRestHandler("GET", "/regions/", m_gridManager.RestGetRegionMethod);
140 //httpServer.AddRestHandler("POST", "/regions/", m_gridManager.RestSetRegionMethod); 140 //httpServer.AddRestHandler("POST", "/regions/", m_gridManager.RestSetRegionMethod);
141 141
142 httpServer.Start(); 142 httpServer.Start();
143 143
144 m_console.Verbose( "Main.cs:Startup() - Starting sim status checker"); 144 m_console.Verbose( "Main.cs:Startup() - Starting sim status checker");
145 145
146 Timer simCheckTimer = new Timer(3600000 * 3); // 3 Hours between updates. 146 Timer simCheckTimer = new Timer(3600000 * 3); // 3 Hours between updates.
147 simCheckTimer.Elapsed += new ElapsedEventHandler(CheckSims); 147 simCheckTimer.Elapsed += new ElapsedEventHandler(CheckSims);
148 simCheckTimer.Enabled = true; 148 simCheckTimer.Enabled = true;
149 } 149 }
150 150
151 private GridConfig LoadConfigDll(string dllName) 151 private GridConfig LoadConfigDll(string dllName)
152 { 152 {
153 Assembly pluginAssembly = Assembly.LoadFrom(dllName); 153 Assembly pluginAssembly = Assembly.LoadFrom(dllName);
154 GridConfig config = null; 154 GridConfig config = null;
155 155
156 foreach (Type pluginType in pluginAssembly.GetTypes()) 156 foreach (Type pluginType in pluginAssembly.GetTypes())
157 { 157 {
158 if (pluginType.IsPublic) 158 if (pluginType.IsPublic)
159 { 159 {
160 if (!pluginType.IsAbstract) 160 if (!pluginType.IsAbstract)
161 { 161 {
162 Type typeInterface = pluginType.GetInterface("IGridConfig", true); 162 Type typeInterface = pluginType.GetInterface("IGridConfig", true);
163 163
164 if (typeInterface != null) 164 if (typeInterface != null)
165 { 165 {
166 IGridConfig plug = (IGridConfig)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); 166 IGridConfig plug = (IGridConfig)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
167 config = plug.GetConfigObject(); 167 config = plug.GetConfigObject();
168 break; 168 break;
169 } 169 }
170 170
171 typeInterface = null; 171 typeInterface = null;
172 } 172 }
173 } 173 }
174 } 174 }
175 pluginAssembly = null; 175 pluginAssembly = null;
176 return config; 176 return config;
177 } 177 }
178 178
179 public void CheckSims(object sender, ElapsedEventArgs e) 179 public void CheckSims(object sender, ElapsedEventArgs e)
180 { 180 {
181 /* 181 /*
182 foreach (SimProfileBase sim in m_simProfileManager.SimProfiles.Values) 182 foreach (SimProfileBase sim in m_simProfileManager.SimProfiles.Values)
183 { 183 {
184 string SimResponse = ""; 184 string SimResponse = "";
185 try 185 try
186 { 186 {
187 WebRequest CheckSim = WebRequest.Create("http://" + sim.sim_ip + ":" + sim.sim_port.ToString() + "/checkstatus/"); 187 WebRequest CheckSim = WebRequest.Create("http://" + sim.sim_ip + ":" + sim.sim_port.ToString() + "/checkstatus/");
188 CheckSim.Method = "GET"; 188 CheckSim.Method = "GET";
189 CheckSim.ContentType = "text/plaintext"; 189 CheckSim.ContentType = "text/plaintext";
190 CheckSim.ContentLength = 0; 190 CheckSim.ContentLength = 0;
191 191
192 StreamWriter stOut = new StreamWriter(CheckSim.GetRequestStream(), System.Text.Encoding.ASCII); 192 StreamWriter stOut = new StreamWriter(CheckSim.GetRequestStream(), System.Text.Encoding.ASCII);
193 stOut.Write(""); 193 stOut.Write("");
194 stOut.Close(); 194 stOut.Close();
195 195
196 StreamReader stIn = new StreamReader(CheckSim.GetResponse().GetResponseStream()); 196 StreamReader stIn = new StreamReader(CheckSim.GetResponse().GetResponseStream());
197 SimResponse = stIn.ReadToEnd(); 197 SimResponse = stIn.ReadToEnd();
198 stIn.Close(); 198 stIn.Close();
199 } 199 }
200 catch 200 catch
201 { 201 {
202 } 202 }
203 203
204 if (SimResponse == "OK") 204 if (SimResponse == "OK")
205 { 205 {
206 m_simProfileManager.SimProfiles[sim.UUID].online = true; 206 m_simProfileManager.SimProfiles[sim.UUID].online = true;
207 } 207 }
208 else 208 else
209 { 209 {
210 m_simProfileManager.SimProfiles[sim.UUID].online = false; 210 m_simProfileManager.SimProfiles[sim.UUID].online = false;
211 } 211 }
212 } 212 }
213 */ 213 */
214 } 214 }
215 215
216 public void RunCmd(string cmd, string[] cmdparams) 216 public void RunCmd(string cmd, string[] cmdparams)
217 { 217 {
218 switch (cmd) 218 switch (cmd)
219 { 219 {
220 case "help": 220 case "help":
221 m_console.Notice("shutdown - shutdown the grid (USE CAUTION!)"); 221 m_console.Notice("shutdown - shutdown the grid (USE CAUTION!)");
222 break; 222 break;
223 223
224 case "shutdown": 224 case "shutdown":
225 m_console.Close(); 225 m_console.Close();
226 Environment.Exit(0); 226 Environment.Exit(0);
227 break; 227 break;
228 } 228 }
229 } 229 }
230 230
231 public void Show(string ShowWhat) 231 public void Show(string ShowWhat)
232 { 232 {
233 } 233 }
234 234
235 private void ConfigDB(IGenericConfig configData) 235 private void ConfigDB(IGenericConfig configData)
236 { 236 {
237 try 237 try
238 { 238 {
239 string attri = ""; 239 string attri = "";
240 attri = configData.GetAttribute("DataBaseProvider"); 240 attri = configData.GetAttribute("DataBaseProvider");
241 if (attri == "") 241 if (attri == "")
242 { 242 {
243 GridDll = "OpenSim.Framework.Data.DB4o.dll"; 243 GridDll = "OpenSim.Framework.Data.DB4o.dll";
244 configData.SetAttribute("DataBaseProvider", "OpenSim.Framework.Data.DB4o.dll"); 244 configData.SetAttribute("DataBaseProvider", "OpenSim.Framework.Data.DB4o.dll");
245 } 245 }
246 else 246 else
247 { 247 {
248 GridDll = attri; 248 GridDll = attri;
249 } 249 }
250 configData.Commit(); 250 configData.Commit();
251 } 251 }
252 catch 252 catch
253 { 253 {
254 254
255 } 255 }
256 } 256 }
257 } 257 }
258} 258}