let Grid Servers specify a connect string in their configuration.

0.6.0-stable
Sean Dague 2008-05-28 17:59:46 +00:00
parent a8b8bacf28
commit 89c164fbc1
12 changed files with 69 additions and 36 deletions

View File

@ -36,7 +36,7 @@ namespace OpenSim.Data
public abstract RegionProfileData GetProfileByString(string regionName); public abstract RegionProfileData GetProfileByString(string regionName);
public abstract RegionProfileData[] GetProfilesInRange(uint Xmin, uint Ymin, uint Xmax, uint Ymax); public abstract RegionProfileData[] GetProfilesInRange(uint Xmin, uint Ymin, uint Xmax, uint Ymax);
public abstract bool AuthenticateSim(LLUUID UUID, ulong regionHandle, string simrecvkey); public abstract bool AuthenticateSim(LLUUID UUID, ulong regionHandle, string simrecvkey);
public abstract void Initialise(); public abstract void Initialise(string connect);
public abstract void Close(); public abstract void Close();
public abstract string getName(); public abstract string getName();
public abstract string getVersion(); public abstract string getVersion();

View File

@ -86,7 +86,7 @@ namespace OpenSim.Data
/// <summary> /// <summary>
/// Initialises the interface /// Initialises the interface
/// </summary> /// </summary>
void Initialise(); void Initialise(string connect);
/// <summary> /// <summary>
/// Closes the interface /// Closes the interface

View File

@ -69,7 +69,7 @@ namespace OpenSim.Data
/// <summary> /// <summary>
/// Initialises the interface /// Initialises the interface
/// </summary> /// </summary>
void Initialise(); void Initialise(string connect);
/// <summary> /// <summary>
/// Closes the interface /// Closes the interface

View File

