aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequest.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequest.cs122
1 files changed, 67 insertions, 55 deletions
diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequest.cs
index cb2c7f1..11c53d7 100644
--- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequest.cs
+++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequest.cs
@@ -60,8 +60,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver
60 /// <summary> 60 /// <summary>
61 /// The minimum major version of OAR that we can write. 61 /// The minimum major version of OAR that we can write.
62 /// </summary> 62 /// </summary>
63 public static int MIN_MAJOR_VERSION = 0; 63 public static int MIN_MAJOR_VERSION = 0;
64 64
65 /// <summary> 65 /// <summary>
66 /// The maximum major version of OAR that we can write. 66 /// The maximum major version of OAR that we can write.
67 /// </summary> 67 /// </summary>
@@ -112,7 +112,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
112 m_log.ErrorFormat("{0} {1}", e.Message, e.StackTrace); 112 m_log.ErrorFormat("{0} {1}", e.Message, e.StackTrace);
113 } 113 }
114 } 114 }
115 115
116 /// <summary> 116 /// <summary>
117 /// Constructor. 117 /// Constructor.
118 /// </summary> 118 /// </summary>
@@ -181,11 +181,13 @@ namespace OpenSim.Region.CoreModules.World.Archiver
181 // Archive the regions 181 // Archive the regions
182 182
183 Dictionary<UUID, sbyte> assetUuids = new Dictionary<UUID, sbyte>(); 183 Dictionary<UUID, sbyte> assetUuids = new Dictionary<UUID, sbyte>();
184 HashSet<UUID> failedIDs = new HashSet<UUID>();
185 HashSet<UUID> uncertainAssetsUUIDs = new HashSet<UUID>();
184 186
185 scenesGroup.ForEachScene(delegate(Scene scene) 187 scenesGroup.ForEachScene(delegate(Scene scene)
186 { 188 {
187 string regionDir = MultiRegionFormat ? scenesGroup.GetRegionDir(scene.RegionInfo.RegionID) : ""; 189 string regionDir = MultiRegionFormat ? scenesGroup.GetRegionDir(scene.RegionInfo.RegionID) : "";
188 ArchiveOneRegion(scene, regionDir, assetUuids); 190 ArchiveOneRegion(scene, regionDir, assetUuids, failedIDs, uncertainAssetsUUIDs);
189 }); 191 });
190 192
191 // Archive the assets 193 // Archive the assets
@@ -193,23 +195,21 @@ namespace OpenSim.Region.CoreModules.World.Archiver
193 if (SaveAssets) 195 if (SaveAssets)
194 { 196 {
195 m_log.DebugFormat("[ARCHIVER]: Saving {0} assets", assetUuids.Count); 197 m_log.DebugFormat("[ARCHIVER]: Saving {0} assets", assetUuids.Count);
196 198
197 // Asynchronously request all the assets required to perform this archive operation 199 AssetsRequest ar = new AssetsRequest(
198 AssetsRequest ar
199 = new AssetsRequest(
200 new AssetsArchiver(m_archiveWriter), assetUuids, 200 new AssetsArchiver(m_archiveWriter), assetUuids,
201 failedIDs.Count,
201 m_rootScene.AssetService, m_rootScene.UserAccountService, 202 m_rootScene.AssetService, m_rootScene.UserAccountService,
202 m_rootScene.RegionInfo.ScopeID, options, ReceivedAllAssets); 203 m_rootScene.RegionInfo.ScopeID, options, null);
203 204 ar.Execute();
204 WorkManager.RunInThread(o => ar.Execute(), null, "Archive Assets Request"); 205 assetUuids = null;
205
206 // CloseArchive() will be called from ReceivedAllAssets()
207 } 206 }
208 else 207 else
209 { 208 {
210 m_log.DebugFormat("[ARCHIVER]: Not saving assets since --noassets was specified"); 209 m_log.DebugFormat("[ARCHIVER]: Not saving assets since --noassets was specified");
211 CloseArchive(string.Empty); 210// CloseArchive(string.Empty);
212 } 211 }
212 CloseArchive(string.Empty);
213 } 213 }
214 catch (Exception e) 214 catch (Exception e)
215 { 215 {
@@ -218,7 +218,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver
218 } 218 }
219 } 219 }
220 220
221 private void ArchiveOneRegion(Scene scene, string regionDir, Dictionary<UUID, sbyte> assetUuids) 221 private void ArchiveOneRegion(Scene scene, string regionDir, Dictionary<UUID, sbyte> assetUuids,
222 HashSet<UUID> failedIDs, HashSet<UUID> uncertainAssetsUUIDs)
222 { 223 {
223 m_log.InfoFormat("[ARCHIVER]: Writing region {0}", scene.Name); 224 m_log.InfoFormat("[ARCHIVER]: Writing region {0}", scene.Name);
224 225
@@ -226,7 +227,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
226 List<SceneObjectGroup> sceneObjects = new List<SceneObjectGroup>(); 227 List<SceneObjectGroup> sceneObjects = new List<SceneObjectGroup>();
227 228
228 int numObjectsSkippedPermissions = 0; 229 int numObjectsSkippedPermissions = 0;
229 230
230 // Filter entities so that we only have scene objects. 231 // Filter entities so that we only have scene objects.
231 // FIXME: Would be nicer to have this as a proper list in SceneGraph, since lots of methods 232 // FIXME: Would be nicer to have this as a proper list in SceneGraph, since lots of methods
232 // end up having to do this 233 // end up having to do this
@@ -237,7 +238,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
237 { 238 {
238 SceneObjectGroup sceneObject = (SceneObjectGroup)entity; 239 SceneObjectGroup sceneObject = (SceneObjectGroup)entity;
239 240
240 if (!sceneObject.IsDeleted && !sceneObject.IsAttachment) 241 if (!sceneObject.IsDeleted && !sceneObject.IsAttachment && !sceneObject.IsTemporary && !sceneObject.inTransit)
241 { 242 {
242 if (!CanUserArchiveObject(scene.RegionInfo.EstateSettings.EstateOwner, sceneObject, FilterContent, permissionsModule)) 243 if (!CanUserArchiveObject(scene.RegionInfo.EstateSettings.EstateOwner, sceneObject, FilterContent, permissionsModule))
243 { 244 {
@@ -254,17 +255,39 @@ namespace OpenSim.Region.CoreModules.World.Archiver
254 255
255 if (SaveAssets) 256 if (SaveAssets)
256 { 257 {
257 UuidGatherer assetGatherer = new UuidGatherer(scene.AssetService, assetUuids); 258 UuidGatherer assetGatherer = new UuidGatherer(scene.AssetService, assetUuids, failedIDs, uncertainAssetsUUIDs);
258 int prevAssets = assetUuids.Count; 259 int prevAssets = assetUuids.Count;
259 260
260 foreach (SceneObjectGroup sceneObject in sceneObjects) 261 foreach (SceneObjectGroup sceneObject in sceneObjects)
262 {
263 int curErrorCntr = assetGatherer.ErrorCount;
264 int possible = assetGatherer.possibleNotAssetCount;
261 assetGatherer.AddForInspection(sceneObject); 265 assetGatherer.AddForInspection(sceneObject);
266 assetGatherer.GatherAll();
267 curErrorCntr = assetGatherer.ErrorCount - curErrorCntr;
268 possible = assetGatherer.possibleNotAssetCount - possible;
269 if(curErrorCntr > 0)
270 {
271 m_log.ErrorFormat("[ARCHIVER]: object {0} '{1}', at {2}, contains {3} references to missing or damaged assets",
272 sceneObject.UUID, sceneObject.Name ,sceneObject.AbsolutePosition.ToString(), curErrorCntr);
273 if(possible > 0)
274 m_log.WarnFormat("[ARCHIVER Warning]: object also contains {0} references that may be to missing or damaged assets or not a problem", possible);
275 }
276 else if(possible > 0)
277 {
278 m_log.WarnFormat("[ARCHIVER Warning]: object {0} '{1}', at {2}, contains {3} references that may be to missing or damaged assets or not a problem",
279 sceneObject.UUID, sceneObject.Name ,sceneObject.AbsolutePosition.ToString(), possible);
280 }
281 }
262 282
263 assetGatherer.GatherAll(); 283 assetGatherer.GatherAll();
264 284
285 int errors = assetGatherer.FailedUUIDs.Count;
265 m_log.DebugFormat( 286 m_log.DebugFormat(
266 "[ARCHIVER]: {0} scene objects to serialize requiring save of {1} assets", 287 "[ARCHIVER]: {0} region scene objects to save reference {1} possible assets",
267 sceneObjects.Count, assetUuids.Count - prevAssets); 288 sceneObjects.Count, assetUuids.Count - prevAssets + errors);
289 if(errors > 0)
290 m_log.DebugFormat("[ARCHIVER]: {0} of these have problems or are not assets and will be ignored", errors);
268 } 291 }
269 292
270 if (numObjectsSkippedPermissions > 0) 293 if (numObjectsSkippedPermissions > 0)
@@ -276,16 +299,16 @@ namespace OpenSim.Region.CoreModules.World.Archiver
276 299
277 // Make sure that we also request terrain texture assets 300 // Make sure that we also request terrain texture assets
278 RegionSettings regionSettings = scene.RegionInfo.RegionSettings; 301 RegionSettings regionSettings = scene.RegionInfo.RegionSettings;
279 302
280 if (regionSettings.TerrainTexture1 != RegionSettings.DEFAULT_TERRAIN_TEXTURE_1) 303 if (regionSettings.TerrainTexture1 != RegionSettings.DEFAULT_TERRAIN_TEXTURE_1)
281 assetUuids[regionSettings.TerrainTexture1] = (sbyte)AssetType.Texture; 304 assetUuids[regionSettings.TerrainTexture1] = (sbyte)AssetType.Texture;
282 305
283 if (regionSettings.TerrainTexture2 != RegionSettings.DEFAULT_TERRAIN_TEXTURE_2) 306 if (regionSettings.TerrainTexture2 != RegionSettings.DEFAULT_TERRAIN_TEXTURE_2)
284 assetUuids[regionSettings.TerrainTexture2] = (sbyte)AssetType.Texture; 307 assetUuids[regionSettings.TerrainTexture2] = (sbyte)AssetType.Texture;
285 308
286 if (regionSettings.TerrainTexture3 != RegionSettings.DEFAULT_TERRAIN_TEXTURE_3) 309 if (regionSettings.TerrainTexture3 != RegionSettings.DEFAULT_TERRAIN_TEXTURE_3)
287 assetUuids[regionSettings.TerrainTexture3] = (sbyte)AssetType.Texture; 310 assetUuids[regionSettings.TerrainTexture3] = (sbyte)AssetType.Texture;
288 311
289 if (regionSettings.TerrainTexture4 != RegionSettings.DEFAULT_TERRAIN_TEXTURE_4) 312 if (regionSettings.TerrainTexture4 != RegionSettings.DEFAULT_TERRAIN_TEXTURE_4)
290 assetUuids[regionSettings.TerrainTexture4] = (sbyte)AssetType.Texture; 313 assetUuids[regionSettings.TerrainTexture4] = (sbyte)AssetType.Texture;
291 314
@@ -398,18 +421,18 @@ namespace OpenSim.Region.CoreModules.World.Archiver
398// string[] parts = m_options["version"].ToString().Split('.'); 421// string[] parts = m_options["version"].ToString().Split('.');
399// if (parts.Length >= 1) 422// if (parts.Length >= 1)
400// { 423// {
401// majorVersion = Int32.Parse(parts[0]); 424// majorVersion = Int32.Parse(parts[0]);
402// 425//
403// if (parts.Length >= 2) 426// if (parts.Length >= 2)
404// minorVersion = Int32.Parse(parts[1]); 427// minorVersion = Int32.Parse(parts[1]);
405// } 428// }
406// } 429// }
407// 430//
408// if (majorVersion < MIN_MAJOR_VERSION || majorVersion > MAX_MAJOR_VERSION) 431// if (majorVersion < MIN_MAJOR_VERSION || majorVersion > MAX_MAJOR_VERSION)
409// { 432// {
410// throw new Exception( 433// throw new Exception(
411// string.Format( 434// string.Format(
412// "OAR version number for save must be between {0} and {1}", 435// "OAR version number for save must be between {0} and {1}",
413// MIN_MAJOR_VERSION, MAX_MAJOR_VERSION)); 436// MIN_MAJOR_VERSION, MAX_MAJOR_VERSION));
414// } 437// }
415// else if (majorVersion == MAX_MAJOR_VERSION) 438// else if (majorVersion == MAX_MAJOR_VERSION)
@@ -420,9 +443,9 @@ namespace OpenSim.Region.CoreModules.World.Archiver
420// else if (majorVersion == MIN_MAJOR_VERSION) 443// else if (majorVersion == MIN_MAJOR_VERSION)
421// { 444// {
422// // Force 0.4 445// // Force 0.4
423// minorVersion = 4; 446// minorVersion = 4;
424// } 447// }
425 448
426 m_log.InfoFormat("[ARCHIVER]: Creating version {0}.{1} OAR", majorVersion, minorVersion); 449 m_log.InfoFormat("[ARCHIVER]: Creating version {0}.{1} OAR", majorVersion, minorVersion);
427 if (majorVersion == 1) 450 if (majorVersion == 1)
428 { 451 {
@@ -430,7 +453,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
430 } 453 }
431 454
432 String s; 455 String s;
433 456
434 using (StringWriter sw = new StringWriter()) 457 using (StringWriter sw = new StringWriter())
435 { 458 {
436 using (XmlTextWriter xtw = new XmlTextWriter(sw)) 459 using (XmlTextWriter xtw = new XmlTextWriter(sw))
@@ -440,7 +463,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
440 xtw.WriteStartElement("archive"); 463 xtw.WriteStartElement("archive");
441 xtw.WriteAttributeString("major_version", majorVersion.ToString()); 464 xtw.WriteAttributeString("major_version", majorVersion.ToString());
442 xtw.WriteAttributeString("minor_version", minorVersion.ToString()); 465 xtw.WriteAttributeString("minor_version", minorVersion.ToString());
443 466
444 xtw.WriteStartElement("creation_info"); 467 xtw.WriteStartElement("creation_info");
445 DateTime now = DateTime.UtcNow; 468 DateTime now = DateTime.UtcNow;
446 TimeSpan t = now - new DateTime(1970, 1, 1); 469 TimeSpan t = now - new DateTime(1970, 1, 1);
@@ -448,7 +471,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
448 if (!MultiRegionFormat) 471 if (!MultiRegionFormat)
449 xtw.WriteElementString("id", m_rootScene.RegionInfo.RegionID.ToString()); 472 xtw.WriteElementString("id", m_rootScene.RegionInfo.RegionID.ToString());
450 xtw.WriteEndElement(); 473 xtw.WriteEndElement();
451 474
452 xtw.WriteElementString("assets_included", SaveAssets.ToString()); 475 xtw.WriteElementString("assets_included", SaveAssets.ToString());
453 476
454 if (MultiRegionFormat) 477 if (MultiRegionFormat)
@@ -463,7 +486,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
463 } 486 }
464 487
465 xtw.WriteEndElement(); 488 xtw.WriteEndElement();
466 489
467 xtw.Flush(); 490 xtw.Flush();
468 } 491 }
469 492
@@ -522,22 +545,10 @@ namespace OpenSim.Region.CoreModules.World.Archiver
522 545
523 protected static void WriteRegionInfo(Scene scene, XmlTextWriter xtw) 546 protected static void WriteRegionInfo(Scene scene, XmlTextWriter xtw)
524 { 547 {
525 bool isMegaregion;
526 Vector2 size; 548 Vector2 size;
527 549
528 IRegionCombinerModule rcMod = scene.RequestModuleInterface<IRegionCombinerModule>(); 550 size = new Vector2((float)scene.RegionInfo.RegionSizeX, (float)scene.RegionInfo.RegionSizeY);
529 551
530 if (rcMod != null)
531 isMegaregion = rcMod.IsRootForMegaregion(scene.RegionInfo.RegionID);
532 else
533 isMegaregion = false;
534
535 if (isMegaregion)
536 size = rcMod.GetSizeOfMegaregion(scene.RegionInfo.RegionID);
537 else
538 size = new Vector2((float)scene.RegionInfo.RegionSizeX, (float)scene.RegionInfo.RegionSizeY);
539
540 xtw.WriteElementString("is_megaregion", isMegaregion.ToString());
541 xtw.WriteElementString("size_in_meters", string.Format("{0},{1}", size.X, size.Y)); 552 xtw.WriteElementString("size_in_meters", string.Format("{0},{1}", size.X, size.Y));
542 } 553 }
543 554
@@ -560,7 +571,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
560 foreach (ILandObject lo in landObjects) 571 foreach (ILandObject lo in landObjects)
561 { 572 {
562 LandData landData = lo.LandData; 573 LandData landData = lo.LandData;
563 string landDataPath 574 string landDataPath
564 = String.Format("{0}{1}", regionDir, ArchiveConstants.CreateOarLandDataPath(landData)); 575 = String.Format("{0}{1}", regionDir, ArchiveConstants.CreateOarLandDataPath(landData));
565 m_archiveWriter.WriteFile(landDataPath, LandDataSerializer.Serialize(landData, m_options)); 576 m_archiveWriter.WriteFile(landDataPath, LandDataSerializer.Serialize(landData, m_options));
566 } 577 }
@@ -584,17 +595,18 @@ namespace OpenSim.Region.CoreModules.World.Archiver
584 foreach (SceneObjectGroup sceneObject in sceneObjects) 595 foreach (SceneObjectGroup sceneObject in sceneObjects)
585 { 596 {
586 //m_log.DebugFormat("[ARCHIVER]: Saving {0} {1}, {2}", entity.Name, entity.UUID, entity.GetType()); 597 //m_log.DebugFormat("[ARCHIVER]: Saving {0} {1}, {2}", entity.Name, entity.UUID, entity.GetType());
587 598 if(sceneObject.IsDeleted || sceneObject.inTransit)
599 continue;
588 string serializedObject = serializer.SerializeGroupToXml2(sceneObject, m_options); 600 string serializedObject = serializer.SerializeGroupToXml2(sceneObject, m_options);
589 string objectPath = string.Format("{0}{1}", regionDir, ArchiveHelpers.CreateObjectPath(sceneObject)); 601 string objectPath = string.Format("{0}{1}", regionDir, ArchiveHelpers.CreateObjectPath(sceneObject));
590 m_archiveWriter.WriteFile(objectPath, serializedObject); 602 m_archiveWriter.WriteFile(objectPath, serializedObject);
591 } 603 }
592 } 604 }
593 605
594 protected void ReceivedAllAssets(ICollection<UUID> assetsFoundUuids, ICollection<UUID> assetsNotFoundUuids, bool timedOut) 606 protected void ReceivedAllAssets(ICollection<UUID> assetsFoundUuids, ICollection<UUID> assetsNotFoundUuids, bool timedOut)
595 { 607 {
596 string errorMessage; 608 string errorMessage;
597 609
598 if (timedOut) 610 if (timedOut)
599 { 611 {
600 errorMessage = "Loading assets timed out"; 612 errorMessage = "Loading assets timed out";
@@ -612,10 +624,10 @@ namespace OpenSim.Region.CoreModules.World.Archiver
612 624
613 errorMessage = String.Empty; 625 errorMessage = String.Empty;
614 } 626 }
615 627
616 CloseArchive(errorMessage); 628 CloseArchive(errorMessage);
617 } 629 }
618 630
619 /// <summary> 631 /// <summary>
620 /// Closes the archive and notifies that we're done. 632 /// Closes the archive and notifies that we're done.
621 /// </summary> 633 /// </summary>
@@ -634,7 +646,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
634 if (errorMessage == string.Empty) 646 if (errorMessage == string.Empty)
635 errorMessage = e.Message; 647 errorMessage = e.Message;
636 } 648 }
637 649
638 m_log.InfoFormat("[ARCHIVER]: Finished writing out OAR for {0}", m_rootScene.RegionInfo.RegionName); 650 m_log.InfoFormat("[ARCHIVER]: Finished writing out OAR for {0}", m_rootScene.RegionInfo.RegionName);
639 651
640 m_rootScene.EventManager.TriggerOarFileSaved(m_requestId, errorMessage); 652 m_rootScene.EventManager.TriggerOarFileSaved(m_requestId, errorMessage);