From 89c164fbc18e082bf2d036bd2167b824e90aebc1 Mon Sep 17 00:00:00 2001
From: Sean Dague
Date: Wed, 28 May 2008 17:59:46 +0000
Subject: let Grid Servers specify a connect string in their configuration.
---
OpenSim/Data/GridDataBase.cs | 2 +-
OpenSim/Data/IGridData.cs | 2 +-
OpenSim/Data/ILogData.cs | 2 +-
OpenSim/Data/MSSQL/MSSQLGridData.cs | 3 ++-
OpenSim/Data/MSSQL/MSSQLLogData.cs | 3 ++-
OpenSim/Data/MySQL/MySQLGridData.cs | 29 +++++++++++++++++------------
OpenSim/Data/MySQL/MySQLLogData.cs | 34 ++++++++++++++++++++++------------
OpenSim/Data/SQLite/SQLiteGridData.cs | 4 ++--
OpenSim/Data/SQLite/SQLiteManager.cs | 14 ++++++++++++--
9 files changed, 60 insertions(+), 33 deletions(-)
(limited to 'OpenSim/Data')
diff --git a/OpenSim/Data/GridDataBase.cs b/OpenSim/Data/GridDataBase.cs
index 036e2eb..0c9d24a 100644
--- a/OpenSim/Data/GridDataBase.cs
+++ b/OpenSim/Data/GridDataBase.cs
@@ -36,7 +36,7 @@ namespace OpenSim.Data
public abstract RegionProfileData GetProfileByString(string regionName);
public abstract RegionProfileData[] GetProfilesInRange(uint Xmin, uint Ymin, uint Xmax, uint Ymax);
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 string getName();
public abstract string getVersion();
diff --git a/OpenSim/Data/IGridData.cs b/OpenSim/Data/IGridData.cs
index b2a8d26..e242312 100644
--- a/OpenSim/Data/IGridData.cs
+++ b/OpenSim/Data/IGridData.cs
@@ -86,7 +86,7 @@ namespace OpenSim.Data
///
/// Initialises the interface
///
- void Initialise();
+ void Initialise(string connect);
///
/// Closes the interface
diff --git a/OpenSim/Data/ILogData.cs b/OpenSim/Data/ILogData.cs
index a533c87..7275637 100644
--- a/OpenSim/Data/ILogData.cs
+++ b/OpenSim/Data/ILogData.cs
@@ -69,7 +69,7 @@ namespace OpenSim.Data
///
/// Initialises the interface
///
- void Initialise();
+ void Initialise(string connect);
///
/// Closes the interface
diff --git a/OpenSim/Data/MSSQL/MSSQLGridData.cs b/OpenSim/Data/MSSQL/MSSQLGridData.cs
index 0bdd460..d7adb84 100644
--- a/OpenSim/Data/MSSQL/MSSQLGridData.cs
+++ b/OpenSim/Data/MSSQL/MSSQLGridData.cs
@@ -53,8 +53,9 @@ namespace OpenSim.Data.MSSQL
///
/// Initialises the Grid Interface
///
- 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");
string settingDataSource = iniFile.ParseFileReadValue("data_source");
diff --git a/OpenSim/Data/MSSQL/MSSQLLogData.cs b/OpenSim/Data/MSSQL/MSSQLLogData.cs
index 2bb5839..c75290e 100644
--- a/OpenSim/Data/MSSQL/MSSQLLogData.cs
+++ b/OpenSim/Data/MSSQL/MSSQLLogData.cs
@@ -43,8 +43,9 @@ namespace OpenSim.Data.MSSQL
///
/// Artificial constructor called when the plugin is loaded
///
- public void Initialise()
+ public void Initialise(string connect)
{
+ // TODO: do something with the connect string
IniFile GridDataMySqlFile = new IniFile("mssql_connection.ini");
string settingDataSource = GridDataMySqlFile.ParseFileReadValue("data_source");
string settingInitialCatalog = GridDataMySqlFile.ParseFileReadValue("initial_catalog");
diff --git a/OpenSim/Data/MySQL/MySQLGridData.cs b/OpenSim/Data/MySQL/MySQLGridData.cs
index e830133..421c283 100644
--- a/OpenSim/Data/MySQL/MySQLGridData.cs
+++ b/OpenSim/Data/MySQL/MySQLGridData.cs
@@ -51,19 +51,24 @@ namespace OpenSim.Data.MySQL
///
/// Initialises the Grid Interface
///
- override public void Initialise()
+ override public void Initialise(string connect)
{
- IniFile GridDataMySqlFile = new IniFile("mysql_connection.ini");
- string settingHostname = GridDataMySqlFile.ParseFileReadValue("hostname");
- 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);
+ if (connect != String.Empty) {
+ database = new MySQLManager(connect);
+ } else {
+ m_log.Warn("Using deprecated mysql_connection.ini. Please update database_connect in GridServer_Config.xml and we'll use that instead");
+ IniFile GridDataMySqlFile = new IniFile("mysql_connection.ini");
+ string settingHostname = GridDataMySqlFile.ParseFileReadValue("hostname");
+ 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);
+ }
TestTables();
}
diff --git a/OpenSim/Data/MySQL/MySQLLogData.cs b/OpenSim/Data/MySQL/MySQLLogData.cs
index bb34d34..0873066 100644
--- a/OpenSim/Data/MySQL/MySQLLogData.cs
+++ b/OpenSim/Data/MySQL/MySQLLogData.cs
@@ -24,6 +24,9 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+using System;
+using System.Reflection;
+using log4net;
namespace OpenSim.Data.MySQL
{
@@ -31,7 +34,8 @@ namespace OpenSim.Data.MySQL
/// An interface to the log database for MySQL
///
internal class MySQLLogData : ILogData
- {
+ {
+ private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
///
/// The database manager
///
@@ -40,19 +44,25 @@ namespace OpenSim.Data.MySQL
///
/// Artificial constructor called when the plugin is loaded
///
- public void Initialise()
+ public void Initialise(string connect)
{
- IniFile GridDataMySqlFile = new IniFile("mysql_connection.ini");
- string settingHostname = GridDataMySqlFile.ParseFileReadValue("hostname");
- 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");
+ if (connect != String.Empty) {
+ database = new MySQLManager(connect);
+ } else {
+ m_log.Warn("Using deprecated mysql_connection.ini. Please update database_connect in GridServer_Config.xml and we'll use that instead");
- database =
- new MySQLManager(settingHostname, settingDatabase, settingUsername, settingPassword, settingPooling,
- settingPort);
+ IniFile GridDataMySqlFile = new IniFile("mysql_connection.ini");
+ string settingHostname = GridDataMySqlFile.ParseFileReadValue("hostname");
+ 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);
+ }
}
///
diff --git a/OpenSim/Data/SQLite/SQLiteGridData.cs b/OpenSim/Data/SQLite/SQLiteGridData.cs
index 989ec77..7c5bb0c 100644
--- a/OpenSim/Data/SQLite/SQLiteGridData.cs
+++ b/OpenSim/Data/SQLite/SQLiteGridData.cs
@@ -48,9 +48,9 @@ namespace OpenSim.Data.SQLite
///
/// Initialises the Grid Interface
///
- override public void Initialise()
+ override public void Initialise(string connect)
{
- database = new SQLiteManager("localhost", "db", "user", "password", "false");
+ database = new SQLiteManager(connect);
}
///
diff --git a/OpenSim/Data/SQLite/SQLiteManager.cs b/OpenSim/Data/SQLite/SQLiteManager.cs
index e1d2cdf..4d39527 100644
--- a/OpenSim/Data/SQLite/SQLiteManager.cs
+++ b/OpenSim/Data/SQLite/SQLiteManager.cs
@@ -49,11 +49,21 @@ namespace OpenSim.Data.SQLite
/// The username logging into the database
/// The password for the user logging in
/// Whether to use connection pooling or not, can be one of the following: 'yes', 'true', 'no' or 'false', if unsure use 'false'.
- public SQLiteManager(string hostname, string database, string username, string password, string cpooling)
+ public SQLiteManager(string connect)
{
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.Open();
--
cgit v1.1