aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Data.MySQL/MySQLDataStore.cs
diff options
context:
space:
mode:
authorJustin Clarke Casey2008-01-21 15:06:49 +0000
committerJustin Clarke Casey2008-01-21 15:06:49 +0000
commit504ae63669e5c57cd89e8213b853c27506012f79 (patch)
tree0d12e5baa7b7e5ec29676398629e56f3c93b98d5 /OpenSim/Framework/Data.MySQL/MySQLDataStore.cs
parentSmall bug in ResetScript (diff)
downloadopensim-SC-504ae63669e5c57cd89e8213b853c27506012f79.zip
opensim-SC-504ae63669e5c57cd89e8213b853c27506012f79.tar.gz
opensim-SC-504ae63669e5c57cd89e8213b853c27506012f79.tar.bz2
opensim-SC-504ae63669e5c57cd89e8213b853c27506012f79.tar.xz
* Make object persistence more granular by separating prim and prim inventory persistence
Diffstat (limited to 'OpenSim/Framework/Data.MySQL/MySQLDataStore.cs')
-rw-r--r--OpenSim/Framework/Data.MySQL/MySQLDataStore.cs162
1 files changed, 71 insertions, 91 deletions
diff --git a/OpenSim/Framework/Data.MySQL/MySQLDataStore.cs b/OpenSim/Framework/Data.MySQL/MySQLDataStore.cs
index a314d2e..698569a 100644
--- a/OpenSim/Framework/Data.MySQL/MySQLDataStore.cs
+++ b/OpenSim/Framework/Data.MySQL/MySQLDataStore.cs
@@ -156,9 +156,9 @@ namespace OpenSim.Framework.Data.MySQL
156 // MainLog.Instance.Verbose("DATASTORE", "Ignoring Physical obj: " + obj.UUID + " in region: " + regionUUID); 156 // MainLog.Instance.Verbose("DATASTORE", "Ignoring Physical obj: " + obj.UUID + " in region: " + regionUUID);
157 } 157 }
158 } 158 }
159 }
159 160
160 Commit(); 161 Commit();
161 }
162 } 162 }
163 163
164 public void RemoveObject(LLUUID obj, LLUUID regionUUID) 164 public void RemoveObject(LLUUID obj, LLUUID regionUUID)
@@ -198,9 +198,9 @@ namespace OpenSim.Framework.Data.MySQL
198 // Remove prim row 198 // Remove prim row
199 row.Delete(); 199 row.Delete();
200 } 200 }
201 }
201 202
202 Commit(); 203 Commit();
203 }
204 } 204 }
205 205
206 /// <summary> 206 /// <summary>
@@ -215,84 +215,77 @@ namespace OpenSim.Framework.Data.MySQL
215 DataTable prims = m_primTable; 215 DataTable prims = m_primTable;
216 DataTable shapes = m_shapeTable; 216 DataTable shapes = m_shapeTable;
217 217
218 try 218 string byRegion = "RegionUUID = '" + Util.ToRawUuidString(regionUUID) + "'";
219 string orderByParent = "ParentID ASC";
220
221 lock (m_dataSet)
219 { 222 {
220 string byRegion = "RegionUUID = '" + Util.ToRawUuidString(regionUUID) + "'"; 223 DataRow[] primsForRegion = prims.Select(byRegion, orderByParent);
221 string orderByParent = "ParentID ASC"; 224 MainLog.Instance.Verbose("DATASTORE",
225 "Loaded " + primsForRegion.Length + " prims for region: " + regionUUID);
222 226
223 lock (m_dataSet) 227 foreach (DataRow primRow in primsForRegion)
224 { 228 {
225 DataRow[] primsForRegion = prims.Select(byRegion, orderByParent); 229 try
226 MainLog.Instance.Verbose("DATASTORE",
227 "Loaded " + primsForRegion.Length + " prims for region: " + regionUUID);
228
229 foreach (DataRow primRow in primsForRegion)
230 { 230 {
231 try 231 string uuid = (string) primRow["UUID"];
232 string objID = (string) primRow["SceneGroupID"];
233
234 SceneObjectPart prim = buildPrim(primRow);
235
236 if (uuid == objID) //is new SceneObjectGroup ?
232 { 237 {
233 string uuid = (string)primRow["UUID"]; 238 SceneObjectGroup group = new SceneObjectGroup();
234 string objID = (string)primRow["SceneGroupID"]; 239
235 240 DataRow shapeRow = shapes.Rows.Find(Util.ToRawUuidString(prim.UUID));
236 SceneObjectPart prim = buildPrim(primRow); 241 if (shapeRow != null)
237
238 if (uuid == objID) //is new SceneObjectGroup ?
239 { 242 {
240 SceneObjectGroup group = new SceneObjectGroup(); 243 prim.Shape = buildShape(shapeRow);
241
242 DataRow shapeRow = shapes.Rows.Find(Util.ToRawUuidString(prim.UUID));
243 if (shapeRow != null)
244 {
245 prim.Shape = buildShape(shapeRow);
246 }
247 else
248 {
249 MainLog.Instance.Notice(
250 "No shape found for prim in storage, so setting default box shape");
251 prim.Shape = PrimitiveBaseShape.Default;
252 }
253 group.AddPart(prim);
254 group.RootPart = prim;
255
256 createdObjects.Add(group.UUID, group);
257 retvals.Add(group);
258 } 244 }
259 else 245 else
260 { 246 {
261 DataRow shapeRow = shapes.Rows.Find(Util.ToRawUuidString(prim.UUID)); 247 MainLog.Instance.Notice(
262 if (shapeRow != null) 248 "No shape found for prim in storage, so setting default box shape");
263 { 249 prim.Shape = PrimitiveBaseShape.Default;
264 prim.Shape = buildShape(shapeRow);
265 }
266 else
267 {
268 MainLog.Instance.Notice(
269 "No shape found for prim in storage, so setting default box shape");
270 prim.Shape = PrimitiveBaseShape.Default;
271 }
272 createdObjects[new LLUUID(objID)].AddPart(prim);
273 } 250 }
251 group.AddPart(prim);
252 group.RootPart = prim;
274 253
275 if (persistPrimInventories) 254 createdObjects.Add(group.UUID, group);
276 { 255 retvals.Add(group);
277 LoadItems(prim);
278 }
279 } 256 }
280 catch (Exception e) 257 else
281 { 258 {
282 MainLog.Instance.Error("DATASTORE", "Failed create prim object, exception and data follows"); 259 DataRow shapeRow = shapes.Rows.Find(Util.ToRawUuidString(prim.UUID));
283 MainLog.Instance.Verbose("DATASTORE", e.ToString()); 260 if (shapeRow != null)
284 foreach (DataColumn col in prims.Columns)
285 { 261 {
286 MainLog.Instance.Verbose("DATASTORE", "Col: " + col.ColumnName + " => " + primRow[col]); 262 prim.Shape = buildShape(shapeRow);
287 } 263 }
264 else
265 {
266 MainLog.Instance.Notice(
267 "No shape found for prim in storage, so setting default box shape");
268 prim.Shape = PrimitiveBaseShape.Default;
269 }
270 createdObjects[new LLUUID(objID)].AddPart(prim);
271 }
272
273 if (persistPrimInventories)
274 {
275 LoadItems(prim);
276 }
277 }
278 catch (Exception e)
279 {
280 MainLog.Instance.Error("DATASTORE", "Failed create prim object, exception and data follows");
281 MainLog.Instance.Verbose("DATASTORE", e.ToString());
282 foreach (DataColumn col in prims.Columns)
283 {
284 MainLog.Instance.Verbose("DATASTORE", "Col: " + col.ColumnName + " => " + primRow[col]);
288 } 285 }
289 } 286 }
290 } 287 }
291 } 288 }
292 catch (Exception ex)
293 {
294 MainLog.Instance.Error("DATASTORE", "Exception trying to load prim objects for region " + regionUUID + ": " + ex.ToString());
295 }
296 return retvals; 289 return retvals;
297 } 290 }
298 291
@@ -416,8 +409,6 @@ namespace OpenSim.Framework.Data.MySQL
416 409
417 public void StoreLandObject(Land parcel, LLUUID regionUUID) 410 public void StoreLandObject(Land parcel, LLUUID regionUUID)
418 { 411 {
419 MainLog.Instance.Verbose("DATASTORE", "Tedds temp fix: Waiting 3 seconds for stuff to catch up. (Someone please fix! :))");
420 System.Threading.Thread.Sleep(3000);
421 lock (m_dataSet) 412 lock (m_dataSet)
422 { 413 {
423 DataTable land = m_landTable; 414 DataTable land = m_landTable;
@@ -449,9 +440,9 @@ namespace OpenSim.Framework.Data.MySQL
449 fillLandAccessRow(newAccessRow, entry, parcel.landData.globalID); 440 fillLandAccessRow(newAccessRow, entry, parcel.landData.globalID);
450 landaccesslist.Rows.Add(newAccessRow); 441 landaccesslist.Rows.Add(newAccessRow);
451 } 442 }
443 }
452 444
453 Commit(); 445 Commit();
454 }
455 } 446 }
456 447
457 public List<LandData> LoadLandObjects(LLUUID regionUUID) 448 public List<LandData> LoadLandObjects(LLUUID regionUUID)
@@ -519,6 +510,8 @@ namespace OpenSim.Framework.Data.MySQL
519 m_connection.Open(); 510 m_connection.Open();
520 } 511 }
521 512
513 lock (m_dataSet)
514 {
522 // DisplayDataSet(m_dataSet, "Region DataSet"); 515 // DisplayDataSet(m_dataSet, "Region DataSet");
523 516
524 m_primDataAdapter.Update(m_primTable); 517 m_primDataAdapter.Update(m_primTable);
@@ -528,20 +521,18 @@ namespace OpenSim.Framework.Data.MySQL
528 { 521 {
529 m_itemsDataAdapter.Update(m_itemsTable); 522 m_itemsDataAdapter.Update(m_itemsTable);
530 } 523 }
531 524
532 m_terrainDataAdapter.Update(m_terrainTable); 525 m_terrainDataAdapter.Update(m_terrainTable);
533 m_landDataAdapter.Update(m_landTable); 526 m_landDataAdapter.Update(m_landTable);
534 m_landAccessListDataAdapter.Update(m_landAccessListTable); 527 m_landAccessListDataAdapter.Update(m_landAccessListTable);
535 528
536 m_dataSet.AcceptChanges(); 529 m_dataSet.AcceptChanges();
530 }
537 } 531 }
538 532
539 public void Shutdown() 533 public void Shutdown()
540 { 534 {
541 lock (m_dataSet) 535 Commit();
542 {
543 Commit();
544 }
545 } 536 }
546 537
547 /*********************************************************************** 538 /***********************************************************************
@@ -1201,23 +1192,16 @@ namespace OpenSim.Framework.Data.MySQL
1201 else 1192 else
1202 { 1193 {
1203 fillShapeRow(shapeRow, prim); 1194 fillShapeRow(shapeRow, prim);
1204 } 1195 }
1205
1206 if (persistPrimInventories)
1207 {
1208 addPrimInventory(prim.UUID, prim.TaskInventory);
1209 }
1210 } 1196 }
1211 1197
1212 /// <summary> 1198 // see IRegionDatastore
1213 /// Persist prim inventory. Deletes, updates and inserts rows. 1199 public void StorePrimInventory(LLUUID primID, IDictionary<LLUUID, TaskInventoryItem> items)
1214 /// </summary>
1215 /// <param name="primID"></param>
1216 /// <param name="items"></param>
1217 /// <returns></returns>
1218 private void addPrimInventory(LLUUID primID, IDictionary<LLUUID, TaskInventoryItem> items)
1219 { 1200 {
1220 MainLog.Instance.Verbose("DATASTORE", "Entered addPrimInventory with prim ID {0}", primID); 1201 if (!persistPrimInventories)
1202 return;
1203
1204 MainLog.Instance.Verbose("DATASTORE", "Entered StorePrimInventory with prim ID {0}", primID);
1221 1205
1222 // Find all existing inventory rows for this prim 1206 // Find all existing inventory rows for this prim
1223 DataTable dbItems = m_itemsTable; 1207 DataTable dbItems = m_itemsTable;
@@ -1585,12 +1569,10 @@ namespace OpenSim.Framework.Data.MySQL
1585 { 1569 {
1586 pDa.Fill(tmpDS, "prims"); 1570 pDa.Fill(tmpDS, "prims");
1587 sDa.Fill(tmpDS, "primshapes"); 1571 sDa.Fill(tmpDS, "primshapes");
1588 1572
1589 if (persistPrimInventories) 1573 if (persistPrimInventories)
1590 {
1591 iDa.Fill(tmpDS, "primitems"); 1574 iDa.Fill(tmpDS, "primitems");
1592 } 1575
1593
1594 tDa.Fill(tmpDS, "terrain"); 1576 tDa.Fill(tmpDS, "terrain");
1595 lDa.Fill(tmpDS, "land"); 1577 lDa.Fill(tmpDS, "land");
1596 lalDa.Fill(tmpDS, "landaccesslist"); 1578 lalDa.Fill(tmpDS, "landaccesslist");
@@ -1603,12 +1585,10 @@ namespace OpenSim.Framework.Data.MySQL
1603 1585
1604 pDa.Fill(tmpDS, "prims"); 1586 pDa.Fill(tmpDS, "prims");
1605 sDa.Fill(tmpDS, "primshapes"); 1587 sDa.Fill(tmpDS, "primshapes");
1606 1588
1607 if (persistPrimInventories) 1589 if (persistPrimInventories)
1608 {
1609 iDa.Fill(tmpDS, "primitems"); 1590 iDa.Fill(tmpDS, "primitems");
1610 } 1591
1611
1612 tDa.Fill(tmpDS, "terrain"); 1592 tDa.Fill(tmpDS, "terrain");
1613 lDa.Fill(tmpDS, "land"); 1593 lDa.Fill(tmpDS, "land");
1614 lalDa.Fill(tmpDS, "landaccesslist"); 1594 lalDa.Fill(tmpDS, "landaccesslist");