* Rex merges, Grid Server

afrisby-3
Adam Frisby 2008-02-23 02:44:32 +00:00
parent f55bba8019
commit 79cb89f406
4 changed files with 1360 additions and 1293 deletions

View File

@ -38,13 +38,15 @@ namespace OpenGrid.Config.GridConfigDb4o
/// </summary>
public class Db40ConfigPlugin: IGridConfig
{
private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
/// <summary>
/// Loads and returns a configuration objeect
/// </summary>
/// <returns>A grid configuration object</returns>
public GridConfig GetConfigObject()
{
MainLog.Instance.Verbose("DBGRIDCONFIG", "Loading Db40Config dll");
m_log.Info("[DBGRIDCONFIG]: Loading Db40Config dll");
return new DbGridConfig();
}
}
@ -64,24 +66,24 @@ namespace OpenGrid.Config.GridConfigDb4o
/// </summary>
public void LoadDefaults()
{
MainLog.Instance.Notice("DbGridConfig.cs:LoadDefaults() - Please press enter to retain default or enter new settings");
MainConsole.Instance.Info("DbGridConfig.cs:LoadDefaults() - Please press enter to retain default or enter new settings");
// About the grid options
this.GridOwner = MainLog.Instance.CmdPrompt("Grid owner", "OGS development team");
this.GridOwner = MainConsole.Instance.CmdPrompt("Grid owner", "OGS development team");
// Asset Options
this.DefaultAssetServer = MainLog.Instance.CmdPrompt("Default asset server","http://127.0.0.1:" + AssetConfig.DefaultHttpPort.ToString() + "/");
this.AssetSendKey = MainLog.Instance.CmdPrompt("Key to send to asset server","null");
this.AssetRecvKey = MainLog.Instance.CmdPrompt("Key to expect from asset server","null");
this.DefaultAssetServer = MainConsole.Instance.CmdPrompt("Default asset server","http://127.0.0.1:" + AssetConfig.DefaultHttpPort.ToString() + "/");
this.AssetSendKey = MainConsole.Instance.CmdPrompt("Key to send to asset server","null");
this.AssetRecvKey = MainConsole.Instance.CmdPrompt("Key to expect from asset server","null");
// User Server Options
this.DefaultUserServer = MainLog.Instance.CmdPrompt("Default user server","http://127.0.0.1:" + UserConfig.DefaultHttpPort.ToString() + "/");
this.UserSendKey = MainLog.Instance.CmdPrompt("Key to send to user server","null");
this.UserRecvKey = MainLog.Instance.CmdPrompt("Key to expect from user server","null");
this.DefaultUserServer = MainConsole.Instance.CmdPrompt("Default user server","http://127.0.0.1:" + UserConfig.DefaultHttpPort.ToString() + "/");
this.UserSendKey = MainConsole.Instance.CmdPrompt("Key to send to user server","null");
this.UserRecvKey = MainConsole.Instance.CmdPrompt("Key to expect from user server","null");
// Region Server Options
this.SimSendKey = MainLog.Instance.CmdPrompt("Key to send to sims","null");
this.SimRecvKey = MainLog.Instance.CmdPrompt("Key to expect from sims","null");
this.SimSendKey = MainConsole.Instance.CmdPrompt("Key to send to sims","null");
this.SimRecvKey = MainConsole.Instance.CmdPrompt("Key to expect from sims","null");
}
/// <summary>
@ -99,7 +101,7 @@ namespace OpenGrid.Config.GridConfigDb4o
// Found?
if (result.Count==1)
{
MainLog.Instance.Verbose("DBGRIDCONFIG", "Found a GridConfig object in the local database, loading");
m_log.Info("[DBGRIDCONFIG]: Found a GridConfig object in the local database, loading");
foreach (DbGridConfig cfg in result)
{
// Import each setting into this class
@ -121,13 +123,13 @@ namespace OpenGrid.Config.GridConfigDb4o
}
else
{
MainLog.Instance.Verbose("DBGRIDCONFIG", "Could not find object in database, loading precompiled defaults");
m_log.Info("[DBGRIDCONFIG]: Could not find object in database, loading precompiled defaults");
// Load default settings into this class
LoadDefaults();
// Saves to the database file...
MainLog.Instance.Verbose("DBGRIDCONFIG", "Writing out default settings to local database");
m_log.Info("[DBGRIDCONFIG]: Writing out default settings to local database");
db.Set(this);
// Closes file locks
@ -136,27 +138,27 @@ namespace OpenGrid.Config.GridConfigDb4o
}
catch(Exception e)
{
MainLog.Instance.Warn("DbGridConfig.cs:InitConfig() - Exception occured");
MainLog.Instance.Warn(e.ToString());
m_log.Warn("DbGridConfig.cs:InitConfig() - Exception occured");
m_log.Warn(e.ToString());
}
// Grid Settings
MainLog.Instance.Verbose("DBGRIDCONFIG", "Grid settings loaded:");
MainLog.Instance.Verbose("DBGRIDCONFIG", "Grid owner: " + this.GridOwner);
m_log.Info("[DBGRIDCONFIG]: Grid settings loaded:");
m_log.Info("[DBGRIDCONFIG]: Grid owner: " + this.GridOwner);
// Asset Settings
MainLog.Instance.Verbose("DBGRIDCONFIG", "Default asset server: " + this.DefaultAssetServer);
MainLog.Instance.Verbose("DBGRIDCONFIG", "Key to send to asset server: " + this.AssetSendKey);
MainLog.Instance.Verbose("DBGRIDCONFIG", "Key to expect from asset server: " + this.AssetRecvKey);
m_log.Info("[DBGRIDCONFIG]: Default asset server: " + this.DefaultAssetServer);
m_log.Info("[DBGRIDCONFIG]: Key to send to asset server: " + this.AssetSendKey);
m_log.Info("[DBGRIDCONFIG]: Key to expect from asset server: " + this.AssetRecvKey);
// User Settings
MainLog.Instance.Verbose("DBGRIDCONFIG", "Default user server: " + this.DefaultUserServer);
MainLog.Instance.Verbose("DBGRIDCONFIG", "Key to send to user server: " + this.UserSendKey);
MainLog.Instance.Verbose("DBGRIDCONFIG", "Key to expect from user server: " + this.UserRecvKey);
m_log.Info("[DBGRIDCONFIG]: Default user server: " + this.DefaultUserServer);
m_log.Info("[DBGRIDCONFIG]: Key to send to user server: " + this.UserSendKey);
m_log.Info("[DBGRIDCONFIG]: Key to expect from user server: " + this.UserRecvKey);
// Region Settings
MainLog.Instance.Verbose("DBGRIDCONFIG", "Key to send to sims: " + this.SimSendKey);
MainLog.Instance.Verbose("DBGRIDCONFIG", "Key to expect from sims: " + this.SimRecvKey);
m_log.Info("[DBGRIDCONFIG]: Key to send to sims: " + this.SimSendKey);
m_log.Info("[DBGRIDCONFIG]: Key to expect from sims: " + this.SimRecvKey);
}
/// <summary>

