aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs
diff options
context:
space:
mode:
authorJustin Clarke Casey2009-05-14 20:37:54 +0000
committerJustin Clarke Casey2009-05-14 20:37:54 +0000
commit62771560448edbc2112d427acd4b37780dfe2154 (patch)
treeba07c1ae1d8de5e24e24a013fcaa39ade898f039 /OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs
parent* refactor: move SceneXmlLoader into subpackage (diff)
downloadopensim-SC_OLD-62771560448edbc2112d427acd4b37780dfe2154.zip
opensim-SC_OLD-62771560448edbc2112d427acd4b37780dfe2154.tar.gz
opensim-SC_OLD-62771560448edbc2112d427acd4b37780dfe2154.tar.bz2
opensim-SC_OLD-62771560448edbc2112d427acd4b37780dfe2154.tar.xz
* When saving an oar, save assets when immediately received rather than storing them all up in memory
* Hopefully this will remove out of memory problems when saving large oars on machines without much memory * It may also speed up saving of large oars
Diffstat (limited to 'OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs')
-rw-r--r--OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs53
1 files changed, 31 insertions, 22 deletions
diff --git a/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs
index 0a0bb4c..d806a9c 100644
--- a/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs
+++ b/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs
@@ -32,6 +32,7 @@ using System.Threading;
32using log4net; 32using log4net;
33using OpenMetaverse; 33using OpenMetaverse;
34using OpenSim.Framework; 34using OpenSim.Framework;
35using OpenSim.Framework.Serialization;
35 36
36namespace OpenSim.Region.CoreModules.World.Archiver 37namespace OpenSim.Region.CoreModules.World.Archiver
37{ 38{
@@ -42,39 +43,43 @@ namespace OpenSim.Region.CoreModules.World.Archiver
42 { 43 {
43 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 44 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
44 45
45 /// <summary> 46 /// <value>
46 /// uuids to request 47 /// uuids to request
47 /// </summary> 48 /// </value>
48 protected ICollection<UUID> m_uuids; 49 protected ICollection<UUID> m_uuids;
49 50
50 /// <summary> 51 /// <value>
51 /// Callback used when all the assets requested have been received. 52 /// Callback used when all the assets requested have been received.
52 /// </summary> 53 /// </value>
53 protected AssetsRequestCallback m_assetsRequestCallback; 54 protected AssetsRequestCallback m_assetsRequestCallback;
54 55
55 /// <summary> 56 /// <value>
56 /// Assets retrieved in this request 57 /// List of assets that were found. This will be passed back to the requester.
57 /// </summary> 58 /// </value>
58 protected Dictionary<UUID, AssetBase> m_assets = new Dictionary<UUID, AssetBase>(); 59 protected List<UUID> m_foundAssetUuids = new List<UUID>();
59 60
60 /// <summary> 61 /// <value>
61 /// Maintain a list of assets that could not be found. This will be passed back to the requester. 62 /// Maintain a list of assets that could not be found. This will be passed back to the requester.
62 /// </summary> 63 /// </value>
63 protected List<UUID> m_notFoundAssetUuids = new List<UUID>(); 64 protected List<UUID> m_notFoundAssetUuids = new List<UUID>();
64 65
65 /// <summary> 66 /// <value>
66 /// Record the number of asset replies required so we know when we've finished 67 /// Record the number of asset replies required so we know when we've finished
67 /// </summary> 68 /// </value>
68 private int m_repliesRequired; 69 private int m_repliesRequired;
69 70
70 /// <summary> 71 /// <value>
71 /// Asset cache used to request the assets 72 /// Asset cache used to request the assets
72 /// </summary> 73 /// </value>
73 protected IAssetCache m_assetCache; 74 protected IAssetCache m_assetCache;
74 75
76 protected AssetsArchiver m_assetsArchiver;
77
75 protected internal AssetsRequest( 78 protected internal AssetsRequest(
76 ICollection<UUID> uuids, IAssetCache assetCache, AssetsRequestCallback assetsRequestCallback) 79 AssetsArchiver assetsArchiver, ICollection<UUID> uuids,
80 IAssetCache assetCache, AssetsRequestCallback assetsRequestCallback)
77 { 81 {
82 m_assetsArchiver = assetsArchiver;
78 m_uuids = uuids; 83 m_uuids = uuids;
79 m_assetsRequestCallback = assetsRequestCallback; 84 m_assetsRequestCallback = assetsRequestCallback;
80 m_assetCache = assetCache; 85 m_assetCache = assetCache;
@@ -87,7 +92,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
87 92
88 // We can stop here if there are no assets to fetch 93 // We can stop here if there are no assets to fetch
89 if (m_repliesRequired == 0) 94 if (m_repliesRequired == 0)
90 m_assetsRequestCallback(m_assets, m_notFoundAssetUuids); 95 m_assetsRequestCallback(m_foundAssetUuids, m_notFoundAssetUuids);
91 96
92 foreach (UUID uuid in m_uuids) 97 foreach (UUID uuid in m_uuids)
93 { 98 {
@@ -106,21 +111,25 @@ namespace OpenSim.Region.CoreModules.World.Archiver
106 111
107 if (asset != null) 112 if (asset != null)
108 { 113 {
114 // Make sure that we don't run out of memory by hogging assets in the cache
109 m_assetCache.ExpireAsset(assetID); 115 m_assetCache.ExpireAsset(assetID);
110 m_assets[assetID] = asset; 116
117 m_foundAssetUuids.Add(assetID);
118 m_assetsArchiver.WriteAsset(asset);
111 } 119 }
112 else 120 else
113 { 121 {
114 m_notFoundAssetUuids.Add(assetID); 122 m_notFoundAssetUuids.Add(assetID);
115 } 123 }
116 124
117 if (m_assets.Count + m_notFoundAssetUuids.Count == m_repliesRequired) 125 if (m_foundAssetUuids.Count + m_notFoundAssetUuids.Count == m_repliesRequired)
118 { 126 {
119 m_log.DebugFormat( 127 m_log.DebugFormat(
120 "[ARCHIVER]: Successfully received {0} assets and notification of {1} missing assets", 128 "[ARCHIVER]: Successfully received {0} assets and notification of {1} missing assets",
121 m_assets.Count, m_notFoundAssetUuids.Count); 129 m_foundAssetUuids.Count, m_notFoundAssetUuids.Count);
122 130
123 // We want to stop using the asset cache thread asap as we now need to do the actual work of producing the archive 131 // We want to stop using the asset cache thread asap
132 // as we now need to do the work of producing the rest of the archive
124 Thread newThread = new Thread(PerformAssetsRequestCallback); 133 Thread newThread = new Thread(PerformAssetsRequestCallback);
125 newThread.Name = "OpenSimulator archiving thread post assets receipt"; 134 newThread.Name = "OpenSimulator archiving thread post assets receipt";
126 newThread.Start(); 135 newThread.Start();
@@ -134,7 +143,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
134 { 143 {
135 try 144 try
136 { 145 {
137 m_assetsRequestCallback(m_assets, m_notFoundAssetUuids); 146 m_assetsRequestCallback(m_foundAssetUuids, m_notFoundAssetUuids);
138 } 147 }
139 catch (Exception e) 148 catch (Exception e)
140 { 149 {