aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorlbsa712008-03-12 08:44:36 +0000
committerlbsa712008-03-12 08:44:36 +0000
commitda854b9691ddd3345049dd1a18232e08bae7dc6d (patch)
tree54eed7beb6090abe55287a683de3e789a40dcca3
parent* ignored some bins (diff)
downloadopensim-SC_OLD-da854b9691ddd3345049dd1a18232e08bae7dc6d.zip
opensim-SC_OLD-da854b9691ddd3345049dd1a18232e08bae7dc6d.tar.gz
opensim-SC_OLD-da854b9691ddd3345049dd1a18232e08bae7dc6d.tar.bz2
opensim-SC_OLD-da854b9691ddd3345049dd1a18232e08bae7dc6d.tar.xz
* minor refactoring
-rw-r--r--OpenSim/Grid/GridServer/GridManager.cs166
1 files changed, 82 insertions, 84 deletions
diff --git a/OpenSim/Grid/GridServer/GridManager.cs b/OpenSim/Grid/GridServer/GridManager.cs
index 5ea2a3a..3597792 100644
--- a/OpenSim/Grid/GridServer/GridManager.cs
+++ b/OpenSim/Grid/GridServer/GridManager.cs
@@ -234,17 +234,15 @@ namespace OpenSim.Grid.GridServer
234 Hashtable responseData = new Hashtable(); 234 Hashtable responseData = new Hashtable();
235 response.Value = responseData; 235 response.Value = responseData;
236 236
237 RegionProfileData TheSim = null; 237 RegionProfileData sim;
238 RegionProfileData OldSim = null; 238 RegionProfileData existingSim;
239 239
240 Hashtable requestData = (Hashtable)request.Params[0]; 240 Hashtable requestData = (Hashtable)request.Params[0];
241 string myword; 241 string myword;
242 LLUUID uuid; 242 LLUUID uuid;
243 if (requestData.ContainsKey("UUID") && LLUUID.TryParse((string)requestData["UUID"], out uuid)) 243 if (requestData.ContainsKey("UUID") && LLUUID.TryParse((string)requestData["UUID"], out uuid))
244 { 244 {
245 TheSim = getRegion(uuid); 245 sim = getRegion(uuid);
246
247 // logToDB((new LLUUID((string)requestData["UUID"])).ToString(),"XmlRpcSimulatorLoginMethod",String.Empty, 5,"Region attempting login with UUID.");
248 } 246 }
249 else 247 else
250 { 248 {
@@ -253,7 +251,7 @@ namespace OpenSim.Grid.GridServer
253 return response; 251 return response;
254 } 252 }
255 253
256 if (TheSim == null) // Shouldnt this be in the REST Simulator Set method? 254 if (sim == null) // Shouldnt this be in the REST Simulator Set method?
257 { 255 {
258 m_log.Info("[GRID]: New region connecting"); 256 m_log.Info("[GRID]: New region connecting");
259 myword = "creation"; 257 myword = "creation";
@@ -263,28 +261,28 @@ namespace OpenSim.Grid.GridServer
263 myword = "connection"; 261 myword = "connection";
264 } 262 }
265 263
266 TheSim = new RegionProfileData(); 264 sim = new RegionProfileData();
267 265
268 TheSim.regionRecvKey = String.Empty; 266 sim.regionRecvKey = String.Empty;
269 TheSim.regionSendKey = String.Empty; 267 sim.regionSendKey = String.Empty;
270 TheSim.regionSecret = config.SimRecvKey; 268 sim.regionSecret = config.SimRecvKey;
271 TheSim.regionDataURI = String.Empty; 269 sim.regionDataURI = String.Empty;
272 TheSim.regionAssetURI = config.DefaultAssetServer; 270 sim.regionAssetURI = config.DefaultAssetServer;
273 TheSim.regionAssetRecvKey = config.AssetRecvKey; 271 sim.regionAssetRecvKey = config.AssetRecvKey;
274 TheSim.regionAssetSendKey = config.AssetSendKey; 272 sim.regionAssetSendKey = config.AssetSendKey;
275 TheSim.regionUserURI = config.DefaultUserServer; 273 sim.regionUserURI = config.DefaultUserServer;
276 TheSim.regionUserSendKey = config.UserSendKey; 274 sim.regionUserSendKey = config.UserSendKey;
277 TheSim.regionUserRecvKey = config.UserRecvKey; 275 sim.regionUserRecvKey = config.UserRecvKey;
278 276
279 try 277 try
280 { 278 {
281 TheSim.serverIP = (string)requestData["sim_ip"]; 279 sim.serverIP = (string)requestData["sim_ip"];
282 TheSim.serverPort = Convert.ToUInt32((string)requestData["sim_port"]); 280 sim.serverPort = Convert.ToUInt32((string)requestData["sim_port"]);
283 TheSim.httpPort = Convert.ToUInt32((string)requestData["http_port"]); 281 sim.httpPort = Convert.ToUInt32((string)requestData["http_port"]);
284 TheSim.remotingPort = Convert.ToUInt32((string)requestData["remoting_port"]); 282 sim.remotingPort = Convert.ToUInt32((string)requestData["remoting_port"]);
285 TheSim.regionLocX = Convert.ToUInt32((string)requestData["region_locx"]); 283 sim.regionLocX = Convert.ToUInt32((string)requestData["region_locx"]);
286 TheSim.regionLocY = Convert.ToUInt32((string)requestData["region_locy"]); 284 sim.regionLocY = Convert.ToUInt32((string)requestData["region_locy"]);
287 TheSim.regionLocZ = 0; 285 sim.regionLocZ = 0;
288 } 286 }
289 catch (FormatException) 287 catch (FormatException)
290 { 288 {
@@ -294,7 +292,7 @@ namespace OpenSim.Grid.GridServer
294 } 292 }
295 LLUUID textureID = LLUUID.Zero; 293 LLUUID textureID = LLUUID.Zero;
296 if (LLUUID.TryParse((string)requestData["map-image-id"], out textureID)) 294 if (LLUUID.TryParse((string)requestData["map-image-id"], out textureID))
297 TheSim.regionMapTextureID = textureID; 295 sim.regionMapTextureID = textureID;
298 296
299 // part of an initial brutish effort to provide accurate information (as per the xml region spec) 297 // part of an initial brutish effort to provide accurate information (as per the xml region spec)
300 // wrt the ownership of a given region 298 // wrt the ownership of a given region
@@ -304,48 +302,48 @@ namespace OpenSim.Grid.GridServer
304 // 302 //
305 // this particular section of the mod attempts to receive a value from the region's xml file by way of 303 // this particular section of the mod attempts to receive a value from the region's xml file by way of
306 // OSG1GridServices for the region's owner 304 // OSG1GridServices for the region's owner
307 TheSim.owner_uuid = (string)requestData["master_avatar_uuid"]; 305 sim.owner_uuid = (string)requestData["master_avatar_uuid"];
308 306
309 try 307 try
310 { 308 {
311 TheSim.regionRecvKey = (string)requestData["recvkey"]; 309 sim.regionRecvKey = (string)requestData["recvkey"];
312 TheSim.regionSendKey = (string)requestData["authkey"]; 310 sim.regionSendKey = (string)requestData["authkey"];
313 } 311 }
314 catch (KeyNotFoundException) { } 312 catch (KeyNotFoundException) { }
315 313
316 TheSim.regionHandle = Helpers.UIntsToLong((TheSim.regionLocX * Constants.RegionSize), (TheSim.regionLocY * Constants.RegionSize)); 314 sim.regionHandle = Helpers.UIntsToLong((sim.regionLocX * Constants.RegionSize), (sim.regionLocY * Constants.RegionSize));
317 TheSim.serverURI = (string)requestData["server_uri"]; 315 sim.serverURI = (string)requestData["server_uri"];
318 Console.WriteLine("adding region " + TheSim.regionLocX + " , " + TheSim.regionLocY + " , " + 316 Console.WriteLine("adding region " + sim.regionLocX + " , " + sim.regionLocY + " , " +
319 TheSim.serverURI); 317 sim.serverURI);
320 318
321 TheSim.httpServerURI = "http://" + TheSim.serverIP + ":" + TheSim.httpPort + "/"; 319 sim.httpServerURI = "http://" + sim.serverIP + ":" + sim.httpPort + "/";
322 320
323 TheSim.regionName = (string)requestData["sim_name"]; 321 sim.regionName = (string)requestData["sim_name"];
324 TheSim.UUID = new LLUUID((string)requestData["UUID"]); 322 sim.UUID = new LLUUID((string)requestData["UUID"]);
325 TheSim.originUUID = new LLUUID((string) requestData["originUUID"]); 323 sim.originUUID = new LLUUID((string) requestData["originUUID"]);
326 324
327 //make sure there is not an existing region at this location 325 //make sure there is not an existing region at this location
328 OldSim = getRegion(TheSim.regionHandle); 326 existingSim = getRegion(sim.regionHandle);
329 //if (OldSim == null || OldSim.UUID == TheSim.UUID) 327 //if (OldSim == null || OldSim.UUID == TheSim.UUID)
330 if (OldSim == null || OldSim.UUID == TheSim.UUID || TheSim.UUID != TheSim.originUUID) 328 if (existingSim == null || existingSim.UUID == sim.UUID || sim.UUID != sim.originUUID)
331 { 329 {
332 bool brandNew = ( OldSim == null && TheSim.regionRecvKey == config.SimSendKey && 330 bool brandNew = ( existingSim == null && sim.regionRecvKey == config.SimSendKey &&
333 TheSim.regionSendKey == config.SimRecvKey); 331 sim.regionSendKey == config.SimRecvKey);
334 332
335 bool overwritingOldOne = ( OldSim != null && OldSim.regionRecvKey == TheSim.regionRecvKey && 333 bool overwritingOldOne = ( existingSim != null && existingSim.regionRecvKey == sim.regionRecvKey &&
336 OldSim.regionSendKey == TheSim.regionSendKey ); 334 existingSim.regionSendKey == sim.regionSendKey );
337 335
338 if (brandNew) 336 if (brandNew)
339 { 337 {
340 m_log.Info("[GRID]: Adding region " + TheSim.regionLocX + " , " + TheSim.regionLocY + " , " + 338 m_log.Info("[GRID]: Adding region " + sim.regionLocX + " , " + sim.regionLocY + " , " +
341 TheSim.serverURI); 339 sim.serverURI);
342 } 340 }
343 341
344 if (overwritingOldOne) 342 if (overwritingOldOne)
345 { 343 {
346 m_log.Info("[GRID]: Overwriting region " + OldSim.regionLocX + " , " + OldSim.regionLocY + " , " + 344 m_log.Info("[GRID]: Overwriting region " + existingSim.regionLocX + " , " + existingSim.regionLocY + " , " +
347 OldSim.serverURI + " with " + TheSim.regionLocX + " , " + TheSim.regionLocY + " , " + 345 existingSim.serverURI + " with " + sim.regionLocX + " , " + sim.regionLocY + " , " +
348 TheSim.serverURI); 346 sim.serverURI);
349 } 347 }
350 348
351 if (brandNew || 349 if (brandNew ||
@@ -356,35 +354,35 @@ namespace OpenSim.Grid.GridServer
356 { 354 {
357 try 355 try
358 { 356 {
359 DataResponse insertResponse = kvp.Value.AddProfile(TheSim); 357 DataResponse insertResponse = kvp.Value.AddProfile(sim);
360 switch (insertResponse) 358 switch (insertResponse)
361 { 359 {
362 case DataResponse.RESPONSE_OK: 360 case DataResponse.RESPONSE_OK:
363 m_log.Info("[grid]: New sim " + myword + " successful: " + TheSim.regionName); 361 m_log.Info("[grid]: New sim " + myword + " successful: " + sim.regionName);
364 break; 362 break;
365 case DataResponse.RESPONSE_ERROR: 363 case DataResponse.RESPONSE_ERROR:
366 m_log.Warn("[storage]: New sim creation failed (Error): " + TheSim.regionName); 364 m_log.Warn("[storage]: New sim creation failed (Error): " + sim.regionName);
367 break; 365 break;
368 case DataResponse.RESPONSE_INVALIDCREDENTIALS: 366 case DataResponse.RESPONSE_INVALIDCREDENTIALS:
369 m_log.Warn("[storage]: " + 367 m_log.Warn("[storage]: " +
370 "New sim creation failed (Invalid Credentials): " + TheSim.regionName); 368 "New sim creation failed (Invalid Credentials): " + sim.regionName);
371 break; 369 break;
372 case DataResponse.RESPONSE_AUTHREQUIRED: 370 case DataResponse.RESPONSE_AUTHREQUIRED:
373 m_log.Warn("[storage]: " + 371 m_log.Warn("[storage]: " +
374 "New sim creation failed (Authentication Required): " + 372 "New sim creation failed (Authentication Required): " +
375 TheSim.regionName); 373 sim.regionName);
376 break; 374 break;
377 } 375 }
378 } 376 }
379 catch (Exception e) 377 catch (Exception e)
380 { 378 {
381 m_log.Warn("[storage]: " + 379 m_log.Warn("[storage]: " +
382 "Unable to add region " + TheSim.UUID.ToString() + " via " + kvp.Key); 380 "Unable to add region " + sim.UUID.ToString() + " via " + kvp.Key);
383 m_log.Warn("[storage]: " + e.ToString()); 381 m_log.Warn("[storage]: " + e.ToString());
384 } 382 }
385 383
386 384
387 if (getRegion(TheSim.regionHandle) == null) 385 if (getRegion(sim.regionHandle) == null)
388 { 386 {
389 responseData["error"] = "Unable to add new region"; 387 responseData["error"] = "Unable to add new region";
390 return response; 388 return response;
@@ -403,8 +401,8 @@ namespace OpenSim.Grid.GridServer
403 if (fastMode) 401 if (fastMode)
404 { 402 {
405 Dictionary<ulong, RegionProfileData> neighbours = 403 Dictionary<ulong, RegionProfileData> neighbours =
406 getRegions(TheSim.regionLocX - 1, TheSim.regionLocY - 1, TheSim.regionLocX + 1, 404 getRegions(sim.regionLocX - 1, sim.regionLocY - 1, sim.regionLocX + 1,
407 TheSim.regionLocY + 1); 405 sim.regionLocY + 1);
408 406
409 foreach (KeyValuePair<ulong, RegionProfileData> aSim in neighbours) 407 foreach (KeyValuePair<ulong, RegionProfileData> aSim in neighbours)
410 { 408 {
@@ -416,7 +414,7 @@ namespace OpenSim.Grid.GridServer
416 NeighbourBlock["UUID"] = aSim.Value.UUID.ToString(); 414 NeighbourBlock["UUID"] = aSim.Value.UUID.ToString();
417 NeighbourBlock["regionHandle"] = aSim.Value.regionHandle.ToString(); 415 NeighbourBlock["regionHandle"] = aSim.Value.regionHandle.ToString();
418 416
419 if (aSim.Value.UUID != TheSim.UUID) 417 if (aSim.Value.UUID != sim.UUID)
420 { 418 {
421 SimNeighboursData.Add(NeighbourBlock); 419 SimNeighboursData.Add(NeighbourBlock);
422 } 420 }
@@ -429,13 +427,13 @@ namespace OpenSim.Grid.GridServer
429 { 427 {
430 if ( 428 if (
431 getRegion( 429 getRegion(
432 Helpers.UIntsToLong((uint)((TheSim.regionLocX + x) * Constants.RegionSize), 430 Helpers.UIntsToLong((uint)((sim.regionLocX + x) * Constants.RegionSize),
433 (uint)(TheSim.regionLocY + y) * Constants.RegionSize)) != null) 431 (uint)(sim.regionLocY + y) * Constants.RegionSize)) != null)
434 { 432 {
435 neighbour = 433 neighbour =
436 getRegion( 434 getRegion(
437 Helpers.UIntsToLong((uint)((TheSim.regionLocX + x) * Constants.RegionSize), 435 Helpers.UIntsToLong((uint)((sim.regionLocX + x) * Constants.RegionSize),
438 (uint)(TheSim.regionLocY + y) * Constants.RegionSize)); 436 (uint)(sim.regionLocY + y) * Constants.RegionSize));
439 437
440 NeighbourBlock = new Hashtable(); 438 NeighbourBlock = new Hashtable();
441 NeighbourBlock["sim_ip"] = Util.GetHostFromDNS(neighbour.serverIP).ToString(); 439 NeighbourBlock["sim_ip"] = Util.GetHostFromDNS(neighbour.serverIP).ToString();
@@ -445,30 +443,30 @@ namespace OpenSim.Grid.GridServer
445 NeighbourBlock["UUID"] = neighbour.UUID.ToString(); 443 NeighbourBlock["UUID"] = neighbour.UUID.ToString();
446 NeighbourBlock["regionHandle"] = neighbour.regionHandle.ToString(); 444 NeighbourBlock["regionHandle"] = neighbour.regionHandle.ToString();
447 445
448 if (neighbour.UUID != TheSim.UUID) SimNeighboursData.Add(NeighbourBlock); 446 if (neighbour.UUID != sim.UUID) SimNeighboursData.Add(NeighbourBlock);
449 } 447 }
450 } 448 }
451 } 449 }
452 450
453 responseData["UUID"] = TheSim.UUID.ToString(); 451 responseData["UUID"] = sim.UUID.ToString();
454 responseData["region_locx"] = TheSim.regionLocX.ToString(); 452 responseData["region_locx"] = sim.regionLocX.ToString();
455 responseData["region_locy"] = TheSim.regionLocY.ToString(); 453 responseData["region_locy"] = sim.regionLocY.ToString();
456 responseData["regionname"] = TheSim.regionName; 454 responseData["regionname"] = sim.regionName;
457 responseData["estate_id"] = "1"; 455 responseData["estate_id"] = "1";
458 responseData["neighbours"] = SimNeighboursData; 456 responseData["neighbours"] = SimNeighboursData;
459 457
460 responseData["sim_ip"] = TheSim.serverIP; 458 responseData["sim_ip"] = sim.serverIP;
461 responseData["sim_port"] = TheSim.serverPort.ToString(); 459 responseData["sim_port"] = sim.serverPort.ToString();
462 responseData["asset_url"] = TheSim.regionAssetURI; 460 responseData["asset_url"] = sim.regionAssetURI;
463 responseData["asset_sendkey"] = TheSim.regionAssetSendKey; 461 responseData["asset_sendkey"] = sim.regionAssetSendKey;
464 responseData["asset_recvkey"] = TheSim.regionAssetRecvKey; 462 responseData["asset_recvkey"] = sim.regionAssetRecvKey;
465 responseData["user_url"] = TheSim.regionUserURI; 463 responseData["user_url"] = sim.regionUserURI;
466 responseData["user_sendkey"] = TheSim.regionUserSendKey; 464 responseData["user_sendkey"] = sim.regionUserSendKey;
467 responseData["user_recvkey"] = TheSim.regionUserRecvKey; 465 responseData["user_recvkey"] = sim.regionUserRecvKey;
468 responseData["authkey"] = TheSim.regionSecret; 466 responseData["authkey"] = sim.regionSecret;
469 467
470 // New! If set, use as URL to local sim storage (ie http://remotehost/region.yap) 468 // New! If set, use as URL to local sim storage (ie http://remotehost/region.yap)
471 responseData["data_uri"] = TheSim.regionDataURI; 469 responseData["data_uri"] = sim.regionDataURI;
472 470
473 responseData["allow_forceful_banlines"] = config.AllowForcefulBanlines; 471 responseData["allow_forceful_banlines"] = config.AllowForcefulBanlines;
474 472
@@ -490,17 +488,17 @@ namespace OpenSim.Grid.GridServer
490 } 488 }
491 else 489 else
492 { 490 {
493 if (OldSim == null) 491 if (existingSim == null)
494 { 492 {
495 m_log.Warn("[grid]: Authentication failed when trying to add new region " + TheSim.regionName + 493 m_log.Warn("[grid]: Authentication failed when trying to add new region " + sim.regionName +
496 " at location " + TheSim.regionLocX + 494 " at location " + sim.regionLocX +
497 " " + TheSim.regionLocY + " with TheSim.regionRecvKey " + TheSim.regionRecvKey + "(" + config.SimSendKey + ") and TheSim.regionRecvKey " + TheSim.regionSendKey + "(" + config.SimRecvKey + ") "); 495 " " + sim.regionLocY + " with TheSim.regionRecvKey " + sim.regionRecvKey + "(" + config.SimSendKey + ") and TheSim.regionRecvKey " + sim.regionSendKey + "(" + config.SimRecvKey + ") ");
498 } 496 }
499 else 497 else
500 { 498 {
501 m_log.Warn("[grid]: Authentication failed when trying to add new region " + TheSim.regionName + 499 m_log.Warn("[grid]: Authentication failed when trying to add new region " + sim.regionName +
502 " at location " + TheSim.regionLocX + 500 " at location " + sim.regionLocX +
503 " " + TheSim.regionLocY + " currently occupied by " + OldSim.regionName); 501 " " + sim.regionLocY + " currently occupied by " + existingSim.regionName);
504 } 502 }
505 503
506 responseData["error"] = 504 responseData["error"] =
@@ -510,7 +508,7 @@ namespace OpenSim.Grid.GridServer
510 } 508 }
511 else 509 else
512 { 510 {
513 m_log.Warn("[grid]: Failed to add new region " + TheSim.regionName + " at location " + TheSim.regionLocX + " " + TheSim.regionLocY + " currently occupied by " + OldSim.regionName); 511 m_log.Warn("[grid]: Failed to add new region " + sim.regionName + " at location " + sim.regionLocX + " " + sim.regionLocY + " currently occupied by " + existingSim.regionName);
514 responseData["error"] = "Another region already exists at that location. Try another"; 512 responseData["error"] = "Another region already exists at that location. Try another";
515 return response; 513 return response;
516 } 514 }