diff options
author | Adam Frisby | 2008-05-02 16:41:35 +0000 |
---|---|---|
committer | Adam Frisby | 2008-05-02 16:41:35 +0000 |
commit | cfc62d62529bfd9a961eab457cf7f31c9ef9f94c (patch) | |
tree | 356e809ff96c8c055b98ebc340343d2acf0748fd /ThirdParty/3Di/LoadBalancer/LoadBalancerPlugin.cs | |
parent | * Commit 2/3 - Please dont attempt to update to this revision until all 3 are... (diff) | |
download | opensim-SC_OLD-cfc62d62529bfd9a961eab457cf7f31c9ef9f94c.zip opensim-SC_OLD-cfc62d62529bfd9a961eab457cf7f31c9ef9f94c.tar.gz opensim-SC_OLD-cfc62d62529bfd9a961eab457cf7f31c9ef9f94c.tar.bz2 opensim-SC_OLD-cfc62d62529bfd9a961eab457cf7f31c9ef9f94c.tar.xz |
* Commit 3/3 - Please test this revision.
Diffstat (limited to 'ThirdParty/3Di/LoadBalancer/LoadBalancerPlugin.cs')
-rw-r--r-- | ThirdParty/3Di/LoadBalancer/LoadBalancerPlugin.cs | 59 |
1 files changed, 34 insertions, 25 deletions
diff --git a/ThirdParty/3Di/LoadBalancer/LoadBalancerPlugin.cs b/ThirdParty/3Di/LoadBalancer/LoadBalancerPlugin.cs index dda8be6..668b413 100644 --- a/ThirdParty/3Di/LoadBalancer/LoadBalancerPlugin.cs +++ b/ThirdParty/3Di/LoadBalancer/LoadBalancerPlugin.cs | |||
@@ -39,7 +39,9 @@ using Mono.Addins; | |||
39 | using Nwc.XmlRpc; | 39 | using Nwc.XmlRpc; |
40 | using OpenSim.Framework; | 40 | using OpenSim.Framework; |
41 | using OpenSim.Framework.Servers; | 41 | using OpenSim.Framework.Servers; |
42 | //using OpenSim.Region.ClientStack.LindenUDP; | ||
42 | using OpenSim.Region.ClientStack; | 43 | using OpenSim.Region.ClientStack; |
44 | using OpenSim.Region.ClientStack.LindenUDP; | ||
43 | using OpenSim.Region.Environment.Scenes; | 45 | using OpenSim.Region.Environment.Scenes; |
44 | 46 | ||
45 | [assembly : Addin] | 47 | [assembly : Addin] |
@@ -68,7 +70,7 @@ namespace OpenSim.ApplicationPlugins.LoadBalancer | |||
68 | private string serializeDir; | 70 | private string serializeDir; |
69 | private OpenSimMain simMain; | 71 | private OpenSimMain simMain; |
70 | private TcpClient[] tcpClientList; | 72 | private TcpClient[] tcpClientList; |
71 | private List<UDPServer> udpServers; | 73 | private List<IClientNetworkServer> m_clientServers; |
72 | 74 | ||
73 | #region IApplicationPlugin Members | 75 | #region IApplicationPlugin Members |
74 | 76 | ||
@@ -80,11 +82,13 @@ namespace OpenSim.ApplicationPlugins.LoadBalancer | |||
80 | if (proxyURL.Length == 0) return; | 82 | if (proxyURL.Length == 0) return; |
81 | 83 | ||
82 | StartTcpServer(); | 84 | StartTcpServer(); |
83 | ClientView.SynchronizeClient = new ClientView.SynchronizeClientHandler(SynchronizePackets); | 85 | // BUG: This needs to be fixed |
86 | // TODO: YARLY. | ||
87 | // LLClientView.SynchronizeClient = new LLClientView.SynchronizeClientHandler(SynchronizePackets); | ||
84 | AsynchronousSocketListener.PacketHandler = new AsynchronousSocketListener.PacketRecieveHandler(SynchronizePacketRecieve); | 88 | AsynchronousSocketListener.PacketHandler = new AsynchronousSocketListener.PacketRecieveHandler(SynchronizePacketRecieve); |
85 | 89 | ||
86 | sceneManager = openSim.SceneManager; | 90 | sceneManager = openSim.SceneManager; |
87 | udpServers = openSim.UdpServers; | 91 | m_clientServers = openSim.UdpServers; |
88 | regionData = openSim.RegionData; | 92 | regionData = openSim.RegionData; |
89 | simMain = openSim; | 93 | simMain = openSim; |
90 | commandServer = openSim.HttpServer; | 94 | commandServer = openSim.HttpServer; |
@@ -144,9 +148,9 @@ namespace OpenSim.ApplicationPlugins.LoadBalancer | |||
144 | int get_scene_presence_filter = 0; | 148 | int get_scene_presence_filter = 0; |
145 | foreach (ScenePresence pre in presences) | 149 | foreach (ScenePresence pre in presences) |
146 | { | 150 | { |
147 | ClientView client = (ClientView) pre.ControllingClient; | 151 | IClientAPI client = pre.ControllingClient; |
148 | //if(pre.MovementFlag!=0 && client.PacketProcessingEnabled==true) { | 152 | //if(pre.MovementFlag!=0 && client.PacketProcessingEnabled==true) { |
149 | if (client.PacketProcessingEnabled == true) | 153 | if (client.IsActive) |
150 | { | 154 | { |
151 | get_scene_presence_filter++; | 155 | get_scene_presence_filter++; |
152 | } | 156 | } |
@@ -157,9 +161,9 @@ namespace OpenSim.ApplicationPlugins.LoadBalancer | |||
157 | string avatar_names = ""; | 161 | string avatar_names = ""; |
158 | foreach (ScenePresence pre in avatars) | 162 | foreach (ScenePresence pre in avatars) |
159 | { | 163 | { |
160 | ClientView client = (ClientView) pre.ControllingClient; | 164 | IClientAPI client = pre.ControllingClient; |
161 | //if(pre.MovementFlag!=0 && client.PacketProcessingEnabled==true) { | 165 | //if(pre.MovementFlag!=0 && client.PacketProcessingEnabled==true) { |
162 | if (client.PacketProcessingEnabled == true) | 166 | if (client.IsActive) |
163 | { | 167 | { |
164 | get_avatar_filter++; | 168 | get_avatar_filter++; |
165 | avatar_names += pre.Firstname + " " + pre.Lastname + "; "; | 169 | avatar_names += pre.Firstname + " " + pre.Lastname + "; "; |
@@ -386,9 +390,9 @@ namespace OpenSim.ApplicationPlugins.LoadBalancer | |||
386 | return result; | 390 | return result; |
387 | } | 391 | } |
388 | 392 | ||
389 | private UDPServer SearchUDPServerFromPortNum(int portnum) | 393 | private IClientNetworkServer SearchUDPServerFromPortNum(int portnum) |
390 | { | 394 | { |
391 | return udpServers.Find(delegate(UDPServer server) { return (portnum + proxyOffset == ((IPEndPoint) server.Server.LocalEndPoint).Port); }); | 395 | return m_clientServers.Find(delegate(IClientNetworkServer server) { return (portnum + proxyOffset == ((IPEndPoint)server.Server.LocalEndPoint).Port); }); |
392 | } | 396 | } |
393 | 397 | ||
394 | private void SerializeRegion(RegionInfo src_region, string export_dir) | 398 | private void SerializeRegion(RegionInfo src_region, string export_dir) |
@@ -518,7 +522,7 @@ namespace OpenSim.ApplicationPlugins.LoadBalancer | |||
518 | Scene scene = null; | 522 | Scene scene = null; |
519 | string[] files = null; | 523 | string[] files = null; |
520 | IClientAPI controller = null; | 524 | IClientAPI controller = null; |
521 | UDPServer udpserv = null; | 525 | IClientNetworkServer udpserv = null; |
522 | 526 | ||
523 | if (sceneManager.TryGetScene(dst_region.RegionID, out scene)) | 527 | if (sceneManager.TryGetScene(dst_region.RegionID, out scene)) |
524 | { | 528 | { |
@@ -559,7 +563,12 @@ namespace OpenSim.ApplicationPlugins.LoadBalancer | |||
559 | AgentCircuitData agentdata = new AgentCircuitData(data.agentcircuit); | 563 | AgentCircuitData agentdata = new AgentCircuitData(data.agentcircuit); |
560 | scene.AuthenticateHandler.AddNewCircuit(circuit_code, agentdata); | 564 | scene.AuthenticateHandler.AddNewCircuit(circuit_code, agentdata); |
561 | 565 | ||
562 | udpserv.RestoreClient(agentdata, data.userEP, data.proxyEP); | 566 | // BUG: Will only work with LLUDPServer. |
567 | // TODO: This needs to be abstracted and converted into IClientNetworkServer | ||
568 | if (udpserv is LLUDPServer) | ||
569 | { | ||
570 | ((LLUDPServer) udpserv).RestoreClient(agentdata, data.userEP, data.proxyEP); | ||
571 | } | ||
563 | 572 | ||
564 | // waiting for the scene-presense restored | 573 | // waiting for the scene-presense restored |
565 | lock (scene.m_restorePresences) | 574 | lock (scene.m_restorePresences) |
@@ -618,12 +627,12 @@ namespace OpenSim.ApplicationPlugins.LoadBalancer | |||
618 | } | 627 | } |
619 | 628 | ||
620 | // Shutting down the UDP server | 629 | // Shutting down the UDP server |
621 | UDPServer udpsvr = SearchUDPServerFromPortNum(port); | 630 | IClientNetworkServer udpsvr = SearchUDPServerFromPortNum(port); |
622 | 631 | ||
623 | if (udpsvr != null) | 632 | if (udpsvr != null) |
624 | { | 633 | { |
625 | udpsvr.Server.Close(); | 634 | udpsvr.Server.Close(); |
626 | udpServers.Remove(udpsvr); | 635 | m_clientServers.Remove(udpsvr); |
627 | } | 636 | } |
628 | } | 637 | } |
629 | 638 | ||
@@ -655,10 +664,10 @@ namespace OpenSim.ApplicationPlugins.LoadBalancer | |||
655 | if (scene.ClientManager.TryGetClient(code, out controller)) | 664 | if (scene.ClientManager.TryGetClient(code, out controller)) |
656 | { | 665 | { |
657 | // stopping clientview thread | 666 | // stopping clientview thread |
658 | if (((ClientView) controller).PacketProcessingEnabled) | 667 | if ((controller).IsActive) |
659 | { | 668 | { |
660 | controller.Stop(); | 669 | controller.Stop(); |
661 | ((ClientView) controller).PacketProcessingEnabled = false; | 670 | (controller).IsActive = false; |
662 | } | 671 | } |
663 | // teminateing clientview thread | 672 | // teminateing clientview thread |
664 | controller.Terminate(); | 673 | controller.Terminate(); |
@@ -740,12 +749,12 @@ namespace OpenSim.ApplicationPlugins.LoadBalancer | |||
740 | if (scene.ClientManager.TryGetClient(code, out controller)) | 749 | if (scene.ClientManager.TryGetClient(code, out controller)) |
741 | { | 750 | { |
742 | // Divide the presences evenly over the set of subscenes | 751 | // Divide the presences evenly over the set of subscenes |
743 | ClientView client = (ClientView) controller; | 752 | LLClientView client = (LLClientView) controller; |
744 | client.PacketProcessingEnabled = (((i + myID) % sceneURL.Length) == 0); | 753 | client.IsActive = (((i + myID) % sceneURL.Length) == 0); |
745 | 754 | ||
746 | m_log.InfoFormat("[SPLITSCENE] === SplitRegion {0}: SP.PacketEnabled {1}", region.RegionID, client.PacketProcessingEnabled); | 755 | m_log.InfoFormat("[SPLITSCENE] === SplitRegion {0}: SP.PacketEnabled {1}", region.RegionID, client.IsActive); |
747 | 756 | ||
748 | if (!client.PacketProcessingEnabled) | 757 | if (!client.IsActive) |
749 | { | 758 | { |
750 | // stopping clientview thread | 759 | // stopping clientview thread |
751 | client.Stop(); | 760 | client.Stop(); |
@@ -798,11 +807,11 @@ namespace OpenSim.ApplicationPlugins.LoadBalancer | |||
798 | List<ScenePresence> presences = scene.GetScenePresences(); | 807 | List<ScenePresence> presences = scene.GetScenePresences(); |
799 | foreach (ScenePresence pre in presences) | 808 | foreach (ScenePresence pre in presences) |
800 | { | 809 | { |
801 | ClientView client = (ClientView) pre.ControllingClient; | 810 | LLClientView client = (LLClientView) pre.ControllingClient; |
802 | if (!client.PacketProcessingEnabled) | 811 | if (!client.IsActive) |
803 | { | 812 | { |
804 | client.Restart(); | 813 | client.Restart(); |
805 | client.PacketProcessingEnabled = true; | 814 | client.IsActive = true; |
806 | } | 815 | } |
807 | } | 816 | } |
808 | } | 817 | } |
@@ -888,12 +897,12 @@ namespace OpenSim.ApplicationPlugins.LoadBalancer | |||
888 | List<ScenePresence> presences = scene.GetScenePresences(); | 897 | List<ScenePresence> presences = scene.GetScenePresences(); |
889 | foreach (ScenePresence pre in presences) | 898 | foreach (ScenePresence pre in presences) |
890 | { | 899 | { |
891 | ClientView client = (ClientView) pre.ControllingClient; | 900 | LLClientView client = (LLClientView) pre.ControllingClient; |
892 | 901 | ||
893 | // Because data changes by the physics simulation when the client doesn't move, | 902 | // Because data changes by the physics simulation when the client doesn't move, |
894 | // if MovementFlag is false, It is necessary to synchronize. | 903 | // if MovementFlag is false, It is necessary to synchronize. |
895 | //if(pre.MovementFlag!=0 && client.PacketProcessingEnabled==true) | 904 | //if(pre.MovementFlag!=0 && client.PacketProcessingEnabled==true) |
896 | if (client.PacketProcessingEnabled == true) | 905 | if (client.IsActive == true) |
897 | { | 906 | { |
898 | //m_log.Info("[SPLITSCENE] "+String.Format("Client moving in {0} {1}", scene.RegionInfo.RegionID, pre.AbsolutePosition)); | 907 | //m_log.Info("[SPLITSCENE] "+String.Format("Client moving in {0} {1}", scene.RegionInfo.RegionID, pre.AbsolutePosition)); |
899 | 908 | ||
@@ -1016,7 +1025,7 @@ namespace OpenSim.ApplicationPlugins.LoadBalancer | |||
1016 | return; | 1025 | return; |
1017 | } | 1026 | } |
1018 | 1027 | ||
1019 | if (((ClientView) pre.ControllingClient).PacketProcessingEnabled == true) | 1028 | if (((LLClientView) pre.ControllingClient).IsActive) |
1020 | { | 1029 | { |
1021 | pre.ControllingClient.OutPacket(packet, throttlePacketType); | 1030 | pre.ControllingClient.OutPacket(packet, throttlePacketType); |
1022 | } | 1031 | } |