aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Data.MySQL/MySQLDataStore.cs
diff options
context:
space:
mode:
authorJeff Ames2008-02-05 19:44:27 +0000
committerJeff Ames2008-02-05 19:44:27 +0000
commit6ed5283bc06a62f38eb517e67b975832b603bf61 (patch)
treee5f635018789b73a99ddeca0883a68368fa5eece /OpenSim/Framework/Data.MySQL/MySQLDataStore.cs
parentCut down on the number of packets sent during terraforming. Terraforming shou... (diff)
downloadopensim-SC_OLD-6ed5283bc06a62f38eb517e67b975832b603bf61.zip
opensim-SC_OLD-6ed5283bc06a62f38eb517e67b975832b603bf61.tar.gz
opensim-SC_OLD-6ed5283bc06a62f38eb517e67b975832b603bf61.tar.bz2
opensim-SC_OLD-6ed5283bc06a62f38eb517e67b975832b603bf61.tar.xz
Converted logging to use log4net.
Changed LogBase to ConsoleBase, which handles console I/O. This is mostly an in-place conversion, so lots of refactoring can still be done.
Diffstat (limited to '')
-rw-r--r--OpenSim/Framework/Data.MySQL/MySQLDataStore.cs74
1 files changed, 38 insertions, 36 deletions
diff --git a/OpenSim/Framework/Data.MySQL/MySQLDataStore.cs b/OpenSim/Framework/Data.MySQL/MySQLDataStore.cs
index 54f39bb..e2ea018 100644
--- a/OpenSim/Framework/Data.MySQL/MySQLDataStore.cs
+++ b/OpenSim/Framework/Data.MySQL/MySQLDataStore.cs
@@ -42,6 +42,8 @@ namespace OpenSim.Framework.Data.MySQL
42{ 42{
43 public class MySQLDataStore : IRegionDataStore 43 public class MySQLDataStore : IRegionDataStore
44 { 44 {
45 private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
46
45 private const string m_primSelect = "select * from prims"; 47 private const string m_primSelect = "select * from prims";
46 private const string m_shapeSelect = "select * from primshapes"; 48 private const string m_shapeSelect = "select * from primshapes";
47 private const string m_itemsSelect = "select * from primitems"; 49 private const string m_itemsSelect = "select * from primitems";
@@ -80,7 +82,7 @@ namespace OpenSim.Framework.Data.MySQL
80 m_dataSet = new DataSet(); 82 m_dataSet = new DataSet();
81 this.persistPrimInventories = persistPrimInventories; 83 this.persistPrimInventories = persistPrimInventories;
82 84
83 MainLog.Instance.Verbose("DATASTORE", "MySql - connecting: " + connectionstring); 85 m_log.Info("[DATASTORE]: MySql - connecting: " + connectionstring);
84 m_connection = new MySqlConnection(connectionstring); 86 m_connection = new MySqlConnection(connectionstring);
85 87
86 MySqlCommand primSelectCmd = new MySqlCommand(m_primSelect, m_connection); 88 MySqlCommand primSelectCmd = new MySqlCommand(m_primSelect, m_connection);
@@ -148,12 +150,12 @@ namespace OpenSim.Framework.Data.MySQL
148 { 150 {
149 if ((prim.ObjectFlags & (uint) LLObject.ObjectFlags.Physics) == 0) 151 if ((prim.ObjectFlags & (uint) LLObject.ObjectFlags.Physics) == 0)
150 { 152 {
151 MainLog.Instance.Verbose("DATASTORE", "Adding obj: " + obj.UUID + " to region: " + regionUUID); 153 m_log.Info("[DATASTORE]: Adding obj: " + obj.UUID + " to region: " + regionUUID);
152 addPrim(prim, obj.UUID, regionUUID); 154 addPrim(prim, obj.UUID, regionUUID);
153 } 155 }
154 else 156 else
155 { 157 {
156 // MainLog.Instance.Verbose("DATASTORE", "Ignoring Physical obj: " + obj.UUID + " in region: " + regionUUID); 158 // m_log.Info("[DATASTORE]: Ignoring Physical obj: " + obj.UUID + " in region: " + regionUUID);
157 } 159 }
158 } 160 }
159 } 161 }
@@ -163,7 +165,7 @@ namespace OpenSim.Framework.Data.MySQL
163 165
164 public void RemoveObject(LLUUID obj, LLUUID regionUUID) 166 public void RemoveObject(LLUUID obj, LLUUID regionUUID)
165 { 167 {
166 MainLog.Instance.Verbose("DATASTORE", "Removing obj: {0} from region: {1}", obj.UUID, regionUUID); 168 m_log.Info(String.Format("[DATASTORE]: Removing obj: {0} from region: {1}", obj.UUID, regionUUID));
167 169
168 DataTable prims = m_primTable; 170 DataTable prims = m_primTable;
169 DataTable shapes = m_shapeTable; 171 DataTable shapes = m_shapeTable;
@@ -228,7 +230,7 @@ namespace OpenSim.Framework.Data.MySQL
228 lock (m_dataSet) 230 lock (m_dataSet)
229 { 231 {
230 DataRow[] primsForRegion = prims.Select(byRegion, orderByParent); 232 DataRow[] primsForRegion = prims.Select(byRegion, orderByParent);
231 MainLog.Instance.Verbose("DATASTORE", 233 m_log.Info("[DATASTORE]: " +
232 "Loaded " + primsForRegion.Length + " prims for region: " + regionUUID); 234 "Loaded " + primsForRegion.Length + " prims for region: " + regionUUID);
233 235
234 foreach (DataRow primRow in primsForRegion) 236 foreach (DataRow primRow in primsForRegion)
@@ -251,7 +253,7 @@ namespace OpenSim.Framework.Data.MySQL
251 } 253 }
252 else 254 else
253 { 255 {
254 MainLog.Instance.Notice( 256 m_log.Info(
255 "No shape found for prim in storage, so setting default box shape"); 257 "No shape found for prim in storage, so setting default box shape");
256 prim.Shape = PrimitiveBaseShape.Default; 258 prim.Shape = PrimitiveBaseShape.Default;
257 } 259 }
@@ -270,7 +272,7 @@ namespace OpenSim.Framework.Data.MySQL
270 } 272 }
271 else 273 else
272 { 274 {
273 MainLog.Instance.Notice( 275 m_log.Info(
274 "No shape found for prim in storage, so setting default box shape"); 276 "No shape found for prim in storage, so setting default box shape");
275 prim.Shape = PrimitiveBaseShape.Default; 277 prim.Shape = PrimitiveBaseShape.Default;
276 } 278 }
@@ -284,11 +286,11 @@ namespace OpenSim.Framework.Data.MySQL
284 } 286 }
285 catch (Exception e) 287 catch (Exception e)
286 { 288 {
287 MainLog.Instance.Error("DATASTORE", "Failed create prim object, exception and data follows"); 289 m_log.Error("[DATASTORE]: Failed create prim object, exception and data follows");
288 MainLog.Instance.Verbose("DATASTORE", e.ToString()); 290 m_log.Info("[DATASTORE]: " + e.ToString());
289 foreach (DataColumn col in prims.Columns) 291 foreach (DataColumn col in prims.Columns)
290 { 292 {
291 MainLog.Instance.Verbose("DATASTORE", "Col: " + col.ColumnName + " => " + primRow[col]); 293 m_log.Info("[DATASTORE]: Col: " + col.ColumnName + " => " + primRow[col]);
292 } 294 }
293 } 295 }
294 } 296 }
@@ -302,7 +304,7 @@ namespace OpenSim.Framework.Data.MySQL
302 /// <param name="prim"></param> 304 /// <param name="prim"></param>
303 private void LoadItems(SceneObjectPart prim) 305 private void LoadItems(SceneObjectPart prim)
304 { 306 {
305 //MainLog.Instance.Verbose("DATASTORE", "Loading inventory for {0}, {1}", prim.Name, prim.UUID); 307 //m_log.Info(String.Format("[DATASTORE]: Loading inventory for {0}, {1}", prim.Name, prim.UUID));
306 308
307 DataTable dbItems = m_itemsTable; 309 DataTable dbItems = m_itemsTable;
308 310
@@ -316,7 +318,7 @@ namespace OpenSim.Framework.Data.MySQL
316 TaskInventoryItem item = buildItem(row); 318 TaskInventoryItem item = buildItem(row);
317 inventory.Add(item); 319 inventory.Add(item);
318 320
319 MainLog.Instance.Verbose("DATASTORE", "Restored item {0}, {1}", item.Name, item.ItemID); 321 m_log.Info(String.Format("[DATASTORE]: Restored item {0}, {1}", item.Name, item.ItemID));
320 } 322 }
321 323
322 prim.RestoreInventoryItems(inventory); 324 prim.RestoreInventoryItems(inventory);
@@ -332,7 +334,7 @@ namespace OpenSim.Framework.Data.MySQL
332 public void StoreTerrain(double[,] ter, LLUUID regionID) 334 public void StoreTerrain(double[,] ter, LLUUID regionID)
333 { 335 {
334 int revision = Util.UnixTimeSinceEpoch(); 336 int revision = Util.UnixTimeSinceEpoch();
335 MainLog.Instance.Verbose("DATASTORE", "Storing terrain revision r" + revision.ToString()); 337 m_log.Info("[DATASTORE]: Storing terrain revision r" + revision.ToString());
336 338
337 DataTable terrain = m_dataSet.Tables["terrain"]; 339 DataTable terrain = m_dataSet.Tables["terrain"];
338 lock (m_dataSet) 340 lock (m_dataSet)
@@ -384,11 +386,11 @@ namespace OpenSim.Framework.Data.MySQL
384 } 386 }
385 else 387 else
386 { 388 {
387 MainLog.Instance.Verbose("DATASTORE", "No terrain found for region"); 389 m_log.Info("[DATASTORE]: No terrain found for region");
388 return null; 390 return null;
389 } 391 }
390 392
391 MainLog.Instance.Verbose("DATASTORE", "Loaded terrain revision r" + rev.ToString()); 393 m_log.Info("[DATASTORE]: Loaded terrain revision r" + rev.ToString());
392 } 394 }
393 395
394 return terret; 396 return terret;
@@ -418,7 +420,7 @@ namespace OpenSim.Framework.Data.MySQL
418 public void StoreLandObject(Land parcel, LLUUID regionUUID) 420 public void StoreLandObject(Land parcel, LLUUID regionUUID)
419 { 421 {
420 // Does the new locking fix it? 422 // Does the new locking fix it?
421 MainLog.Instance.Verbose("DATASTORE", "Tedds temp fix: Waiting 3 seconds for stuff to catch up. (Someone please fix! :))"); 423 m_log.Info("[DATASTORE]: Tedds temp fix: Waiting 3 seconds for stuff to catch up. (Someone please fix! :))");
422 System.Threading.Thread.Sleep(2500 + rnd.Next(300, 900)); 424 System.Threading.Thread.Sleep(2500 + rnd.Next(300, 900));
423 425
424 lock (m_dataSet) 426 lock (m_dataSet)
@@ -1214,7 +1216,7 @@ namespace OpenSim.Framework.Data.MySQL
1214 if (!persistPrimInventories) 1216 if (!persistPrimInventories)
1215 return; 1217 return;
1216 1218
1217 MainLog.Instance.Verbose("DATASTORE", "Persisting Prim Inventory with prim ID {0}", primID); 1219 m_log.Info(String.Format("[DATASTORE]: Persisting Prim Inventory with prim ID {0}", primID));
1218 1220
1219 // For now, we're just going to crudely remove all the previous inventory items 1221 // For now, we're just going to crudely remove all the previous inventory items
1220 // no matter whether they have changed or not, and replace them with the current set. 1222 // no matter whether they have changed or not, and replace them with the current set.
@@ -1225,10 +1227,10 @@ namespace OpenSim.Framework.Data.MySQL
1225 // repalce with current inventory details 1227 // repalce with current inventory details
1226 foreach (TaskInventoryItem newItem in items) 1228 foreach (TaskInventoryItem newItem in items)
1227 { 1229 {
1228// MainLog.Instance.Verbose( 1230// m_log.Info(String.Format(
1229// "DATASTORE", 1231// "[DATASTORE]: " +
1230// "Adding item {0}, {1} to prim ID {2}", 1232// "Adding item {0}, {1} to prim ID {2}",
1231// newItem.Name, newItem.ItemID, newItem.ParentPartID); 1233// newItem.Name, newItem.ItemID, newItem.ParentPartID));
1232 1234
1233 DataRow newItemRow = m_itemsTable.NewRow(); 1235 DataRow newItemRow = m_itemsTable.NewRow();
1234 fillItemRow(newItemRow, newItem); 1236 fillItemRow(newItemRow, newItem);
@@ -1332,7 +1334,7 @@ namespace OpenSim.Framework.Data.MySQL
1332 sql += subsql; 1334 sql += subsql;
1333 sql += ")"; 1335 sql += ")";
1334 1336
1335 //MainLog.Instance.Verbose("DATASTORE", "defineTable() sql {0}", sql); 1337 //m_log.Info(String.Format("[DATASTORE]: defineTable() sql {0}", sql));
1336 1338
1337 return sql; 1339 return sql;
1338 } 1340 }
@@ -1463,8 +1465,8 @@ namespace OpenSim.Framework.Data.MySQL
1463 } 1465 }
1464 catch (Exception ex) 1466 catch (Exception ex)
1465 { 1467 {
1466 MainLog.Instance.Error("MySql", "Error connecting to MySQL server: " + ex.Message); 1468 m_log.Error("[MySql]: Error connecting to MySQL server: " + ex.Message);
1467 MainLog.Instance.Error("MySql", "Application is terminating!"); 1469 m_log.Error("[MySql]: Application is terminating!");
1468 System.Threading.Thread.CurrentThread.Abort(); 1470 System.Threading.Thread.CurrentThread.Abort();
1469 } 1471 }
1470 } 1472 }
@@ -1475,7 +1477,7 @@ namespace OpenSim.Framework.Data.MySQL
1475 } 1477 }
1476 catch (MySqlException e) 1478 catch (MySqlException e)
1477 { 1479 {
1478 MainLog.Instance.Warn("MySql", "Primitives Table Already Exists: {0}", e); 1480 m_log.Warn(String.Format("[MySql]: Primitives Table Already Exists: {0}", e));
1479 } 1481 }
1480 1482
1481 try 1483 try
@@ -1484,7 +1486,7 @@ namespace OpenSim.Framework.Data.MySQL
1484 } 1486 }
1485 catch (MySqlException e) 1487 catch (MySqlException e)
1486 { 1488 {
1487 MainLog.Instance.Warn("MySql", "Shapes Table Already Exists: {0}", e); 1489 m_log.Warn(String.Format("[MySql]: Shapes Table Already Exists: {0}", e));
1488 } 1490 }
1489 1491
1490 try 1492 try
@@ -1493,7 +1495,7 @@ namespace OpenSim.Framework.Data.MySQL
1493 } 1495 }
1494 catch (MySqlException e) 1496 catch (MySqlException e)
1495 { 1497 {
1496 MainLog.Instance.Warn("MySql", "Items Table Already Exists: {0}", e); 1498 m_log.Warn(String.Format("[MySql]: Items Table Already Exists: {0}", e));
1497 } 1499 }
1498 1500
1499 try 1501 try
@@ -1502,7 +1504,7 @@ namespace OpenSim.Framework.Data.MySQL
1502 } 1504 }
1503 catch (MySqlException e) 1505 catch (MySqlException e)
1504 { 1506 {
1505 MainLog.Instance.Warn("MySql", "Terrain Table Already Exists: {0}", e); 1507 m_log.Warn(String.Format("[MySql]: Terrain Table Already Exists: {0}", e));
1506 } 1508 }
1507 1509
1508 try 1510 try
@@ -1511,7 +1513,7 @@ namespace OpenSim.Framework.Data.MySQL
1511 } 1513 }
1512 catch (MySqlException e) 1514 catch (MySqlException e)
1513 { 1515 {
1514 MainLog.Instance.Warn("MySql", "Land Table Already Exists: {0}", e); 1516 m_log.Warn(String.Format("[MySql]: Land Table Already Exists: {0}", e));
1515 } 1517 }
1516 1518
1517 try 1519 try
@@ -1520,7 +1522,7 @@ namespace OpenSim.Framework.Data.MySQL
1520 } 1522 }
1521 catch (MySqlException e) 1523 catch (MySqlException e)
1522 { 1524 {
1523 MainLog.Instance.Warn("MySql", "LandAccessList Table Already Exists: {0}", e); 1525 m_log.Warn(String.Format("[MySql]: LandAccessList Table Already Exists: {0}", e));
1524 } 1526 }
1525 conn.Close(); 1527 conn.Close();
1526 } 1528 }
@@ -1555,7 +1557,7 @@ namespace OpenSim.Framework.Data.MySQL
1555 } 1557 }
1556 catch (MySqlException) 1558 catch (MySqlException)
1557 { 1559 {
1558 MainLog.Instance.Verbose("DATASTORE", "MySql Database doesn't exist... creating"); 1560 m_log.Info("[DATASTORE]: MySql Database doesn't exist... creating");
1559 InitDB(conn); 1561 InitDB(conn);
1560 } 1562 }
1561 1563
@@ -1573,7 +1575,7 @@ namespace OpenSim.Framework.Data.MySQL
1573 { 1575 {
1574 if (!tmpDS.Tables["prims"].Columns.Contains(col.ColumnName)) 1576 if (!tmpDS.Tables["prims"].Columns.Contains(col.ColumnName))
1575 { 1577 {
1576 MainLog.Instance.Verbose("DATASTORE", "Missing required column:" + col.ColumnName); 1578 m_log.Info("[DATASTORE]: Missing required column:" + col.ColumnName);
1577 return false; 1579 return false;
1578 } 1580 }
1579 } 1581 }
@@ -1582,7 +1584,7 @@ namespace OpenSim.Framework.Data.MySQL
1582 { 1584 {
1583 if (!tmpDS.Tables["primshapes"].Columns.Contains(col.ColumnName)) 1585 if (!tmpDS.Tables["primshapes"].Columns.Contains(col.ColumnName))
1584 { 1586 {
1585 MainLog.Instance.Verbose("DATASTORE", "Missing required column:" + col.ColumnName); 1587 m_log.Info("[DATASTORE]: Missing required column:" + col.ColumnName);
1586 return false; 1588 return false;
1587 } 1589 }
1588 } 1590 }
@@ -1593,7 +1595,7 @@ namespace OpenSim.Framework.Data.MySQL
1593 { 1595 {
1594 if (!tmpDS.Tables["terrain"].Columns.Contains(col.ColumnName)) 1596 if (!tmpDS.Tables["terrain"].Columns.Contains(col.ColumnName))
1595 { 1597 {
1596 MainLog.Instance.Verbose("DATASTORE", "Missing require column:" + col.ColumnName); 1598 m_log.Info("[DATASTORE]: Missing require column:" + col.ColumnName);
1597 return false; 1599 return false;
1598 } 1600 }
1599 } 1601 }
@@ -1602,7 +1604,7 @@ namespace OpenSim.Framework.Data.MySQL
1602 { 1604 {
1603 if (!tmpDS.Tables["land"].Columns.Contains(col.ColumnName)) 1605 if (!tmpDS.Tables["land"].Columns.Contains(col.ColumnName))
1604 { 1606 {
1605 MainLog.Instance.Verbose("DATASTORE", "Missing require column:" + col.ColumnName); 1607 m_log.Info("[DATASTORE]: Missing require column:" + col.ColumnName);
1606 return false; 1608 return false;
1607 } 1609 }
1608 } 1610 }
@@ -1611,7 +1613,7 @@ namespace OpenSim.Framework.Data.MySQL
1611 { 1613 {
1612 if (!tmpDS.Tables["landaccesslist"].Columns.Contains(col.ColumnName)) 1614 if (!tmpDS.Tables["landaccesslist"].Columns.Contains(col.ColumnName))
1613 { 1615 {
1614 MainLog.Instance.Verbose("DATASTORE", "Missing require column:" + col.ColumnName); 1616 m_log.Info("[DATASTORE]: Missing require column:" + col.ColumnName);
1615 return false; 1617 return false;
1616 } 1618 }
1617 } 1619 }