diff options
author | Adam Frisby | 2008-05-01 18:04:42 +0000 |
---|---|---|
committer | Adam Frisby | 2008-05-01 18:04:42 +0000 |
commit | 20a9bf08f51351e1e0a9de94f184ff56cd572665 (patch) | |
tree | 52da64dab26353b903c8e4befed0178fa72a188b /ThirdParty/3Di/LoadBalancer/LoadBalancerPlugin.cs | |
parent | More config cleanup in LaunchSLClient. (diff) | |
download | opensim-SC_OLD-20a9bf08f51351e1e0a9de94f184ff56cd572665.zip opensim-SC_OLD-20a9bf08f51351e1e0a9de94f184ff56cd572665.tar.gz opensim-SC_OLD-20a9bf08f51351e1e0a9de94f184ff56cd572665.tar.bz2 opensim-SC_OLD-20a9bf08f51351e1e0a9de94f184ff56cd572665.tar.xz |
* Rolled back a few changes.
Diffstat (limited to '')
-rw-r--r-- | ThirdParty/3Di/LoadBalancer/LoadBalancerPlugin.cs | 60 |
1 files changed, 31 insertions, 29 deletions
diff --git a/ThirdParty/3Di/LoadBalancer/LoadBalancerPlugin.cs b/ThirdParty/3Di/LoadBalancer/LoadBalancerPlugin.cs index af979a6..dda8be6 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(); | ||
56 | 55 | ||
57 | private BaseHttpServer commandServer; | 56 | private BaseHttpServer commandServer; |
58 | private bool[] isLocalNeighbour; | 57 | private bool[] isLocalNeighbour; |
59 | private bool isSplit; | 58 | private bool isSplit = false; |
60 | private TcpServer mTcpServer; | 59 | 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 = SynchronizePackets; | 83 | ClientView.SynchronizeClient = new ClientView.SynchronizeClientHandler(SynchronizePackets); |
84 | AsynchronousSocketListener.PacketHandler = SynchronizePacketRecieve; | 84 | AsynchronousSocketListener.PacketHandler = new AsynchronousSocketListener.PacketRecieveHandler(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) | 149 | if (client.PacketProcessingEnabled == true) |
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) | 162 | if (client.PacketProcessingEnabled == true) |
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); | 181 | m_log.Error("[BALANCER] " + e.ToString()); |
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); | 202 | m_log.Error("[BALANCER] " + e.ToString()); |
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); | 226 | m_log.Error("[BALANCER] " + e.ToString()); |
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); | 250 | m_log.Error("[BALANCER] " + e.ToString()); |
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 = TerminateRegion; | 267 | WaitCallback callback = new WaitCallback(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); | 274 | m_log.Error("[BALANCER] " + e.ToString()); |
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[] {src_port, dst_port}; | 333 | int[] port = new int[] {src_port, dst_port}; |
334 | string[] url = new[] {"http://" + src_url + ":" + commandServer.Port, "http://" + dst_url + ":" + commandServer.Port}; | 334 | string[] url = new string[] {"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 + ".bin"; | 427 | filename = export_dir + "RegionInfo_" + src_region.RegionID.ToString() + ".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 + ".bin"; | 454 | filename = export_dir + "ClientInfo-" + String.Format("{0:0000}", idx) + "_" + controller.CircuitCode.ToString() + ".bin"; |
455 | 455 | ||
456 | Util.SerializeToFile(filename, info); | 456 | Util.SerializeToFile(filename, info); |
457 | 457 | ||
@@ -469,12 +469,13 @@ 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; | ||
472 | RegionInfo dst_region = null; | 473 | RegionInfo dst_region = null; |
473 | 474 | ||
474 | try | 475 | try |
475 | { | 476 | { |
476 | // deserialization of region data | 477 | // deserialization of region data |
477 | string[] files = Directory.GetFiles(import_dir, "RegionInfo_*.bin"); | 478 | files = Directory.GetFiles(import_dir, "RegionInfo_*.bin"); |
478 | 479 | ||
479 | foreach (string filename in files) | 480 | foreach (string filename in files) |
480 | { | 481 | { |
@@ -502,7 +503,7 @@ namespace OpenSim.ApplicationPlugins.LoadBalancer | |||
502 | } | 503 | } |
503 | catch (Exception e) | 504 | catch (Exception e) |
504 | { | 505 | { |
505 | m_log.Error("[BALANCER] " + e); | 506 | m_log.Error("[BALANCER] " + e.ToString()); |
506 | m_log.Error("[BALANCER] " + e.StackTrace); | 507 | m_log.Error("[BALANCER] " + e.StackTrace); |
507 | throw e; | 508 | throw e; |
508 | } | 509 | } |
@@ -592,7 +593,7 @@ namespace OpenSim.ApplicationPlugins.LoadBalancer | |||
592 | 593 | ||
593 | // change RegionInfo (memory only) | 594 | // change RegionInfo (memory only) |
594 | dst_region.InternalEndPoint.Port = dst_port; | 595 | dst_region.InternalEndPoint.Port = dst_port; |
595 | dst_region.ExternalHostName = proxyURL.Split(new[] {'/', ':'})[3]; | 596 | dst_region.ExternalHostName = proxyURL.Split(new char[] {'/', ':'})[3]; |
596 | 597 | ||
597 | // Create new region | 598 | // Create new region |
598 | simMain.CreateRegion(dst_region, false); | 599 | simMain.CreateRegion(dst_region, false); |
@@ -694,7 +695,7 @@ namespace OpenSim.ApplicationPlugins.LoadBalancer | |||
694 | 695 | ||
695 | for (int i = 0; i < numRegions; i++) | 696 | for (int i = 0; i < numRegions; i++) |
696 | { | 697 | { |
697 | hostname = sceneURL[i].Split(new[] {'/', ':'})[3]; | 698 | hostname = sceneURL[i].Split(new char[] {'/', ':'})[3]; |
698 | m_log.InfoFormat("[SPLITSCENE] " + "creating tcp client host:{0}", hostname); | 699 | m_log.InfoFormat("[SPLITSCENE] " + "creating tcp client host:{0}", hostname); |
699 | tcpClientList[i] = new TcpClient(hostname, 10001); | 700 | tcpClientList[i] = new TcpClient(hostname, 10001); |
700 | } | 701 | } |
@@ -730,11 +731,12 @@ namespace OpenSim.ApplicationPlugins.LoadBalancer | |||
730 | List<uint> circuits = scene.ClientManager.GetAllCircuitCodes(); | 731 | List<uint> circuits = scene.ClientManager.GetAllCircuitCodes(); |
731 | circuits.Sort(); | 732 | circuits.Sort(); |
732 | 733 | ||
734 | IClientAPI controller = null; | ||
735 | |||
733 | foreach (uint code in circuits) | 736 | foreach (uint code in circuits) |
734 | { | 737 | { |
735 | m_log.InfoFormat("[BALANCER] " + "circuit code : {0}", code); | 738 | m_log.InfoFormat("[BALANCER] " + "circuit code : {0}", code); |
736 | 739 | ||
737 | IClientAPI controller; | ||
738 | if (scene.ClientManager.TryGetClient(code, out controller)) | 740 | if (scene.ClientManager.TryGetClient(code, out controller)) |
739 | { | 741 | { |
740 | // Divide the presences evenly over the set of subscenes | 742 | // Divide the presences evenly over the set of subscenes |
@@ -754,7 +756,7 @@ namespace OpenSim.ApplicationPlugins.LoadBalancer | |||
754 | } | 756 | } |
755 | 757 | ||
756 | scene.splitID = myID; | 758 | scene.splitID = myID; |
757 | scene.SynchronizeScene = SynchronizeScenes; | 759 | scene.SynchronizeScene = new Scene.SynchronizeSceneHandler(SynchronizeScenes); |
758 | isSplit = true; | 760 | isSplit = true; |
759 | } | 761 | } |
760 | else | 762 | else |
@@ -764,7 +766,7 @@ namespace OpenSim.ApplicationPlugins.LoadBalancer | |||
764 | } | 766 | } |
765 | catch (Exception e) | 767 | catch (Exception e) |
766 | { | 768 | { |
767 | m_log.Error("[SPLITSCENE] " + e); | 769 | m_log.Error("[SPLITSCENE] " + e.ToString()); |
768 | m_log.Error("[SPLITSCENE] " + e.StackTrace); | 770 | m_log.Error("[SPLITSCENE] " + e.StackTrace); |
769 | } | 771 | } |
770 | 772 | ||
@@ -818,7 +820,7 @@ namespace OpenSim.ApplicationPlugins.LoadBalancer | |||
818 | } | 820 | } |
819 | catch (Exception e) | 821 | catch (Exception e) |
820 | { | 822 | { |
821 | m_log.Error("[BALANCER] " + e); | 823 | m_log.Error("[BALANCER] " + e.ToString()); |
822 | m_log.Error("[BALANCER] " + e.StackTrace); | 824 | m_log.Error("[BALANCER] " + e.StackTrace); |
823 | throw e; | 825 | throw e; |
824 | } | 826 | } |
@@ -891,7 +893,7 @@ namespace OpenSim.ApplicationPlugins.LoadBalancer | |||
891 | // Because data changes by the physics simulation when the client doesn't move, | 893 | // Because data changes by the physics simulation when the client doesn't move, |
892 | // if MovementFlag is false, It is necessary to synchronize. | 894 | // if MovementFlag is false, It is necessary to synchronize. |
893 | //if(pre.MovementFlag!=0 && client.PacketProcessingEnabled==true) | 895 | //if(pre.MovementFlag!=0 && client.PacketProcessingEnabled==true) |
894 | if (client.PacketProcessingEnabled) | 896 | if (client.PacketProcessingEnabled == true) |
895 | { | 897 | { |
896 | //m_log.Info("[SPLITSCENE] "+String.Format("Client moving in {0} {1}", scene.RegionInfo.RegionID, pre.AbsolutePosition)); | 898 | //m_log.Info("[SPLITSCENE] "+String.Format("Client moving in {0} {1}", scene.RegionInfo.RegionID, pre.AbsolutePosition)); |
897 | 899 | ||
@@ -1014,7 +1016,7 @@ namespace OpenSim.ApplicationPlugins.LoadBalancer | |||
1014 | return; | 1016 | return; |
1015 | } | 1017 | } |
1016 | 1018 | ||
1017 | if (((ClientView) pre.ControllingClient).PacketProcessingEnabled) | 1019 | if (((ClientView) pre.ControllingClient).PacketProcessingEnabled == true) |
1018 | { | 1020 | { |
1019 | pre.ControllingClient.OutPacket(packet, throttlePacketType); | 1021 | pre.ControllingClient.OutPacket(packet, throttlePacketType); |
1020 | } | 1022 | } |
@@ -1058,7 +1060,7 @@ namespace OpenSim.ApplicationPlugins.LoadBalancer | |||
1058 | } | 1060 | } |
1059 | catch (Exception e) | 1061 | catch (Exception e) |
1060 | { | 1062 | { |
1061 | m_log.Error("[SPLITSCENE] " + e); | 1063 | m_log.Error("[SPLITSCENE] " + e.ToString()); |
1062 | m_log.Error("[SPLITSCENE] " + e.StackTrace); | 1064 | m_log.Error("[SPLITSCENE] " + e.StackTrace); |
1063 | } | 1065 | } |
1064 | 1066 | ||
@@ -1070,7 +1072,7 @@ namespace OpenSim.ApplicationPlugins.LoadBalancer | |||
1070 | LLUUID scenePresenceID = new LLUUID(header.agent_id); | 1072 | LLUUID scenePresenceID = new LLUUID(header.agent_id); |
1071 | LLVector3 position = new LLVector3(buff, 0); | 1073 | LLVector3 position = new LLVector3(buff, 0); |
1072 | LLVector3 velocity = new LLVector3(buff, 12); | 1074 | LLVector3 velocity = new LLVector3(buff, 12); |
1073 | bool flying = ((buff[24] == 1) ? true : false); | 1075 | bool flying = ((buff[24] == (byte) 1) ? true : false); |
1074 | 1076 | ||
1075 | LocalUpdatePhysics(regionPort, scenePresenceID, position, velocity, flying); | 1077 | LocalUpdatePhysics(regionPort, scenePresenceID, position, velocity, flying); |
1076 | 1078 | ||
@@ -1084,4 +1086,4 @@ namespace OpenSim.ApplicationPlugins.LoadBalancer | |||
1084 | // m_log.Info("[SPLITSCENE] "+"exiting SynchronizePacketRecieve"); | 1086 | // m_log.Info("[SPLITSCENE] "+"exiting SynchronizePacketRecieve"); |
1085 | } | 1087 | } |
1086 | } | 1088 | } |
1087 | } \ No newline at end of file | 1089 | } |