diff options
author | diva | 2009-05-17 01:38:43 +0000 |
---|---|---|
committer | diva | 2009-05-17 01:38:43 +0000 |
commit | aac8ca041170f6d1d648c6c5244dc3dfad428587 (patch) | |
tree | 190873d49a54f7462190331344aa308d8b6eb15f /OpenSim/Region | |
parent | Send the owner name, not the client name on SendDialog. (diff) | |
download | opensim-SC-aac8ca041170f6d1d648c6c5244dc3dfad428587.zip opensim-SC-aac8ca041170f6d1d648c6c5244dc3dfad428587.tar.gz opensim-SC-aac8ca041170f6d1d648c6c5244dc3dfad428587.tar.bz2 opensim-SC-aac8ca041170f6d1d648c6c5244dc3dfad428587.tar.xz |
HG asset transfers starting to work -- GETs only for now.
Diffstat (limited to 'OpenSim/Region')
-rw-r--r-- | OpenSim/Region/CoreModules/ServiceConnectors/Asset/HGAssetBroker.cs | 62 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs | 76 |
2 files changed, 55 insertions, 83 deletions
diff --git a/OpenSim/Region/CoreModules/ServiceConnectors/Asset/HGAssetBroker.cs b/OpenSim/Region/CoreModules/ServiceConnectors/Asset/HGAssetBroker.cs index d537d7b..c3a878e 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectors/Asset/HGAssetBroker.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectors/Asset/HGAssetBroker.cs | |||
@@ -35,6 +35,7 @@ using OpenSim.Servers.Base; | |||
35 | using OpenSim.Region.Framework.Interfaces; | 35 | using OpenSim.Region.Framework.Interfaces; |
36 | using OpenSim.Region.Framework.Scenes; | 36 | using OpenSim.Region.Framework.Scenes; |
37 | using OpenSim.Services.Interfaces; | 37 | using OpenSim.Services.Interfaces; |
38 | using OpenMetaverse; | ||
38 | 39 | ||
39 | namespace OpenSim.Region.CoreModules.ServiceConnectors.Asset | 40 | namespace OpenSim.Region.CoreModules.ServiceConnectors.Asset |
40 | { | 41 | { |
@@ -46,7 +47,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectors.Asset | |||
46 | MethodBase.GetCurrentMethod().DeclaringType); | 47 | MethodBase.GetCurrentMethod().DeclaringType); |
47 | 48 | ||
48 | private IImprovedAssetCache m_Cache = null; | 49 | private IImprovedAssetCache m_Cache = null; |
49 | private IAssetService m_LocalService; | 50 | private IAssetService m_GridService; |
50 | private IAssetService m_HGService; | 51 | private IAssetService m_HGService; |
51 | 52 | ||
52 | private bool m_Enabled = false; | 53 | private bool m_Enabled = false; |
@@ -67,29 +68,29 @@ namespace OpenSim.Region.CoreModules.ServiceConnectors.Asset | |||
67 | IConfig assetConfig = source.Configs["AssetService"]; | 68 | IConfig assetConfig = source.Configs["AssetService"]; |
68 | if (assetConfig == null) | 69 | if (assetConfig == null) |
69 | { | 70 | { |
70 | m_log.Error("[ASSET CONNECTOR]: AssetService missing from OpanSim.ini"); | 71 | m_log.Error("[HG ASSET CONNECTOR]: AssetService missing from OpenSim.ini"); |
71 | return; | 72 | return; |
72 | } | 73 | } |
73 | 74 | ||
74 | string localDll = assetConfig.GetString("LocalModule", | 75 | string localDll = assetConfig.GetString("LocalGridAssetService", |
75 | String.Empty); | 76 | String.Empty); |
76 | string HGDll = assetConfig.GetString("HypergridModule", | 77 | string HGDll = assetConfig.GetString("HypergridAssetService", |
77 | String.Empty); | 78 | String.Empty); |
78 | 79 | ||
79 | if (localDll == String.Empty) | 80 | if (localDll == String.Empty) |
80 | { | 81 | { |
81 | m_log.Error("[ASSET CONNECTOR]: No LocalModule named in section AssetService"); | 82 | m_log.Error("[HG ASSET CONNECTOR]: No LocalGridAssetService named in section AssetService"); |
82 | return; | 83 | return; |
83 | } | 84 | } |
84 | 85 | ||
85 | if (HGDll == String.Empty) | 86 | if (HGDll == String.Empty) |
86 | { | 87 | { |
87 | m_log.Error("[ASSET CONNECTOR]: No HypergridModule named in section AssetService"); | 88 | m_log.Error("[HG ASSET CONNECTOR]: No HypergridAssetService named in section AssetService"); |
88 | return; | 89 | return; |
89 | } | 90 | } |
90 | 91 | ||
91 | Object[] args = new Object[] { source }; | 92 | Object[] args = new Object[] { source }; |
92 | m_LocalService = | 93 | m_GridService = |
93 | ServerUtils.LoadPlugin<IAssetService>(localDll, | 94 | ServerUtils.LoadPlugin<IAssetService>(localDll, |
94 | args); | 95 | args); |
95 | 96 | ||
@@ -97,19 +98,19 @@ namespace OpenSim.Region.CoreModules.ServiceConnectors.Asset | |||
97 | ServerUtils.LoadPlugin<IAssetService>(HGDll, | 98 | ServerUtils.LoadPlugin<IAssetService>(HGDll, |
98 | args); | 99 | args); |
99 | 100 | ||
100 | if (m_LocalService == null) | 101 | if (m_GridService == null) |
101 | { | 102 | { |
102 | m_log.Error("[ASSET CONNECTOR]: Can't load local asset service"); | 103 | m_log.Error("[HG ASSET CONNECTOR]: Can't load local asset service"); |
103 | return; | 104 | return; |
104 | } | 105 | } |
105 | if (m_HGService == null) | 106 | if (m_HGService == null) |
106 | { | 107 | { |
107 | m_log.Error("[ASSET CONNECTOR]: Can't load hypergrid asset service"); | 108 | m_log.Error("[HG ASSET CONNECTOR]: Can't load hypergrid asset service"); |
108 | return; | 109 | return; |
109 | } | 110 | } |
110 | 111 | ||
111 | m_Enabled = true; | 112 | m_Enabled = true; |
112 | m_log.Info("[ASSET CONNECTOR]: HG asset broker enabled"); | 113 | m_log.Info("[HG ASSET CONNECTOR]: HG asset broker enabled"); |
113 | } | 114 | } |
114 | } | 115 | } |
115 | } | 116 | } |
@@ -147,11 +148,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectors.Asset | |||
147 | m_Cache = null; | 148 | m_Cache = null; |
148 | } | 149 | } |
149 | 150 | ||
150 | m_log.InfoFormat("[ASSET CONNECTOR]: Enabled hypergrid asset broker for region {0}", scene.RegionInfo.RegionName); | 151 | m_log.InfoFormat("[HG ASSET CONNECTOR]: Enabled hypergrid asset broker for region {0}", scene.RegionInfo.RegionName); |
151 | 152 | ||
152 | if (m_Cache != null) | 153 | if (m_Cache != null) |
153 | { | 154 | { |
154 | m_log.InfoFormat("[ASSET CONNECTOR]: Enabled asset caching for region {0}", scene.RegionInfo.RegionName); | 155 | m_log.InfoFormat("[HG ASSET CONNECTOR]: Enabled asset caching for region {0}", scene.RegionInfo.RegionName); |
155 | } | 156 | } |
156 | } | 157 | } |
157 | 158 | ||
@@ -168,20 +169,36 @@ namespace OpenSim.Region.CoreModules.ServiceConnectors.Asset | |||
168 | 169 | ||
169 | public AssetBase Get(string id) | 170 | public AssetBase Get(string id) |
170 | { | 171 | { |
172 | m_log.DebugFormat("[HG ASSET CONNECTOR]: Get {0}", id); | ||
171 | AssetBase asset = null; | 173 | AssetBase asset = null; |
172 | 174 | ||
173 | if (m_Cache != null) | 175 | if (m_Cache != null) |
174 | { | 176 | { |
175 | m_Cache.Get(id); | 177 | asset = m_Cache.Get(id); |
176 | 178 | ||
177 | if (asset != null) | 179 | if (asset != null) |
178 | return asset; | 180 | return asset; |
181 | else | ||
182 | m_log.DebugFormat("[HG ASSSET CONNECTOR]: Requested asset is not in cache. This shouldn't happen."); | ||
179 | } | 183 | } |
180 | 184 | ||
181 | if (IsHG(id)) | 185 | if (IsHG(id)) |
186 | { | ||
182 | asset = m_HGService.Get(id); | 187 | asset = m_HGService.Get(id); |
188 | if (asset != null) | ||
189 | { | ||
190 | // Now store it locally | ||
191 | // For now, let me just do it for textures and scripts | ||
192 | if (((AssetType)asset.Type == AssetType.Texture) || | ||
193 | ((AssetType)asset.Type == AssetType.LSLBytecode) || | ||
194 | ((AssetType)asset.Type == AssetType.LSLText)) | ||
195 | { | ||
196 | m_GridService.Store(asset); | ||
197 | } | ||
198 | } | ||
199 | } | ||
183 | else | 200 | else |
184 | asset = m_LocalService.Get(id); | 201 | asset = m_GridService.Get(id); |
185 | 202 | ||
186 | if (asset != null) | 203 | if (asset != null) |
187 | { | 204 | { |
@@ -210,7 +227,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectors.Asset | |||
210 | if (IsHG(id)) | 227 | if (IsHG(id)) |
211 | metadata = m_HGService.GetMetadata(id); | 228 | metadata = m_HGService.GetMetadata(id); |
212 | else | 229 | else |
213 | metadata = m_LocalService.GetMetadata(id); | 230 | metadata = m_GridService.GetMetadata(id); |
214 | 231 | ||
215 | return metadata; | 232 | return metadata; |
216 | } | 233 | } |
@@ -231,7 +248,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectors.Asset | |||
231 | if (IsHG(id)) | 248 | if (IsHG(id)) |
232 | asset = m_HGService.Get(id); | 249 | asset = m_HGService.Get(id); |
233 | else | 250 | else |
234 | asset = m_LocalService.Get(id); | 251 | asset = m_GridService.Get(id); |
235 | 252 | ||
236 | if (asset != null) | 253 | if (asset != null) |
237 | { | 254 | { |
@@ -267,7 +284,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectors.Asset | |||
267 | } | 284 | } |
268 | else | 285 | else |
269 | { | 286 | { |
270 | return m_LocalService.Get(id, sender, delegate (string assetID, Object s, AssetBase a) | 287 | return m_GridService.Get(id, sender, delegate (string assetID, Object s, AssetBase a) |
271 | { | 288 | { |
272 | if (a != null && m_Cache != null) | 289 | if (a != null && m_Cache != null) |
273 | m_Cache.Cache(a); | 290 | m_Cache.Cache(a); |
@@ -281,10 +298,13 @@ namespace OpenSim.Region.CoreModules.ServiceConnectors.Asset | |||
281 | if (m_Cache != null) | 298 | if (m_Cache != null) |
282 | m_Cache.Cache(asset); | 299 | m_Cache.Cache(asset); |
283 | 300 | ||
301 | if (asset.Temporary || asset.Local) | ||
302 | return asset.ID; | ||
303 | |||
284 | if (IsHG(asset.ID)) | 304 | if (IsHG(asset.ID)) |
285 | return m_HGService.Store(asset); | 305 | return m_HGService.Store(asset); |
286 | else | 306 | else |
287 | return m_LocalService.Store(asset); | 307 | return m_GridService.Store(asset); |
288 | } | 308 | } |
289 | 309 | ||
290 | public bool UpdateContent(string id, byte[] data) | 310 | public bool UpdateContent(string id, byte[] data) |
@@ -303,7 +323,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectors.Asset | |||
303 | if (IsHG(id)) | 323 | if (IsHG(id)) |
304 | return m_HGService.UpdateContent(id, data); | 324 | return m_HGService.UpdateContent(id, data); |
305 | else | 325 | else |
306 | return m_LocalService.UpdateContent(id, data); | 326 | return m_GridService.UpdateContent(id, data); |
307 | } | 327 | } |
308 | 328 | ||
309 | public bool Delete(string id) | 329 | public bool Delete(string id) |
@@ -314,7 +334,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectors.Asset | |||
314 | if (IsHG(id)) | 334 | if (IsHG(id)) |
315 | return m_HGService.Delete(id); | 335 | return m_HGService.Delete(id); |
316 | else | 336 | else |
317 | return m_LocalService.Delete(id); | 337 | return m_GridService.Delete(id); |
318 | } | 338 | } |
319 | } | 339 | } |
320 | } | 340 | } |
diff --git a/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs b/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs index 985ee98..e659ad1 100644 --- a/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs +++ b/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs | |||
@@ -108,50 +108,16 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid | |||
108 | return m_assetMap.ContainsKey(uuid); | 108 | return m_assetMap.ContainsKey(uuid); |
109 | } | 109 | } |
110 | 110 | ||
111 | private bool FetchAsset(GridAssetClient asscli, UUID assetID, bool isTexture) | 111 | private AssetBase FetchAsset(string url, UUID assetID, bool isTexture) |
112 | { | 112 | { |
113 | // I'm not going over 3 seconds since this will be blocking processing of all the other inbound | 113 | AssetBase asset = m_scene.AssetService.Get(url + "/" + assetID.ToString()); |
114 | // packets from the client. | ||
115 | int pollPeriod = 200; | ||
116 | int maxPolls = 15; | ||
117 | 114 | ||
118 | AssetBase asset; | 115 | if (asset != null) |
119 | |||
120 | // Maybe it came late, and it's already here. Check first. | ||
121 | if (m_scene.CommsManager.AssetCache.TryGetCachedAsset(assetID, out asset)) | ||
122 | { | 116 | { |
123 | m_log.Debug("[HGScene]: Asset already in asset cache. " + assetID); | 117 | m_log.Debug("[HGScene]: Asset made it to asset cache. " + asset.Name + " " + assetID); |
124 | return true; | 118 | return asset; |
125 | } | 119 | } |
126 | 120 | return null; | |
127 | |||
128 | asscli.RequestAsset(assetID, isTexture); | ||
129 | |||
130 | do | ||
131 | { | ||
132 | Thread.Sleep(pollPeriod); | ||
133 | |||
134 | if (m_scene.CommsManager.AssetCache.TryGetCachedAsset(assetID, out asset) && (asset != null)) | ||
135 | { | ||
136 | m_log.Debug("[HGScene]: Asset made it to asset cache. " + asset.Name + " " + assetID); | ||
137 | // I think I need to store it in the asset DB too. | ||
138 | // For now, let me just do it for textures and scripts | ||
139 | if (((AssetType)asset.Type == AssetType.Texture) || | ||
140 | ((AssetType)asset.Type == AssetType.LSLBytecode) || | ||
141 | ((AssetType)asset.Type == AssetType.LSLText)) | ||
142 | { | ||
143 | AssetBase asset1 = new AssetBase(); | ||
144 | Copy(asset, asset1); | ||
145 | m_scene.CommsManager.AssetCache.AssetServer.StoreAsset(asset1); | ||
146 | } | ||
147 | return true; | ||
148 | } | ||
149 | } while (--maxPolls > 0); | ||
150 | |||
151 | m_log.WarnFormat("[HGScene]: {0} {1} was not received before the retrieval timeout was reached", | ||
152 | isTexture ? "texture" : "asset", assetID.ToString()); | ||
153 | |||
154 | return false; | ||
155 | } | 121 | } |
156 | 122 | ||
157 | private bool PostAsset(GridAssetClient asscli, UUID assetID, bool isTexture) | 123 | private bool PostAsset(GridAssetClient asscli, UUID assetID, bool isTexture) |
@@ -291,39 +257,25 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid | |||
291 | 257 | ||
292 | public void Get(UUID assetID, UUID ownerID) | 258 | public void Get(UUID assetID, UUID ownerID) |
293 | { | 259 | { |
294 | if (!IsInAssetMap(assetID) && !IsLocalUser(ownerID)) | 260 | if (!IsLocalUser(ownerID)) |
295 | { | 261 | { |
296 | // Get the item from the remote asset server onto the local AssetCache | 262 | // Get the item from the remote asset server onto the local AssetCache |
297 | // and place an entry in m_assetMap | 263 | // and place an entry in m_assetMap |
298 | 264 | ||
299 | GridAssetClient asscli = null; | ||
300 | string userAssetURL = UserAssetURL(ownerID); | 265 | string userAssetURL = UserAssetURL(ownerID); |
301 | if (userAssetURL != null) | 266 | if (userAssetURL != null) |
302 | { | 267 | { |
303 | m_assetServers.TryGetValue(userAssetURL, out asscli); | ||
304 | if (asscli == null) | ||
305 | { | ||
306 | m_log.Debug("[HGScene]: Starting new GridAssetClient for " + userAssetURL); | ||
307 | asscli = new GridAssetClient(userAssetURL); | ||
308 | asscli.SetReceiver(m_scene.CommsManager.AssetCache); // Straight to the asset cache! | ||
309 | m_assetServers.Add(userAssetURL, asscli); | ||
310 | asscli.Start(); | ||
311 | } | ||
312 | |||
313 | m_log.Debug("[HGScene]: Fetching object " + assetID + " to asset server " + userAssetURL); | 268 | m_log.Debug("[HGScene]: Fetching object " + assetID + " to asset server " + userAssetURL); |
314 | bool success = FetchAsset(asscli, assetID, false); // asscli.RequestAsset(item.ItemID, false); | 269 | AssetBase asset = FetchAsset(userAssetURL, assetID, false); |
315 | 270 | ||
316 | // OK, now fetch the inside. | 271 | if (asset != null) |
317 | Dictionary<UUID, bool> ids = SniffUUIDs(assetID); | ||
318 | Dump(ids); | ||
319 | foreach (KeyValuePair<UUID, bool> kvp in ids) | ||
320 | FetchAsset(asscli, kvp.Key, kvp.Value); | ||
321 | |||
322 | |||
323 | if (success) | ||
324 | { | 272 | { |
325 | m_log.Debug("[HGScene]: Successfully fetched item from remote asset server " + userAssetURL); | 273 | m_log.Debug("[HGScene]: Successfully fetched item from remote asset server " + userAssetURL); |
326 | m_assetMap.Add(assetID, asscli); | 274 | // OK, now fetch the inside. |
275 | Dictionary<UUID, bool> ids = SniffUUIDs(asset); | ||
276 | Dump(ids); | ||
277 | foreach (KeyValuePair<UUID, bool> kvp in ids) | ||
278 | FetchAsset(userAssetURL, kvp.Key, kvp.Value); | ||
327 | } | 279 | } |
328 | else | 280 | else |
329 | m_log.Warn("[HGScene]: Could not fetch asset from remote asset server " + userAssetURL); | 281 | m_log.Warn("[HGScene]: Could not fetch asset from remote asset server " + userAssetURL); |