diff options
Diffstat (limited to 'OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/HGAssetBroker.cs')
-rw-r--r-- | OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/HGAssetBroker.cs | 73 |
1 files changed, 40 insertions, 33 deletions
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/HGAssetBroker.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/HGAssetBroker.cs index 7fcfc74..92ae36f 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/HGAssetBroker.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/HGAssetBroker.cs | |||
@@ -48,7 +48,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset | |||
48 | LogManager.GetLogger( | 48 | LogManager.GetLogger( |
49 | MethodBase.GetCurrentMethod().DeclaringType); | 49 | MethodBase.GetCurrentMethod().DeclaringType); |
50 | 50 | ||
51 | private IImprovedAssetCache m_Cache = null; | 51 | private IAssetCache m_Cache = null; |
52 | private IAssetService m_GridService; | 52 | private IAssetService m_GridService; |
53 | private IAssetService m_HGService; | 53 | private IAssetService m_HGService; |
54 | 54 | ||
@@ -59,7 +59,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset | |||
59 | 59 | ||
60 | private AssetPermissions m_AssetPerms; | 60 | private AssetPermissions m_AssetPerms; |
61 | 61 | ||
62 | public Type ReplaceableInterface | 62 | public Type ReplaceableInterface |
63 | { | 63 | { |
64 | get { return null; } | 64 | get { return null; } |
65 | } | 65 | } |
@@ -159,7 +159,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset | |||
159 | { | 159 | { |
160 | if (!m_Enabled) | 160 | if (!m_Enabled) |
161 | return; | 161 | return; |
162 | 162 | ||
163 | m_aScene = scene; | 163 | m_aScene = scene; |
164 | 164 | ||
165 | m_aScene.RegisterModuleInterface<IAssetService>(this); | 165 | m_aScene.RegisterModuleInterface<IAssetService>(this); |
@@ -176,10 +176,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset | |||
176 | 176 | ||
177 | if (m_Cache == null) | 177 | if (m_Cache == null) |
178 | { | 178 | { |
179 | m_Cache = scene.RequestModuleInterface<IImprovedAssetCache>(); | 179 | m_Cache = scene.RequestModuleInterface<IAssetCache>(); |
180 | 180 | ||
181 | if (!(m_Cache is ISharedRegionModule)) | 181 | if (!(m_Cache is ISharedRegionModule)) |
182 | m_Cache = null; | 182 | m_Cache = null; |
183 | |||
183 | } | 184 | } |
184 | 185 | ||
185 | m_log.InfoFormat("[HG ASSET CONNECTOR]: Enabled hypergrid asset broker for region {0}", scene.RegionInfo.RegionName); | 186 | m_log.InfoFormat("[HG ASSET CONNECTOR]: Enabled hypergrid asset broker for region {0}", scene.RegionInfo.RegionName); |
@@ -205,10 +206,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset | |||
205 | { | 206 | { |
206 | //m_log.DebugFormat("[HG ASSET CONNECTOR]: Get {0}", id); | 207 | //m_log.DebugFormat("[HG ASSET CONNECTOR]: Get {0}", id); |
207 | AssetBase asset = null; | 208 | AssetBase asset = null; |
208 | 209 | ||
209 | if (m_Cache != null) | 210 | if (m_Cache != null) |
210 | { | 211 | { |
211 | asset = m_Cache.Get(id); | 212 | if (!m_Cache.Get(id, out asset)) |
213 | return null; | ||
212 | 214 | ||
213 | if (asset != null) | 215 | if (asset != null) |
214 | return asset; | 216 | return asset; |
@@ -237,20 +239,21 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset | |||
237 | 239 | ||
238 | public AssetBase GetCached(string id) | 240 | public AssetBase GetCached(string id) |
239 | { | 241 | { |
242 | AssetBase asset = null; | ||
240 | if (m_Cache != null) | 243 | if (m_Cache != null) |
241 | return m_Cache.Get(id); | 244 | m_Cache.Get(id, out asset); |
242 | 245 | ||
243 | return null; | 246 | return asset; |
244 | } | 247 | } |
245 | 248 | ||
246 | public AssetMetadata GetMetadata(string id) | 249 | public AssetMetadata GetMetadata(string id) |
247 | { | 250 | { |
248 | AssetBase asset = null; | 251 | AssetBase asset = null; |
249 | 252 | ||
250 | if (m_Cache != null) | 253 | if (m_Cache != null) |
251 | { | 254 | { |
252 | if (m_Cache != null) | 255 | if (!m_Cache.Get(id, out asset)) |
253 | m_Cache.Get(id); | 256 | return null; |
254 | 257 | ||
255 | if (asset != null) | 258 | if (asset != null) |
256 | return asset.Metadata; | 259 | return asset.Metadata; |
@@ -269,11 +272,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset | |||
269 | public byte[] GetData(string id) | 272 | public byte[] GetData(string id) |
270 | { | 273 | { |
271 | AssetBase asset = null; | 274 | AssetBase asset = null; |
272 | 275 | ||
273 | if (m_Cache != null) | 276 | if (m_Cache != null) |
274 | { | 277 | { |
275 | if (m_Cache != null) | 278 | if (!m_Cache.Get(id, out asset)) |
276 | m_Cache.Get(id); | 279 | return null; |
277 | 280 | ||
278 | if (asset != null) | 281 | if (asset != null) |
279 | return asset.Data; | 282 | return asset.Data; |
@@ -289,9 +292,12 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset | |||
289 | public bool Get(string id, Object sender, AssetRetrieved handler) | 292 | public bool Get(string id, Object sender, AssetRetrieved handler) |
290 | { | 293 | { |
291 | AssetBase asset = null; | 294 | AssetBase asset = null; |
292 | 295 | ||
293 | if (m_Cache != null) | 296 | if (m_Cache != null) |
294 | asset = m_Cache.Get(id); | 297 | { |
298 | if (!m_Cache.Get(id, out asset)) | ||
299 | return false; | ||
300 | } | ||
295 | 301 | ||
296 | if (asset != null) | 302 | if (asset != null) |
297 | { | 303 | { |
@@ -338,23 +344,22 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset | |||
338 | 344 | ||
339 | public string Store(AssetBase asset) | 345 | public string Store(AssetBase asset) |
340 | { | 346 | { |
341 | bool isHG = IsHG(asset.ID); | 347 | if (asset.Local || asset.Temporary) |
342 | |||
343 | if ((m_Cache != null) && !isHG) | ||
344 | // Don't store it in the cache if the asset is to | ||
345 | // be sent to the other grid, because this is already | ||
346 | // a copy of the local asset. | ||
347 | m_Cache.Cache(asset); | ||
348 | |||
349 | if (asset.Local) | ||
350 | { | 348 | { |
351 | if (m_Cache != null) | 349 | if (m_Cache != null) |
352 | m_Cache.Cache(asset); | 350 | m_Cache.Cache(asset); |
353 | return asset.ID; | 351 | return asset.ID; |
354 | } | 352 | } |
355 | 353 | ||
354 | bool isHG = IsHG(asset.ID); | ||
355 | if ((m_Cache != null) && !isHG) | ||
356 | // Don't store it in the cache if the asset is to | ||
357 | // be sent to the other grid, because this is already | ||
358 | // a copy of the local asset. | ||
359 | m_Cache.Cache(asset); | ||
360 | |||
356 | string id; | 361 | string id; |
357 | if (IsHG(asset.ID)) | 362 | if (isHG) |
358 | { | 363 | { |
359 | if (m_AssetPerms.AllowedExport(asset.Type)) | 364 | if (m_AssetPerms.AllowedExport(asset.Type)) |
360 | id = m_HGService.Store(asset); | 365 | id = m_HGService.Store(asset); |
@@ -366,21 +371,23 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset | |||
366 | 371 | ||
367 | if (String.IsNullOrEmpty(id)) | 372 | if (String.IsNullOrEmpty(id)) |
368 | return string.Empty; | 373 | return string.Empty; |
369 | |||
370 | asset.ID = id; | ||
371 | 374 | ||
372 | if (m_Cache != null) | 375 | if(asset.ID != id) |
373 | m_Cache.Cache(asset); | 376 | { |
377 | asset.ID = id; | ||
378 | if (m_Cache != null) | ||
379 | m_Cache.Cache(asset); | ||
380 | } | ||
374 | 381 | ||
375 | return id; | 382 | return id; |
376 | } | 383 | } |
377 | 384 | ||
378 | public bool UpdateContent(string id, byte[] data) | 385 | public bool UpdateContent(string id, byte[] data) |
379 | { | 386 | { |
380 | AssetBase asset = null; | 387 | AssetBase asset = null; |
381 | 388 | ||
382 | if (m_Cache != null) | 389 | if (m_Cache != null) |
383 | asset = m_Cache.Get(id); | 390 | m_Cache.Get(id, out asset); |
384 | 391 | ||
385 | if (asset != null) | 392 | if (asset != null) |
386 | { | 393 | { |