aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2010-04-16 22:29:11 +0100
committerJustin Clark-Casey (justincc)2010-04-16 22:29:11 +0100
commitbf3956aeb0a44d0dd455e330234fcf0e18f5ea43 (patch)
treeef98a5c369f1359ee1ebcfd9e90ad945039c9c17
parentadd a missing initialization of the m_memoryCache in XmlRpcGroupsServicesConn... (diff)
downloadopensim-SC_OLD-bf3956aeb0a44d0dd455e330234fcf0e18f5ea43.zip
opensim-SC_OLD-bf3956aeb0a44d0dd455e330234fcf0e18f5ea43.tar.gz
opensim-SC_OLD-bf3956aeb0a44d0dd455e330234fcf0e18f5ea43.tar.bz2
opensim-SC_OLD-bf3956aeb0a44d0dd455e330234fcf0e18f5ea43.tar.xz
Add --skip-assets option to load oar.
This allows you to load an oar without loading its assets. This is useful if you know that the required assets are already in the asset service, since loading without assets is quicker. This option will become more useful when the ability to save oars without assets is added, which should happen fairly soon. At this point there will also be better documentation.
-rw-r--r--[-rwxr-xr-x]OpenSim/Region/Application/OpenSim.cs5
-rw-r--r--OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs40
-rw-r--r--OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs19
-rw-r--r--OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs2
-rw-r--r--OpenSim/Region/Framework/Interfaces/IRegionArchiverModule.cs12
5 files changed, 50 insertions, 28 deletions
diff --git a/OpenSim/Region/Application/OpenSim.cs b/OpenSim/Region/Application/OpenSim.cs
index 38b2084..1395030 100755..100644
--- a/OpenSim/Region/Application/OpenSim.cs
+++ b/OpenSim/Region/Application/OpenSim.cs
@@ -251,8 +251,9 @@ namespace OpenSim
251 "Save named prim to XML2", SavePrimsXml2); 251 "Save named prim to XML2", SavePrimsXml2);
252 252
253 m_console.Commands.AddCommand("region", false, "load oar", 253 m_console.Commands.AddCommand("region", false, "load oar",
254 "load oar [--merge] <oar name>", 254 "load oar [--merge] [--skip-assets] <oar name>",
255 "Load a region's data from OAR archive", LoadOar); 255 "Load a region's data from OAR archive. --merge will merge the oar with the existing scene. --skip-assets will load the oar but ignore the assets it contains",
256 LoadOar);
256 257
257 m_console.Commands.AddCommand("region", false, "save oar", 258 m_console.Commands.AddCommand("region", false, "save oar",
258 "save oar <oar name>", 259 "save oar <oar name>",
diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs
index b1b2336f8..cde7c93 100644
--- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs
+++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs
@@ -53,25 +53,30 @@ namespace OpenSim.Region.CoreModules.World.Archiver
53 { 53 {
54 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 54 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
55 55
56 private static ASCIIEncoding m_asciiEncoding = new ASCIIEncoding(); 56 protected static ASCIIEncoding m_asciiEncoding = new ASCIIEncoding();
57 private static UTF8Encoding m_utf8Encoding = new UTF8Encoding(); 57 protected static UTF8Encoding m_utf8Encoding = new UTF8Encoding();
58 58
59 private Scene m_scene; 59 protected Scene m_scene;
60 private Stream m_loadStream; 60 protected Stream m_loadStream;
61 private Guid m_requestId; 61 protected Guid m_requestId;
62 private string m_errorMessage; 62 protected string m_errorMessage;
63 63
64 /// <value> 64 /// <value>
65 /// Should the archive being loaded be merged with what is already on the region? 65 /// Should the archive being loaded be merged with what is already on the region?
66 /// </value> 66 /// </value>
67 private bool m_merge; 67 protected bool m_merge;
68
69 /// <value>
70 /// Should we ignore any assets when reloading the archive?
71 /// </value>
72 protected bool m_skipAssets;
68 73
69 /// <summary> 74 /// <summary>
70 /// Used to cache lookups for valid uuids. 75 /// Used to cache lookups for valid uuids.
71 /// </summary> 76 /// </summary>
72 private IDictionary<UUID, bool> m_validUserUuids = new Dictionary<UUID, bool>(); 77 private IDictionary<UUID, bool> m_validUserUuids = new Dictionary<UUID, bool>();
73 78
74 public ArchiveReadRequest(Scene scene, string loadPath, bool merge, Guid requestId) 79 public ArchiveReadRequest(Scene scene, string loadPath, bool merge, bool skipAssets, Guid requestId)
75 { 80 {
76 m_scene = scene; 81 m_scene = scene;
77 82
@@ -89,14 +94,16 @@ namespace OpenSim.Region.CoreModules.World.Archiver
89 94
90 m_errorMessage = String.Empty; 95 m_errorMessage = String.Empty;
91 m_merge = merge; 96 m_merge = merge;
97 m_skipAssets = skipAssets;
92 m_requestId = requestId; 98 m_requestId = requestId;
93 } 99 }
94 100
95 public ArchiveReadRequest(Scene scene, Stream loadStream, bool merge, Guid requestId) 101 public ArchiveReadRequest(Scene scene, Stream loadStream, bool merge, bool skipAssets, Guid requestId)
96 { 102 {
97 m_scene = scene; 103 m_scene = scene;
98 m_loadStream = loadStream; 104 m_loadStream = loadStream;
99 m_merge = merge; 105 m_merge = merge;
106 m_skipAssets = skipAssets;
100 m_requestId = requestId; 107 m_requestId = requestId;
101 } 108 }
102 109
@@ -135,7 +142,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
135 { 142 {
136 serialisedSceneObjects.Add(m_utf8Encoding.GetString(data)); 143 serialisedSceneObjects.Add(m_utf8Encoding.GetString(data));
137 } 144 }
138 else if (filePath.StartsWith(ArchiveConstants.ASSETS_PATH)) 145 else if (filePath.StartsWith(ArchiveConstants.ASSETS_PATH) && !m_skipAssets)
139 { 146 {
140 if (LoadAsset(filePath, data)) 147 if (LoadAsset(filePath, data))
141 successfulAssetRestores++; 148 successfulAssetRestores++;
@@ -178,12 +185,15 @@ namespace OpenSim.Region.CoreModules.World.Archiver
178 archive.Close(); 185 archive.Close();
179 } 186 }
180 187
181 m_log.InfoFormat("[ARCHIVER]: Restored {0} assets", successfulAssetRestores); 188 if (!m_skipAssets)
182
183 if (failedAssetRestores > 0)
184 { 189 {
185 m_log.ErrorFormat("[ARCHIVER]: Failed to load {0} assets", failedAssetRestores); 190 m_log.InfoFormat("[ARCHIVER]: Restored {0} assets", successfulAssetRestores);
186 m_errorMessage += String.Format("Failed to load {0} assets", failedAssetRestores); 191
192 if (failedAssetRestores > 0)
193 {
194 m_log.ErrorFormat("[ARCHIVER]: Failed to load {0} assets", failedAssetRestores);
195 m_errorMessage += String.Format("Failed to load {0} assets", failedAssetRestores);
196 }
187 } 197 }
188 198
189 if (!m_merge) 199 if (!m_merge)
diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs
index fc8d4e1..82ede01 100644
--- a/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs
+++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs
@@ -94,8 +94,11 @@ namespace OpenSim.Region.CoreModules.World.Archiver
94 public void HandleLoadOarConsoleCommand(string module, string[] cmdparams) 94 public void HandleLoadOarConsoleCommand(string module, string[] cmdparams)
95 { 95 {
96 bool mergeOar = false; 96 bool mergeOar = false;
97 bool skipAssets = false;
97 98
98 OptionSet options = new OptionSet().Add("m|merge", delegate (string v) { mergeOar = v != null; }); 99 OptionSet options = new OptionSet().Add("m|merge", delegate (string v) { mergeOar = v != null; });
100 options.Add("s|skip-assets", delegate (string v) { skipAssets = v != null; });
101
99 List<string> mainParams = options.Parse(cmdparams); 102 List<string> mainParams = options.Parse(cmdparams);
100 103
101// m_log.DebugFormat("MERGE OAR IS [{0}]", mergeOar); 104// m_log.DebugFormat("MERGE OAR IS [{0}]", mergeOar);
@@ -105,11 +108,11 @@ namespace OpenSim.Region.CoreModules.World.Archiver
105 108
106 if (mainParams.Count > 2) 109 if (mainParams.Count > 2)
107 { 110 {
108 DearchiveRegion(mainParams[2], mergeOar, Guid.Empty); 111 DearchiveRegion(mainParams[2], mergeOar, skipAssets, Guid.Empty);
109 } 112 }
110 else 113 else
111 { 114 {
112 DearchiveRegion(DEFAULT_OAR_BACKUP_FILENAME, mergeOar, Guid.Empty); 115 DearchiveRegion(DEFAULT_OAR_BACKUP_FILENAME, mergeOar, skipAssets, Guid.Empty);
113 } 116 }
114 } 117 }
115 118
@@ -154,25 +157,25 @@ namespace OpenSim.Region.CoreModules.World.Archiver
154 157
155 public void DearchiveRegion(string loadPath) 158 public void DearchiveRegion(string loadPath)
156 { 159 {
157 DearchiveRegion(loadPath, false, Guid.Empty); 160 DearchiveRegion(loadPath, false, false, Guid.Empty);
158 } 161 }
159 162
160 public void DearchiveRegion(string loadPath, bool merge, Guid requestId) 163 public void DearchiveRegion(string loadPath, bool merge, bool skipAssets, Guid requestId)
161 { 164 {
162 m_log.InfoFormat( 165 m_log.InfoFormat(
163 "[ARCHIVER]: Loading archive to region {0} from {1}", m_scene.RegionInfo.RegionName, loadPath); 166 "[ARCHIVER]: Loading archive to region {0} from {1}", m_scene.RegionInfo.RegionName, loadPath);
164 167
165 new ArchiveReadRequest(m_scene, loadPath, merge, requestId).DearchiveRegion(); 168 new ArchiveReadRequest(m_scene, loadPath, merge, skipAssets, requestId).DearchiveRegion();
166 } 169 }
167 170
168 public void DearchiveRegion(Stream loadStream) 171 public void DearchiveRegion(Stream loadStream)
169 { 172 {
170 DearchiveRegion(loadStream, false, Guid.Empty); 173 DearchiveRegion(loadStream, false, false, Guid.Empty);
171 } 174 }
172 175
173 public void DearchiveRegion(Stream loadStream, bool merge, Guid requestId) 176 public void DearchiveRegion(Stream loadStream, bool merge, bool skipAssets, Guid requestId)
174 { 177 {
175 new ArchiveReadRequest(m_scene, loadStream, merge, requestId).DearchiveRegion(); 178 new ArchiveReadRequest(m_scene, loadStream, merge, skipAssets, requestId).DearchiveRegion();
176 } 179 }
177 } 180 }
178} 181}
diff --git a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs
index de16d89..624dc22 100644
--- a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs
+++ b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs
@@ -442,7 +442,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
442 byte[] archive = archiveWriteStream.ToArray(); 442 byte[] archive = archiveWriteStream.ToArray();
443 MemoryStream archiveReadStream = new MemoryStream(archive); 443 MemoryStream archiveReadStream = new MemoryStream(archive);
444 444
445 m_archiverModule.DearchiveRegion(archiveReadStream, true, Guid.Empty); 445 m_archiverModule.DearchiveRegion(archiveReadStream, true, false, Guid.Empty);
446 446
447 SceneObjectPart object1Existing = m_scene.GetSceneObjectPart(part1.Name); 447 SceneObjectPart object1Existing = m_scene.GetSceneObjectPart(part1.Name);
448 Assert.That(object1Existing, Is.Not.Null, "object1 was not present after merge"); 448 Assert.That(object1Existing, Is.Not.Null, "object1 was not present after merge");
diff --git a/OpenSim/Region/Framework/Interfaces/IRegionArchiverModule.cs b/OpenSim/Region/Framework/Interfaces/IRegionArchiverModule.cs
index 991d60c..89e59d0 100644
--- a/OpenSim/Region/Framework/Interfaces/IRegionArchiverModule.cs
+++ b/OpenSim/Region/Framework/Interfaces/IRegionArchiverModule.cs
@@ -90,8 +90,12 @@ namespace OpenSim.Region.Framework.Interfaces
90 /// If true, the loaded region merges with the existing one rather than replacing it. Any terrain or region 90 /// If true, the loaded region merges with the existing one rather than replacing it. Any terrain or region
91 /// settings in the archive will be ignored. 91 /// settings in the archive will be ignored.
92 /// </param> 92 /// </param>
93 /// <param name="skipAssets">
94 /// If true, the archive is loaded without loading any assets contained within it. This is useful if the
95 /// assets are already known to be present in the grid's asset service.
96 /// </param>
93 /// <param name="requestId">If supplied, this request Id is later returned in the saved event</param> 97 /// <param name="requestId">If supplied, this request Id is later returned in the saved event</param>
94 void DearchiveRegion(string loadPath, bool merge, Guid requestId); 98 void DearchiveRegion(string loadPath, bool merge, bool skipAssets, Guid requestId);
95 99
96 /// <summary> 100 /// <summary>
97 /// Dearchive a region from a stream. This replaces the existing scene. 101 /// Dearchive a region from a stream. This replaces the existing scene.
@@ -113,7 +117,11 @@ namespace OpenSim.Region.Framework.Interfaces
113 /// If true, the loaded region merges with the existing one rather than replacing it. Any terrain or region 117 /// If true, the loaded region merges with the existing one rather than replacing it. Any terrain or region
114 /// settings in the archive will be ignored. 118 /// settings in the archive will be ignored.
115 /// </param> 119 /// </param>
120 /// <param name="skipAssets">
121 /// If true, the archive is loaded without loading any assets contained within it. This is useful if the
122 /// assets are already known to be present in the grid's asset service.
123 /// </param
116 /// <param name="requestId">If supplied, this request Id is later returned in the saved event</param> 124 /// <param name="requestId">If supplied, this request Id is later returned in the saved event</param>
117 void DearchiveRegion(Stream loadStream, bool merge, Guid requestId); 125 void DearchiveRegion(Stream loadStream, bool merge, bool skipAssets, Guid requestId);
118 } 126 }
119} 127}