aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Application
diff options
context:
space:
mode:
authorDavid Walter Seikel2016-11-03 21:44:39 +1000
committerDavid Walter Seikel2016-11-03 21:44:39 +1000
commit134f86e8d5c414409631b25b8c6f0ee45fbd8631 (patch)
tree216b89d3fb89acfb81be1e440c25c41ab09fa96d /OpenSim/Region/Application
parentMore changing to production grid. Double oops. (diff)
downloadopensim-SC_OLD-134f86e8d5c414409631b25b8c6f0ee45fbd8631.zip
opensim-SC_OLD-134f86e8d5c414409631b25b8c6f0ee45fbd8631.tar.gz
opensim-SC_OLD-134f86e8d5c414409631b25b8c6f0ee45fbd8631.tar.bz2
opensim-SC_OLD-134f86e8d5c414409631b25b8c6f0ee45fbd8631.tar.xz
Initial update to OpenSim 0.8.2.1 source code.
Diffstat (limited to 'OpenSim/Region/Application')
-rw-r--r--OpenSim/Region/Application/Application.cs67
-rw-r--r--OpenSim/Region/Application/ConfigurationLoader.cs98
-rw-r--r--OpenSim/Region/Application/IApplicationPlugin.cs2
-rw-r--r--OpenSim/Region/Application/OpenSim.cs641
-rw-r--r--OpenSim/Region/Application/OpenSimBackground.cs2
-rw-r--r--OpenSim/Region/Application/OpenSimBase.cs305
-rw-r--r--OpenSim/Region/Application/Properties/AssemblyInfo.cs36
-rw-r--r--OpenSim/Region/Application/RegionApplicationBase.cs103
8 files changed, 868 insertions, 386 deletions
diff --git a/OpenSim/Region/Application/Application.cs b/OpenSim/Region/Application/Application.cs
index 0f90d37..bf34419 100644
--- a/OpenSim/Region/Application/Application.cs
+++ b/OpenSim/Region/Application/Application.cs
@@ -102,34 +102,81 @@ namespace OpenSim
102 m_log.InfoFormat( 102 m_log.InfoFormat(
103 "[OPENSIM MAIN]: Environment variable MONO_THREADS_PER_CPU is {0}", monoThreadsPerCpu ?? "unset"); 103 "[OPENSIM MAIN]: Environment variable MONO_THREADS_PER_CPU is {0}", monoThreadsPerCpu ?? "unset");
104 104
105 // Increase the number of IOCP threads available. Mono defaults to a tragically low number 105 // Verify the Threadpool allocates or uses enough worker and IO completion threads
106 // .NET 2.0, workerthreads default to 50 * numcores
107 // .NET 3.0, workerthreads defaults to 250 * numcores
108 // .NET 4.0, workerthreads are dynamic based on bitness and OS resources
109 // Max IO Completion threads are 1000 on all 3 CLRs
110 //
111 // Mono 2.10.9 to at least Mono 3.1, workerthreads default to 100 * numcores, iocp threads to 4 * numcores
112 int workerThreadsMin = 500;
113 int workerThreadsMax = 1000; // may need further adjustment to match other CLR
114 int iocpThreadsMin = 1000;
115 int iocpThreadsMax = 2000; // may need further adjustment to match other CLR
116
117 {
118 int currentMinWorkerThreads, currentMinIocpThreads;
119 System.Threading.ThreadPool.GetMinThreads(out currentMinWorkerThreads, out currentMinIocpThreads);
120 m_log.InfoFormat(
121 "[OPENSIM MAIN]: Runtime gave us {0} min worker threads and {1} min IOCP threads",
122 currentMinWorkerThreads, currentMinIocpThreads);
123 }
124
106 int workerThreads, iocpThreads; 125 int workerThreads, iocpThreads;
107 System.Threading.ThreadPool.GetMaxThreads(out workerThreads, out iocpThreads); 126 System.Threading.ThreadPool.GetMaxThreads(out workerThreads, out iocpThreads);
108 m_log.InfoFormat("[OPENSIM MAIN]: Runtime gave us {0} worker threads and {1} IOCP threads", workerThreads, iocpThreads); 127 m_log.InfoFormat("[OPENSIM MAIN]: Runtime gave us {0} max worker threads and {1} max IOCP threads", workerThreads, iocpThreads);
109 if (workerThreads < 500 || iocpThreads < 1000) 128
129 if (workerThreads < workerThreadsMin)
130 {
131 workerThreads = workerThreadsMin;
132 m_log.InfoFormat("[OPENSIM MAIN]: Bumping up max worker threads to {0}",workerThreads);
133 }
134 if (workerThreads > workerThreadsMax)
110 { 135 {
111 workerThreads = 500; 136 workerThreads = workerThreadsMax;
112 iocpThreads = 1000; 137 m_log.InfoFormat("[OPENSIM MAIN]: Limiting max worker threads to {0}",workerThreads);
113 m_log.Info("[OPENSIM MAIN]: Bumping up to 500 worker threads and 1000 IOCP threads");
114 System.Threading.ThreadPool.SetMaxThreads(workerThreads, iocpThreads);
115 } 138 }
116 139
140 // Increase the number of IOCP threads available.
141 // Mono defaults to a tragically low number (24 on 6-core / 8GB Fedora 17)
142 if (iocpThreads < iocpThreadsMin)
143 {
144 iocpThreads = iocpThreadsMin;
145 m_log.InfoFormat("[OPENSIM MAIN]: Bumping up max IOCP threads to {0}",iocpThreads);
146 }
147 // Make sure we don't overallocate IOCP threads and thrash system resources
148 if ( iocpThreads > iocpThreadsMax )
149 {
150 iocpThreads = iocpThreadsMax;
151 m_log.InfoFormat("[OPENSIM MAIN]: Limiting max IOCP completion threads to {0}",iocpThreads);
152 }
153 // set the resulting worker and IO completion thread counts back to ThreadPool
154 if ( System.Threading.ThreadPool.SetMaxThreads(workerThreads, iocpThreads) )
155 {
156 m_log.InfoFormat(
157 "[OPENSIM MAIN]: Threadpool set to {0} max worker threads and {1} max IOCP threads",
158 workerThreads, iocpThreads);
159 }
160 else
161 {
162 m_log.Warn("[OPENSIM MAIN]: Threadpool reconfiguration failed, runtime defaults still in effect.");
163 }
164
117 // Check if the system is compatible with OpenSimulator. 165 // Check if the system is compatible with OpenSimulator.
118 // Ensures that the minimum system requirements are met 166 // Ensures that the minimum system requirements are met
119 string supported = String.Empty; 167 string supported = String.Empty;
120 if (Util.IsEnvironmentSupported(ref supported)) 168 if (Util.IsEnvironmentSupported(ref supported))
121 { 169 {
122 m_log.Info("Environment is compatible.\n"); 170 m_log.Info("[OPENSIM MAIN]: Environment is supported by OpenSimulator.");
123 } 171 }
124 else 172 else
125 { 173 {
126 m_log.Warn("Environment is unsupported (" + supported + ")\n"); 174 m_log.Warn("[OPENSIM MAIN]: Environment is not supported by OpenSimulator (" + supported + ")\n");
127 } 175 }
128 176
129 // Configure nIni aliases and localles 177 // Configure nIni aliases and localles
130 Culture.SetCurrentCulture(); 178 Culture.SetCurrentCulture();
131 179
132
133 // Validate that the user has the most basic configuration done 180 // Validate that the user has the most basic configuration done
134 // If not, offer to do the most basic configuration for them warning them along the way of the importance of 181 // If not, offer to do the most basic configuration for them warning them along the way of the importance of
135 // reading these files. 182 // reading these files.
diff --git a/OpenSim/Region/Application/ConfigurationLoader.cs b/OpenSim/Region/Application/ConfigurationLoader.cs
index fc3999f..b19e549 100644
--- a/OpenSim/Region/Application/ConfigurationLoader.cs
+++ b/OpenSim/Region/Application/ConfigurationLoader.cs
@@ -82,8 +82,7 @@ namespace OpenSim
82 82
83 List<string> sources = new List<string>(); 83 List<string> sources = new List<string>();
84 84
85 string masterFileName = 85 string masterFileName = startupConfig.GetString("inimaster", "OpenSimDefaults.ini");
86 startupConfig.GetString("inimaster", "OpenSimDefaults.ini");
87 86
88 if (masterFileName == "none") 87 if (masterFileName == "none")
89 masterFileName = String.Empty; 88 masterFileName = String.Empty;
@@ -124,7 +123,7 @@ namespace OpenSim
124 else 123 else
125 { 124 {
126 Application.iniFilePath = Path.GetFullPath( 125 Application.iniFilePath = Path.GetFullPath(
127 Path.Combine(Util.configDir(), iniFileName)); 126 Path.Combine(Util.configDir(), iniFileName));
128 127
129 if (!File.Exists(Application.iniFilePath)) 128 if (!File.Exists(Application.iniFilePath))
130 { 129 {
@@ -139,12 +138,29 @@ namespace OpenSim
139 } 138 }
140 } 139 }
141 140
141 m_config = new OpenSimConfigSource();
142 m_config.Source = new IniConfigSource();
143 m_config.Source.Merge(DefaultConfig());
144
145 m_log.Info("[CONFIG]: Reading configuration settings");
146
147 for (int i = 0 ; i < sources.Count ; i++)
148 {
149 if (ReadConfig(m_config, sources[i]))
150 {
151 iniFileExists = true;
152 AddIncludes(m_config, sources);
153 }
154 }
155
156 // Override distro settings with contents of inidirectory
142 string iniDirName = startupConfig.GetString("inidirectory", "config"); 157 string iniDirName = startupConfig.GetString("inidirectory", "config");
143 string iniDirPath = Path.Combine(Util.configDir(), iniDirName); 158 string iniDirPath = Path.Combine(Util.configDir(), iniDirName);
144 159
145 if (Directory.Exists(iniDirPath)) 160 if (Directory.Exists(iniDirPath))
146 { 161 {
147 m_log.InfoFormat("Searching folder {0} for config ini files", iniDirPath); 162 m_log.InfoFormat("[CONFIG]: Searching folder {0} for config ini files", iniDirPath);
163 List<string> overrideSources = new List<string>();
148 164
149 string[] fileEntries = Directory.GetFiles(iniDirName); 165 string[] fileEntries = Directory.GetFiles(iniDirName);
150 foreach (string filePath in fileEntries) 166 foreach (string filePath in fileEntries)
@@ -152,58 +168,52 @@ namespace OpenSim
152 if (Path.GetExtension(filePath).ToLower() == ".ini") 168 if (Path.GetExtension(filePath).ToLower() == ".ini")
153 { 169 {
154 if (!sources.Contains(Path.GetFullPath(filePath))) 170 if (!sources.Contains(Path.GetFullPath(filePath)))
171 {
172 overrideSources.Add(Path.GetFullPath(filePath));
173 // put it in sources too, to avoid circularity
155 sources.Add(Path.GetFullPath(filePath)); 174 sources.Add(Path.GetFullPath(filePath));
175 }
156 } 176 }
157 } 177 }
158 }
159 178
160 m_config = new OpenSimConfigSource();
161 m_config.Source = new IniConfigSource();
162 m_config.Source.Merge(DefaultConfig());
163 179
164 m_log.Info("[CONFIG]: Reading configuration settings"); 180 if (overrideSources.Count > 0)
181 {
182 OpenSimConfigSource overrideConfig = new OpenSimConfigSource();
183 overrideConfig.Source = new IniConfigSource();
184
185 for (int i = 0 ; i < overrideSources.Count ; i++)
186 {
187 if (ReadConfig(overrideConfig, overrideSources[i]))
188 {
189 iniFileExists = true;
190 AddIncludes(overrideConfig, overrideSources);
191 }
192 }
193 m_config.Source.Merge(overrideConfig.Source);
194 }
195 }
165 196
166 if (sources.Count == 0) 197 if (sources.Count == 0)
167 { 198 {
168 m_log.FatalFormat("[CONFIG]: Could not load any configuration"); 199 m_log.FatalFormat("[CONFIG]: Could not load any configuration");
169 Environment.Exit(1); 200 Environment.Exit(1);
170 } 201 }
171 202 else if (!iniFileExists)
172 for (int i = 0 ; i < sources.Count ; i++)
173 {
174 if (ReadConfig(sources[i]))
175 {
176 iniFileExists = true;
177 AddIncludes(sources);
178 }
179 }
180
181 if (!iniFileExists)
182 { 203 {
183 m_log.FatalFormat("[CONFIG]: Could not load any configuration"); 204 m_log.FatalFormat("[CONFIG]: Could not load any configuration");
184 m_log.FatalFormat("[CONFIG]: Configuration exists, but there was an error loading it!"); 205 m_log.FatalFormat("[CONFIG]: Configuration exists, but there was an error loading it!");
185 Environment.Exit(1); 206 Environment.Exit(1);
186 } 207 }
187 208
209 // Merge OpSys env vars
210 m_log.Info("[CONFIG]: Loading environment variables for Config");
211 Util.MergeEnvironmentToConfig(m_config.Source);
212
188 // Make sure command line options take precedence 213 // Make sure command line options take precedence
189 m_config.Source.Merge(argvSource); 214 m_config.Source.Merge(argvSource);
190 215
191 IConfig enVars = m_config.Source.Configs["Environment"]; 216 m_config.Source.ReplaceKeyValues();
192
193 if( enVars != null )
194 {
195 string[] env_keys = enVars.GetKeys();
196
197 foreach ( string key in env_keys )
198 {
199 envConfigSource.AddEnv(key, string.Empty);
200 }
201
202 envConfigSource.LoadEnv();
203 m_config.Source.Merge(envConfigSource);
204 m_config.Source.ExpandKeyValues();
205 }
206
207 217
208 ReadConfigSettings(); 218 ReadConfigSettings();
209 219
@@ -214,10 +224,10 @@ namespace OpenSim
214 /// Adds the included files as ini configuration files 224 /// Adds the included files as ini configuration files
215 /// </summary> 225 /// </summary>
216 /// <param name="sources">List of URL strings or filename strings</param> 226 /// <param name="sources">List of URL strings or filename strings</param>
217 private void AddIncludes(List<string> sources) 227 private void AddIncludes(OpenSimConfigSource configSource, List<string> sources)
218 { 228 {
219 //loop over config sources 229 //loop over config sources
220 foreach (IConfig config in m_config.Source.Configs) 230 foreach (IConfig config in configSource.Source.Configs)
221 { 231 {
222 // Look for Include-* in the key name 232 // Look for Include-* in the key name
223 string[] keys = config.GetKeys(); 233 string[] keys = config.GetKeys();
@@ -284,7 +294,7 @@ namespace OpenSim
284 /// </summary> 294 /// </summary>
285 /// <param name="iniPath">Full path to the ini</param> 295 /// <param name="iniPath">Full path to the ini</param>
286 /// <returns></returns> 296 /// <returns></returns>
287 private bool ReadConfig(string iniPath) 297 private bool ReadConfig(OpenSimConfigSource configSource, string iniPath)
288 { 298 {
289 bool success = false; 299 bool success = false;
290 300
@@ -292,7 +302,7 @@ namespace OpenSim
292 { 302 {
293 m_log.InfoFormat("[CONFIG]: Reading configuration file {0}", Path.GetFullPath(iniPath)); 303 m_log.InfoFormat("[CONFIG]: Reading configuration file {0}", Path.GetFullPath(iniPath));
294 304
295 m_config.Source.Merge(new IniConfigSource(iniPath)); 305 configSource.Source.Merge(new IniConfigSource(iniPath));
296 success = true; 306 success = true;
297 } 307 }
298 else 308 else
@@ -305,7 +315,7 @@ namespace OpenSim
305 { 315 {
306 XmlReader r = XmlReader.Create(iniPath); 316 XmlReader r = XmlReader.Create(iniPath);
307 XmlConfigSource cs = new XmlConfigSource(r); 317 XmlConfigSource cs = new XmlConfigSource(r);
308 m_config.Source.Merge(cs); 318 configSource.Source.Merge(cs);
309 319
310 success = true; 320 success = true;
311 } 321 }
@@ -337,10 +347,7 @@ namespace OpenSim
337 config.Set("physics", "OpenDynamicsEngine"); 347 config.Set("physics", "OpenDynamicsEngine");
338 config.Set("meshing", "Meshmerizer"); 348 config.Set("meshing", "Meshmerizer");
339 config.Set("physical_prim", true); 349 config.Set("physical_prim", true);
340 config.Set("see_into_this_sim_from_neighbor", true);
341 config.Set("serverside_object_permissions", true); 350 config.Set("serverside_object_permissions", true);
342 config.Set("storage_plugin", "OpenSim.Data.SQLite.dll");
343 config.Set("storage_connection_string", "URI=file:OpenSim.db,version=3");
344 config.Set("storage_prim_inventories", true); 351 config.Set("storage_prim_inventories", true);
345 config.Set("startup_console_commands_file", String.Empty); 352 config.Set("startup_console_commands_file", String.Empty);
346 config.Set("shutdown_console_commands_file", String.Empty); 353 config.Set("shutdown_console_commands_file", String.Empty);
@@ -372,7 +379,6 @@ namespace OpenSim
372 { 379 {
373 m_configSettings.PhysicsEngine = startupConfig.GetString("physics"); 380 m_configSettings.PhysicsEngine = startupConfig.GetString("physics");
374 m_configSettings.MeshEngineName = startupConfig.GetString("meshing"); 381 m_configSettings.MeshEngineName = startupConfig.GetString("meshing");
375 m_configSettings.StorageDll = startupConfig.GetString("storage_plugin");
376 382
377 m_configSettings.ClientstackDll 383 m_configSettings.ClientstackDll
378 = startupConfig.GetString("clientstack_plugin", "OpenSim.Region.ClientStack.LindenUDP.dll"); 384 = startupConfig.GetString("clientstack_plugin", "OpenSim.Region.ClientStack.LindenUDP.dll");
diff --git a/OpenSim/Region/Application/IApplicationPlugin.cs b/OpenSim/Region/Application/IApplicationPlugin.cs
index 6e6d48c..a3fa66c 100644
--- a/OpenSim/Region/Application/IApplicationPlugin.cs
+++ b/OpenSim/Region/Application/IApplicationPlugin.cs
@@ -26,12 +26,14 @@
26 */ 26 */
27 27
28using OpenSim.Framework; 28using OpenSim.Framework;
29using Mono.Addins;
29 30
30namespace OpenSim 31namespace OpenSim
31{ 32{
32 /// <summary> 33 /// <summary>
33 /// OpenSimulator Application Plugin framework interface 34 /// OpenSimulator Application Plugin framework interface
34 /// </summary> 35 /// </summary>
36 [TypeExtensionPoint(NodeName="Plugin", NodeType = typeof(PluginExtensionNode), Path="/OpenSim/Startup")]
35 public interface IApplicationPlugin : IPlugin 37 public interface IApplicationPlugin : IPlugin
36 { 38 {
37 /// <summary> 39 /// <summary>
diff --git a/OpenSim/Region/Application/OpenSim.cs b/OpenSim/Region/Application/OpenSim.cs
index c4731a3..5af8194 100644
--- a/OpenSim/Region/Application/OpenSim.cs
+++ b/OpenSim/Region/Application/OpenSim.cs
@@ -30,6 +30,7 @@ using System.Collections;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using System.Diagnostics; 31using System.Diagnostics;
32using System.IO; 32using System.IO;
33using System.Linq;
33using System.Reflection; 34using System.Reflection;
34using System.Text; 35using System.Text;
35using System.Text.RegularExpressions; 36using System.Text.RegularExpressions;
@@ -44,6 +45,7 @@ using OpenSim.Framework.Servers;
44using OpenSim.Framework.Monitoring; 45using OpenSim.Framework.Monitoring;
45using OpenSim.Region.Framework.Interfaces; 46using OpenSim.Region.Framework.Interfaces;
46using OpenSim.Region.Framework.Scenes; 47using OpenSim.Region.Framework.Scenes;
48using OpenSim.Services.Interfaces;
47 49
48namespace OpenSim 50namespace OpenSim
49{ 51{
@@ -85,6 +87,7 @@ namespace OpenSim
85 IConfig startupConfig = Config.Configs["Startup"]; 87 IConfig startupConfig = Config.Configs["Startup"];
86 IConfig networkConfig = Config.Configs["Network"]; 88 IConfig networkConfig = Config.Configs["Network"];
87 89
90 int stpMinThreads = 2;
88 int stpMaxThreads = 15; 91 int stpMaxThreads = 15;
89 92
90 if (startupConfig != null) 93 if (startupConfig != null)
@@ -111,12 +114,13 @@ namespace OpenSim
111 if (!String.IsNullOrEmpty(asyncCallMethodStr) && Utils.EnumTryParse<FireAndForgetMethod>(asyncCallMethodStr, out asyncCallMethod)) 114 if (!String.IsNullOrEmpty(asyncCallMethodStr) && Utils.EnumTryParse<FireAndForgetMethod>(asyncCallMethodStr, out asyncCallMethod))
112 Util.FireAndForgetMethod = asyncCallMethod; 115 Util.FireAndForgetMethod = asyncCallMethod;
113 116
114 stpMaxThreads = startupConfig.GetInt("MaxPoolThreads", 15); 117 stpMinThreads = startupConfig.GetInt("MinPoolThreads", 15);
118 stpMaxThreads = startupConfig.GetInt("MaxPoolThreads", 300);
115 m_consolePrompt = startupConfig.GetString("ConsolePrompt", @"Region (\R) "); 119 m_consolePrompt = startupConfig.GetString("ConsolePrompt", @"Region (\R) ");
116 } 120 }
117 121
118 if (Util.FireAndForgetMethod == FireAndForgetMethod.SmartThreadPool) 122 if (Util.FireAndForgetMethod == FireAndForgetMethod.SmartThreadPool)
119 Util.InitThreadPool(stpMaxThreads); 123 Util.InitThreadPool(stpMinThreads, stpMaxThreads);
120 124
121 m_log.Info("[OPENSIM MAIN]: Using async_call_method " + Util.FireAndForgetMethod); 125 m_log.Info("[OPENSIM MAIN]: Using async_call_method " + Util.FireAndForgetMethod);
122 } 126 }
@@ -151,13 +155,14 @@ namespace OpenSim
151 ((RemoteConsole)m_console).ReadConfig(Config); 155 ((RemoteConsole)m_console).ReadConfig(Config);
152 break; 156 break;
153 default: 157 default:
154 m_console = new LocalConsole("Region"); 158 m_console = new LocalConsole("Region", Config.Configs["Startup"]);
155 break; 159 break;
156 } 160 }
157 } 161 }
158 162
159 MainConsole.Instance = m_console; 163 MainConsole.Instance = m_console;
160 164
165 LogEnvironmentInformation();
161 RegisterCommonAppenders(Config.Configs["Startup"]); 166 RegisterCommonAppenders(Config.Configs["Startup"]);
162 RegisterConsoleCommands(); 167 RegisterConsoleCommands();
163 168
@@ -168,6 +173,13 @@ namespace OpenSim
168 if (userStatsURI != String.Empty) 173 if (userStatsURI != String.Empty)
169 MainServer.Instance.AddStreamHandler(new OpenSim.UXSimStatusHandler(this)); 174 MainServer.Instance.AddStreamHandler(new OpenSim.UXSimStatusHandler(this));
170 175
176 if (managedStatsURI != String.Empty)
177 {
178 string urlBase = String.Format("/{0}/", managedStatsURI);
179 MainServer.Instance.AddHTTPHandler(urlBase, StatsManager.HandleStatsRequest);
180 m_log.InfoFormat("[OPENSIM] Enabling remote managed stats fetch. URL = {0}", urlBase);
181 }
182
171 if (m_console is RemoteConsole) 183 if (m_console is RemoteConsole)
172 { 184 {
173 if (m_consolePort == 0) 185 if (m_consolePort == 0)
@@ -224,49 +236,56 @@ namespace OpenSim
224 "Force the update of all objects on clients", 236 "Force the update of all objects on clients",
225 HandleForceUpdate); 237 HandleForceUpdate);
226 238
227 m_console.Commands.AddCommand("Debug", false, "debug packet",
228 "debug packet <level> [<avatar-first-name> <avatar-last-name>]",
229 "Turn on packet debugging",
230 "If level > 255 then all incoming and outgoing packets are logged.\n"
231 + "If level <= 255 then incoming AgentUpdate and outgoing SimStats and SimulatorViewerTimeMessage packets are not logged.\n"
232 + "If level <= 200 then incoming RequestImage and outgoing ImagePacket, ImageData, LayerData and CoarseLocationUpdate packets are not logged.\n"
233 + "If level <= 100 then incoming ViewerEffect and AgentAnimation and outgoing ViewerEffect and AvatarAnimation packets are not logged.\n"
234 + "If level <= 50 then outgoing ImprovedTerseObjectUpdate packets are not logged.\n"
235 + "If level <= 0 then no packets are logged.\n"
236 + "If an avatar name is given then only packets from that avatar are logged",
237 Debug);
238
239 m_console.Commands.AddCommand("General", false, "change region", 239 m_console.Commands.AddCommand("General", false, "change region",
240 "change region <region name>", 240 "change region <region name>",
241 "Change current console region", ChangeSelectedRegion); 241 "Change current console region",
242 ChangeSelectedRegion);
242 243
243 m_console.Commands.AddCommand("Archiving", false, "save xml", 244 m_console.Commands.AddCommand("Archiving", false, "save xml",
244 "save xml", 245 "save xml",
245 "Save a region's data in XML format", SaveXml); 246 "Save a region's data in XML format",
247 SaveXml);
246 248
247 m_console.Commands.AddCommand("Archiving", false, "save xml2", 249 m_console.Commands.AddCommand("Archiving", false, "save xml2",
248 "save xml2", 250 "save xml2",
249 "Save a region's data in XML2 format", SaveXml2); 251 "Save a region's data in XML2 format",
252 SaveXml2);
250 253
251 m_console.Commands.AddCommand("Archiving", false, "load xml", 254 m_console.Commands.AddCommand("Archiving", false, "load xml",
252 "load xml [-newIDs [<x> <y> <z>]]", 255 "load xml [-newIDs [<x> <y> <z>]]",
253 "Load a region's data from XML format", LoadXml); 256 "Load a region's data from XML format",
257 LoadXml);
254 258
255 m_console.Commands.AddCommand("Archiving", false, "load xml2", 259 m_console.Commands.AddCommand("Archiving", false, "load xml2",
256 "load xml2", 260 "load xml2",
257 "Load a region's data from XML2 format", LoadXml2); 261 "Load a region's data from XML2 format",
262 LoadXml2);
258 263
259 m_console.Commands.AddCommand("Archiving", false, "save prims xml2", 264 m_console.Commands.AddCommand("Archiving", false, "save prims xml2",
260 "save prims xml2 [<prim name> <file name>]", 265 "save prims xml2 [<prim name> <file name>]",
261 "Save named prim to XML2", SavePrimsXml2); 266 "Save named prim to XML2",
267 SavePrimsXml2);
262 268
263 m_console.Commands.AddCommand("Archiving", false, "load oar", 269 m_console.Commands.AddCommand("Archiving", false, "load oar",
264 "load oar [--merge] [--skip-assets] [<OAR path>]", 270 "load oar [--merge] [--skip-assets]"
271 + " [--default-user \"User Name\"]"
272 + " [--force-terrain] [--force-parcels]"
273 + " [--no-objects]"
274 + " [--rotation degrees] [--rotation-center \"<x,y,z>\"]"
275 + " [--displacement \"<x,y,z>\"]"
276 + " [<OAR path>]",
265 "Load a region's data from an OAR archive.", 277 "Load a region's data from an OAR archive.",
266 "--merge will merge the OAR with the existing scene." + Environment.NewLine 278 "--merge will merge the OAR with the existing scene (suppresses terrain and parcel info loading).\n"
267 + "--skip-assets will load the OAR but ignore the assets it contains." + Environment.NewLine 279 + "--default-user will use this user for any objects with an owner whose UUID is not found in the grid.\n"
268 + "The path can be either a filesystem location or a URI." 280 + "--displacement will add this value to the position of every object loaded.\n"
269 + " If this is not given then the command looks for an OAR named region.oar in the current directory.", 281 + "--force-terrain forces the loading of terrain from the oar (undoes suppression done by --merge).\n"
282 + "--force-parcels forces the loading of parcels from the oar (undoes suppression done by --merge).\n"
283 + "--no-objects suppresses the addition of any objects (good for loading only the terrain).\n"
284 + "--rotation specified rotation to be applied to the oar. Specified in degrees.\n"
285 + "--rotation-center Location (relative to original OAR) to apply rotation. Default is <128,128,0>.\n"
286 + "--skip-assets will load the OAR but ignore the assets it contains.\n\n"
287 + "The path can be either a filesystem location or a URI.\n"
288 + " If this is not given then the command looks for an OAR named region.oar in the current directory.",
270 LoadOar); 289 LoadOar);
271 290
272 m_console.Commands.AddCommand("Archiving", false, "save oar", 291 m_console.Commands.AddCommand("Archiving", false, "save oar",
@@ -288,7 +307,23 @@ namespace OpenSim
288 307
289 m_console.Commands.AddCommand("Objects", false, "edit scale", 308 m_console.Commands.AddCommand("Objects", false, "edit scale",
290 "edit scale <name> <x> <y> <z>", 309 "edit scale <name> <x> <y> <z>",
291 "Change the scale of a named prim", HandleEditScale); 310 "Change the scale of a named prim",
311 HandleEditScale);
312
313 m_console.Commands.AddCommand("Objects", false, "rotate scene",
314 "rotate scene <degrees> [centerX, centerY]",
315 "Rotates all scene objects around centerX, centerY (defailt 128, 128) (please back up your region before using)",
316 HandleRotateScene);
317
318 m_console.Commands.AddCommand("Objects", false, "scale scene",
319 "scale scene <factor>",
320 "Scales the scene objects (please back up your region before using)",
321 HandleScaleScene);
322
323 m_console.Commands.AddCommand("Objects", false, "translate scene",
324 "translate scene xOffset yOffset zOffset",
325 "translates the scene objects (please back up your region before using)",
326 HandleTranslateScene);
292 327
293 m_console.Commands.AddCommand("Users", false, "kick user", 328 m_console.Commands.AddCommand("Users", false, "kick user",
294 "kick user <first> <last> [--force] [message]", 329 "kick user <first> <last> [--force] [message]",
@@ -306,31 +341,38 @@ namespace OpenSim
306 341
307 m_console.Commands.AddCommand("Comms", false, "show connections", 342 m_console.Commands.AddCommand("Comms", false, "show connections",
308 "show connections", 343 "show connections",
309 "Show connection data", HandleShow); 344 "Show connection data",
345 HandleShow);
310 346
311 m_console.Commands.AddCommand("Comms", false, "show circuits", 347 m_console.Commands.AddCommand("Comms", false, "show circuits",
312 "show circuits", 348 "show circuits",
313 "Show agent circuit data", HandleShow); 349 "Show agent circuit data",
350 HandleShow);
314 351
315 m_console.Commands.AddCommand("Comms", false, "show pending-objects", 352 m_console.Commands.AddCommand("Comms", false, "show pending-objects",
316 "show pending-objects", 353 "show pending-objects",
317 "Show # of objects on the pending queues of all scene viewers", HandleShow); 354 "Show # of objects on the pending queues of all scene viewers",
355 HandleShow);
318 356
319 m_console.Commands.AddCommand("General", false, "show modules", 357 m_console.Commands.AddCommand("General", false, "show modules",
320 "show modules", 358 "show modules",
321 "Show module data", HandleShow); 359 "Show module data",
360 HandleShow);
322 361
323 m_console.Commands.AddCommand("Regions", false, "show regions", 362 m_console.Commands.AddCommand("Regions", false, "show regions",
324 "show regions", 363 "show regions",
325 "Show region data", HandleShow); 364 "Show region data",
365 HandleShow);
326 366
327 m_console.Commands.AddCommand("Regions", false, "show ratings", 367 m_console.Commands.AddCommand("Regions", false, "show ratings",
328 "show ratings", 368 "show ratings",
329 "Show rating data", HandleShow); 369 "Show rating data",
370 HandleShow);
330 371
331 m_console.Commands.AddCommand("Objects", false, "backup", 372 m_console.Commands.AddCommand("Objects", false, "backup",
332 "backup", 373 "backup",
333 "Persist currently unsaved object changes immediately instead of waiting for the normal persistence call.", RunCommand); 374 "Persist currently unsaved object changes immediately instead of waiting for the normal persistence call.",
375 RunCommand);
334 376
335 m_console.Commands.AddCommand("Regions", false, "create region", 377 m_console.Commands.AddCommand("Regions", false, "create region",
336 "create region [\"region name\"] <region_file.ini>", 378 "create region [\"region name\"] <region_file.ini>",
@@ -343,34 +385,47 @@ namespace OpenSim
343 385
344 m_console.Commands.AddCommand("Regions", false, "restart", 386 m_console.Commands.AddCommand("Regions", false, "restart",
345 "restart", 387 "restart",
346 "Restart all sims in this instance", RunCommand); 388 "Restart the currently selected region(s) in this instance",
389 RunCommand);
347 390
348 m_console.Commands.AddCommand("General", false, "command-script", 391 m_console.Commands.AddCommand("General", false, "command-script",
349 "command-script <script>", 392 "command-script <script>",
350 "Run a command script from file", RunCommand); 393 "Run a command script from file",
394 RunCommand);
351 395
352 m_console.Commands.AddCommand("Regions", false, "remove-region", 396 m_console.Commands.AddCommand("Regions", false, "remove-region",
353 "remove-region <name>", 397 "remove-region <name>",
354 "Remove a region from this simulator", RunCommand); 398 "Remove a region from this simulator",
399 RunCommand);
355 400
356 m_console.Commands.AddCommand("Regions", false, "delete-region", 401 m_console.Commands.AddCommand("Regions", false, "delete-region",
357 "delete-region <name>", 402 "delete-region <name>",
358 "Delete a region from disk", RunCommand); 403 "Delete a region from disk",
359 404 RunCommand);
360 m_console.Commands.AddCommand("General", false, "modules list", 405
361 "modules list", 406 m_console.Commands.AddCommand("Estates", false, "estate create",
362 "List modules", HandleModules); 407 "estate create <owner UUID> <estate name>",
363 408 "Creates a new estate with the specified name, owned by the specified user."
364 m_console.Commands.AddCommand("General", false, "modules load", 409 + " Estate name must be unique.",
365 "modules load <name>", 410 CreateEstateCommand);
366 "Load a module", HandleModules); 411
367 412 m_console.Commands.AddCommand("Estates", false, "estate set owner",
368 m_console.Commands.AddCommand("General", false, "modules unload", 413 "estate set owner <estate-id>[ <UUID> | <Firstname> <Lastname> ]",
369 "modules unload <name>", 414 "Sets the owner of the specified estate to the specified UUID or user. ",
370 "Unload a module", HandleModules); 415 SetEstateOwnerCommand);
416
417 m_console.Commands.AddCommand("Estates", false, "estate set name",
418 "estate set name <estate-id> <new name>",
419 "Sets the name of the specified estate to the specified value. New name must be unique.",
420 SetEstateNameCommand);
421
422 m_console.Commands.AddCommand("Estates", false, "estate link region",
423 "estate link region <estate ID> <region ID>",
424 "Attaches the specified region to the specified estate.",
425 EstateLinkRegionCommand);
371 } 426 }
372 427
373 public override void ShutdownSpecific() 428 protected override void ShutdownSpecific()
374 { 429 {
375 if (m_shutdownCommandsFile != String.Empty) 430 if (m_shutdownCommandsFile != String.Empty)
376 { 431 {
@@ -433,8 +488,8 @@ namespace OpenSim
433 { 488 {
434 RegionInfo regionInfo = presence.Scene.RegionInfo; 489 RegionInfo regionInfo = presence.Scene.RegionInfo;
435 490
436 if (presence.Firstname.ToLower().Contains(mainParams[2].ToLower()) && 491 if (presence.Firstname.ToLower().Equals(mainParams[2].ToLower()) &&
437 presence.Lastname.ToLower().Contains(mainParams[3].ToLower())) 492 presence.Lastname.ToLower().Equals(mainParams[3].ToLower()))
438 { 493 {
439 MainConsole.Instance.Output( 494 MainConsole.Instance.Output(
440 String.Format( 495 String.Format(
@@ -447,7 +502,8 @@ namespace OpenSim
447 else 502 else
448 presence.ControllingClient.Kick("\nThe OpenSim manager kicked you out.\n"); 503 presence.ControllingClient.Kick("\nThe OpenSim manager kicked you out.\n");
449 504
450 presence.Scene.IncomingCloseAgent(presence.UUID, force); 505 presence.Scene.CloseAgent(presence.UUID, force);
506 break;
451 } 507 }
452 } 508 }
453 509
@@ -499,6 +555,121 @@ namespace OpenSim
499 } 555 }
500 } 556 }
501 557
558 private void HandleRotateScene(string module, string[] args)
559 {
560 string usage = "Usage: rotate scene <angle in degrees> [centerX centerY] (centerX and centerY are optional and default to Constants.RegionSize / 2";
561
562 float centerX = Constants.RegionSize * 0.5f;
563 float centerY = Constants.RegionSize * 0.5f;
564
565 if (args.Length < 3 || args.Length == 4)
566 {
567 MainConsole.Instance.Output(usage);
568 return;
569 }
570
571 float angle = (float)(Convert.ToSingle(args[2]) / 180.0 * Math.PI);
572 OpenMetaverse.Quaternion rot = OpenMetaverse.Quaternion.CreateFromAxisAngle(0, 0, 1, angle);
573
574 if (args.Length > 4)
575 {
576 centerX = Convert.ToSingle(args[3]);
577 centerY = Convert.ToSingle(args[4]);
578 }
579
580 Vector3 center = new Vector3(centerX, centerY, 0.0f);
581
582 SceneManager.ForEachSelectedScene(delegate(Scene scene)
583 {
584 scene.ForEachSOG(delegate(SceneObjectGroup sog)
585 {
586 if (!sog.IsAttachment)
587 {
588 sog.RootPart.UpdateRotation(rot * sog.GroupRotation);
589 Vector3 offset = sog.AbsolutePosition - center;
590 offset *= rot;
591 sog.UpdateGroupPosition(center + offset);
592 }
593 });
594 });
595 }
596
597 private void HandleScaleScene(string module, string[] args)
598 {
599 string usage = "Usage: scale scene <factor>";
600
601 if (args.Length < 3)
602 {
603 MainConsole.Instance.Output(usage);
604 return;
605 }
606
607 float factor = (float)(Convert.ToSingle(args[2]));
608
609 float minZ = float.MaxValue;
610
611 SceneManager.ForEachSelectedScene(delegate(Scene scene)
612 {
613 scene.ForEachSOG(delegate(SceneObjectGroup sog)
614 {
615 if (!sog.IsAttachment)
616 {
617 if (sog.RootPart.AbsolutePosition.Z < minZ)
618 minZ = sog.RootPart.AbsolutePosition.Z;
619 }
620 });
621 });
622
623 SceneManager.ForEachSelectedScene(delegate(Scene scene)
624 {
625 scene.ForEachSOG(delegate(SceneObjectGroup sog)
626 {
627 if (!sog.IsAttachment)
628 {
629 Vector3 tmpRootPos = sog.RootPart.AbsolutePosition;
630 tmpRootPos.Z -= minZ;
631 tmpRootPos *= factor;
632 tmpRootPos.Z += minZ;
633
634 foreach (SceneObjectPart sop in sog.Parts)
635 {
636 if (sop.ParentID != 0)
637 sop.OffsetPosition *= factor;
638 sop.Scale *= factor;
639 }
640
641 sog.UpdateGroupPosition(tmpRootPos);
642 }
643 });
644 });
645 }
646
647 private void HandleTranslateScene(string module, string[] args)
648 {
649 string usage = "Usage: translate scene <xOffset, yOffset, zOffset>";
650
651 if (args.Length < 5)
652 {
653 MainConsole.Instance.Output(usage);
654 return;
655 }
656
657 float xOFfset = (float)Convert.ToSingle(args[2]);
658 float yOffset = (float)Convert.ToSingle(args[3]);
659 float zOffset = (float)Convert.ToSingle(args[4]);
660
661 Vector3 offset = new Vector3(xOFfset, yOffset, zOffset);
662
663 SceneManager.ForEachSelectedScene(delegate(Scene scene)
664 {
665 scene.ForEachSOG(delegate(SceneObjectGroup sog)
666 {
667 if (!sog.IsAttachment)
668 sog.UpdateGroupPosition(sog.AbsolutePosition + offset);
669 });
670 });
671 }
672
502 /// <summary> 673 /// <summary>
503 /// Creates a new region based on the parameters specified. This will ask the user questions on the console 674 /// Creates a new region based on the parameters specified. This will ask the user questions on the console
504 /// </summary> 675 /// </summary>
@@ -560,35 +731,9 @@ namespace OpenSim
560 CreateRegion(regInfo, true, out scene); 731 CreateRegion(regInfo, true, out scene);
561 732
562 if (changed) 733 if (changed)
563 regInfo.EstateSettings.Save(); 734 m_estateDataService.StoreEstateSettings(regInfo.EstateSettings);
564 } 735
565 736 scene.Start();
566 /// <summary>
567 /// Load, Unload, and list Region modules in use
568 /// </summary>
569 /// <param name="module"></param>
570 /// <param name="cmd"></param>
571 private void HandleModules(string module, string[] cmd)
572 {
573 List<string> args = new List<string>(cmd);
574 args.RemoveAt(0);
575 string[] cmdparams = args.ToArray();
576
577 if (cmdparams.Length > 0)
578 {
579 switch (cmdparams[0].ToLower())
580 {
581 case "list":
582 //TODO: Convert to new region modules
583 break;
584 case "unload":
585 //TODO: Convert to new region modules
586 break;
587 case "load":
588 //TODO: Convert to new region modules
589 break;
590 }
591 }
592 } 737 }
593 738
594 /// <summary> 739 /// <summary>
@@ -699,45 +844,6 @@ namespace OpenSim
699 RefreshPrompt(); 844 RefreshPrompt();
700 } 845 }
701 846
702 /// <summary>
703 /// Turn on some debugging values for OpenSim.
704 /// </summary>
705 /// <param name="args"></param>
706 protected void Debug(string module, string[] args)
707 {
708 if (args.Length == 1)
709 return;
710
711 switch (args[1])
712 {
713 case "packet":
714 string name = null;
715 if (args.Length == 5)
716 name = string.Format("{0} {1}", args[3], args[4]);
717
718 if (args.Length > 2)
719 {
720 int newDebug;
721 if (int.TryParse(args[2], out newDebug))
722 {
723 SceneManager.SetDebugPacketLevelOnCurrentScene(newDebug, name);
724 // We provide user information elsewhere if any clients had their debug level set.
725// MainConsole.Instance.OutputFormat("Debug packet level set to {0}", newDebug);
726 }
727 else
728 {
729 MainConsole.Instance.Output("Usage: debug packet 0..255");
730 }
731 }
732
733 break;
734
735 default:
736 MainConsole.Instance.Output("Unknown debug command");
737 break;
738 }
739 }
740
741 // see BaseOpenSimServer 847 // see BaseOpenSimServer
742 /// <summary> 848 /// <summary>
743 /// Many commands list objects for debugging. Some of the types are listed here 849 /// Many commands list objects for debugging. Some of the types are listed here
@@ -808,33 +914,58 @@ namespace OpenSim
808 break; 914 break;
809 915
810 case "modules": 916 case "modules":
811 SceneManager.ForEachScene( 917 SceneManager.ForEachSelectedScene(
812 delegate(Scene scene) { 918 scene =>
813 MainConsole.Instance.Output("Loaded region modules in" + scene.RegionInfo.RegionName + " are:");
814 foreach (IRegionModuleBase module in scene.RegionModules.Values)
815 { 919 {
816 Type type = module.GetType().GetInterface("ISharedRegionModule"); 920 MainConsole.Instance.OutputFormat("Loaded region modules in {0} are:", scene.Name);
817 string module_type = type != null ? "Shared" : "Non-Shared"; 921
818 MainConsole.Instance.OutputFormat("New Region Module ({0}): {1}", module_type, module.Name); 922 List<IRegionModuleBase> sharedModules = new List<IRegionModuleBase>();
923 List<IRegionModuleBase> nonSharedModules = new List<IRegionModuleBase>();
924
925 foreach (IRegionModuleBase module in scene.RegionModules.Values)
926 {
927 if (module.GetType().GetInterface("ISharedRegionModule") == null)
928 nonSharedModules.Add(module);
929 else
930 sharedModules.Add(module);
931 }
932
933 foreach (IRegionModuleBase module in sharedModules.OrderBy(m => m.Name))
934 MainConsole.Instance.OutputFormat("New Region Module (Shared): {0}", module.Name);
935
936 foreach (IRegionModuleBase module in nonSharedModules.OrderBy(m => m.Name))
937 MainConsole.Instance.OutputFormat("New Region Module (Non-Shared): {0}", module.Name);
819 } 938 }
820 }
821 ); 939 );
822 940
823 MainConsole.Instance.Output(""); 941 MainConsole.Instance.Output("");
824 break; 942 break;
825 943
826 case "regions": 944 case "regions":
945 ConsoleDisplayTable cdt = new ConsoleDisplayTable();
946 cdt.AddColumn("Name", ConsoleDisplayUtil.RegionNameSize);
947 cdt.AddColumn("ID", ConsoleDisplayUtil.UuidSize);
948 cdt.AddColumn("Position", ConsoleDisplayUtil.CoordTupleSize);
949 cdt.AddColumn("Size", 11);
950 cdt.AddColumn("Port", ConsoleDisplayUtil.PortSize);
951 cdt.AddColumn("Ready?", 6);
952 cdt.AddColumn("Estate", ConsoleDisplayUtil.EstateNameSize);
827 SceneManager.ForEachScene( 953 SceneManager.ForEachScene(
828 delegate(Scene scene) 954 scene =>
829 { 955 {
830 MainConsole.Instance.Output(String.Format( 956 RegionInfo ri = scene.RegionInfo;
831 "Region Name: {0}, Region XLoc: {1}, Region YLoc: {2}, Region Port: {3}, Estate Name: {4}", 957 cdt.AddRow(
832 scene.RegionInfo.RegionName, 958 ri.RegionName,
833 scene.RegionInfo.RegionLocX, 959 ri.RegionID,
834 scene.RegionInfo.RegionLocY, 960 string.Format("{0},{1}", ri.RegionLocX, ri.RegionLocY),
835 scene.RegionInfo.InternalEndPoint.Port, 961 string.Format("{0}x{1}", ri.RegionSizeX, ri.RegionSizeY),
836 scene.RegionInfo.EstateSettings.EstateName)); 962 ri.InternalEndPoint.Port,
837 }); 963 scene.Ready ? "Yes" : "No",
964 ri.EstateSettings.EstateName);
965 }
966 );
967
968 MainConsole.Instance.Output(cdt.ToString());
838 break; 969 break;
839 970
840 case "ratings": 971 case "ratings":
@@ -883,7 +1014,7 @@ namespace OpenSim
883 aCircuit.child ? "child" : "root", 1014 aCircuit.child ? "child" : "root",
884 aCircuit.circuitcode.ToString(), 1015 aCircuit.circuitcode.ToString(),
885 aCircuit.IPAddress != null ? aCircuit.IPAddress.ToString() : "not set", 1016 aCircuit.IPAddress != null ? aCircuit.IPAddress.ToString() : "not set",
886 aCircuit.Viewer); 1017 Util.GetViewerName(aCircuit));
887 }); 1018 });
888 1019
889 MainConsole.Instance.Output(cdt.ToString()); 1020 MainConsole.Instance.Output(cdt.ToString());
@@ -1066,6 +1197,232 @@ namespace OpenSim
1066 SceneManager.SaveCurrentSceneToArchive(cmdparams); 1197 SceneManager.SaveCurrentSceneToArchive(cmdparams);
1067 } 1198 }
1068 1199
1200 protected void CreateEstateCommand(string module, string[] args)
1201 {
1202 string response = null;
1203 UUID userID;
1204
1205 if (args.Length == 2)
1206 {
1207 response = "No user specified.";
1208 }
1209 else if (!UUID.TryParse(args[2], out userID))
1210 {
1211 response = String.Format("{0} is not a valid UUID", args[2]);
1212 }
1213 else if (args.Length == 3)
1214 {
1215 response = "No estate name specified.";
1216 }
1217 else
1218 {
1219 Scene scene = SceneManager.CurrentOrFirstScene;
1220
1221 // TODO: Is there a better choice here?
1222 UUID scopeID = UUID.Zero;
1223 UserAccount account = scene.UserAccountService.GetUserAccount(scopeID, userID);
1224 if (account == null)
1225 {
1226 response = String.Format("Could not find user {0}", userID);
1227 }
1228 else
1229 {
1230 // concatenate it all to "name"
1231 StringBuilder sb = new StringBuilder(args[3]);
1232 for (int i = 4; i < args.Length; i++)
1233 sb.Append (" " + args[i]);
1234 string estateName = sb.ToString().Trim();
1235
1236 // send it off for processing.
1237 IEstateModule estateModule = scene.RequestModuleInterface<IEstateModule>();
1238 response = estateModule.CreateEstate(estateName, userID);
1239 if (response == String.Empty)
1240 {
1241 List<int> estates = scene.EstateDataService.GetEstates(estateName);
1242 response = String.Format("Estate {0} created as \"{1}\"", estates.ElementAt(0), estateName);
1243 }
1244 }
1245 }
1246
1247 // give the user some feedback
1248 if (response != null)
1249 MainConsole.Instance.Output(response);
1250 }
1251
1252 protected void SetEstateOwnerCommand(string module, string[] args)
1253 {
1254 string response = null;
1255
1256 Scene scene = SceneManager.CurrentOrFirstScene;
1257 IEstateModule estateModule = scene.RequestModuleInterface<IEstateModule>();
1258
1259 if (args.Length == 3)
1260 {
1261 response = "No estate specified.";
1262 }
1263 else
1264 {
1265 int estateId;
1266 if (!int.TryParse(args[3], out estateId))
1267 {
1268 response = String.Format("\"{0}\" is not a valid ID for an Estate", args[3]);
1269 }
1270 else
1271 {
1272 if (args.Length == 4)
1273 {
1274 response = "No user specified.";
1275 }
1276 else
1277 {
1278 UserAccount account = null;
1279
1280 // TODO: Is there a better choice here?
1281 UUID scopeID = UUID.Zero;
1282
1283 string s1 = args[4];
1284 if (args.Length == 5)
1285 {
1286 // attempt to get account by UUID
1287 UUID u;
1288 if (UUID.TryParse(s1, out u))
1289 {
1290 account = scene.UserAccountService.GetUserAccount(scopeID, u);
1291 if (account == null)
1292 response = String.Format("Could not find user {0}", s1);
1293 }
1294 else
1295 {
1296 response = String.Format("Invalid UUID {0}", s1);
1297 }
1298 }
1299 else
1300 {
1301 // attempt to get account by Firstname, Lastname
1302 string s2 = args[5];
1303 account = scene.UserAccountService.GetUserAccount(scopeID, s1, s2);
1304 if (account == null)
1305 response = String.Format("Could not find user {0} {1}", s1, s2);
1306 }
1307
1308 // If it's valid, send it off for processing.
1309 if (account != null)
1310 response = estateModule.SetEstateOwner(estateId, account);
1311
1312 if (response == String.Empty)
1313 {
1314 response = String.Format("Estate owner changed to {0} ({1} {2})", account.PrincipalID, account.FirstName, account.LastName);
1315 }
1316 }
1317 }
1318 }
1319
1320 // give the user some feedback
1321 if (response != null)
1322 MainConsole.Instance.Output(response);
1323 }
1324
1325 protected void SetEstateNameCommand(string module, string[] args)
1326 {
1327 string response = null;
1328
1329 Scene scene = SceneManager.CurrentOrFirstScene;
1330 IEstateModule estateModule = scene.RequestModuleInterface<IEstateModule>();
1331
1332 if (args.Length == 3)
1333 {
1334 response = "No estate specified.";
1335 }
1336 else
1337 {
1338 int estateId;
1339 if (!int.TryParse(args[3], out estateId))
1340 {
1341 response = String.Format("\"{0}\" is not a valid ID for an Estate", args[3]);
1342 }
1343 else
1344 {
1345 if (args.Length == 4)
1346 {
1347 response = "No name specified.";
1348 }
1349 else
1350 {
1351 // everything after the estate ID is "name"
1352 StringBuilder sb = new StringBuilder(args[4]);
1353 for (int i = 5; i < args.Length; i++)
1354 sb.Append (" " + args[i]);
1355
1356 string estateName = sb.ToString();
1357
1358 // send it off for processing.
1359 response = estateModule.SetEstateName(estateId, estateName);
1360
1361 if (response == String.Empty)
1362 {
1363 response = String.Format("Estate {0} renamed to \"{1}\"", estateId, estateName);
1364 }
1365 }
1366 }
1367 }
1368
1369 // give the user some feedback
1370 if (response != null)
1371 MainConsole.Instance.Output(response);
1372 }
1373
1374 private void EstateLinkRegionCommand(string module, string[] args)
1375 {
1376 int estateId =-1;
1377 UUID regionId = UUID.Zero;
1378 Scene scene = null;
1379 string response = null;
1380
1381 if (args.Length == 3)
1382 {
1383 response = "No estate specified.";
1384 }
1385 else if (!int.TryParse(args [3], out estateId))
1386 {
1387 response = String.Format("\"{0}\" is not a valid ID for an Estate", args [3]);
1388 }
1389 else if (args.Length == 4)
1390 {
1391 response = "No region specified.";
1392 }
1393 else if (!UUID.TryParse(args[4], out regionId))
1394 {
1395 response = String.Format("\"{0}\" is not a valid UUID for a Region", args [4]);
1396 }
1397 else if (!SceneManager.TryGetScene(regionId, out scene))
1398 {
1399 // region may exist, but on a different sim.
1400 response = String.Format("No access to Region \"{0}\"", args [4]);
1401 }
1402
1403 if (response != null)
1404 {
1405 MainConsole.Instance.Output(response);
1406 return;
1407 }
1408
1409 // send it off for processing.
1410 IEstateModule estateModule = scene.RequestModuleInterface<IEstateModule>();
1411 response = estateModule.SetRegionEstate(scene.RegionInfo, estateId);
1412 if (response == String.Empty)
1413 {
1414 estateModule.TriggerRegionInfoChange();
1415 estateModule.sendRegionHandshakeToAll();
1416 response = String.Format ("Region {0} is now attached to estate {1}", regionId, estateId);
1417 }
1418
1419 // give the user some feedback
1420 if (response != null)
1421 MainConsole.Instance.Output (response);
1422 }
1423
1424 #endregion
1425
1069 private static string CombineParams(string[] commandParams, int pos) 1426 private static string CombineParams(string[] commandParams, int pos)
1070 { 1427 {
1071 string result = String.Empty; 1428 string result = String.Empty;
@@ -1076,7 +1433,5 @@ namespace OpenSim
1076 result = result.TrimEnd(' '); 1433 result = result.TrimEnd(' ');
1077 return result; 1434 return result;
1078 } 1435 }
1079
1080 #endregion
1081 } 1436 }
1082} 1437}
diff --git a/OpenSim/Region/Application/OpenSimBackground.cs b/OpenSim/Region/Application/OpenSimBackground.cs
index 008c6b0..15d9065 100644
--- a/OpenSim/Region/Application/OpenSimBackground.cs
+++ b/OpenSim/Region/Application/OpenSimBackground.cs
@@ -55,7 +55,7 @@ namespace OpenSim
55 base.Startup(); 55 base.Startup();
56 56
57 m_log.InfoFormat("[OPENSIM MAIN]: Startup complete, serving {0} region{1}", 57 m_log.InfoFormat("[OPENSIM MAIN]: Startup complete, serving {0} region{1}",
58 m_clientServers.Count.ToString(), m_clientServers.Count > 1 ? "s" : ""); 58 SceneManager.Scenes.Count, SceneManager.Scenes.Count > 1 ? "s" : "");
59 59
60 WorldHasComeToAnEnd.WaitOne(); 60 WorldHasComeToAnEnd.WaitOne();
61 WorldHasComeToAnEnd.Close(); 61 WorldHasComeToAnEnd.Close();
diff --git a/OpenSim/Region/Application/OpenSimBase.cs b/OpenSim/Region/Application/OpenSimBase.cs
index c3c87e7..ab6f036 100644
--- a/OpenSim/Region/Application/OpenSimBase.cs
+++ b/OpenSim/Region/Application/OpenSimBase.cs
@@ -36,17 +36,15 @@ using log4net;
36using Nini.Config; 36using Nini.Config;
37using OpenMetaverse; 37using OpenMetaverse;
38using OpenSim.Framework; 38using OpenSim.Framework;
39using OpenSim.Framework.Communications;
40using OpenSim.Framework.Console; 39using OpenSim.Framework.Console;
41using OpenSim.Framework.Servers; 40using OpenSim.Framework.Servers;
42using OpenSim.Framework.Servers.HttpServer; 41using OpenSim.Framework.Servers.HttpServer;
43using OpenSim.Framework.Monitoring; 42using OpenSim.Framework.Monitoring;
44using OpenSim.Region.ClientStack;
45using OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts; 43using OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts;
46using OpenSim.Region.Framework; 44using OpenSim.Region.Framework;
47using OpenSim.Region.Framework.Interfaces; 45using OpenSim.Region.Framework.Interfaces;
48using OpenSim.Region.Framework.Scenes; 46using OpenSim.Region.Framework.Scenes;
49using OpenSim.Region.Physics.Manager; 47using OpenSim.Region.PhysicsModules.SharedBase;
50using OpenSim.Server.Base; 48using OpenSim.Server.Base;
51using OpenSim.Services.Base; 49using OpenSim.Services.Base;
52using OpenSim.Services.Interfaces; 50using OpenSim.Services.Interfaces;
@@ -71,10 +69,25 @@ namespace OpenSim
71 // OpenSim.ini Section name for ESTATES Settings 69 // OpenSim.ini Section name for ESTATES Settings
72 public const string ESTATE_SECTION_NAME = "Estates"; 70 public const string ESTATE_SECTION_NAME = "Estates";
73 71
72 /// <summary>
73 /// Allow all plugin loading to be disabled for tests/debug.
74 /// </summary>
75 /// <remarks>
76 /// true by default
77 /// </remarks>
78 public bool EnableInitialPluginLoad { get; set; }
79
80 /// <summary>
81 /// Control whether we attempt to load an estate data service.
82 /// </summary>
83 /// <remarks>For tests/debugging</remarks>
84 public bool LoadEstateDataService { get; set; }
85
74 protected string proxyUrl; 86 protected string proxyUrl;
75 protected int proxyOffset = 0; 87 protected int proxyOffset = 0;
76 88
77 public string userStatsURI = String.Empty; 89 public string userStatsURI = String.Empty;
90 public string managedStatsURI = String.Empty;
78 91
79 protected bool m_autoCreateClientStack = true; 92 protected bool m_autoCreateClientStack = true;
80 93
@@ -95,26 +108,19 @@ namespace OpenSim
95 108
96 public ConsoleCommand CreateAccount = null; 109 public ConsoleCommand CreateAccount = null;
97 110
98 protected List<IApplicationPlugin> m_plugins = new List<IApplicationPlugin>(); 111 public List<IApplicationPlugin> m_plugins = new List<IApplicationPlugin>();
99 112
100 /// <value> 113 /// <value>
101 /// The config information passed into the OpenSimulator region server. 114 /// The config information passed into the OpenSimulator region server.
102 /// </value> 115 /// </value>
103 public OpenSimConfigSource ConfigSource { get; private set; } 116 public OpenSimConfigSource ConfigSource { get; private set; }
104 117
105 public List<IClientNetworkServer> ClientServers
106 {
107 get { return m_clientServers; }
108 }
109
110 protected EnvConfigSource m_EnvConfigSource = new EnvConfigSource(); 118 protected EnvConfigSource m_EnvConfigSource = new EnvConfigSource();
111 119
112 public EnvConfigSource envConfigSource 120 public EnvConfigSource envConfigSource
113 { 121 {
114 get { return m_EnvConfigSource; } 122 get { return m_EnvConfigSource; }
115 } 123 }
116
117 protected List<IClientNetworkServer> m_clientServers = new List<IClientNetworkServer>();
118 124
119 public uint HttpServerPort 125 public uint HttpServerPort
120 { 126 {
@@ -134,6 +140,8 @@ namespace OpenSim
134 /// <param name="configSource"></param> 140 /// <param name="configSource"></param>
135 public OpenSimBase(IConfigSource configSource) : base() 141 public OpenSimBase(IConfigSource configSource) : base()
136 { 142 {
143 EnableInitialPluginLoad = true;
144 LoadEstateDataService = true;
137 LoadConfigSettings(configSource); 145 LoadConfigSettings(configSource);
138 } 146 }
139 147
@@ -153,14 +161,37 @@ namespace OpenSim
153 proxyUrl = networkConfig.GetString("proxy_url", ""); 161 proxyUrl = networkConfig.GetString("proxy_url", "");
154 proxyOffset = Int32.Parse(networkConfig.GetString("proxy_offset", "0")); 162 proxyOffset = Int32.Parse(networkConfig.GetString("proxy_offset", "0"));
155 } 163 }
164
165 IConfig startupConfig = Config.Configs["Startup"];
166 if (startupConfig != null)
167 {
168 Util.LogOverloads = startupConfig.GetBoolean("LogOverloads", true);
169 }
156 } 170 }
157 171
158 protected virtual void LoadPlugins() 172 protected virtual void LoadPlugins()
159 { 173 {
160 using (PluginLoader<IApplicationPlugin> loader = new PluginLoader<IApplicationPlugin>(new ApplicationPluginInitialiser(this))) 174 IConfig startupConfig = Config.Configs["Startup"];
175 string registryLocation = (startupConfig != null) ? startupConfig.GetString("RegistryLocation", String.Empty) : String.Empty;
176
177 // The location can also be specified in the environment. If there
178 // is no location in the configuration, we must call the constructor
179 // without a location parameter to allow that to happen.
180 if (registryLocation == String.Empty)
161 { 181 {
162 loader.Load("/OpenSim/Startup"); 182 using (PluginLoader<IApplicationPlugin> loader = new PluginLoader<IApplicationPlugin>(new ApplicationPluginInitialiser(this)))
163 m_plugins = loader.Plugins; 183 {
184 loader.Load("/OpenSim/Startup");
185 m_plugins = loader.Plugins;
186 }
187 }
188 else
189 {
190 using (PluginLoader<IApplicationPlugin> loader = new PluginLoader<IApplicationPlugin>(new ApplicationPluginInitialiser(this), registryLocation))
191 {
192 loader.Load("/OpenSim/Startup");
193 m_plugins = loader.Plugins;
194 }
164 } 195 }
165 } 196 }
166 197
@@ -188,6 +219,7 @@ namespace OpenSim
188 CreatePIDFile(pidFile); 219 CreatePIDFile(pidFile);
189 220
190 userStatsURI = startupConfig.GetString("Stats_URI", String.Empty); 221 userStatsURI = startupConfig.GetString("Stats_URI", String.Empty);
222 managedStatsURI = startupConfig.GetString("ManagedStatsRemoteFetchURI", String.Empty);
191 } 223 }
192 224
193 // Load the simulation data service 225 // Load the simulation data service
@@ -207,34 +239,32 @@ namespace OpenSim
207 module)); 239 module));
208 240
209 // Load the estate data service 241 // Load the estate data service
210 IConfig estateDataConfig = Config.Configs["EstateDataStore"]; 242 module = Util.GetConfigVarFromSections<string>(Config, "LocalServiceModule", new string[]{"EstateDataStore", "EstateService"}, String.Empty);
211 if (estateDataConfig == null)
212 throw new Exception("Configuration file is missing the [EstateDataStore] section. Have you copied OpenSim.ini.example to OpenSim.ini to reference config-include/ files?");
213
214 module = estateDataConfig.GetString("LocalServiceModule", String.Empty);
215 if (String.IsNullOrEmpty(module)) 243 if (String.IsNullOrEmpty(module))
216 throw new Exception("Configuration file is missing the LocalServiceModule parameter in the [EstateDataStore] section"); 244 throw new Exception("Configuration file is missing the LocalServiceModule parameter in the [EstateDataStore] or [EstateService] section");
217 245
218 m_estateDataService = ServerUtils.LoadPlugin<IEstateDataService>(module, new object[] { Config }); 246 if (LoadEstateDataService)
219 if (m_estateDataService == null) 247 {
220 throw new Exception( 248 m_estateDataService = ServerUtils.LoadPlugin<IEstateDataService>(module, new object[] { Config });
221 string.Format( 249 if (m_estateDataService == null)
222 "Could not load an IEstateDataService implementation from {0}, as configured in the LocalServiceModule parameter of the [EstateDataStore] config section.", 250 throw new Exception(
223 module)); 251 string.Format(
252 "Could not load an IEstateDataService implementation from {0}, as configured in the LocalServiceModule parameter of the [EstateDataStore] config section.",
253 module));
254 }
224 255
225 base.StartupSpecific(); 256 base.StartupSpecific();
226 257
227 LoadPlugins(); 258 if (EnableInitialPluginLoad)
259 LoadPlugins();
260
261 // We still want to post initalize any plugins even if loading has been disabled since a test may have
262 // inserted them manually.
228 foreach (IApplicationPlugin plugin in m_plugins) 263 foreach (IApplicationPlugin plugin in m_plugins)
229 {
230 plugin.PostInitialise(); 264 plugin.PostInitialise();
231 }
232 265
233 if (m_console != null) 266 if (m_console != null)
234 {
235 StatsManager.RegisterConsoleCommands(m_console);
236 AddPluginCommands(m_console); 267 AddPluginCommands(m_console);
237 }
238 } 268 }
239 269
240 protected virtual void AddPluginCommands(ICommandConsole console) 270 protected virtual void AddPluginCommands(ICommandConsole console)
@@ -298,6 +328,10 @@ namespace OpenSim
298 { 328 {
299 // Called from base.StartUp() 329 // Called from base.StartUp()
300 330
331 IConfig startupConfig = Config.Configs["Startup"];
332 if (startupConfig == null || startupConfig.GetBoolean("JobEngineEnabled", true))
333 WorkManager.JobEngine.Start();
334
301 m_httpServerPort = m_networkServersInfo.HttpListenerPort; 335 m_httpServerPort = m_networkServersInfo.HttpListenerPort;
302 SceneManager.OnRestartSim += HandleRestartRegion; 336 SceneManager.OnRestartSim += HandleRestartRegion;
303 337
@@ -316,9 +350,9 @@ namespace OpenSim
316 /// <param name="regionInfo"></param> 350 /// <param name="regionInfo"></param>
317 /// <param name="portadd_flag"></param> 351 /// <param name="portadd_flag"></param>
318 /// <returns></returns> 352 /// <returns></returns>
319 public IClientNetworkServer CreateRegion(RegionInfo regionInfo, bool portadd_flag, out IScene scene) 353 public void CreateRegion(RegionInfo regionInfo, bool portadd_flag, out IScene scene)
320 { 354 {
321 return CreateRegion(regionInfo, portadd_flag, false, out scene); 355 CreateRegion(regionInfo, portadd_flag, false, out scene);
322 } 356 }
323 357
324 /// <summary> 358 /// <summary>
@@ -326,9 +360,9 @@ namespace OpenSim
326 /// </summary> 360 /// </summary>
327 /// <param name="regionInfo"></param> 361 /// <param name="regionInfo"></param>
328 /// <returns></returns> 362 /// <returns></returns>
329 public IClientNetworkServer CreateRegion(RegionInfo regionInfo, out IScene scene) 363 public void CreateRegion(RegionInfo regionInfo, out IScene scene)
330 { 364 {
331 return CreateRegion(regionInfo, false, true, out scene); 365 CreateRegion(regionInfo, false, true, out scene);
332 } 366 }
333 367
334 /// <summary> 368 /// <summary>
@@ -338,7 +372,7 @@ namespace OpenSim
338 /// <param name="portadd_flag"></param> 372 /// <param name="portadd_flag"></param>
339 /// <param name="do_post_init"></param> 373 /// <param name="do_post_init"></param>
340 /// <returns></returns> 374 /// <returns></returns>
341 public IClientNetworkServer CreateRegion(RegionInfo regionInfo, bool portadd_flag, bool do_post_init, out IScene mscene) 375 public void CreateRegion(RegionInfo regionInfo, bool portadd_flag, bool do_post_init, out IScene mscene)
342 { 376 {
343 int port = regionInfo.InternalEndPoint.Port; 377 int port = regionInfo.InternalEndPoint.Port;
344 378
@@ -363,8 +397,7 @@ namespace OpenSim
363 Util.XmlRpcCommand(proxyUrl, "AddPort", port, port + proxyOffset, regionInfo.ExternalHostName); 397 Util.XmlRpcCommand(proxyUrl, "AddPort", port, port + proxyOffset, regionInfo.ExternalHostName);
364 } 398 }
365 399
366 IClientNetworkServer clientServer; 400 Scene scene = SetupScene(regionInfo, proxyOffset, Config);
367 Scene scene = SetupScene(regionInfo, proxyOffset, Config, out clientServer);
368 401
369 m_log.Info("[MODULES]: Loading Region's modules (old style)"); 402 m_log.Info("[MODULES]: Loading Region's modules (old style)");
370 403
@@ -412,20 +445,20 @@ namespace OpenSim
412 445
413 SceneManager.Add(scene); 446 SceneManager.Add(scene);
414 447
415 if (m_autoCreateClientStack) 448 //if (m_autoCreateClientStack)
416 { 449 //{
417 m_clientServers.Add(clientServer); 450 // foreach (IClientNetworkServer clientserver in clientServers)
418 clientServer.Start(); 451 // {
419 } 452 // m_clientServers.Add(clientserver);
453 // clientserver.Start();
454 // }
455 //}
420 456
421 scene.EventManager.OnShutdown += delegate() { ShutdownRegion(scene); }; 457 scene.EventManager.OnShutdown += delegate() { ShutdownRegion(scene); };
422 458
423 mscene = scene; 459 mscene = scene;
424 460
425 scene.Start(); 461 //return clientServers;
426 scene.StartScripts();
427
428 return clientServer;
429 } 462 }
430 463
431 /// <summary> 464 /// <summary>
@@ -533,7 +566,7 @@ namespace OpenSim
533 else 566 else
534 { 567 {
535 regionInfo.EstateSettings.EstateOwner = account.PrincipalID; 568 regionInfo.EstateSettings.EstateOwner = account.PrincipalID;
536 regionInfo.EstateSettings.Save(); 569 m_estateDataService.StoreEstateSettings(regionInfo.EstateSettings);
537 } 570 }
538 } 571 }
539 572
@@ -559,7 +592,7 @@ namespace OpenSim
559 592
560 scene.DeleteAllSceneObjects(); 593 scene.DeleteAllSceneObjects();
561 SceneManager.CloseScene(scene); 594 SceneManager.CloseScene(scene);
562 ShutdownClientServer(scene.RegionInfo); 595 //ShutdownClientServer(scene.RegionInfo);
563 596
564 if (!cleanup) 597 if (!cleanup)
565 return; 598 return;
@@ -620,7 +653,7 @@ namespace OpenSim
620 } 653 }
621 654
622 SceneManager.CloseScene(scene); 655 SceneManager.CloseScene(scene);
623 ShutdownClientServer(scene.RegionInfo); 656 //ShutdownClientServer(scene.RegionInfo);
624 } 657 }
625 658
626 /// <summary> 659 /// <summary>
@@ -641,9 +674,9 @@ namespace OpenSim
641 /// <param name="regionInfo"></param> 674 /// <param name="regionInfo"></param>
642 /// <param name="clientServer"> </param> 675 /// <param name="clientServer"> </param>
643 /// <returns></returns> 676 /// <returns></returns>
644 protected Scene SetupScene(RegionInfo regionInfo, out IClientNetworkServer clientServer) 677 protected Scene SetupScene(RegionInfo regionInfo)
645 { 678 {
646 return SetupScene(regionInfo, 0, null, out clientServer); 679 return SetupScene(regionInfo, 0, null);
647 } 680 }
648 681
649 /// <summary> 682 /// <summary>
@@ -654,176 +687,87 @@ namespace OpenSim
654 /// <param name="configSource"></param> 687 /// <param name="configSource"></param>
655 /// <param name="clientServer"> </param> 688 /// <param name="clientServer"> </param>
656 /// <returns></returns> 689 /// <returns></returns>
657 protected Scene SetupScene( 690 protected Scene SetupScene(RegionInfo regionInfo, int proxyOffset, IConfigSource configSource)
658 RegionInfo regionInfo, int proxyOffset, IConfigSource configSource, out IClientNetworkServer clientServer)
659 { 691 {
660 AgentCircuitManager circuitManager = new AgentCircuitManager(); 692 //List<IClientNetworkServer> clientNetworkServers = null;
661 IPAddress listenIP = regionInfo.InternalEndPoint.Address;
662 //if (!IPAddress.TryParse(regionInfo.InternalEndPoint, out listenIP))
663 // listenIP = IPAddress.Parse("0.0.0.0");
664
665 uint port = (uint) regionInfo.InternalEndPoint.Port;
666
667 if (m_autoCreateClientStack)
668 {
669 clientServer
670 = m_clientStackManager.CreateServer(
671 listenIP, ref port, proxyOffset, regionInfo.m_allow_alternate_ports, configSource,
672 circuitManager);
673 }
674 else
675 {
676 clientServer = null;
677 }
678
679 regionInfo.InternalEndPoint.Port = (int) port;
680 693
694 AgentCircuitManager circuitManager = new AgentCircuitManager();
681 Scene scene = CreateScene(regionInfo, m_simulationDataService, m_estateDataService, circuitManager); 695 Scene scene = CreateScene(regionInfo, m_simulationDataService, m_estateDataService, circuitManager);
682 696
683 if (m_autoCreateClientStack)
684 {
685 clientServer.AddScene(scene);
686 }
687
688 scene.LoadWorldMap(); 697 scene.LoadWorldMap();
689 698
690 scene.PhysicsScene = GetPhysicsScene(scene.RegionInfo.RegionName);
691 scene.PhysicsScene.RequestAssetMethod = scene.PhysicsRequestAsset;
692 scene.PhysicsScene.SetTerrain(scene.Heightmap.GetFloatsSerialised());
693 scene.PhysicsScene.SetWaterLevel((float) regionInfo.RegionSettings.WaterHeight);
694
695 return scene; 699 return scene;
696 } 700 }
697 701
698 protected override ClientStackManager CreateClientStackManager()
699 {
700 return new ClientStackManager(m_configSettings.ClientstackDll);
701 }
702
703 protected override Scene CreateScene(RegionInfo regionInfo, ISimulationDataService simDataService, 702 protected override Scene CreateScene(RegionInfo regionInfo, ISimulationDataService simDataService,
704 IEstateDataService estateDataService, AgentCircuitManager circuitManager) 703 IEstateDataService estateDataService, AgentCircuitManager circuitManager)
705 { 704 {
706 SceneCommunicationService sceneGridService = new SceneCommunicationService();
707
708 return new Scene( 705 return new Scene(
709 regionInfo, circuitManager, sceneGridService, 706 regionInfo, circuitManager,
710 simDataService, estateDataService, false, 707 simDataService, estateDataService,
711 Config, m_version); 708 Config, m_version);
712 } 709 }
713 710
714 protected void ShutdownClientServer(RegionInfo whichRegion)
715 {
716 // Close and remove the clientserver for a region
717 bool foundClientServer = false;
718 int clientServerElement = 0;
719 Location location = new Location(whichRegion.RegionHandle);
720
721 for (int i = 0; i < m_clientServers.Count; i++)
722 {
723 if (m_clientServers[i].HandlesRegion(location))
724 {
725 clientServerElement = i;
726 foundClientServer = true;
727 break;
728 }
729 }
730
731 if (foundClientServer)
732 {
733 m_clientServers[clientServerElement].NetworkStop();
734 m_clientServers.RemoveAt(clientServerElement);
735 }
736 }
737
738 protected virtual void HandleRestartRegion(RegionInfo whichRegion) 711 protected virtual void HandleRestartRegion(RegionInfo whichRegion)
739 { 712 {
740 m_log.InfoFormat( 713 m_log.InfoFormat(
741 "[OPENSIM]: Got restart signal from SceneManager for region {0} ({1},{2})", 714 "[OPENSIM]: Got restart signal from SceneManager for region {0} ({1},{2})",
742 whichRegion.RegionName, whichRegion.RegionLocX, whichRegion.RegionLocY); 715 whichRegion.RegionName, whichRegion.RegionLocX, whichRegion.RegionLocY);
743 716
744 ShutdownClientServer(whichRegion); 717 //ShutdownClientServer(whichRegion);
745 IScene scene; 718 IScene scene;
746 CreateRegion(whichRegion, true, out scene); 719 CreateRegion(whichRegion, true, out scene);
720 scene.Start();
747 } 721 }
748 722
749 # region Setup methods 723 # region Setup methods
750 724
751 protected override PhysicsScene GetPhysicsScene(string osSceneIdentifier)
752 {
753 return GetPhysicsScene(
754 m_configSettings.PhysicsEngine, m_configSettings.MeshEngineName, Config, osSceneIdentifier);
755 }
756
757 /// <summary> 725 /// <summary>
758 /// Handler to supply the current status of this sim 726 /// Handler to supply the current status of this sim
759 /// </summary> 727 /// </summary>
728 /// <remarks>
760 /// Currently this is always OK if the simulator is still listening for connections on its HTTP service 729 /// Currently this is always OK if the simulator is still listening for connections on its HTTP service
761 public class SimStatusHandler : IStreamedRequestHandler 730 /// </remarks>
731 public class SimStatusHandler : BaseStreamHandler
762 { 732 {
763 public byte[] Handle(string path, Stream request, 733 public SimStatusHandler() : base("GET", "/simstatus", "SimStatus", "Simulator Status") {}
734
735 protected override byte[] ProcessRequest(string path, Stream request,
764 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) 736 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
765 { 737 {
766 return Util.UTF8.GetBytes("OK"); 738 return Util.UTF8.GetBytes("OK");
767 } 739 }
768 740
769 public string Name { get { return "SimStatus"; } } 741 public override string ContentType
770 public string Description { get { return "Simulator Status"; } }
771
772 public string ContentType
773 { 742 {
774 get { return "text/plain"; } 743 get { return "text/plain"; }
775 } 744 }
776
777 public string HttpMethod
778 {
779 get { return "GET"; }
780 }
781
782 public string Path
783 {
784 get { return "/simstatus"; }
785 }
786 } 745 }
787 746
788 /// <summary> 747 /// <summary>
789 /// Handler to supply the current extended status of this sim 748 /// Handler to supply the current extended status of this sim
790 /// Sends the statistical data in a json serialization 749 /// Sends the statistical data in a json serialization
791 /// </summary> 750 /// </summary>
792 public class XSimStatusHandler : IStreamedRequestHandler 751 public class XSimStatusHandler : BaseStreamHandler
793 { 752 {
794 OpenSimBase m_opensim; 753 OpenSimBase m_opensim;
795 string osXStatsURI = String.Empty;
796
797 public string Name { get { return "XSimStatus"; } }
798 public string Description { get { return "Simulator XStatus"; } }
799 754
800 public XSimStatusHandler(OpenSimBase sim) 755 public XSimStatusHandler(OpenSimBase sim)
756 : base("GET", "/" + Util.SHA1Hash(sim.osSecret), "XSimStatus", "Simulator XStatus")
801 { 757 {
802 m_opensim = sim; 758 m_opensim = sim;
803 osXStatsURI = Util.SHA1Hash(sim.osSecret);
804 } 759 }
805 760
806 public byte[] Handle(string path, Stream request, 761 protected override byte[] ProcessRequest(string path, Stream request,
807 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) 762 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
808 { 763 {
809 return Util.UTF8.GetBytes(m_opensim.StatReport(httpRequest)); 764 return Util.UTF8.GetBytes(m_opensim.StatReport(httpRequest));
810 } 765 }
811 766
812 public string ContentType 767 public override string ContentType
813 { 768 {
814 get { return "text/plain"; } 769 get { return "text/plain"; }
815 } 770 }
816
817 public string HttpMethod
818 {
819 get { return "GET"; }
820 }
821
822 public string Path
823 {
824 // This is for the OpenSimulator instance and is the osSecret hashed
825 get { return "/" + osXStatsURI; }
826 }
827 } 771 }
828 772
829 /// <summary> 773 /// <summary>
@@ -832,42 +776,26 @@ namespace OpenSim
832 /// If the request contains a key, "callback" the response will be wrappend in the 776 /// If the request contains a key, "callback" the response will be wrappend in the
833 /// associated value for jsonp used with ajax/javascript 777 /// associated value for jsonp used with ajax/javascript
834 /// </summary> 778 /// </summary>
835 public class UXSimStatusHandler : IStreamedRequestHandler 779 protected class UXSimStatusHandler : BaseStreamHandler
836 { 780 {
837 OpenSimBase m_opensim; 781 OpenSimBase m_opensim;
838 string osUXStatsURI = String.Empty;
839
840 public string Name { get { return "UXSimStatus"; } }
841 public string Description { get { return "Simulator UXStatus"; } }
842 782
843 public UXSimStatusHandler(OpenSimBase sim) 783 public UXSimStatusHandler(OpenSimBase sim)
784 : base("GET", "/" + sim.userStatsURI, "UXSimStatus", "Simulator UXStatus")
844 { 785 {
845 m_opensim = sim; 786 m_opensim = sim;
846 osUXStatsURI = sim.userStatsURI;
847
848 } 787 }
849 788
850 public byte[] Handle(string path, Stream request, 789 protected override byte[] ProcessRequest(string path, Stream request,
851 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) 790 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
852 { 791 {
853 return Util.UTF8.GetBytes(m_opensim.StatReport(httpRequest)); 792 return Util.UTF8.GetBytes(m_opensim.StatReport(httpRequest));
854 } 793 }
855 794
856 public string ContentType 795 public override string ContentType
857 { 796 {
858 get { return "text/plain"; } 797 get { return "text/plain"; }
859 } 798 }
860
861 public string HttpMethod
862 {
863 get { return "GET"; }
864 }
865
866 public string Path
867 {
868 // This is for the OpenSimulator instance and is the user provided URI
869 get { return "/" + osUXStatsURI; }
870 }
871 } 799 }
872 800
873 #endregion 801 #endregion
@@ -875,7 +803,7 @@ namespace OpenSim
875 /// <summary> 803 /// <summary>
876 /// Performs any last-minute sanity checking and shuts down the region server 804 /// Performs any last-minute sanity checking and shuts down the region server
877 /// </summary> 805 /// </summary>
878 public override void ShutdownSpecific() 806 protected override void ShutdownSpecific()
879 { 807 {
880 if (proxyUrl.Length > 0) 808 if (proxyUrl.Length > 0)
881 { 809 {
@@ -890,11 +818,16 @@ namespace OpenSim
890 try 818 try
891 { 819 {
892 SceneManager.Close(); 820 SceneManager.Close();
821
822 foreach (IApplicationPlugin plugin in m_plugins)
823 plugin.Dispose();
893 } 824 }
894 catch (Exception e) 825 catch (Exception e)
895 { 826 {
896 m_log.Error("[SHUTDOWN]: Ignoring failure during shutdown - ", e); 827 m_log.Error("[SHUTDOWN]: Ignoring failure during shutdown - ", e);
897 } 828 }
829
830 base.ShutdownSpecific();
898 } 831 }
899 832
900 /// <summary> 833 /// <summary>
@@ -942,7 +875,7 @@ namespace OpenSim
942 regInfo.EstateSettings = EstateDataService.LoadEstateSettings(regInfo.RegionID, true); 875 regInfo.EstateSettings = EstateDataService.LoadEstateSettings(regInfo.RegionID, true);
943 876
944 string newName; 877 string newName;
945 if (estateName != null && estateName != "") 878 if (!string.IsNullOrEmpty(estateName))
946 newName = estateName; 879 newName = estateName;
947 else 880 else
948 newName = MainConsole.Instance.CmdPrompt("New estate name", regInfo.EstateSettings.EstateName); 881 newName = MainConsole.Instance.CmdPrompt("New estate name", regInfo.EstateSettings.EstateName);
@@ -960,7 +893,7 @@ namespace OpenSim
960 // back to the default. The reloading of estate settings by scene could be eliminated if it 893 // back to the default. The reloading of estate settings by scene could be eliminated if it
961 // knows that the passed in settings in RegionInfo are already valid. Also, it might be 894 // knows that the passed in settings in RegionInfo are already valid. Also, it might be
962 // possible to eliminate some additional later saves made by callers of this method. 895 // possible to eliminate some additional later saves made by callers of this method.
963 regInfo.EstateSettings.Save(); 896 EstateDataService.StoreEstateSettings(regInfo.EstateSettings);
964 897
965 return true; 898 return true;
966 } 899 }
@@ -1082,4 +1015,4 @@ namespace OpenSim
1082 { 1015 {
1083 public IConfigSource Source; 1016 public IConfigSource Source;
1084 } 1017 }
1085} \ No newline at end of file 1018}
diff --git a/OpenSim/Region/Application/Properties/AssemblyInfo.cs b/OpenSim/Region/Application/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..26990f7
--- /dev/null
+++ b/OpenSim/Region/Application/Properties/AssemblyInfo.cs
@@ -0,0 +1,36 @@
1using System.Reflection;
2using System.Runtime.CompilerServices;
3using System.Runtime.InteropServices;
4using Mono.Addins;
5
6// General Information about an assembly is controlled through the following
7// set of attributes. Change these attribute values to modify the information
8// associated with an assembly.
9[assembly: AssemblyTitle("OpenSim")]
10[assembly: AssemblyDescription("The executable for for simulator")]
11[assembly: AssemblyConfiguration("")]
12[assembly: AssemblyCompany("http://opensimulator.org")]
13[assembly: AssemblyProduct("OpenSim")]
14[assembly: AssemblyCopyright("OpenSimulator developers")]
15[assembly: AssemblyTrademark("")]
16[assembly: AssemblyCulture("")]
17
18// Setting ComVisible to false makes the types in this assembly not visible
19// to COM components. If you need to access a type in this assembly from
20// COM, set the ComVisible attribute to true on that type.
21[assembly: ComVisible(false)]
22
23// The following GUID is for the ID of the typelib if this project is exposed to COM
24[assembly: Guid("f6700ed5-1e6f-44d8-8397-e5eac42b3856")]
25
26// Version information for an assembly consists of the following four values:
27//
28// Major Version
29// Minor Version
30// Build Number
31// Revision
32//
33[assembly: AssemblyVersion("0.8.3.*")]
34
35[assembly: AddinRoot("OpenSim", OpenSim.VersionInfo.VersionNumber)]
36[assembly: ImportAddinAssembly("OpenSim.Framework.dll")]
diff --git a/OpenSim/Region/Application/RegionApplicationBase.cs b/OpenSim/Region/Application/RegionApplicationBase.cs
new file mode 100644
index 0000000..08c8579
--- /dev/null
+++ b/OpenSim/Region/Application/RegionApplicationBase.cs
@@ -0,0 +1,103 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
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
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
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System.Collections.Generic;
29using System.Net;
30using System.Reflection;
31using log4net;
32using Nini.Config;
33using OpenMetaverse;
34using OpenSim.Framework;
35using OpenSim.Framework.Servers;
36using OpenSim.Framework.Servers.HttpServer;
37using OpenSim.Region.Framework;
38using OpenSim.Region.Framework.Interfaces;
39using OpenSim.Region.Framework.Scenes;
40using OpenSim.Region.PhysicsModules.SharedBase;
41using OpenSim.Services.Interfaces;
42
43namespace OpenSim
44{
45 public abstract class RegionApplicationBase : BaseOpenSimServer
46 {
47 private static readonly ILog m_log
48 = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
49
50 protected Dictionary<EndPoint, uint> m_clientCircuits = new Dictionary<EndPoint, uint>();
51 protected NetworkServersInfo m_networkServersInfo;
52 protected uint m_httpServerPort;
53 protected ISimulationDataService m_simulationDataService;
54 protected IEstateDataService m_estateDataService;
55
56 public SceneManager SceneManager { get; protected set; }
57 public NetworkServersInfo NetServersInfo { get { return m_networkServersInfo; } }
58 public ISimulationDataService SimulationDataService { get { return m_simulationDataService; } }
59 public IEstateDataService EstateDataService { get { return m_estateDataService; } }
60
61 protected abstract void Initialize();
62
63 protected abstract Scene CreateScene(RegionInfo regionInfo, ISimulationDataService simDataService, IEstateDataService estateDataService, AgentCircuitManager circuitManager);
64
65 protected override void StartupSpecific()
66 {
67 SceneManager = SceneManager.Instance;
68
69 Initialize();
70
71 m_httpServer
72 = new BaseHttpServer(
73 m_httpServerPort, m_networkServersInfo.HttpUsesSSL, m_networkServersInfo.httpSSLPort,
74 m_networkServersInfo.HttpSSLCN);
75
76 if (m_networkServersInfo.HttpUsesSSL && (m_networkServersInfo.HttpListenerPort == m_networkServersInfo.httpSSLPort))
77 {
78 m_log.Error("[REGION SERVER]: HTTP Server config failed. HTTP Server and HTTPS server must be on different ports");
79 }
80
81 m_log.InfoFormat("[REGION SERVER]: Starting HTTP server on port {0}", m_httpServerPort);
82 m_httpServer.Start();
83
84 MainServer.AddHttpServer(m_httpServer);
85 MainServer.Instance = m_httpServer;
86
87 // "OOB" Server
88 if (m_networkServersInfo.ssl_listener)
89 {
90 BaseHttpServer server = new BaseHttpServer(
91 m_networkServersInfo.https_port, m_networkServersInfo.ssl_listener, m_networkServersInfo.cert_path,
92 m_networkServersInfo.cert_pass);
93
94 m_log.InfoFormat("[REGION SERVER]: Starting HTTPS server on port {0}", server.Port);
95 MainServer.AddHttpServer(server);
96 server.Start();
97 }
98
99 base.StartupSpecific();
100 }
101
102 }
103} \ No newline at end of file