aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authordiva2009-05-23 17:51:13 +0000
committerdiva2009-05-23 17:51:13 +0000
commitfb6d314d4db0a157799a1d49a5f467f1c051ec9b (patch)
tree3a5f7c8d3f91722d6a32ee85b7031dfb4c2de6b0 /OpenSim
parentAdded one missing config var for HG standalones. (diff)
downloadopensim-SC_OLD-fb6d314d4db0a157799a1d49a5f467f1c051ec9b.zip
opensim-SC_OLD-fb6d314d4db0a157799a1d49a5f467f1c051ec9b.tar.gz
opensim-SC_OLD-fb6d314d4db0a157799a1d49a5f467f1c051ec9b.tar.bz2
opensim-SC_OLD-fb6d314d4db0a157799a1d49a5f467f1c051ec9b.tar.xz
This should make HG asset transfers work much better. It now uses HGUuidGatherer, which is a subclass of UuidGatherer. Hence, on-line HG asset transfers use exactly the same UUID collection code as save oar/xml. If it doesn't work, it's Justin's fault :D
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectors/Asset/HGAssetBroker.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs122
-rw-r--r--OpenSim/Region/Framework/Scenes/Hypergrid/HGScene.Inventory.cs34
-rw-r--r--OpenSim/Region/Framework/Scenes/Hypergrid/HGUuidGatherer.cs29
-rw-r--r--OpenSim/Region/Framework/Scenes/UuidGatherer.cs2
-rw-r--r--OpenSim/Services/AssetService/AssetService.cs5
6 files changed, 76 insertions, 118 deletions
diff --git a/OpenSim/Region/CoreModules/ServiceConnectors/Asset/HGAssetBroker.cs b/OpenSim/Region/CoreModules/ServiceConnectors/Asset/HGAssetBroker.cs
index aef04bf..42acde7 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectors/Asset/HGAssetBroker.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectors/Asset/HGAssetBroker.cs
@@ -169,7 +169,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectors.Asset
169 169
170 public AssetBase Get(string id) 170 public AssetBase Get(string id)
171 { 171 {
172 m_log.DebugFormat("[HG ASSET CONNECTOR]: Get {0}", id); 172 //m_log.DebugFormat("[HG ASSET CONNECTOR]: Get {0}", id);
173 AssetBase asset = null; 173 AssetBase asset = null;
174 174
175 if (m_Cache != null) 175 if (m_Cache != null)
diff --git a/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs b/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs
index 720a09b..1d4bc9c 100644
--- a/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs
+++ b/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs
@@ -97,7 +97,7 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
97 return false; 97 return false;
98 } 98 }
99 99
100 private AssetBase FetchAsset(string url, UUID assetID, bool isTexture) 100 public AssetBase FetchAsset(string url, UUID assetID)
101 { 101 {
102 AssetBase asset = m_scene.AssetService.Get(url + "/" + assetID.ToString()); 102 AssetBase asset = m_scene.AssetService.Get(url + "/" + assetID.ToString());
103 103
@@ -109,7 +109,7 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
109 return null; 109 return null;
110 } 110 }
111 111
112 private bool PostAsset(string url, AssetBase asset) 112 public bool PostAsset(string url, AssetBase asset)
113 { 113 {
114 if (asset != null) 114 if (asset != null)
115 { 115 {
@@ -129,7 +129,7 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
129 } 129 }
130 catch 130 catch
131 { 131 {
132 m_log.Warn("[HGScene]: This won't work until Melanie kills a few more dragons"); 132 m_log.Warn("[HGScene]: Oops.");
133 } 133 }
134 134
135 m_scene.AssetService.Store(asset1); 135 m_scene.AssetService.Store(asset1);
@@ -155,86 +155,6 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
155 155
156 } 156 }
157 157
158 private void _guardedAdd(Dictionary<UUID, bool> lst, UUID obj, bool val)
159 {
160 if (!lst.ContainsKey(obj))
161 lst.Add(obj, val);
162 }
163
164 private void SniffTextureUUIDs(Dictionary<UUID, bool> uuids, SceneObjectGroup sog)
165 {
166 try
167 {
168 _guardedAdd(uuids, sog.RootPart.Shape.Textures.DefaultTexture.TextureID, true);
169 }
170 catch (Exception) { }
171
172 foreach (Primitive.TextureEntryFace tface in sog.RootPart.Shape.Textures.FaceTextures)
173 {
174 try
175 {
176 _guardedAdd(uuids, tface.TextureID, true);
177 }
178 catch (Exception) { }
179 }
180
181 foreach (SceneObjectPart sop in sog.Children.Values)
182 {
183 try
184 {
185 _guardedAdd(uuids, sop.Shape.Textures.DefaultTexture.TextureID, true);
186 }
187 catch (Exception) { }
188 foreach (Primitive.TextureEntryFace tface in sop.Shape.Textures.FaceTextures)
189 {
190 try
191 {
192 _guardedAdd(uuids, tface.TextureID, true);
193 }
194 catch (Exception) { }
195 }
196 }
197 }
198
199 private void SniffTaskInventoryUUIDs(Dictionary<UUID, bool> uuids, SceneObjectGroup sog)
200 {
201 TaskInventoryDictionary tinv = sog.RootPart.TaskInventory;
202
203 lock (tinv)
204 {
205 foreach (TaskInventoryItem titem in tinv.Values)
206 {
207 uuids.Add(titem.AssetID, (InventoryType)titem.Type == InventoryType.Texture);
208 }
209 }
210 }
211
212 private Dictionary<UUID, bool> SniffUUIDs(AssetBase asset)
213 {
214 Dictionary<UUID, bool> uuids = new Dictionary<UUID, bool>();
215 if ((asset != null) && ((AssetType)asset.Type == AssetType.Object))
216 {
217 string ass_str = Utils.BytesToString(asset.Data);
218 SceneObjectGroup sog = SceneObjectSerializer.FromOriginalXmlFormat(ass_str);
219
220 SniffTextureUUIDs(uuids, sog);
221
222 // We need to sniff further...
223 SniffTaskInventoryUUIDs(uuids, sog);
224 }
225
226 return uuids;
227 }
228
229 private Dictionary<UUID, bool> SniffUUIDs(UUID assetID)
230 {
231 //Dictionary<UUID, bool> uuids = new Dictionary<UUID, bool>();
232
233 AssetBase asset = m_scene.AssetService.Get(assetID.ToString());
234
235 return SniffUUIDs(asset);
236 }
237
238 private void Dump(Dictionary<UUID, bool> lst) 158 private void Dump(Dictionary<UUID, bool> lst)
239 { 159 {
240 m_log.Debug("XXX -------- UUID DUMP ------- XXX"); 160 m_log.Debug("XXX -------- UUID DUMP ------- XXX");
@@ -259,16 +179,18 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
259 if (userAssetURL != null) 179 if (userAssetURL != null)
260 { 180 {
261 m_log.Debug("[HGScene]: Fetching object " + assetID + " to asset server " + userAssetURL); 181 m_log.Debug("[HGScene]: Fetching object " + assetID + " to asset server " + userAssetURL);
262 AssetBase asset = FetchAsset(userAssetURL, assetID, false); 182 AssetBase asset = FetchAsset(userAssetURL, assetID);
263 183
264 if (asset != null) 184 if (asset != null)
265 { 185 {
266 m_log.Debug("[HGScene]: Successfully fetched item from remote asset server " + userAssetURL); 186 m_log.Debug("[HGScene]: Successfully fetched item from remote asset server " + userAssetURL);
187
267 // OK, now fetch the inside. 188 // OK, now fetch the inside.
268 Dictionary<UUID, bool> ids = SniffUUIDs(asset); 189 Dictionary<UUID, int> ids = new Dictionary<UUID, int>();
269 Dump(ids); 190 HGUuidGatherer uuidGatherer = new HGUuidGatherer(this, m_scene.AssetService, userAssetURL);
270 foreach (KeyValuePair<UUID, bool> kvp in ids) 191 uuidGatherer.GatherAssetUuids(asset.FullID, (AssetType)asset.Type, ids);
271 FetchAsset(userAssetURL, kvp.Key, kvp.Value); 192 foreach (UUID uuid in ids.Keys)
193 FetchAsset(userAssetURL, uuid);
272 } 194 }
273 else 195 else
274 m_log.Warn("[HGScene]: Could not fetch asset from remote asset server " + userAssetURL); 196 m_log.Warn("[HGScene]: Could not fetch asset from remote asset server " + userAssetURL);
@@ -315,21 +237,23 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
315 if (userAssetURL != null) 237 if (userAssetURL != null)
316 { 238 {
317 m_log.Debug("[HGScene]: Posting object " + assetID + " to asset server " + userAssetURL); 239 m_log.Debug("[HGScene]: Posting object " + assetID + " to asset server " + userAssetURL);
318 AssetBase ass1 = m_scene.AssetService.Get(assetID.ToString()); 240 AssetBase asset = m_scene.AssetService.Get(assetID.ToString());
319 if (ass1 != null) 241 if (asset != null)
320 { 242 {
321 bool success = PostAsset(userAssetURL, ass1); 243 Dictionary<UUID, int> ids = new Dictionary<UUID, int>();
322 244 HGUuidGatherer uuidGatherer = new HGUuidGatherer(this, m_scene.AssetService, string.Empty);
323 // Now the inside 245 uuidGatherer.GatherAssetUuids(asset.FullID, (AssetType)asset.Type, ids);
324 Dictionary<UUID, bool> ids = SniffUUIDs(assetID); 246 foreach (UUID uuid in ids.Keys)
325 Dump(ids);
326 foreach (KeyValuePair<UUID, bool> kvp in ids)
327 { 247 {
328 ass1 = m_scene.AssetService.Get(kvp.Key.ToString()); 248 asset = m_scene.AssetService.Get(uuid.ToString());
329 PostAsset(userAssetURL, ass1); 249 if (asset != null)
250 m_log.DebugFormat("[HGScene]: Posting {0} {1}", asset.Type.ToString(), asset.Name);
251 else
252 m_log.DebugFormat("[HGScene]: Could not find asset {0}", uuid);
253 PostAsset(userAssetURL, asset);
330 } 254 }
331 255
332 if (success) 256 if (ids.Count > 0) // maybe it succeeded...
333 m_log.DebugFormat("[HGScene]: Successfully posted item {0} to remote asset server {1}", assetID, userAssetURL); 257 m_log.DebugFormat("[HGScene]: Successfully posted item {0} to remote asset server {1}", assetID, userAssetURL);
334 else 258 else
335 m_log.WarnFormat("[HGScene]: Could not post asset {0} to remote asset server {1}", assetID, userAssetURL); 259 m_log.WarnFormat("[HGScene]: Could not post asset {0} to remote asset server {1}", assetID, userAssetURL);
diff --git a/OpenSim/Region/Framework/Scenes/Hypergrid/HGScene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Hypergrid/HGScene.Inventory.cs
index 4fde9bb..da9b5ec 100644
--- a/OpenSim/Region/Framework/Scenes/Hypergrid/HGScene.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/Hypergrid/HGScene.Inventory.cs
@@ -113,24 +113,28 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
113 UUID RayTargetID, byte BypassRayCast, bool RayEndIsIntersection, 113 UUID RayTargetID, byte BypassRayCast, bool RayEndIsIntersection,
114 bool RezSelected, bool RemoveItem, UUID fromTaskID, bool attachment) 114 bool RezSelected, bool RemoveItem, UUID fromTaskID, bool attachment)
115 { 115 {
116 CachedUserInfo userInfo = CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId); 116 //m_log.DebugFormat("[HGScene] RezObject itemID={0} fromTaskID={1}", itemID, fromTaskID);
117 if (userInfo != null) 117
118 if (fromTaskID.Equals(UUID.Zero))
118 { 119 {
119 if (userInfo.RootFolder != null) 120 CachedUserInfo userInfo = CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId);
121 if (userInfo != null)
120 { 122 {
121 InventoryItemBase item = userInfo.RootFolder.FindItem(itemID); 123 if (userInfo.RootFolder != null)
122
123 if (item == null)
124 { // Fetch the item
125 item = new InventoryItemBase();
126 item.Owner = remoteClient.AgentId;
127 item.ID = itemID;
128 item = m_assMapper.Get(item, userInfo.RootFolder.ID, userInfo);
129 }
130 if (item != null)
131 { 124 {
132 m_assMapper.Get(item.AssetID, remoteClient.AgentId); 125 InventoryItemBase item = userInfo.RootFolder.FindItem(itemID);
133 126 if (item == null)
127 { // Fetch the item
128 item = new InventoryItemBase();
129 item.Owner = remoteClient.AgentId;
130 item.ID = itemID;
131 item = m_assMapper.Get(item, userInfo.RootFolder.ID, userInfo);
132 }
133 if (item != null)
134 {
135 m_assMapper.Get(item.AssetID, remoteClient.AgentId);
136
137 }
134 } 138 }
135 } 139 }
136 } 140 }
diff --git a/OpenSim/Region/Framework/Scenes/Hypergrid/HGUuidGatherer.cs b/OpenSim/Region/Framework/Scenes/Hypergrid/HGUuidGatherer.cs
new file mode 100644
index 0000000..e83478d
--- /dev/null
+++ b/OpenSim/Region/Framework/Scenes/Hypergrid/HGUuidGatherer.cs
@@ -0,0 +1,29 @@
1using System;
2using System.Collections.Generic;
3
4using OpenSim.Framework;
5using OpenSim.Services.Interfaces;
6using OpenMetaverse;
7
8namespace OpenSim.Region.Framework.Scenes.Hypergrid
9{
10 public class HGUuidGatherer : UuidGatherer
11 {
12 protected string m_assetServerURL;
13 protected HGAssetMapper m_assetMapper;
14
15 public HGUuidGatherer(HGAssetMapper assMap, IAssetService assetCache, string assetServerURL) : base(assetCache)
16 {
17 m_assetMapper = assMap;
18 m_assetServerURL = assetServerURL;
19 }
20
21 protected override AssetBase GetAsset(UUID uuid)
22 {
23 if (string.Empty == m_assetServerURL)
24 return m_assetCache.Get(uuid.ToString());
25 else
26 return m_assetMapper.FetchAsset(m_assetServerURL, uuid);
27 }
28 }
29}
diff --git a/OpenSim/Region/Framework/Scenes/UuidGatherer.cs b/OpenSim/Region/Framework/Scenes/UuidGatherer.cs
index 5eb42f7..1324978 100644
--- a/OpenSim/Region/Framework/Scenes/UuidGatherer.cs
+++ b/OpenSim/Region/Framework/Scenes/UuidGatherer.cs
@@ -187,7 +187,7 @@ namespace OpenSim.Region.Framework.Scenes
187 /// </summary> 187 /// </summary>
188 /// <param name="uuid"></param> 188 /// <param name="uuid"></param>
189 /// <returns></returns> 189 /// <returns></returns>
190 protected AssetBase GetAsset(UUID uuid) 190 protected virtual AssetBase GetAsset(UUID uuid)
191 { 191 {
192 m_waitingForObjectAsset = true; 192 m_waitingForObjectAsset = true;
193 m_assetCache.Get(uuid.ToString(), this, AssetReceived); 193 m_assetCache.Get(uuid.ToString(), this, AssetReceived);
diff --git a/OpenSim/Services/AssetService/AssetService.cs b/OpenSim/Services/AssetService/AssetService.cs
index 968cf5c..d1053f1 100644
--- a/OpenSim/Services/AssetService/AssetService.cs
+++ b/OpenSim/Services/AssetService/AssetService.cs
@@ -66,7 +66,7 @@ namespace OpenSim.Services.AssetService
66 66
67 public AssetBase Get(string id) 67 public AssetBase Get(string id)
68 { 68 {
69 m_log.DebugFormat("[ASSET SERVICE]: Get asset {0}", id); 69 //m_log.DebugFormat("[ASSET SERVICE]: Get asset {0}", id);
70 UUID assetID; 70 UUID assetID;
71 71
72 if (!UUID.TryParse(id, out assetID)) 72 if (!UUID.TryParse(id, out assetID))
@@ -99,7 +99,7 @@ namespace OpenSim.Services.AssetService
99 99
100 public bool Get(string id, Object sender, AssetRetrieved handler) 100 public bool Get(string id, Object sender, AssetRetrieved handler)
101 { 101 {
102 //m_log.DebugFormat("[AssetService]: Got request for {0}", id); 102 //m_log.DebugFormat("[AssetService]: Get asset async {0}", id);
103 103
104 UUID assetID; 104 UUID assetID;
105 105
@@ -117,6 +117,7 @@ namespace OpenSim.Services.AssetService
117 117
118 public string Store(AssetBase asset) 118 public string Store(AssetBase asset)
119 { 119 {
120 //m_log.DebugFormat("[ASSET SERVICE]: Store asset {0} {1}", asset.Name, asset.ID);
120 m_Database.CreateAsset(asset); 121 m_Database.CreateAsset(asset);
121 122
122 return asset.ID; 123 return asset.ID;