XmlRpcCommand refactoring
parent
12a32b0608
commit
39f340e687
|
@ -35,6 +35,7 @@ using System.Security.Cryptography;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using libsecondlife;
|
using libsecondlife;
|
||||||
using Nini.Config;
|
using Nini.Config;
|
||||||
|
using Nwc.XmlRpc;
|
||||||
|
|
||||||
using System.Runtime.Serialization;
|
using System.Runtime.Serialization;
|
||||||
using System.Runtime.Serialization.Formatters.Binary;
|
using System.Runtime.Serialization.Formatters.Binary;
|
||||||
|
@ -605,5 +606,17 @@ namespace OpenSim.Framework
|
||||||
}
|
}
|
||||||
return returnstring;
|
return returnstring;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static public XmlRpcResponse XmlRpcCommand(string url, string methodName, params object[] args)
|
||||||
|
{
|
||||||
|
return SendXmlRpcCommand(url, methodName, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
static public XmlRpcResponse SendXmlRpcCommand(string url, string methodName, object[] args)
|
||||||
|
{
|
||||||
|
XmlRpcRequest client = new XmlRpcRequest(methodName, args);
|
||||||
|
return client.Send(url, 6000);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,7 +48,7 @@ namespace OpenSim.Grid.GridServer
|
||||||
protected BaseHttpServer httpServer;
|
protected BaseHttpServer httpServer;
|
||||||
protected List<IGridPlugin> m_plugins = new List<IGridPlugin>();
|
protected List<IGridPlugin> m_plugins = new List<IGridPlugin>();
|
||||||
|
|
||||||
public BaseHttpServer
|
public BaseHttpServer HttpServer
|
||||||
{
|
{
|
||||||
get { return httpServer; }
|
get { return httpServer; }
|
||||||
}
|
}
|
||||||
|
|
|
@ -461,7 +461,7 @@ namespace OpenSim
|
||||||
{
|
{
|
||||||
// set proxy url to RegionInfo
|
// set proxy url to RegionInfo
|
||||||
regionInfo.proxyUrl = proxyUrl;
|
regionInfo.proxyUrl = proxyUrl;
|
||||||
ProxyCommand(proxyUrl, "AddPort", port, port + proxyOffset, regionInfo.ExternalHostName);
|
Util.XmlRpcCommand(proxyUrl, "AddPort", port, port + proxyOffset, regionInfo.ExternalHostName);
|
||||||
}
|
}
|
||||||
|
|
||||||
UDPServer udpServer;
|
UDPServer udpServer;
|
||||||
|
@ -618,7 +618,7 @@ namespace OpenSim
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public virtual void Shutdown()
|
public virtual void Shutdown()
|
||||||
{
|
{
|
||||||
ProxyCommand(proxyUrl, "Stop");
|
Util.XmlRpcCommand(proxyUrl, "Stop");
|
||||||
|
|
||||||
if (m_startupCommandsFile != String.Empty)
|
if (m_startupCommandsFile != String.Empty)
|
||||||
{
|
{
|
||||||
|
@ -1200,39 +1200,6 @@ namespace OpenSim
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
// TODO: remove me!! (almost same as XmlRpcCommand)
|
|
||||||
public object ProxyCommand(string url, string methodName, params object[] args)
|
|
||||||
{
|
|
||||||
if(proxyUrl.Length==0) return null;
|
|
||||||
return SendXmlRpcCommand(url, methodName, args);
|
|
||||||
}
|
|
||||||
|
|
||||||
public object XmlRpcCommand(uint port, string methodName, params object[] args)
|
|
||||||
{
|
|
||||||
return SendXmlRpcCommand("http://localhost:"+port, methodName, args);
|
|
||||||
}
|
|
||||||
|
|
||||||
public object XmlRpcCommand(string url, string methodName, params object[] args)
|
|
||||||
{
|
|
||||||
return SendXmlRpcCommand(url, methodName, args);
|
|
||||||
}
|
|
||||||
|
|
||||||
private object SendXmlRpcCommand(string url, string methodName, object[] args)
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
//MainLog.Instance.Verbose("XMLRPC", "Sending command {0} to {1}", methodName, url);
|
|
||||||
XmlRpcRequest client = new XmlRpcRequest(methodName, args);
|
|
||||||
//MainLog.Instance.Verbose("XMLRPC", client.ToString());
|
|
||||||
XmlRpcResponse response = client.Send(url, 6000);
|
|
||||||
if(!response.IsFault) return response.Value;
|
|
||||||
}
|
|
||||||
catch(Exception e)
|
|
||||||
{
|
|
||||||
m_log.ErrorFormat("XMLRPC Failed to send command {0} to {1}: {2}", methodName, url, e.Message);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get the start time and up time of Region server
|
/// Get the start time and up time of Region server
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -296,7 +296,7 @@ namespace OpenSim.ApplicationPlugins.LoadBalancer
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
simMain.ProxyCommand(src_region.proxyUrl, "BlockClientMessages", src_url, src_port + proxyOffset);
|
Util.XmlRpcCommand(src_region.proxyUrl, "BlockClientMessages", src_url, src_port + proxyOffset);
|
||||||
|
|
||||||
// serialization of origin region's data
|
// serialization of origin region's data
|
||||||
SerializeRegion(src_region, serializeDir);
|
SerializeRegion(src_region, serializeDir);
|
||||||
|
@ -313,8 +313,8 @@ namespace OpenSim.ApplicationPlugins.LoadBalancer
|
||||||
// import the source region's data
|
// import the source region's data
|
||||||
dst_region = DeserializeRegion(dst_port, true, serializeDir);
|
dst_region = DeserializeRegion(dst_port, true, serializeDir);
|
||||||
|
|
||||||
simMain.ProxyCommand(dst_region.proxyUrl, "ChangeRegion", src_port + proxyOffset, src_url, dst_port + proxyOffset, dst_url);
|
Util.XmlRpcCommand(dst_region.proxyUrl, "ChangeRegion", src_port + proxyOffset, src_url, dst_port + proxyOffset, dst_url);
|
||||||
simMain.ProxyCommand(dst_region.proxyUrl, "UnblockClientMessages", dst_url, dst_port + proxyOffset);
|
Util.XmlRpcCommand(dst_region.proxyUrl, "UnblockClientMessages", dst_url, dst_port + proxyOffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DeserializeRegion_Clone(int src_port, int dst_port, string src_url, string dst_url)
|
private void DeserializeRegion_Clone(int src_port, int dst_port, string src_url, string dst_url)
|
||||||
|
@ -331,11 +331,11 @@ namespace OpenSim.ApplicationPlugins.LoadBalancer
|
||||||
// Decide who is in charge for each section
|
// Decide who is in charge for each section
|
||||||
int[] port = new int[] { src_port, dst_port };
|
int[] port = new int[] { src_port, dst_port };
|
||||||
string[] url = new string[] { "http://" + src_url + ":" + commandServer.Port, "http://" + dst_url + ":" + commandServer.Port };
|
string[] url = new string[] { "http://" + src_url + ":" + commandServer.Port, "http://" + dst_url + ":" + commandServer.Port };
|
||||||
for(int i=0; i<2; i++) simMain.XmlRpcCommand(url[i], "SplitRegion", i, 2, port[0], port[1], url[0], url[1]);
|
for(int i=0; i<2; i++) Util.XmlRpcCommand(url[i], "SplitRegion", i, 2, port[0], port[1], url[0], url[1]);
|
||||||
|
|
||||||
// Enable the proxy
|
// Enable the proxy
|
||||||
simMain.ProxyCommand(dst_region.proxyUrl, "AddRegion", src_port + proxyOffset, src_url, dst_port + proxyOffset, dst_url);
|
Util.XmlRpcCommand(dst_region.proxyUrl, "AddRegion", src_port + proxyOffset, src_url, dst_port + proxyOffset, dst_url);
|
||||||
simMain.ProxyCommand(dst_region.proxyUrl, "UnblockClientMessages", dst_url, dst_port + proxyOffset);
|
Util.XmlRpcCommand(dst_region.proxyUrl, "UnblockClientMessages", dst_url, dst_port + proxyOffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void TerminateRegion(object param)
|
private void TerminateRegion(object param)
|
||||||
|
@ -789,7 +789,7 @@ namespace OpenSim.ApplicationPlugins.LoadBalancer
|
||||||
|
|
||||||
RegionInfo region = SearchRegionFromPortNum(src_port);
|
RegionInfo region = SearchRegionFromPortNum(src_port);
|
||||||
|
|
||||||
simMain.ProxyCommand(region.proxyUrl, "BlockClientMessages", src_url, src_port + proxyOffset);
|
Util.XmlRpcCommand(region.proxyUrl, "BlockClientMessages", src_url, src_port + proxyOffset);
|
||||||
|
|
||||||
Scene scene;
|
Scene scene;
|
||||||
if (sceneManager.TryGetScene(region.RegionID, out scene))
|
if (sceneManager.TryGetScene(region.RegionID, out scene))
|
||||||
|
@ -815,12 +815,12 @@ namespace OpenSim.ApplicationPlugins.LoadBalancer
|
||||||
for(int i=1; i<sceneURL.Length; i++)
|
for(int i=1; i<sceneURL.Length; i++)
|
||||||
{
|
{
|
||||||
string url = (sceneURL[i].Split('/')[2]).Split(':')[0]; // get URL part from EP
|
string url = (sceneURL[i].Split('/')[2]).Split(':')[0]; // get URL part from EP
|
||||||
simMain.ProxyCommand(region.proxyUrl, "DeleteRegion", regionPortList[i] + proxyOffset, url);
|
Util.XmlRpcCommand(region.proxyUrl, "DeleteRegion", regionPortList[i] + proxyOffset, url);
|
||||||
Thread.Sleep(1000);
|
Thread.Sleep(1000);
|
||||||
simMain.XmlRpcCommand(sceneURL[i], "TerminateRegion", regionPortList[i]); // TODO: need + proxyOffset?
|
Util.XmlRpcCommand(sceneURL[i], "TerminateRegion", regionPortList[i]); // TODO: need + proxyOffset?
|
||||||
}
|
}
|
||||||
|
|
||||||
simMain.ProxyCommand(region.proxyUrl, "UnblockClientMessages", src_url, src_port + proxyOffset);
|
Util.XmlRpcCommand(region.proxyUrl, "UnblockClientMessages", src_url, src_port + proxyOffset);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
@ -922,10 +922,10 @@ namespace OpenSim.ApplicationPlugins.LoadBalancer
|
||||||
// pre.Velocity.ToString(), pre.PhysicsActor.Flying);
|
// pre.Velocity.ToString(), pre.PhysicsActor.Flying);
|
||||||
|
|
||||||
|
|
||||||
simMain.XmlRpcCommand(sceneURL[i], "UpdatePhysics",
|
Util.XmlRpcCommand(sceneURL[i], "UpdatePhysics",
|
||||||
regionPortList[i], pre.UUID.GetBytes(),
|
regionPortList[i], pre.UUID.GetBytes(),
|
||||||
pre.AbsolutePosition.GetBytes(), pre.Velocity.GetBytes(),
|
pre.AbsolutePosition.GetBytes(), pre.Velocity.GetBytes(),
|
||||||
pre.PhysicsActor.Flying);
|
pre.PhysicsActor.Flying);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
byte[] buff = new byte[12+12+1];
|
byte[] buff = new byte[12+12+1];
|
||||||
|
|
Loading…
Reference in New Issue