diff options
author | Johan Berntsson | 2008-03-24 01:37:00 +0000 |
---|---|---|
committer | Johan Berntsson | 2008-03-24 01:37:00 +0000 |
commit | 39f340e6875c55927fc9dbeb51af2357c7d28c04 (patch) | |
tree | ec7bd54fd3f15abca441faa500e4275559779818 | |
parent | Added a plugin loader in GridServer (diff) | |
download | opensim-SC-39f340e6875c55927fc9dbeb51af2357c7d28c04.zip opensim-SC-39f340e6875c55927fc9dbeb51af2357c7d28c04.tar.gz opensim-SC-39f340e6875c55927fc9dbeb51af2357c7d28c04.tar.bz2 opensim-SC-39f340e6875c55927fc9dbeb51af2357c7d28c04.tar.xz |
XmlRpcCommand refactoring
-rw-r--r-- | OpenSim/Framework/Util.cs | 13 | ||||
-rw-r--r-- | OpenSim/Grid/GridServer/GridServerBase.cs | 2 | ||||
-rw-r--r-- | OpenSim/Region/Application/OpenSimMain.cs | 37 | ||||
-rw-r--r-- | ThirdParty/3Di/LoadBalancer/LoadBalancerPlugin.cs | 30 |
4 files changed, 31 insertions, 51 deletions
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs index 6c95c88..a184f89 100644 --- a/OpenSim/Framework/Util.cs +++ b/OpenSim/Framework/Util.cs | |||
@@ -35,6 +35,7 @@ using System.Security.Cryptography; | |||
35 | using System.Text; | 35 | using System.Text; |
36 | using libsecondlife; | 36 | using libsecondlife; |
37 | using Nini.Config; | 37 | using Nini.Config; |
38 | using Nwc.XmlRpc; | ||
38 | 39 | ||
39 | using System.Runtime.Serialization; | 40 | using System.Runtime.Serialization; |
40 | using System.Runtime.Serialization.Formatters.Binary; | 41 | using System.Runtime.Serialization.Formatters.Binary; |
@@ -605,5 +606,17 @@ namespace OpenSim.Framework | |||
605 | } | 606 | } |
606 | return returnstring; | 607 | return returnstring; |
607 | } | 608 | } |
609 | |||
610 | static public XmlRpcResponse XmlRpcCommand(string url, string methodName, params object[] args) | ||
611 | { | ||
612 | return SendXmlRpcCommand(url, methodName, args); | ||
613 | } | ||
614 | |||
615 | static public XmlRpcResponse SendXmlRpcCommand(string url, string methodName, object[] args) | ||
616 | { | ||
617 | XmlRpcRequest client = new XmlRpcRequest(methodName, args); | ||
618 | return client.Send(url, 6000); | ||
619 | } | ||
620 | |||
608 | } | 621 | } |
609 | } | 622 | } |
diff --git a/OpenSim/Grid/GridServer/GridServerBase.cs b/OpenSim/Grid/GridServer/GridServerBase.cs index c29924b..acefe3f 100644 --- a/OpenSim/Grid/GridServer/GridServerBase.cs +++ b/OpenSim/Grid/GridServer/GridServerBase.cs | |||
@@ -48,7 +48,7 @@ namespace OpenSim.Grid.GridServer | |||
48 | protected BaseHttpServer httpServer; | 48 | protected BaseHttpServer httpServer; |
49 | protected List<IGridPlugin> m_plugins = new List<IGridPlugin>(); | 49 | protected List<IGridPlugin> m_plugins = new List<IGridPlugin>(); |
50 | 50 | ||
51 | public BaseHttpServer | 51 | public BaseHttpServer HttpServer |
52 | { | 52 | { |
53 | get { return httpServer; } | 53 | get { return httpServer; } |
54 | } | 54 | } |
diff --git a/OpenSim/Region/Application/OpenSimMain.cs b/OpenSim/Region/Application/OpenSimMain.cs index aa5a432..35f146d 100644 --- a/OpenSim/Region/Application/OpenSimMain.cs +++ b/OpenSim/Region/Application/OpenSimMain.cs | |||
@@ -461,7 +461,7 @@ namespace OpenSim | |||
461 | { | 461 | { |
462 | // set proxy url to RegionInfo | 462 | // set proxy url to RegionInfo |
463 | regionInfo.proxyUrl = proxyUrl; | 463 | regionInfo.proxyUrl = proxyUrl; |
464 | ProxyCommand(proxyUrl, "AddPort", port, port + proxyOffset, regionInfo.ExternalHostName); | 464 | Util.XmlRpcCommand(proxyUrl, "AddPort", port, port + proxyOffset, regionInfo.ExternalHostName); |
465 | } | 465 | } |
466 | 466 | ||
467 | UDPServer udpServer; | 467 | UDPServer udpServer; |
@@ -618,7 +618,7 @@ namespace OpenSim | |||
618 | /// </summary> | 618 | /// </summary> |
619 | public virtual void Shutdown() | 619 | public virtual void Shutdown() |
620 | { | 620 | { |
621 | ProxyCommand(proxyUrl, "Stop"); | 621 | Util.XmlRpcCommand(proxyUrl, "Stop"); |
622 | 622 | ||
623 | if (m_startupCommandsFile != String.Empty) | 623 | if (m_startupCommandsFile != String.Empty) |
624 | { | 624 | { |
@@ -1200,39 +1200,6 @@ namespace OpenSim | |||
1200 | 1200 | ||
1201 | #endregion | 1201 | #endregion |
1202 | 1202 | ||
1203 | // TODO: remove me!! (almost same as XmlRpcCommand) | ||
1204 | public object ProxyCommand(string url, string methodName, params object[] args) | ||
1205 | { | ||
1206 | if(proxyUrl.Length==0) return null; | ||
1207 | return SendXmlRpcCommand(url, methodName, args); | ||
1208 | } | ||
1209 | |||
1210 | public object XmlRpcCommand(uint port, string methodName, params object[] args) | ||
1211 | { | ||
1212 | return SendXmlRpcCommand("http://localhost:"+port, methodName, args); | ||
1213 | } | ||
1214 | |||
1215 | public object XmlRpcCommand(string url, string methodName, params object[] args) | ||
1216 | { | ||
1217 | return SendXmlRpcCommand(url, methodName, args); | ||
1218 | } | ||
1219 | |||
1220 | private object SendXmlRpcCommand(string url, string methodName, object[] args) | ||
1221 | { | ||
1222 | try { | ||
1223 | //MainLog.Instance.Verbose("XMLRPC", "Sending command {0} to {1}", methodName, url); | ||
1224 | XmlRpcRequest client = new XmlRpcRequest(methodName, args); | ||
1225 | //MainLog.Instance.Verbose("XMLRPC", client.ToString()); | ||
1226 | XmlRpcResponse response = client.Send(url, 6000); | ||
1227 | if(!response.IsFault) return response.Value; | ||
1228 | } | ||
1229 | catch(Exception e) | ||
1230 | { | ||
1231 | m_log.ErrorFormat("XMLRPC Failed to send command {0} to {1}: {2}", methodName, url, e.Message); | ||
1232 | } | ||
1233 | return null; | ||
1234 | } | ||
1235 | |||
1236 | /// <summary> | 1203 | /// <summary> |
1237 | /// Get the start time and up time of Region server | 1204 | /// Get the start time and up time of Region server |
1238 | /// </summary> | 1205 | /// </summary> |
diff --git a/ThirdParty/3Di/LoadBalancer/LoadBalancerPlugin.cs b/ThirdParty/3Di/LoadBalancer/LoadBalancerPlugin.cs index 325385a..b552d62 100644 --- a/ThirdParty/3Di/LoadBalancer/LoadBalancerPlugin.cs +++ b/ThirdParty/3Di/LoadBalancer/LoadBalancerPlugin.cs | |||
@@ -296,7 +296,7 @@ namespace OpenSim.ApplicationPlugins.LoadBalancer | |||
296 | return; | 296 | return; |
297 | } | 297 | } |
298 | 298 | ||
299 | simMain.ProxyCommand(src_region.proxyUrl, "BlockClientMessages", src_url, src_port + proxyOffset); | 299 | Util.XmlRpcCommand(src_region.proxyUrl, "BlockClientMessages", src_url, src_port + proxyOffset); |
300 | 300 | ||
301 | // serialization of origin region's data | 301 | // serialization of origin region's data |
302 | SerializeRegion(src_region, serializeDir); | 302 | SerializeRegion(src_region, serializeDir); |
@@ -313,8 +313,8 @@ namespace OpenSim.ApplicationPlugins.LoadBalancer | |||
313 | // import the source region's data | 313 | // import the source region's data |
314 | dst_region = DeserializeRegion(dst_port, true, serializeDir); | 314 | dst_region = DeserializeRegion(dst_port, true, serializeDir); |
315 | 315 | ||
316 | simMain.ProxyCommand(dst_region.proxyUrl, "ChangeRegion", src_port + proxyOffset, src_url, dst_port + proxyOffset, dst_url); | 316 | Util.XmlRpcCommand(dst_region.proxyUrl, "ChangeRegion", src_port + proxyOffset, src_url, dst_port + proxyOffset, dst_url); |
317 | simMain.ProxyCommand(dst_region.proxyUrl, "UnblockClientMessages", dst_url, dst_port + proxyOffset); | 317 | Util.XmlRpcCommand(dst_region.proxyUrl, "UnblockClientMessages", dst_url, dst_port + proxyOffset); |
318 | } | 318 | } |
319 | 319 | ||
320 | private void DeserializeRegion_Clone(int src_port, int dst_port, string src_url, string dst_url) | 320 | private void DeserializeRegion_Clone(int src_port, int dst_port, string src_url, string dst_url) |
@@ -331,11 +331,11 @@ namespace OpenSim.ApplicationPlugins.LoadBalancer | |||
331 | // Decide who is in charge for each section | 331 | // Decide who is in charge for each section |
332 | int[] port = new int[] { src_port, dst_port }; | 332 | int[] port = new int[] { src_port, dst_port }; |
333 | string[] url = new string[] { "http://" + src_url + ":" + commandServer.Port, "http://" + dst_url + ":" + commandServer.Port }; | 333 | string[] url = new string[] { "http://" + src_url + ":" + commandServer.Port, "http://" + dst_url + ":" + commandServer.Port }; |
334 | for(int i=0; i<2; i++) simMain.XmlRpcCommand(url[i], "SplitRegion", i, 2, port[0], port[1], url[0], url[1]); | 334 | for(int i=0; i<2; i++) Util.XmlRpcCommand(url[i], "SplitRegion", i, 2, port[0], port[1], url[0], url[1]); |
335 | 335 | ||
336 | // Enable the proxy | 336 | // Enable the proxy |
337 | simMain.ProxyCommand(dst_region.proxyUrl, "AddRegion", src_port + proxyOffset, src_url, dst_port + proxyOffset, dst_url); | 337 | Util.XmlRpcCommand(dst_region.proxyUrl, "AddRegion", src_port + proxyOffset, src_url, dst_port + proxyOffset, dst_url); |
338 | simMain.ProxyCommand(dst_region.proxyUrl, "UnblockClientMessages", dst_url, dst_port + proxyOffset); | 338 | Util.XmlRpcCommand(dst_region.proxyUrl, "UnblockClientMessages", dst_url, dst_port + proxyOffset); |
339 | } | 339 | } |
340 | 340 | ||
341 | private void TerminateRegion(object param) | 341 | private void TerminateRegion(object param) |
@@ -758,7 +758,7 @@ namespace OpenSim.ApplicationPlugins.LoadBalancer | |||
758 | ++i; | 758 | ++i; |
759 | } | 759 | } |
760 | } | 760 | } |
761 | 761 | ||
762 | scene.splitID = myID; | 762 | scene.splitID = myID; |
763 | scene.SynchronizeScene = new Scene.SynchronizeSceneHandler(SynchronizeScenes); | 763 | scene.SynchronizeScene = new Scene.SynchronizeSceneHandler(SynchronizeScenes); |
764 | isSplit = true; | 764 | isSplit = true; |
@@ -789,7 +789,7 @@ namespace OpenSim.ApplicationPlugins.LoadBalancer | |||
789 | 789 | ||
790 | RegionInfo region = SearchRegionFromPortNum(src_port); | 790 | RegionInfo region = SearchRegionFromPortNum(src_port); |
791 | 791 | ||
792 | simMain.ProxyCommand(region.proxyUrl, "BlockClientMessages", src_url, src_port + proxyOffset); | 792 | Util.XmlRpcCommand(region.proxyUrl, "BlockClientMessages", src_url, src_port + proxyOffset); |
793 | 793 | ||
794 | Scene scene; | 794 | Scene scene; |
795 | if (sceneManager.TryGetScene(region.RegionID, out scene)) | 795 | if (sceneManager.TryGetScene(region.RegionID, out scene)) |
@@ -815,12 +815,12 @@ namespace OpenSim.ApplicationPlugins.LoadBalancer | |||
815 | for(int i=1; i<sceneURL.Length; i++) | 815 | for(int i=1; i<sceneURL.Length; i++) |
816 | { | 816 | { |
817 | string url = (sceneURL[i].Split('/')[2]).Split(':')[0]; // get URL part from EP | 817 | string url = (sceneURL[i].Split('/')[2]).Split(':')[0]; // get URL part from EP |
818 | simMain.ProxyCommand(region.proxyUrl, "DeleteRegion", regionPortList[i] + proxyOffset, url); | 818 | Util.XmlRpcCommand(region.proxyUrl, "DeleteRegion", regionPortList[i] + proxyOffset, url); |
819 | Thread.Sleep(1000); | 819 | Thread.Sleep(1000); |
820 | simMain.XmlRpcCommand(sceneURL[i], "TerminateRegion", regionPortList[i]); // TODO: need + proxyOffset? | 820 | Util.XmlRpcCommand(sceneURL[i], "TerminateRegion", regionPortList[i]); // TODO: need + proxyOffset? |
821 | } | 821 | } |
822 | 822 | ||
823 | simMain.ProxyCommand(region.proxyUrl, "UnblockClientMessages", src_url, src_port + proxyOffset); | 823 | Util.XmlRpcCommand(region.proxyUrl, "UnblockClientMessages", src_url, src_port + proxyOffset); |
824 | } | 824 | } |
825 | catch (Exception e) | 825 | catch (Exception e) |
826 | { | 826 | { |
@@ -922,10 +922,10 @@ namespace OpenSim.ApplicationPlugins.LoadBalancer | |||
922 | // pre.Velocity.ToString(), pre.PhysicsActor.Flying); | 922 | // pre.Velocity.ToString(), pre.PhysicsActor.Flying); |
923 | 923 | ||
924 | 924 | ||
925 | simMain.XmlRpcCommand(sceneURL[i], "UpdatePhysics", | 925 | Util.XmlRpcCommand(sceneURL[i], "UpdatePhysics", |
926 | regionPortList[i], pre.UUID.GetBytes(), | 926 | regionPortList[i], pre.UUID.GetBytes(), |
927 | pre.AbsolutePosition.GetBytes(), pre.Velocity.GetBytes(), | 927 | pre.AbsolutePosition.GetBytes(), pre.Velocity.GetBytes(), |
928 | pre.PhysicsActor.Flying); | 928 | pre.PhysicsActor.Flying); |
929 | 929 | ||
930 | /* | 930 | /* |
931 | byte[] buff = new byte[12+12+1]; | 931 | byte[] buff = new byte[12+12+1]; |