in some cases store a hg asset on local grid is just waste

This commit is contained in:
UbitUmarov
2020-10-28 12:12:08 +00:00
parent 52c86e543f
commit 7b106564fa
14 changed files with 67 additions and 55 deletions

View File

@@ -562,7 +562,7 @@ namespace OpenSim.Region.CoreModules.Asset
return asset;
}
public AssetBase Get(string id, string ForeignAssetService)
public AssetBase Get(string id, string ForeignAssetService, bool dummy)
{
return null;
}
@@ -630,9 +630,51 @@ namespace OpenSim.Region.CoreModules.Asset
return false;
}
// does not check negative cache
public AssetBase GetCached(string id)
{
Get(id, out AssetBase asset);
AssetBase asset = null;
m_Requests++;
asset = GetFromWeakReference(id);
if (asset != null)
{
if (m_updateFileTimeOnCacheHit)
{
string filename = GetFileName(id);
UpdateFileLastAccessTime(filename);
}
if (m_MemoryCacheEnabled)
UpdateMemoryCache(id, asset);
return asset;
}
if (m_MemoryCacheEnabled)
{
asset = GetFromMemoryCache(id);
if (asset != null)
{
UpdateWeakReference(id, asset);
if (m_updateFileTimeOnCacheHit)
{
string filename = GetFileName(id);
UpdateFileLastAccessTime(filename);
}
return asset;
}
}
if (m_FileCacheEnabled)
{
asset = GetFromFileCache(id);
if (asset != null)
{
UpdateWeakReference(id, asset);
if (m_MemoryCacheEnabled)
UpdateMemoryCache(id, asset);
}
}
return asset;
}

View File

@@ -1891,7 +1891,7 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles
if(string.IsNullOrWhiteSpace(assetServerURI))
return;
Scene.AssetService.Get(imageID.ToString(), assetServerURI);
Scene.AssetService.Get(imageID.ToString(), assetServerURI, false);
}
/// <summary>

View File

@@ -90,24 +90,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
private AssetBase FetchAsset(string url, UUID assetID)
{
string assetIDstr = assetID.ToString();
// Test if it's already here
AssetBase asset = m_scene.AssetService.Get(assetIDstr);
if (asset == null)
{
if (string.IsNullOrEmpty(url))
return null;
asset = m_scene.AssetService.Get(assetIDstr, url);
//if (asset != null)
// m_log.DebugFormat("[HG ASSET MAPPER]: Fetched asset {0} of type {1} from {2} ", assetID, asset.Metadata.Type, url);
//else
// m_log.DebugFormat("[HG ASSET MAPPER]: Unable to fetch asset {0} from {1} ", assetID, url);
}
return asset;
return m_scene.AssetService.Get(url, assetID.ToString(), true);
}
public bool PostAsset(string url, AssetBase asset, bool verbose = true)

View File

@@ -166,7 +166,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset
return asset;
}
public AssetBase Get(string id, string ForeignAssetService)
public AssetBase Get(string id, string ForeignAssetService, bool dummy)
{
return null;
}
@@ -231,7 +231,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset
return null;
}
public bool Get(string id, Object sender, AssetRetrieved handler)
public bool Get(string id, object sender, AssetRetrieved handler)
{
// m_log.DebugFormat("[LOCAL ASSET SERVICES CONNECTOR]: Asynchronously requesting asset {0}", id);

View File

@@ -229,7 +229,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset
{
if (m_HGConnector == null || string.IsNullOrEmpty(ForeignAssetService))
return null;
return m_HGConnector.Get(id , ForeignAssetService);
return m_HGConnector.Get(id , ForeignAssetService, true);
}
public AssetBase GetForeign(string id)
@@ -288,7 +288,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset
return asset;
}
public AssetBase Get(string id, string ForeignAssetService)
public AssetBase Get(string id, string ForeignAssetService, bool StoreOnLocalGrid)
{
// assumes id and ForeignAssetService are valid and resolved
AssetBase asset = null;
@@ -311,7 +311,10 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset
m_Cache.CacheNegative(id);
return null;
}
Store(asset);
if(StoreOnLocalGrid)
Store(asset);
else if (m_Cache != null)
m_Cache.Cache(asset);
}
else if (m_Cache != null)
m_Cache.CacheNegative(id);