View File

@ -38,11 +38,12 @@ using OpenSim.Framework.Console;
using OpenSim.Framework.Data;
using OpenSim.Framework.Servers;
namespace OpenSim.Grid.GridServer
{
internal class GridManager
{
private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
private Dictionary<string, IGridData> _plugins = new Dictionary<string, IGridData>();
private Dictionary<string, ILogData> _logplugins = new Dictionary<string, ILogData>();
@ -57,10 +58,10 @@ namespace OpenSim.Grid.GridServer
/// <param name="FileName">The filename to the grid server plugin DLL</param>
public void AddPlugin(string FileName)
{
MainLog.Instance.Verbose("DATA", "Attempting to load " + FileName);
m_log.Info("[DATA]: Attempting to load " + FileName);
Assembly pluginAssembly = Assembly.LoadFrom(FileName);
MainLog.Instance.Verbose("DATA", "Found " + pluginAssembly.GetTypes().Length + " interfaces.");
m_log.Info("[DATA]: Found " + pluginAssembly.GetTypes().Length + " interfaces.");
foreach (Type pluginType in pluginAssembly.GetTypes())
{
if (!pluginType.IsAbstract)
@ -74,7 +75,7 @@ namespace OpenSim.Grid.GridServer
(IGridData) Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
plug.Initialise();
_plugins.Add(plug.getName(), plug);
MainLog.Instance.Verbose("DATA", "Added IGridData Interface");
m_log.Info("[DATA]: Added IGridData Interface");
}
typeInterface = null;
@ -88,7 +89,7 @@ namespace OpenSim.Grid.GridServer
(ILogData) Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
plug.Initialise();
_logplugins.Add(plug.getName(), plug);
MainLog.Instance.Verbose("DATA", "Added ILogData Interface");
m_log.Info("[DATA]: Added ILogData Interface");
}
typeInterface = null;
@ -116,7 +117,7 @@ namespace OpenSim.Grid.GridServer
}
catch (Exception)
{
MainLog.Instance.Warn("storage", "Unable to write log via " + kvp.Key);
m_log.Warn("[storage]: Unable to write log via " + kvp.Key);
}
}
}
@ -136,7 +137,7 @@ namespace OpenSim.Grid.GridServer
}
catch (Exception e)
{
MainLog.Instance.Warn("storage", "getRegion - " + e.Message);
m_log.Warn("[storage]: getRegion - " + e.Message);
}
}
return null;
@ -157,7 +158,7 @@ namespace OpenSim.Grid.GridServer
}
catch
{
MainLog.Instance.Warn("storage", "Unable to find region " + handle.ToString() + " via " + kvp.Key);
m_log.Warn("[storage]: Unable to find region " + handle.ToString() + " via " + kvp.Key);
}
}
return null;
@ -179,7 +180,7 @@ namespace OpenSim.Grid.GridServer
}
catch
{
MainLog.Instance.Warn("storage", "Unable to query regionblock via " + kvp.Key);
m_log.Warn("[storage]: Unable to query regionblock via " + kvp.Key);
}
}
@ -194,7 +195,7 @@ namespace OpenSim.Grid.GridServer
/// <returns>An XML string containing neighbour entities</returns>
public string GetXMLNeighbours(ulong reqhandle)
{
string response = "";
string response = String.Empty;
RegionProfileData central_region = getRegion(reqhandle);
RegionProfileData neighbour;
for (int x = -1; x < 2; x++)
@ -202,13 +203,13 @@ namespace OpenSim.Grid.GridServer
{
if (
getRegion(
Util.UIntsToLong((uint) ((central_region.regionLocX + x)*256),
(uint) (central_region.regionLocY + y)*256)) != null)
Util.UIntsToLong((uint)((central_region.regionLocX + x) * Constants.RegionSize),
(uint)(central_region.regionLocY + y) * Constants.RegionSize)) != null)
{
neighbour =
getRegion(
Util.UIntsToLong((uint) ((central_region.regionLocX + x)*256),
(uint) (central_region.regionLocY + y)*256));
Util.UIntsToLong((uint)((central_region.regionLocX + x) * Constants.RegionSize),
(uint)(central_region.regionLocY + y) * Constants.RegionSize));
response += "<neighbour>";
response += "<sim_ip>" + neighbour.serverIP + "</sim_ip>";
response += "<sim_port>" + neighbour.serverPort.ToString() + "</sim_port>";
@ -241,22 +242,18 @@ namespace OpenSim.Grid.GridServer
{
TheSim = getRegion(new LLUUID((string)requestData["UUID"]));
// logToDB((new LLUUID((string)requestData["UUID"])).ToString(),"XmlRpcSimulatorLoginMethod","", 5,"Region attempting login with UUID.");
}
else if (requestData.ContainsKey("region_handle"))
{
// TheSim = getRegion((ulong)Convert.ToUInt64(requestData["region_handle"]));
// logToDB((string)requestData["region_handle"], "XmlRpcSimulatorLoginMethod", "", 5, "Region attempting login with regionHandle.");
// logToDB((new LLUUID((string)requestData["UUID"])).ToString(),"XmlRpcSimulatorLoginMethod",String.Empty, 5,"Region attempting login with UUID.");
}
else
{
responseData["error"] = "No UUID or region_handle passed to grid server - unable to connect you";
m_log.Info("[GRID]: Region connected without a UUID, ignoring.");
responseData["error"] = "No UUID passed to grid server - unable to connect you";
return response;
}
if (TheSim == null) // Shouldnt this be in the REST Simulator Set method?
{
Console.WriteLine("NEW SIM");
m_log.Info("[GRID]: New region connecting");
myword = "creation";
}
else
@ -266,10 +263,10 @@ namespace OpenSim.Grid.GridServer
TheSim = new RegionProfileData();
TheSim.regionRecvKey = config.SimRecvKey;
TheSim.regionSendKey = config.SimSendKey;
TheSim.regionRecvKey = String.Empty;
TheSim.regionSendKey = String.Empty;
TheSim.regionSecret = config.SimRecvKey;
TheSim.regionDataURI = "";
TheSim.regionDataURI = String.Empty;
TheSim.regionAssetURI = config.DefaultAssetServer;
TheSim.regionAssetRecvKey = config.AssetRecvKey;
TheSim.regionAssetSendKey = config.AssetSendKey;
@ -286,12 +283,28 @@ namespace OpenSim.Grid.GridServer
TheSim.regionLocZ = 0;
TheSim.regionMapTextureID = new LLUUID((string)requestData["map-image-id"]);
TheSim.regionHandle = Helpers.UIntsToLong((TheSim.regionLocX * 256), (TheSim.regionLocY * 256));
// part of an initial brutish effort to provide accurate information (as per the xml region spec)
// wrt the ownership of a given region
// the (very bad) assumption is that this value is being read and handled inconsistently or
// not at all. Current strategy is to put the code in place to support the validity of this information
// and to roll forward debugging any issues from that point
//
// this particular section of the mod attempts to receive a value from the region's xml file by way of
// OSG1GridServices for the region's owner
TheSim.owner_uuid = (string)requestData["master_avatar_uuid"];
try
{
TheSim.regionRecvKey = (string)requestData["recvkey"];
TheSim.regionSendKey = (string)requestData["authkey"];
}
catch (KeyNotFoundException) { }
TheSim.regionHandle = Helpers.UIntsToLong((TheSim.regionLocX * Constants.RegionSize), (TheSim.regionLocY * Constants.RegionSize));
TheSim.serverURI = "http://" + TheSim.serverIP + ":" + TheSim.serverPort + "/";
TheSim.httpServerURI = "http://" + TheSim.serverIP + ":" + TheSim.httpPort + "/";
TheSim.regionName = (string)requestData["sim_name"];
TheSim.UUID = new LLUUID((string)requestData["UUID"]);
@ -299,8 +312,29 @@ namespace OpenSim.Grid.GridServer
OldSim = getRegion(TheSim.regionHandle);
if (OldSim == null || OldSim.UUID == TheSim.UUID)
{
Console.WriteLine("adding region " + TheSim.regionLocX + " , " + TheSim.regionLocY + " , " +
bool brandNew = ( OldSim == null && TheSim.regionRecvKey == config.SimSendKey &&
TheSim.regionSendKey == config.SimRecvKey);
bool overwritingOldOne = ( OldSim != null && OldSim.regionRecvKey == TheSim.regionRecvKey &&
OldSim.regionSendKey == TheSim.regionSendKey );
if (brandNew)
{
m_log.Info("[GRID]: Adding region " + TheSim.regionLocX + " , " + TheSim.regionLocY + " , " +
TheSim.serverURI);
}
if (overwritingOldOne)
{
m_log.Info("[GRID]: Overwriting region " + OldSim.regionLocX + " , " + OldSim.regionLocY + " , " +
OldSim.serverURI + " with " + TheSim.regionLocX + " , " + TheSim.regionLocY + " , " +
TheSim.serverURI);
}
if (brandNew ||
overwritingOldOne)
{
foreach (KeyValuePair<string, IGridData> kvp in _plugins)
{
try
@ -309,17 +343,17 @@ namespace OpenSim.Grid.GridServer
switch (insertResponse)
{
case DataResponse.RESPONSE_OK:
MainLog.Instance.Verbose("grid", "New sim " + myword + " successful: " + TheSim.regionName);
m_log.Info("[grid]: New sim " + myword + " successful: " + TheSim.regionName);
break;
case DataResponse.RESPONSE_ERROR:
MainLog.Instance.Warn("storage", "New sim creation failed (Error): " + TheSim.regionName);
m_log.Warn("[storage]: New sim creation failed (Error): " + TheSim.regionName);
break;
case DataResponse.RESPONSE_INVALIDCREDENTIALS:
MainLog.Instance.Warn("storage",
m_log.Warn("[storage]: " +
"New sim creation failed (Invalid Credentials): " + TheSim.regionName);
break;
case DataResponse.RESPONSE_AUTHREQUIRED:
MainLog.Instance.Warn("storage",
m_log.Warn("[storage]: " +
"New sim creation failed (Authentication Required): " +
TheSim.regionName);
break;
@ -327,9 +361,9 @@ namespace OpenSim.Grid.GridServer
}
catch (Exception e)
{
MainLog.Instance.Warn("storage",
m_log.Warn("[storage]: " +
"Unable to add region " + TheSim.UUID.ToString() + " via " + kvp.Key);
MainLog.Instance.Warn("storage", e.ToString());
m_log.Warn("[storage]: " + e.ToString());
}
@ -366,9 +400,11 @@ namespace OpenSim.Grid.GridServer
NeighbourBlock["regionHandle"] = aSim.Value.regionHandle.ToString();
if (aSim.Value.UUID != TheSim.UUID)
{
SimNeighboursData.Add(NeighbourBlock);
}
}
}
else
{
for (int x = -1; x < 2; x++)
@ -376,13 +412,13 @@ namespace OpenSim.Grid.GridServer
{
if (
getRegion(
Helpers.UIntsToLong((uint)((TheSim.regionLocX + x) * 256),
(uint)(TheSim.regionLocY + y) * 256)) != null)
Helpers.UIntsToLong((uint)((TheSim.regionLocX + x) * Constants.RegionSize),
(uint)(TheSim.regionLocY + y) * Constants.RegionSize)) != null)
{
neighbour =
getRegion(
Helpers.UIntsToLong((uint)((TheSim.regionLocX + x) * 256),
(uint)(TheSim.regionLocY + y) * 256));
Helpers.UIntsToLong((uint)((TheSim.regionLocX + x) * Constants.RegionSize),
(uint)(TheSim.regionLocY + y) * Constants.RegionSize));
NeighbourBlock = new Hashtable();
NeighbourBlock["sim_ip"] = Util.GetHostFromDNS(neighbour.serverIP).ToString();
@ -434,17 +470,41 @@ namespace OpenSim.Grid.GridServer
responseData["messageserver_recvkey" + i] = _MessageServers[i].recvkey;
}
return response;
}
else
{
MainLog.Instance.Warn("grid", "Failed to add new region " + TheSim.regionName + " at location " + TheSim.regionLocX + " " + TheSim.regionLocY + " currently occupied by " + OldSim.regionName);
if (OldSim == null)
{
m_log.Warn("[grid]: Authentication failed when trying to add new region " + TheSim.regionName +
" at location " + TheSim.regionLocX +
" " + TheSim.regionLocY + " with TheSim.regionRecvKey " + TheSim.regionRecvKey + "(" + config.SimSendKey + ") and TheSim.regionRecvKey " + TheSim.regionSendKey + "(" + config.SimRecvKey + ") ");
}
else
{
m_log.Warn("[grid]: Authentication failed when trying to add new region " + TheSim.regionName +
" at location " + TheSim.regionLocX +
" " + TheSim.regionLocY + " currently occupied by " + OldSim.regionName);
}
responseData["error"] =
"The key required to connect to your region did not match. Please check your send and recieve keys.";
return response;
}
}
else
{
m_log.Warn("[grid]: Failed to add new region " + TheSim.regionName + " at location " + TheSim.regionLocX + " " + TheSim.regionLocY + " currently occupied by " + OldSim.regionName);
responseData["error"] = "Another region already exists at that location. Try another";
return response;
}
}
/// <summary>
/// Returns an XML RPC response to a simulator profile request
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public XmlRpcResponse XmlRpcSimulatorDataRequestMethod(XmlRpcRequest request)
{
Hashtable requestData = (Hashtable) request.Params[0];
@ -469,7 +529,7 @@ namespace OpenSim.Grid.GridServer
}
else
{
MainLog.Instance.Verbose("DATA", "found " + (string) simData.regionName + " regionHandle = " +
m_log.Info("[DATA]: found " + (string) simData.regionName + " regionHandle = " +
(string) requestData["region_handle"]);
responseData["sim_ip"] = Util.GetHostFromDNS(simData.serverIP).ToString();
responseData["sim_port"] = simData.serverPort.ToString();
@ -508,8 +568,8 @@ namespace OpenSim.Grid.GridServer
{
ymax = (Int32) requestData["ymax"];
}
//CFK: The second MainLog is more meaningful and either standard or fast generally occurs.
//CFK: MainLog.Instance.Verbose("MAP", "World map request for range (" + xmin + "," + ymin + ")..(" + xmax + "," + ymax + ")");
//CFK: The second log is more meaningful and either standard or fast generally occurs.
//CFK: m_log.Info("[MAP]: World map request for range (" + xmin + "," + ymin + ")..(" + xmax + "," + ymax + ")");
XmlRpcResponse response = new XmlRpcResponse();
Hashtable responseData = new Hashtable();
@ -517,6 +577,7 @@ namespace OpenSim.Grid.GridServer
IList simProfileList = new ArrayList();
bool fastMode = false; // MySQL Only
fastMode = (config.DatabaseProvider == "OpenSim.Framework.Data.MySQL.dll");
if (fastMode)
{
@ -547,7 +608,7 @@ namespace OpenSim.Grid.GridServer
simProfileList.Add(simProfileBlock);
}
MainLog.Instance.Verbose("MAP", "Fast map " + simProfileList.Count.ToString() +
m_log.Info("[MAP]: Fast map " + simProfileList.Count.ToString() +
" regions @ (" + xmin + "," + ymin + ")..(" + xmax + "," + ymax + ")");
}
else
@ -557,7 +618,7 @@ namespace OpenSim.Grid.GridServer
{
for (int y = ymin; y < ymax + 1; y++)
{
ulong regHandle = Helpers.UIntsToLong((uint) (x*256), (uint) (y*256));
ulong regHandle = Helpers.UIntsToLong((uint)(x * Constants.RegionSize), (uint)(y * Constants.RegionSize));
simProfile = getRegion(regHandle);
if (simProfile != null)
{
@ -582,7 +643,7 @@ namespace OpenSim.Grid.GridServer
}
}
}
MainLog.Instance.Verbose("MAP", "Std map " + simProfileList.Count.ToString() +
m_log.Info("[MAP]: Std map " + simProfileList.Count.ToString() +
" regions @ (" + xmin + "," + ymin + ")..(" + xmax + "," + ymax + ")");
}
@ -601,7 +662,7 @@ namespace OpenSim.Grid.GridServer
/// <returns></returns>
public string RestGetRegionMethod(string request, string path, string param)
{
return RestGetSimMethod("", "/sims/", param);
return RestGetSimMethod(String.Empty, "/sims/", param);
}
/// <summary>
@ -613,7 +674,7 @@ namespace OpenSim.Grid.GridServer
/// <returns></returns>
public string RestSetRegionMethod(string request, string path, string param)
{
return RestSetSimMethod("", "/sims/", param);
return RestSetSimMethod(String.Empty, "/sims/", param);
}
/// <summary>
@ -621,14 +682,17 @@ namespace OpenSim.Grid.GridServer
/// </summary>
/// <param name="request"></param>
/// <param name="path"></param>
/// <param name="param"></param>
/// <param name="param">A string representing the sim's UUID</param>
/// <returns>Information about the sim in XML</returns>
public string RestGetSimMethod(string request, string path, string param)
{
string respstring = String.Empty;
RegionProfileData TheSim;
LLUUID UUID = new LLUUID(param);
LLUUID UUID;
if (LLUUID.TryParse(param, out UUID))
{
TheSim = getRegion(UUID);
if (!(TheSim == null))
@ -646,6 +710,13 @@ namespace OpenSim.Grid.GridServer
respstring += "</sim>";
respstring += "</Root>";
}
}
else
{
respstring = "<Root>";
respstring += "<error>Param must be a UUID</error>";
respstring += "</Root>";
}
return respstring;
}
@ -690,7 +761,7 @@ namespace OpenSim.Grid.GridServer
TheSim.regionRecvKey = config.SimRecvKey;
TheSim.regionSendKey = config.SimSendKey;
TheSim.regionSecret = config.SimRecvKey;
TheSim.regionDataURI = "";
TheSim.regionDataURI = String.Empty;
TheSim.regionAssetURI = config.DefaultAssetServer;
TheSim.regionAssetRecvKey = config.AssetRecvKey;
TheSim.regionAssetSendKey = config.AssetSendKey;
@ -717,12 +788,12 @@ namespace OpenSim.Grid.GridServer
case "region_locx":
TheSim.regionLocX = Convert.ToUInt32((string) simnode.ChildNodes[i].InnerText);
TheSim.regionHandle = Helpers.UIntsToLong((TheSim.regionLocX*256), (TheSim.regionLocY*256));
TheSim.regionHandle = Helpers.UIntsToLong((TheSim.regionLocX * Constants.RegionSize), (TheSim.regionLocY * Constants.RegionSize));
break;
case "region_locy":
TheSim.regionLocY = Convert.ToUInt32((string) simnode.ChildNodes[i].InnerText);
TheSim.regionHandle = Helpers.UIntsToLong((TheSim.regionLocX*256), (TheSim.regionLocY*256));
TheSim.regionHandle = Helpers.UIntsToLong((TheSim.regionLocX * Constants.RegionSize), (TheSim.regionLocY * Constants.RegionSize));
break;
}
}
@ -740,15 +811,15 @@ namespace OpenSim.Grid.GridServer
return "ERROR! Servers must register with public addresses.";
}
if (requireValid && (TheSim.serverIP.StartsWith("0.")))
if (requireValid && (TheSim.serverIP.StartsWith("0.") || TheSim.serverIP.StartsWith("255.")))
{
return "ERROR! 0.*.*.* Addresses are invalid, please check your server config and try again";
return "ERROR! 0.*.*.* / 255.*.*.* Addresses are invalid, please check your server config and try again";
}
try
{
MainLog.Instance.Verbose("DATA",
m_log.Info("[DATA]: " +
"Updating / adding via " + _plugins.Count + " storage provider(s) registered.");
foreach (KeyValuePair<string, IGridData> kvp in _plugins)
{
@ -761,13 +832,13 @@ namespace OpenSim.Grid.GridServer
(reserveData == null && authkeynode.InnerText != TheSim.regionRecvKey))
{
kvp.Value.AddProfile(TheSim);
MainLog.Instance.Verbose("grid", "New sim added to grid (" + TheSim.regionName + ")");
logToDB(TheSim.UUID.ToString(), "RestSetSimMethod", "", 5,
m_log.Info("[grid]: New sim added to grid (" + TheSim.regionName + ")");
logToDB(TheSim.UUID.ToString(), "RestSetSimMethod", String.Empty, 5,
"Region successfully updated and connected to grid.");
}
else
{
MainLog.Instance.Warn("grid",
m_log.Warn("[grid]: " +
"Unable to update region (RestSetSimMethod): Incorrect reservation auth key.");
// Wanted: " + reserveData.gridRecvKey + ", Got: " + TheSim.regionRecvKey + ".");
return "Unable to update region (RestSetSimMethod): Incorrect auth key.";
@ -775,7 +846,7 @@ namespace OpenSim.Grid.GridServer
}
catch (Exception e)
{
MainLog.Instance.Warn("GRID", "getRegionPlugin Handle " + kvp.Key + " unable to add new sim: " +
m_log.Warn("[GRID]: getRegionPlugin Handle " + kvp.Key + " unable to add new sim: " +
e.ToString());
}
}

View File

@ -37,8 +37,10 @@ namespace OpenSim.Grid.GridServer
{
/// <summary>
/// </summary>
public class OpenGrid_Main : conscmd_callback
public class OpenGrid_Main : BaseOpenSimServer, conscmd_callback
{
private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
public GridConfig Cfg;
public static OpenGrid_Main thegrid;
@ -51,16 +53,16 @@ namespace OpenSim.Grid.GridServer
private GridManager m_gridManager;
private LogBase m_console;
[STAThread]
public static void Main(string[] args)
{
log4net.Config.XmlConfigurator.Configure();
if (args.Length > 0)
{
if (args[0] == "-setuponly") setuponly = true;
}
Console.WriteLine("Starting...\n");
m_log.Info("Starting...\n");
thegrid = new OpenGrid_Main();
thegrid.Startup();
@ -74,19 +76,14 @@ namespace OpenSim.Grid.GridServer
while (true)
{
m_console.MainLogPrompt();
m_console.Prompt();
}
}
private OpenGrid_Main()
{
if (!Directory.Exists(Util.logDir()))
{
Directory.CreateDirectory(Util.logDir());
}
m_console =
new LogBase((Path.Combine(Util.logDir(), "opengrid-gridserver-console.log")), "OpenGrid", this, true);
MainLog.Instance = m_console;
m_console = new ConsoleBase("OpenGrid", this);
MainConsole.Instance = m_console;
}
public void managercallback(string cmd)
@ -99,19 +96,18 @@ namespace OpenSim.Grid.GridServer
}
}
public void Startup()
{
Cfg = new GridConfig("GRID SERVER", (Path.Combine(Util.configDir(), "GridServer_Config.xml")));
//Yeah srsly, that's it.
if (setuponly) Environment.Exit(0);
m_console.Verbose("GRID", "Connecting to Storage Server");
m_log.Info("[GRID]: Connecting to Storage Server");
m_gridManager = new GridManager();
m_gridManager.AddPlugin(Cfg.DatabaseProvider); // Made of win
m_gridManager.config = Cfg;
m_console.Verbose("GRID", "Starting HTTP process");
m_log.Info("[GRID]: Starting HTTP process");
BaseHttpServer httpServer = new BaseHttpServer(Cfg.HttpPort);
//GridManagementAgent GridManagerAgent = new GridManagementAgent(httpServer, "gridserver", Cfg.SimSendKey, Cfg.SimRecvKey, managercallback);
@ -137,7 +133,7 @@ namespace OpenSim.Grid.GridServer
httpServer.Start();
m_console.Verbose("GRID", "Starting sim status checker");
m_log.Info("[GRID]: Starting sim status checker");
Timer simCheckTimer = new Timer(3600000*3); // 3 Hours between updates.
simCheckTimer.Elapsed += new ElapsedEventHandler(CheckSims);
@ -149,7 +145,7 @@ namespace OpenSim.Grid.GridServer
/*
foreach (SimProfileBase sim in m_simProfileManager.SimProfiles.Values)
{
string SimResponse = "";
string SimResponse = String.Empty;
try
{
WebRequest CheckSim = WebRequest.Create("http://" + sim.sim_ip + ":" + sim.sim_port.ToString() + "/checkstatus/");
@ -158,7 +154,7 @@ namespace OpenSim.Grid.GridServer
CheckSim.ContentLength = 0;
StreamWriter stOut = new StreamWriter(CheckSim.GetRequestStream(), System.Text.Encoding.ASCII);
stOut.Write("");
stOut.Write(String.Empty);
stOut.Close();
StreamReader stIn = new StreamReader(CheckSim.GetResponse().GetResponseStream());
@ -181,8 +177,10 @@ namespace OpenSim.Grid.GridServer
*/
}
public void RunCmd(string cmd, string[] cmdparams)
public override void RunCmd(string cmd, string[] cmdparams)
{
base.RunCmd(cmd, cmdparams);
switch (cmd)
{
case "help":
@ -196,17 +194,13 @@ namespace OpenSim.Grid.GridServer
}
}
public void Show(string ShowWhat)
{
}
/*private void ConfigDB(IGenericConfig configData)
{
try
{
string attri = "";
string attri = String.Empty;
attri = configData.GetAttribute("DataBaseProvider");
if (attri == "")
if (attri == String.Empty)
{
GridDll = "OpenSim.Framework.Data.DB4o.dll";
configData.SetAttribute("DataBaseProvider", "OpenSim.Framework.Data.DB4o.dll");

View File

@ -37,7 +37,7 @@ using System.Runtime.InteropServices;
[assembly : AssemblyConfiguration("")]
[assembly : AssemblyCompany("")]
[assembly : AssemblyProduct("OGS-GridServer")]
[assembly : AssemblyCopyright("Copyright © 2007")]
[assembly : AssemblyCopyright("Copyright © OpenSimulator.org Developers 2007-2008")]
[assembly : AssemblyTrademark("")]
[assembly : AssemblyCulture("")]