aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/ThirdParty/3Di/LoadBalancer/LoadBalancerPlugin.cs
diff options
context:
space:
mode:
authorAdam Frisby2008-05-01 16:41:01 +0000
committerAdam Frisby2008-05-01 16:41:01 +0000
commitfc6c4dc399587f6f920d3f0759b1bd7a8b9b4ac8 (patch)
tree90a4799fa43e3761ffbe669d1d87837933d8db53 /ThirdParty/3Di/LoadBalancer/LoadBalancerPlugin.cs
parent* Deletes my EventReader ScriptRewriter. It isn't required to rewrite the sc... (diff)
downloadopensim-SC_OLD-fc6c4dc399587f6f920d3f0759b1bd7a8b9b4ac8.zip
opensim-SC_OLD-fc6c4dc399587f6f920d3f0759b1bd7a8b9b4ac8.tar.gz
opensim-SC_OLD-fc6c4dc399587f6f920d3f0759b1bd7a8b9b4ac8.tar.bz2
opensim-SC_OLD-fc6c4dc399587f6f920d3f0759b1bd7a8b9b4ac8.tar.xz
* Cleaning code still.
Diffstat (limited to '')
-rw-r--r--ThirdParty/3Di/LoadBalancer/LoadBalancerPlugin.cs58
1 files changed, 28 insertions, 30 deletions
diff --git a/ThirdParty/3Di/LoadBalancer/LoadBalancerPlugin.cs b/ThirdParty/3Di/LoadBalancer/LoadBalancerPlugin.cs
index 6d593c9..af979a6 100644
--- a/ThirdParty/3Di/LoadBalancer/LoadBalancerPlugin.cs
+++ b/ThirdParty/3Di/LoadBalancer/LoadBalancerPlugin.cs
@@ -52,12 +52,12 @@ namespace OpenSim.ApplicationPlugins.LoadBalancer
52 public class LoadBalancerPlugin : IApplicationPlugin 52 public class LoadBalancerPlugin : IApplicationPlugin
53 { 53 {
54 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 54 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
55 private readonly object padlock = new object();
55 56
56 private BaseHttpServer commandServer; 57 private BaseHttpServer commandServer;
57 private bool[] isLocalNeighbour; 58 private bool[] isLocalNeighbour;
58 private bool isSplit = false; 59 private bool isSplit;
59 private TcpServer mTcpServer; 60 private TcpServer mTcpServer;
60 private object padlock = new object();
61 61
62 private int proxyOffset; 62 private int proxyOffset;
63 private string proxyURL; 63 private string proxyURL;
@@ -80,8 +80,8 @@ namespace OpenSim.ApplicationPlugins.LoadBalancer
80 if (proxyURL.Length == 0) return; 80 if (proxyURL.Length == 0) return;
81 81
82 StartTcpServer(); 82 StartTcpServer();
83 ClientView.SynchronizeClient = new ClientView.SynchronizeClientHandler(SynchronizePackets); 83 ClientView.SynchronizeClient = SynchronizePackets;
84 AsynchronousSocketListener.PacketHandler = new AsynchronousSocketListener.PacketRecieveHandler(SynchronizePacketRecieve); 84 AsynchronousSocketListener.PacketHandler = SynchronizePacketRecieve;
85 85
86 sceneManager = openSim.SceneManager; 86 sceneManager = openSim.SceneManager;
87 udpServers = openSim.UdpServers; 87 udpServers = openSim.UdpServers;
@@ -146,7 +146,7 @@ namespace OpenSim.ApplicationPlugins.LoadBalancer
146 { 146 {
147 ClientView client = (ClientView) pre.ControllingClient; 147 ClientView client = (ClientView) pre.ControllingClient;
148 //if(pre.MovementFlag!=0 && client.PacketProcessingEnabled==true) { 148 //if(pre.MovementFlag!=0 && client.PacketProcessingEnabled==true) {
149 if (client.PacketProcessingEnabled == true) 149 if (client.PacketProcessingEnabled)
150 { 150 {
151 get_scene_presence_filter++; 151 get_scene_presence_filter++;
152 } 152 }
@@ -159,7 +159,7 @@ namespace OpenSim.ApplicationPlugins.LoadBalancer
159 { 159 {
160 ClientView client = (ClientView) pre.ControllingClient; 160 ClientView client = (ClientView) pre.ControllingClient;
161 //if(pre.MovementFlag!=0 && client.PacketProcessingEnabled==true) { 161 //if(pre.MovementFlag!=0 && client.PacketProcessingEnabled==true) {
162 if (client.PacketProcessingEnabled == true) 162 if (client.PacketProcessingEnabled)
163 { 163 {
164 get_avatar_filter++; 164 get_avatar_filter++;
165 avatar_names += pre.Firstname + " " + pre.Lastname + "; "; 165 avatar_names += pre.Firstname + " " + pre.Lastname + "; ";
@@ -178,7 +178,7 @@ namespace OpenSim.ApplicationPlugins.LoadBalancer
178 } 178 }
179 catch (Exception e) 179 catch (Exception e)
180 { 180 {
181 m_log.Error("[BALANCER] " + e.ToString()); 181 m_log.Error("[BALANCER] " + e);
182 m_log.Error("[BALANCER] " + e.StackTrace); 182 m_log.Error("[BALANCER] " + e.StackTrace);
183 } 183 }
184 return response; 184 return response;
@@ -199,7 +199,7 @@ namespace OpenSim.ApplicationPlugins.LoadBalancer
199 } 199 }
200 catch (Exception e) 200 catch (Exception e)
201 { 201 {
202 m_log.Error("[BALANCER] " + e.ToString()); 202 m_log.Error("[BALANCER] " + e);
203 m_log.Error("[BALANCER] " + e.StackTrace); 203 m_log.Error("[BALANCER] " + e.StackTrace);
204 } 204 }
205 205
@@ -223,7 +223,7 @@ namespace OpenSim.ApplicationPlugins.LoadBalancer
223 } 223 }
224 catch (Exception e) 224 catch (Exception e)
225 { 225 {
226 m_log.Error("[BALANCER] " + e.ToString()); 226 m_log.Error("[BALANCER] " + e);
227 m_log.Error("[BALANCER] " + e.StackTrace); 227 m_log.Error("[BALANCER] " + e.StackTrace);
228 } 228 }
229 229
@@ -247,7 +247,7 @@ namespace OpenSim.ApplicationPlugins.LoadBalancer
247 } 247 }
248 catch (Exception e) 248 catch (Exception e)
249 { 249 {
250 m_log.Error("[BALANCER] " + e.ToString()); 250 m_log.Error("[BALANCER] " + e);
251 m_log.Error("[BALANCER] " + e.StackTrace); 251 m_log.Error("[BALANCER] " + e.StackTrace);
252 throw e; 252 throw e;
253 } 253 }
@@ -264,14 +264,14 @@ namespace OpenSim.ApplicationPlugins.LoadBalancer
264 int src_port = (int) request.Params[0]; 264 int src_port = (int) request.Params[0];
265 265
266 // backgroud 266 // backgroud
267 WaitCallback callback = new WaitCallback(TerminateRegion); 267 WaitCallback callback = TerminateRegion;
268 ThreadPool.QueueUserWorkItem(callback, src_port); 268 ThreadPool.QueueUserWorkItem(callback, src_port);
269 269
270 m_log.Info("[BALANCER] " + "Exiting TerminateRegion()"); 270 m_log.Info("[BALANCER] " + "Exiting TerminateRegion()");
271 } 271 }
272 catch (Exception e) 272 catch (Exception e)
273 { 273 {
274 m_log.Error("[BALANCER] " + e.ToString()); 274 m_log.Error("[BALANCER] " + e);
275 m_log.Error("[BALANCER] " + e.StackTrace); 275 m_log.Error("[BALANCER] " + e.StackTrace);
276 } 276 }
277 277
@@ -330,8 +330,8 @@ namespace OpenSim.ApplicationPlugins.LoadBalancer
330 dst_region = DeserializeRegion(dst_port, false, serializeDir); 330 dst_region = DeserializeRegion(dst_port, false, serializeDir);
331 331
332 // Decide who is in charge for each section 332 // Decide who is in charge for each section
333 int[] port = new int[] {src_port, dst_port}; 333 int[] port = new[] {src_port, dst_port};
334 string[] url = new string[] {"http://" + src_url + ":" + commandServer.Port, "http://" + dst_url + ":" + commandServer.Port}; 334 string[] url = new[] {"http://" + src_url + ":" + commandServer.Port, "http://" + dst_url + ":" + commandServer.Port};
335 for (int i = 0; i < 2; i++) Util.XmlRpcCommand(url[i], "SplitRegion", i, 2, port[0], port[1], url[0], url[1]); 335 for (int i = 0; i < 2; i++) Util.XmlRpcCommand(url[i], "SplitRegion", i, 2, port[0], port[1], url[0], url[1]);
336 336
337 // Enable the proxy 337 // Enable the proxy
@@ -424,7 +424,7 @@ namespace OpenSim.ApplicationPlugins.LoadBalancer
424 // serialization of region data 424 // serialization of region data
425 SearializableRegionInfo dst_region = new SearializableRegionInfo(src_region); 425 SearializableRegionInfo dst_region = new SearializableRegionInfo(src_region);
426 426
427 filename = export_dir + "RegionInfo_" + src_region.RegionID.ToString() + ".bin"; 427 filename = export_dir + "RegionInfo_" + src_region.RegionID + ".bin";
428 Util.SerializeToFile(filename, dst_region); 428 Util.SerializeToFile(filename, dst_region);
429 429
430 // backup current scene's entities 430 // backup current scene's entities
@@ -451,7 +451,7 @@ namespace OpenSim.ApplicationPlugins.LoadBalancer
451 { 451 {
452 ClientInfo info = controller.GetClientInfo(); 452 ClientInfo info = controller.GetClientInfo();
453 453
454 filename = export_dir + "ClientInfo-" + String.Format("{0:0000}", idx) + "_" + controller.CircuitCode.ToString() + ".bin"; 454 filename = export_dir + "ClientInfo-" + String.Format("{0:0000}", idx) + "_" + controller.CircuitCode + ".bin";
455 455
456 Util.SerializeToFile(filename, info); 456 Util.SerializeToFile(filename, info);
457 457
@@ -469,13 +469,12 @@ namespace OpenSim.ApplicationPlugins.LoadBalancer
469 469
470 private RegionInfo DeserializeRegion(int dst_port, bool move_flag, string import_dir) 470 private RegionInfo DeserializeRegion(int dst_port, bool move_flag, string import_dir)
471 { 471 {
472 string[] files = null;
473 RegionInfo dst_region = null; 472 RegionInfo dst_region = null;
474 473
475 try 474 try
476 { 475 {
477 // deserialization of region data 476 // deserialization of region data
478 files = Directory.GetFiles(import_dir, "RegionInfo_*.bin"); 477 string[] files = Directory.GetFiles(import_dir, "RegionInfo_*.bin");
479 478
480 foreach (string filename in files) 479 foreach (string filename in files)
481 { 480 {
@@ -503,7 +502,7 @@ namespace OpenSim.ApplicationPlugins.LoadBalancer
503 } 502 }
504 catch (Exception e) 503 catch (Exception e)
505 { 504 {
506 m_log.Error("[BALANCER] " + e.ToString()); 505 m_log.Error("[BALANCER] " + e);
507 m_log.Error("[BALANCER] " + e.StackTrace); 506 m_log.Error("[BALANCER] " + e.StackTrace);
508 throw e; 507 throw e;
509 } 508 }
@@ -593,7 +592,7 @@ namespace OpenSim.ApplicationPlugins.LoadBalancer
593 592
594 // change RegionInfo (memory only) 593 // change RegionInfo (memory only)
595 dst_region.InternalEndPoint.Port = dst_port; 594 dst_region.InternalEndPoint.Port = dst_port;
596 dst_region.ExternalHostName = proxyURL.Split(new char[] {'/', ':'})[3]; 595 dst_region.ExternalHostName = proxyURL.Split(new[] {'/', ':'})[3];
597 596
598 // Create new region 597 // Create new region
599 simMain.CreateRegion(dst_region, false); 598 simMain.CreateRegion(dst_region, false);
@@ -695,7 +694,7 @@ namespace OpenSim.ApplicationPlugins.LoadBalancer
695 694
696 for (int i = 0; i < numRegions; i++) 695 for (int i = 0; i < numRegions; i++)
697 { 696 {
698 hostname = sceneURL[i].Split(new char[] {'/', ':'})[3]; 697 hostname = sceneURL[i].Split(new[] {'/', ':'})[3];
699 m_log.InfoFormat("[SPLITSCENE] " + "creating tcp client host:{0}", hostname); 698 m_log.InfoFormat("[SPLITSCENE] " + "creating tcp client host:{0}", hostname);
700 tcpClientList[i] = new TcpClient(hostname, 10001); 699 tcpClientList[i] = new TcpClient(hostname, 10001);
701 } 700 }
@@ -731,12 +730,11 @@ namespace OpenSim.ApplicationPlugins.LoadBalancer
731 List<uint> circuits = scene.ClientManager.GetAllCircuitCodes(); 730 List<uint> circuits = scene.ClientManager.GetAllCircuitCodes();
732 circuits.Sort(); 731 circuits.Sort();
733 732
734 IClientAPI controller = null;
735
736 foreach (uint code in circuits) 733 foreach (uint code in circuits)
737 { 734 {
738 m_log.InfoFormat("[BALANCER] " + "circuit code : {0}", code); 735 m_log.InfoFormat("[BALANCER] " + "circuit code : {0}", code);
739 736
737 IClientAPI controller;
740 if (scene.ClientManager.TryGetClient(code, out controller)) 738 if (scene.ClientManager.TryGetClient(code, out controller))
741 { 739 {
742 // Divide the presences evenly over the set of subscenes 740 // Divide the presences evenly over the set of subscenes
@@ -756,7 +754,7 @@ namespace OpenSim.ApplicationPlugins.LoadBalancer
756 } 754 }
757 755
758 scene.splitID = myID; 756 scene.splitID = myID;
759 scene.SynchronizeScene = new Scene.SynchronizeSceneHandler(SynchronizeScenes); 757 scene.SynchronizeScene = SynchronizeScenes;
760 isSplit = true; 758 isSplit = true;
761 } 759 }
762 else 760 else
@@ -766,7 +764,7 @@ namespace OpenSim.ApplicationPlugins.LoadBalancer
766 } 764 }
767 catch (Exception e) 765 catch (Exception e)
768 { 766 {
769 m_log.Error("[SPLITSCENE] " + e.ToString()); 767 m_log.Error("[SPLITSCENE] " + e);
770 m_log.Error("[SPLITSCENE] " + e.StackTrace); 768 m_log.Error("[SPLITSCENE] " + e.StackTrace);
771 } 769 }
772 770
@@ -820,7 +818,7 @@ namespace OpenSim.ApplicationPlugins.LoadBalancer
820 } 818 }
821 catch (Exception e) 819 catch (Exception e)
822 { 820 {
823 m_log.Error("[BALANCER] " + e.ToString()); 821 m_log.Error("[BALANCER] " + e);
824 m_log.Error("[BALANCER] " + e.StackTrace); 822 m_log.Error("[BALANCER] " + e.StackTrace);
825 throw e; 823 throw e;
826 } 824 }
@@ -893,7 +891,7 @@ namespace OpenSim.ApplicationPlugins.LoadBalancer
893 // Because data changes by the physics simulation when the client doesn't move, 891 // Because data changes by the physics simulation when the client doesn't move,
894 // if MovementFlag is false, It is necessary to synchronize. 892 // if MovementFlag is false, It is necessary to synchronize.
895 //if(pre.MovementFlag!=0 && client.PacketProcessingEnabled==true) 893 //if(pre.MovementFlag!=0 && client.PacketProcessingEnabled==true)
896 if (client.PacketProcessingEnabled == true) 894 if (client.PacketProcessingEnabled)
897 { 895 {
898 //m_log.Info("[SPLITSCENE] "+String.Format("Client moving in {0} {1}", scene.RegionInfo.RegionID, pre.AbsolutePosition)); 896 //m_log.Info("[SPLITSCENE] "+String.Format("Client moving in {0} {1}", scene.RegionInfo.RegionID, pre.AbsolutePosition));
899 897
@@ -1016,7 +1014,7 @@ namespace OpenSim.ApplicationPlugins.LoadBalancer
1016 return; 1014 return;
1017 } 1015 }
1018 1016
1019 if (((ClientView) pre.ControllingClient).PacketProcessingEnabled == true) 1017 if (((ClientView) pre.ControllingClient).PacketProcessingEnabled)
1020 { 1018 {
1021 pre.ControllingClient.OutPacket(packet, throttlePacketType); 1019 pre.ControllingClient.OutPacket(packet, throttlePacketType);
1022 } 1020 }
@@ -1060,7 +1058,7 @@ namespace OpenSim.ApplicationPlugins.LoadBalancer
1060 } 1058 }
1061 catch (Exception e) 1059 catch (Exception e)
1062 { 1060 {
1063 m_log.Error("[SPLITSCENE] " + e.ToString()); 1061 m_log.Error("[SPLITSCENE] " + e);
1064 m_log.Error("[SPLITSCENE] " + e.StackTrace); 1062 m_log.Error("[SPLITSCENE] " + e.StackTrace);
1065 } 1063 }
1066 1064
@@ -1072,7 +1070,7 @@ namespace OpenSim.ApplicationPlugins.LoadBalancer
1072 LLUUID scenePresenceID = new LLUUID(header.agent_id); 1070 LLUUID scenePresenceID = new LLUUID(header.agent_id);
1073 LLVector3 position = new LLVector3(buff, 0); 1071 LLVector3 position = new LLVector3(buff, 0);
1074 LLVector3 velocity = new LLVector3(buff, 12); 1072 LLVector3 velocity = new LLVector3(buff, 12);
1075 bool flying = ((buff[24] == (byte) 1) ? true : false); 1073 bool flying = ((buff[24] == 1) ? true : false);
1076 1074
1077 LocalUpdatePhysics(regionPort, scenePresenceID, position, velocity, flying); 1075 LocalUpdatePhysics(regionPort, scenePresenceID, position, velocity, flying);
1078 1076