@ -53,8 +53,9 @@ namespace OpenSim.Data.MSSQL
/// <summary> /// <summary>
/// Initialises the Grid Interface /// Initialises the Grid Interface
/// </summary> /// </summary>
override public void Initialise() override public void Initialise(string connect)
{ {
// TODO: make the connect string actually do something
IniFile iniFile = new IniFile("mssql_connection.ini"); IniFile iniFile = new IniFile("mssql_connection.ini");
string settingDataSource = iniFile.ParseFileReadValue("data_source"); string settingDataSource = iniFile.ParseFileReadValue("data_source");

View File

@ -43,8 +43,9 @@ namespace OpenSim.Data.MSSQL
/// <summary> /// <summary>
/// Artificial constructor called when the plugin is loaded /// Artificial constructor called when the plugin is loaded
/// </summary> /// </summary>
public void Initialise() public void Initialise(string connect)
{ {
// TODO: do something with the connect string
IniFile GridDataMySqlFile = new IniFile("mssql_connection.ini"); IniFile GridDataMySqlFile = new IniFile("mssql_connection.ini");
string settingDataSource = GridDataMySqlFile.ParseFileReadValue("data_source"); string settingDataSource = GridDataMySqlFile.ParseFileReadValue("data_source");
string settingInitialCatalog = GridDataMySqlFile.ParseFileReadValue("initial_catalog"); string settingInitialCatalog = GridDataMySqlFile.ParseFileReadValue("initial_catalog");

View File

@ -51,19 +51,24 @@ namespace OpenSim.Data.MySQL
/// <summary> /// <summary>
/// Initialises the Grid Interface /// Initialises the Grid Interface
/// </summary> /// </summary>
override public void Initialise() override public void Initialise(string connect)
{ {
IniFile GridDataMySqlFile = new IniFile("mysql_connection.ini"); if (connect != String.Empty) {
string settingHostname = GridDataMySqlFile.ParseFileReadValue("hostname"); database = new MySQLManager(connect);
string settingDatabase = GridDataMySqlFile.ParseFileReadValue("database"); } else {
string settingUsername = GridDataMySqlFile.ParseFileReadValue("username"); m_log.Warn("Using deprecated mysql_connection.ini. Please update database_connect in GridServer_Config.xml and we'll use that instead");
string settingPassword = GridDataMySqlFile.ParseFileReadValue("password"); IniFile GridDataMySqlFile = new IniFile("mysql_connection.ini");
string settingPooling = GridDataMySqlFile.ParseFileReadValue("pooling"); string settingHostname = GridDataMySqlFile.ParseFileReadValue("hostname");
string settingPort = GridDataMySqlFile.ParseFileReadValue("port"); string settingDatabase = GridDataMySqlFile.ParseFileReadValue("database");
string settingUsername = GridDataMySqlFile.ParseFileReadValue("username");
string settingPassword = GridDataMySqlFile.ParseFileReadValue("password");
string settingPooling = GridDataMySqlFile.ParseFileReadValue("pooling");
string settingPort = GridDataMySqlFile.ParseFileReadValue("port");
database = database =
new MySQLManager(settingHostname, settingDatabase, settingUsername, settingPassword, settingPooling, new MySQLManager(settingHostname, settingDatabase, settingUsername, settingPassword, settingPooling,
settingPort); settingPort);
}
TestTables(); TestTables();
} }

View File

@ -24,6 +24,9 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
using System;
using System.Reflection;
using log4net;
namespace OpenSim.Data.MySQL namespace OpenSim.Data.MySQL
{ {
@ -32,6 +35,7 @@ namespace OpenSim.Data.MySQL
/// </summary> /// </summary>
internal class MySQLLogData : ILogData internal class MySQLLogData : ILogData
{ {
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
/// <summary> /// <summary>
/// The database manager /// The database manager
/// </summary> /// </summary>
@ -40,19 +44,25 @@ namespace OpenSim.Data.MySQL
/// <summary> /// <summary>
/// Artificial constructor called when the plugin is loaded /// Artificial constructor called when the plugin is loaded
/// </summary> /// </summary>
public void Initialise() public void Initialise(string connect)
{ {
IniFile GridDataMySqlFile = new IniFile("mysql_connection.ini"); if (connect != String.Empty) {
string settingHostname = GridDataMySqlFile.ParseFileReadValue("hostname"); database = new MySQLManager(connect);
string settingDatabase = GridDataMySqlFile.ParseFileReadValue("database"); } else {
string settingUsername = GridDataMySqlFile.ParseFileReadValue("username"); m_log.Warn("Using deprecated mysql_connection.ini. Please update database_connect in GridServer_Config.xml and we'll use that instead");
string settingPassword = GridDataMySqlFile.ParseFileReadValue("password");
string settingPooling = GridDataMySqlFile.ParseFileReadValue("pooling");
string settingPort = GridDataMySqlFile.ParseFileReadValue("port");
database = IniFile GridDataMySqlFile = new IniFile("mysql_connection.ini");
new MySQLManager(settingHostname, settingDatabase, settingUsername, settingPassword, settingPooling, string settingHostname = GridDataMySqlFile.ParseFileReadValue("hostname");
settingPort); string settingDatabase = GridDataMySqlFile.ParseFileReadValue("database");
string settingUsername = GridDataMySqlFile.ParseFileReadValue("username");
string settingPassword = GridDataMySqlFile.ParseFileReadValue("password");
string settingPooling = GridDataMySqlFile.ParseFileReadValue("pooling");
string settingPort = GridDataMySqlFile.ParseFileReadValue("port");
database =
new MySQLManager(settingHostname, settingDatabase, settingUsername, settingPassword, settingPooling,
settingPort);
}
} }
/// <summary> /// <summary>

View File

@ -48,9 +48,9 @@ namespace OpenSim.Data.SQLite
/// <summary> /// <summary>
/// Initialises the Grid Interface /// Initialises the Grid Interface
/// </summary> /// </summary>
override public void Initialise() override public void Initialise(string connect)
{ {
database = new SQLiteManager("localhost", "db", "user", "password", "false"); database = new SQLiteManager(connect);
} }
/// <summary> /// <summary>

View File

@ -49,11 +49,21 @@ namespace OpenSim.Data.SQLite
/// <param name="username">The username logging into the database</param> /// <param name="username">The username logging into the database</param>
/// <param name="password">The password for the user logging in</param> /// <param name="password">The password for the user logging in</param>
/// <param name="cpooling">Whether to use connection pooling or not, can be one of the following: 'yes', 'true', 'no' or 'false', if unsure use 'false'.</param> /// <param name="cpooling">Whether to use connection pooling or not, can be one of the following: 'yes', 'true', 'no' or 'false', if unsure use 'false'.</param>
public SQLiteManager(string hostname, string database, string username, string password, string cpooling) public SQLiteManager(string connect)
{ {
try try
{ {
string connectionString = "URI=file:GridServerSqlite.db;"; string connectionString = String.Empty;
if (connect != String.Empty)
{
connectionString = connect;
}
else
{
m_log.Warn("[SQLITE] grid db not specified, using default");
connectionString = "URI=file:GridServerSqlite.db;";
}
dbcon = new SQLiteConnection(connectionString); dbcon = new SQLiteConnection(connectionString);
dbcon.Open(); dbcon.Open();

View File

@ -39,6 +39,7 @@ namespace OpenSim.Framework
private ConfigurationMember configMember; private ConfigurationMember configMember;
public string DatabaseProvider = String.Empty; public string DatabaseProvider = String.Empty;
public string DatabaseConnect = String.Empty;
public string DefaultAssetServer = String.Empty; public string DefaultAssetServer = String.Empty;
public string DefaultUserServer = String.Empty; public string DefaultUserServer = String.Empty;
public string GridOwner = String.Empty; public string GridOwner = String.Empty;
@ -85,6 +86,8 @@ namespace OpenSim.Framework
"Key to expect from a simulator", "null", false); "Key to expect from a simulator", "null", false);
configMember.addConfigurationOption("database_provider", ConfigurationOption.ConfigurationTypes.TYPE_STRING, configMember.addConfigurationOption("database_provider", ConfigurationOption.ConfigurationTypes.TYPE_STRING,
"DLL for database provider", "OpenSim.Data.MySQL.dll", false); "DLL for database provider", "OpenSim.Data.MySQL.dll", false);
configMember.addConfigurationOption("database_connect", ConfigurationOption.ConfigurationTypes.TYPE_STRING,
"Database connect string", "", false);
configMember.addConfigurationOption("http_port", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, configMember.addConfigurationOption("http_port", ConfigurationOption.ConfigurationTypes.TYPE_UINT32,
"Http Listener port", DefaultHttpPort.ToString(), false); "Http Listener port", DefaultHttpPort.ToString(), false);
@ -128,6 +131,9 @@ namespace OpenSim.Framework
case "database_provider": case "database_provider":
DatabaseProvider = (string) configuration_result; DatabaseProvider = (string) configuration_result;
break; break;
case "database_connect":
DatabaseConnect = (string) configuration_result;
break;
case "http_port": case "http_port":
HttpPort = (uint) configuration_result; HttpPort = (uint) configuration_result;
break; break;

View File

@ -58,7 +58,7 @@ namespace OpenSim.Grid.GridServer
/// Adds a new grid server plugin - grid servers will be requested in the order they were loaded. /// Adds a new grid server plugin - grid servers will be requested in the order they were loaded.
/// </summary> /// </summary>
/// <param name="FileName">The filename to the grid server plugin DLL</param> /// <param name="FileName">The filename to the grid server plugin DLL</param>
public void AddPlugin(string FileName) public void AddPlugin(string FileName, string Connect)
{ {
m_log.Info("[DATA]: Attempting to load " + FileName); m_log.Info("[DATA]: Attempting to load " + FileName);
Assembly pluginAssembly = Assembly.LoadFrom(FileName); Assembly pluginAssembly = Assembly.LoadFrom(FileName);
@ -75,7 +75,7 @@ namespace OpenSim.Grid.GridServer
{ {
IGridData plug = IGridData plug =
(IGridData)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); (IGridData)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
plug.Initialise(); plug.Initialise(Connect);
_plugins.Add(plug.getName(), plug); _plugins.Add(plug.getName(), plug);
m_log.Info("[DATA]: Added IGridData Interface"); m_log.Info("[DATA]: Added IGridData Interface");
} }
@ -87,7 +87,7 @@ namespace OpenSim.Grid.GridServer
{ {
ILogData plug = ILogData plug =
(ILogData)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); (ILogData)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
plug.Initialise(); plug.Initialise(Connect);
_logplugins.Add(plug.getName(), plug); _logplugins.Add(plug.getName(), plug);
m_log.Info("[DATA]: Added ILogData Interface"); m_log.Info("[DATA]: Added ILogData Interface");
} }

View File

@ -135,7 +135,7 @@ namespace OpenSim.Grid.GridServer
{ {
m_log.Info("[DATA]: Connecting to Storage Server"); m_log.Info("[DATA]: Connecting to Storage Server");
m_gridManager = new GridManager(); m_gridManager = new GridManager();
m_gridManager.AddPlugin(m_config.DatabaseProvider); m_gridManager.AddPlugin(m_config.DatabaseProvider, m_config.DatabaseConnect);
m_gridManager.Config = m_config; m_gridManager.Config = m_config;
} }