mirror of
https://github.com/opensim/opensim.git
synced 2026-08-01 06:06:06 +08:00
some changes Still BAD
This commit is contained in:
@@ -166,7 +166,6 @@ namespace OpenSim.Region.CoreModules.Asset
|
||||
|
||||
m_negativeCacheEnabled = assetConfig.GetBoolean("NegativeCacheEnabled", m_negativeCacheEnabled);
|
||||
m_negativeExpiration = assetConfig.GetInt("NegativeCacheTimeout", m_negativeExpiration);
|
||||
|
||||
|
||||
m_updateFileTimeOnCacheHit = assetConfig.GetBoolean("UpdateFileTimeOnCacheHit", m_updateFileTimeOnCacheHit);
|
||||
m_updateFileTimeOnCacheHit &= m_FileCacheEnabled;
|
||||
|
||||
@@ -213,12 +213,6 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
|
||||
|
||||
public void Get(UUID assetID, UUID ownerID, string userAssetURL)
|
||||
{
|
||||
// Get the item from the remote asset server onto the local AssetService
|
||||
|
||||
AssetMetadata meta = FetchMetadata(userAssetURL, assetID);
|
||||
if (meta == null)
|
||||
return;
|
||||
|
||||
// The act of gathering UUIDs downloads some assets from the remote server
|
||||
// but not all...
|
||||
HGUuidGatherer uuidGatherer = new HGUuidGatherer(m_scene.AssetService, userAssetURL);
|
||||
@@ -228,8 +222,12 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
|
||||
m_log.DebugFormat("[HG ASSET MAPPER]: Preparing to get {0} assets", uuidGatherer.GatheredUuids.Count);
|
||||
bool success = true;
|
||||
foreach (UUID uuid in uuidGatherer.GatheredUuids.Keys)
|
||||
{
|
||||
if (FetchAsset(userAssetURL, uuid) == null)
|
||||
success = false;
|
||||
}
|
||||
if(uuidGatherer.FailedUUIDs.Count > 0)
|
||||
success = false;
|
||||
|
||||
// maybe all pieces got here...
|
||||
if (!success)
|
||||
|
||||
@@ -29,31 +29,25 @@ using log4net;
|
||||
using Mono.Addins;
|
||||
using Nini.Config;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using OpenSim.Framework;
|
||||
|
||||
using OpenSim.Server.Base;
|
||||
using OpenSim.Region.Framework.Interfaces;
|
||||
using OpenSim.Region.Framework.Scenes;
|
||||
using OpenSim.Server.Base;
|
||||
using OpenSim.Services.Connectors;
|
||||
using OpenSim.Services.Interfaces;
|
||||
using OpenMetaverse;
|
||||
|
||||
|
||||
namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset
|
||||
{
|
||||
[Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "HGAssetBroker")]
|
||||
public class HGAssetBroker : ISharedRegionModule, IAssetService
|
||||
public class HGAssetBroker : AssetServicesConnector, ISharedRegionModule, IAssetService
|
||||
{
|
||||
private static readonly ILog m_log =
|
||||
LogManager.GetLogger(
|
||||
MethodBase.GetCurrentMethod().DeclaringType);
|
||||
private static readonly ILog m_log = LogManager.GetLogger( MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
private IAssetCache m_Cache = null;
|
||||
private IAssetService m_GridService;
|
||||
private IAssetService m_HGService;
|
||||
|
||||
private Scene m_aScene;
|
||||
private string m_LocalAssetServiceURI;
|
||||
|
||||
private bool m_Enabled = false;
|
||||
|
||||
@@ -76,7 +70,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset
|
||||
Initialise(config);
|
||||
}
|
||||
|
||||
public void Initialise(IConfigSource source)
|
||||
public override void Initialise(IConfigSource source)
|
||||
{
|
||||
IConfig moduleConfig = source.Configs["Modules"];
|
||||
if (moduleConfig != null)
|
||||
@@ -91,56 +85,10 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset
|
||||
return;
|
||||
}
|
||||
|
||||
string localDll = assetConfig.GetString("LocalGridAssetService",
|
||||
String.Empty);
|
||||
string HGDll = assetConfig.GetString("HypergridAssetService",
|
||||
String.Empty);
|
||||
|
||||
if (localDll == String.Empty)
|
||||
{
|
||||
m_log.Error("[HG ASSET CONNECTOR]: No LocalGridAssetService named in section AssetService");
|
||||
return;
|
||||
}
|
||||
|
||||
if (HGDll == String.Empty)
|
||||
{
|
||||
m_log.Error("[HG ASSET CONNECTOR]: No HypergridAssetService named in section AssetService");
|
||||
return;
|
||||
}
|
||||
|
||||
Object[] args = new Object[] { source };
|
||||
m_GridService =
|
||||
ServerUtils.LoadPlugin<IAssetService>(localDll,
|
||||
args);
|
||||
|
||||
m_HGService =
|
||||
ServerUtils.LoadPlugin<IAssetService>(HGDll,
|
||||
args);
|
||||
|
||||
if (m_GridService == null)
|
||||
{
|
||||
m_log.Error("[HG ASSET CONNECTOR]: Can't load local asset service");
|
||||
return;
|
||||
}
|
||||
if (m_HGService == null)
|
||||
{
|
||||
m_log.Error("[HG ASSET CONNECTOR]: Can't load hypergrid asset service");
|
||||
return;
|
||||
}
|
||||
|
||||
m_LocalAssetServiceURI = assetConfig.GetString("AssetServerURI", string.Empty);
|
||||
if (m_LocalAssetServiceURI == string.Empty)
|
||||
{
|
||||
IConfig netConfig = source.Configs["Network"];
|
||||
m_LocalAssetServiceURI = netConfig.GetString("asset_server_url", string.Empty);
|
||||
}
|
||||
|
||||
if (m_LocalAssetServiceURI != string.Empty)
|
||||
m_LocalAssetServiceURI = m_LocalAssetServiceURI.Trim('/');
|
||||
|
||||
IConfig hgConfig = source.Configs["HGAssetService"];
|
||||
m_AssetPerms = new AssetPermissions(hgConfig); // it's ok if arg is null
|
||||
|
||||
base.Initialise(source);
|
||||
m_Enabled = true;
|
||||
m_log.Info("[HG ASSET CONNECTOR]: HG asset broker enabled");
|
||||
}
|
||||
@@ -180,115 +128,59 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset
|
||||
|
||||
if (!(m_Cache is ISharedRegionModule))
|
||||
m_Cache = null;
|
||||
|
||||
else
|
||||
SetCache(m_Cache);
|
||||
}
|
||||
|
||||
m_log.InfoFormat("[HG ASSET CONNECTOR]: Enabled hypergrid asset broker for region {0}", scene.RegionInfo.RegionName);
|
||||
|
||||
if (m_Cache != null)
|
||||
{
|
||||
m_log.InfoFormat("[HG ASSET CONNECTOR]: Enabled asset caching for region {0}", scene.RegionInfo.RegionName);
|
||||
}
|
||||
m_log.InfoFormat("[HG ASSET CONNECTOR]: Enabled asset broker with cache for region {0}", scene.RegionInfo.RegionName);
|
||||
else
|
||||
m_log.InfoFormat("[HG ASSET CONNECTOR]: Enabled asset broker without cache for region {0}", scene.RegionInfo.RegionName);
|
||||
}
|
||||
|
||||
private bool IsHG(string id)
|
||||
{
|
||||
Uri assetUri;
|
||||
|
||||
if (Uri.TryCreate(id, UriKind.Absolute, out assetUri) &&
|
||||
assetUri.Scheme == Uri.UriSchemeHttp)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
return id.Length > 0 && (id[0] == 'h' || id[0] == 'H');
|
||||
}
|
||||
|
||||
public AssetBase Get(string id)
|
||||
public override AssetBase Get(string id)
|
||||
{
|
||||
//m_log.DebugFormat("[HG ASSET CONNECTOR]: Get {0}", id);
|
||||
AssetBase asset = null;
|
||||
|
||||
if (m_Cache != null)
|
||||
{
|
||||
if (!m_Cache.Get(id, out asset))
|
||||
return null;
|
||||
|
||||
if (asset != null)
|
||||
return asset;
|
||||
}
|
||||
|
||||
if (IsHG(id))
|
||||
{
|
||||
asset = m_HGService.Get(id);
|
||||
asset = GetForeign(id);
|
||||
if (asset != null)
|
||||
{
|
||||
// Now store it locally, if allowed
|
||||
if (m_AssetPerms.AllowedImport(asset.Type))
|
||||
m_GridService.Store(asset);
|
||||
base.Store(asset);
|
||||
else
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else
|
||||
asset = m_GridService.Get(id);
|
||||
|
||||
if (m_Cache != null)
|
||||
m_Cache.Cache(asset);
|
||||
|
||||
asset = base.Get(id);
|
||||
return asset;
|
||||
}
|
||||
|
||||
public AssetBase GetCached(string id)
|
||||
public override AssetMetadata GetMetadata(string id)
|
||||
{
|
||||
AssetBase asset = null;
|
||||
if (m_Cache != null)
|
||||
m_Cache.Get(id, out asset);
|
||||
|
||||
return asset;
|
||||
}
|
||||
|
||||
public AssetMetadata GetMetadata(string id)
|
||||
{
|
||||
AssetBase asset = null;
|
||||
if (m_Cache != null)
|
||||
{
|
||||
if (!m_Cache.Get(id, out asset))
|
||||
return null;
|
||||
|
||||
if (asset != null)
|
||||
return asset.Metadata;
|
||||
}
|
||||
|
||||
AssetMetadata metadata;
|
||||
|
||||
if (IsHG(id))
|
||||
metadata = m_HGService.GetMetadata(id);
|
||||
return GetForeignMetadata(id);
|
||||
else
|
||||
metadata = m_GridService.GetMetadata(id);
|
||||
|
||||
return metadata;
|
||||
return base.GetMetadata(id);
|
||||
}
|
||||
|
||||
public byte[] GetData(string id)
|
||||
public override byte[] GetData(string id)
|
||||
{
|
||||
AssetBase asset = null;
|
||||
|
||||
if (m_Cache != null)
|
||||
{
|
||||
if (!m_Cache.Get(id, out asset))
|
||||
return null;
|
||||
|
||||
if (asset != null)
|
||||
return asset.Data;
|
||||
}
|
||||
|
||||
if (IsHG(id))
|
||||
return m_HGService.GetData(id);
|
||||
return base.GetForeignData(id);
|
||||
else
|
||||
return m_GridService.GetData(id);
|
||||
|
||||
return base.GetData(id);
|
||||
}
|
||||
|
||||
public bool Get(string id, Object sender, AssetRetrieved handler)
|
||||
public override bool Get(string id, object sender, AssetRetrieved handler)
|
||||
{
|
||||
AssetBase asset = null;
|
||||
|
||||
@@ -306,7 +198,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset
|
||||
|
||||
if (IsHG(id))
|
||||
{
|
||||
return m_HGService.Get(id, sender, delegate (string assetID, Object s, AssetBase a)
|
||||
return base.GetForeign(id, sender, delegate (string assetID, object s, AssetBase a)
|
||||
{
|
||||
if (m_Cache != null)
|
||||
m_Cache.Cache(a);
|
||||
@@ -316,7 +208,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset
|
||||
}
|
||||
else
|
||||
{
|
||||
return m_GridService.Get(id, sender, delegate (string assetID, Object s, AssetBase a)
|
||||
return base.Get(id, sender, delegate (string assetID, object s, AssetBase a)
|
||||
{
|
||||
if (m_Cache != null)
|
||||
m_Cache.Cache(a);
|
||||
@@ -326,7 +218,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset
|
||||
}
|
||||
}
|
||||
|
||||
public virtual bool[] AssetsExist(string[] ids)
|
||||
public override bool[] AssetsExist(string[] ids)
|
||||
{
|
||||
int numHG = 0;
|
||||
foreach (string id in ids)
|
||||
@@ -335,15 +227,10 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset
|
||||
++numHG;
|
||||
}
|
||||
|
||||
if (numHG == 0)
|
||||
return m_GridService.AssetsExist(ids);
|
||||
else if (numHG == ids.Length)
|
||||
return m_HGService.AssetsExist(ids);
|
||||
else
|
||||
throw new Exception("[HG ASSET CONNECTOR]: AssetsExist: all the assets must be either local or foreign");
|
||||
return numHG == 0 ? base.AssetsExist(ids) : base.ForeignAssetsExist(ids);
|
||||
}
|
||||
|
||||
public string Store(AssetBase asset)
|
||||
public override string Store(AssetBase asset)
|
||||
{
|
||||
if (asset.Local || asset.Temporary)
|
||||
{
|
||||
@@ -352,72 +239,36 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset
|
||||
return asset.ID;
|
||||
}
|
||||
|
||||
bool isHG = IsHG(asset.ID);
|
||||
if ((m_Cache != null) && !isHG)
|
||||
// Don't store it in the cache if the asset is to
|
||||
// be sent to the other grid, because this is already
|
||||
// a copy of the local asset.
|
||||
m_Cache.Cache(asset);
|
||||
|
||||
string id;
|
||||
if (isHG)
|
||||
if (IsHG(asset.ID))
|
||||
{
|
||||
if (m_AssetPerms.AllowedExport(asset.Type))
|
||||
id = m_HGService.Store(asset);
|
||||
id = base.StoreForeign(asset);
|
||||
else
|
||||
return String.Empty;
|
||||
return string.Empty;
|
||||
return id;
|
||||
}
|
||||
else
|
||||
id = m_GridService.Store(asset);
|
||||
|
||||
if (String.IsNullOrEmpty(id))
|
||||
id = base.Store(asset);
|
||||
if (string.IsNullOrEmpty(id))
|
||||
return string.Empty;
|
||||
|
||||
if(asset.ID != id)
|
||||
{
|
||||
asset.ID = id;
|
||||
if (m_Cache != null)
|
||||
m_Cache.Cache(asset);
|
||||
}
|
||||
|
||||
return id;
|
||||
return id;
|
||||
}
|
||||
|
||||
public bool UpdateContent(string id, byte[] data)
|
||||
public override bool UpdateContent(string id, byte[] data)
|
||||
{
|
||||
AssetBase asset = null;
|
||||
|
||||
if (m_Cache != null)
|
||||
m_Cache.Get(id, out asset);
|
||||
|
||||
if (asset != null)
|
||||
{
|
||||
asset.Data = data;
|
||||
m_Cache.Cache(asset);
|
||||
}
|
||||
|
||||
if (IsHG(id))
|
||||
return m_HGService.UpdateContent(id, data);
|
||||
else
|
||||
return m_GridService.UpdateContent(id, data);
|
||||
return false;
|
||||
return base.UpdateContent(id, data);
|
||||
}
|
||||
|
||||
public bool Delete(string id)
|
||||
public override bool Delete(string id)
|
||||
{
|
||||
if (m_Cache != null)
|
||||
m_Cache.Expire(id);
|
||||
|
||||
bool result = false;
|
||||
if (IsHG(id))
|
||||
result = m_HGService.Delete(id);
|
||||
else
|
||||
result = m_GridService.Delete(id);
|
||||
return false;
|
||||
|
||||
if (result && m_Cache != null)
|
||||
m_Cache.Expire(id);
|
||||
|
||||
return result;
|
||||
return base.Delete(id);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,24 +75,21 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset
|
||||
return;
|
||||
}
|
||||
|
||||
string serviceDll = assetConfig.GetString("LocalServiceModule", String.Empty);
|
||||
|
||||
if (serviceDll == String.Empty)
|
||||
string serviceDll = assetConfig.GetString("LocalServiceModule", string.Empty);
|
||||
if (string.IsNullOrEmpty(serviceDll))
|
||||
{
|
||||
m_log.Error("[LOCAL ASSET SERVICES CONNECTOR]: No LocalServiceModule named in section AssetService");
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_log.DebugFormat("[LOCAL ASSET SERVICES CONNECTOR]: Loading asset service at {0}", serviceDll);
|
||||
}
|
||||
|
||||
Object[] args = new Object[] { source };
|
||||
//m_log.DebugFormat("[LOCAL ASSET SERVICES CONNECTOR]: Loading asset service at {0}", serviceDll);
|
||||
|
||||
object[] args = new object[] { source };
|
||||
m_AssetService = ServerUtils.LoadPlugin<IAssetService>(serviceDll, args);
|
||||
|
||||
if (m_AssetService == null)
|
||||
{
|
||||
m_log.Error("[LOCAL ASSET SERVICES CONNECTOR]: Can't load asset service");
|
||||
m_log.Error("[LOCAL ASSET SERVICES CONNECTOR]: Fail to load asset service " + serviceDll);
|
||||
return;
|
||||
}
|
||||
m_Enabled = true;
|
||||
@@ -134,13 +131,10 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset
|
||||
m_Cache = null;
|
||||
}
|
||||
|
||||
m_log.DebugFormat(
|
||||
"[LOCAL ASSET SERVICES CONNECTOR]: Enabled connector for region {0}", scene.RegionInfo.RegionName);
|
||||
|
||||
if (m_Cache != null)
|
||||
{
|
||||
m_log.DebugFormat(
|
||||
"[LOCAL ASSET SERVICES CONNECTOR]: Enabled asset caching for region {0}",
|
||||
"[LOCAL ASSET SERVICES CONNECTOR]: Enabled asset connector with caching for region {0}",
|
||||
scene.RegionInfo.RegionName);
|
||||
}
|
||||
else
|
||||
@@ -154,8 +148,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset
|
||||
|
||||
public AssetBase Get(string id)
|
||||
{
|
||||
// m_log.DebugFormat("[LOCAL ASSET SERVICES CONNECTOR]: Synchronously requesting asset {0}", id);
|
||||
|
||||
AssetBase asset = null;
|
||||
if (m_Cache != null)
|
||||
{
|
||||
@@ -166,11 +158,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset
|
||||
if (asset == null)
|
||||
{
|
||||
asset = m_AssetService.Get(id);
|
||||
if ((m_Cache != null) && (asset != null))
|
||||
if ((m_Cache != null) && (asset != null) && asset.ID != id)
|
||||
m_Cache.Cache(asset);
|
||||
|
||||
// if (null == asset)
|
||||
// m_log.WarnFormat("[LOCAL ASSET SERVICES CONNECTOR]: Could not synchronously find asset with id {0}", id);
|
||||
//if (null == asset)
|
||||
// m_log.WarnFormat("[LOCAL ASSET SERVICES CONNECTOR]: Could not synchronously find asset with id {0}", id);
|
||||
}
|
||||
|
||||
return asset;
|
||||
@@ -248,8 +240,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset
|
||||
|
||||
if (asset != null)
|
||||
{
|
||||
Util.FireAndForget(
|
||||
o => handler(id, sender, asset), null, "LocalAssetServiceConnector.GotFromCacheCallback");
|
||||
Util.FireAndForget(o => handler(id, sender, asset), null, "LocalAssetServiceConnector.GotFromCacheCallback");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -262,8 +253,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset
|
||||
// if (null == a)
|
||||
// m_log.WarnFormat("[LOCAL ASSET SERVICES CONNECTOR]: Could not asynchronously find asset with id {0}", id);
|
||||
|
||||
Util.FireAndForget(
|
||||
o => handler(assetID, s, a), null, "LocalAssetServiceConnector.GotFromServiceCallback");
|
||||
Util.FireAndForget(o => handler(assetID, s, a), null, "LocalAssetServiceConnector.GotFromServiceCallback");
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -40,12 +40,9 @@ using OpenSim.Services.Interfaces;
|
||||
namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset
|
||||
{
|
||||
[Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "RemoteAssetServicesConnector")]
|
||||
public class RemoteAssetServicesConnector :
|
||||
AssetServicesConnector, ISharedRegionModule, IAssetService
|
||||
public class RemoteAssetServicesConnector : AssetServicesConnector, ISharedRegionModule, IAssetService
|
||||
{
|
||||
private static readonly ILog m_log =
|
||||
LogManager.GetLogger(
|
||||
MethodBase.GetCurrentMethod().DeclaringType);
|
||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
private bool m_Enabled = false;
|
||||
private IAssetCache m_Cache;
|
||||
|
||||
@@ -36,6 +36,7 @@ using System.Timers;
|
||||
using Nini.Config;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Framework.Monitoring;
|
||||
using OpenSim.Framework.ServiceAuth;
|
||||
using OpenSim.Services.Interfaces;
|
||||
using OpenMetaverse;
|
||||
|
||||
@@ -339,25 +340,23 @@ namespace OpenSim.Services.Connectors
|
||||
AssetBase asset = null;
|
||||
if (m_Cache != null)
|
||||
{
|
||||
if (!m_Cache.Get(uuidstr, out asset))
|
||||
return null;
|
||||
//if (!m_Cache.Get(uuidstr, out asset))
|
||||
// return null;
|
||||
m_Cache.Get(uuidstr, out asset); // negative cache is a fail on HG
|
||||
}
|
||||
|
||||
if (asset == null || asset.Data == null || asset.Data.Length == 0)
|
||||
{
|
||||
IServiceAuth auth = null;
|
||||
if (type == 0)
|
||||
{
|
||||
uri = MapServer(uuidstr) + "/assets/" + uuidstr;
|
||||
auth = m_Auth;
|
||||
}
|
||||
else
|
||||
uri = uri + "/assets/" + uuidstr;
|
||||
|
||||
asset = SynchronousRestObjectRequester.MakeRequest<int, AssetBase>("GET", uri, 0, m_Auth);
|
||||
if (m_Cache != null)
|
||||
{
|
||||
if (asset != null)
|
||||
m_Cache.Cache(asset);
|
||||
else
|
||||
m_Cache.CacheNegative(id);
|
||||
}
|
||||
asset = SynchronousRestObjectRequester.MakeRequest<int, AssetBase>("GET", uri, 0, auth);
|
||||
}
|
||||
return asset;
|
||||
}
|
||||
@@ -396,12 +395,16 @@ namespace OpenSim.Services.Connectors
|
||||
return fullAsset.Metadata;
|
||||
}
|
||||
|
||||
IServiceAuth auth = null;
|
||||
if (type == 0)
|
||||
{
|
||||
auth = m_Auth;
|
||||
uri = MapServer(uuidstr) + "/assets/" + uuidstr + "/metadata";
|
||||
}
|
||||
else
|
||||
uri = uri + "/assets/" + uuidstr + "/metadata";
|
||||
|
||||
AssetMetadata asset = SynchronousRestObjectRequester.MakeRequest<int, AssetMetadata>("GET", uri, 0, m_Auth);
|
||||
AssetMetadata asset = SynchronousRestObjectRequester.MakeRequest<int, AssetMetadata>("GET", uri, 0, auth);
|
||||
return asset;
|
||||
}
|
||||
|
||||
@@ -447,15 +450,19 @@ namespace OpenSim.Services.Connectors
|
||||
return fullAsset.Data;
|
||||
}
|
||||
|
||||
IServiceAuth auth = null;
|
||||
if (type == 0)
|
||||
{
|
||||
uri = MapServer(uuidstr);
|
||||
auth = m_Auth;
|
||||
}
|
||||
|
||||
using (RestClient rc = new RestClient(uri))
|
||||
{
|
||||
rc.AddResourcePath("assets/" + id + "/Data");
|
||||
rc.RequestMethod = "GET";
|
||||
|
||||
using (MemoryStream s = rc.Request(m_Auth))
|
||||
using (MemoryStream s = rc.Request(auth))
|
||||
{
|
||||
if (s == null || s.Length == 0)
|
||||
return null;
|
||||
@@ -468,6 +475,7 @@ namespace OpenSim.Services.Connectors
|
||||
{
|
||||
public string uri;
|
||||
public string id;
|
||||
public IServiceAuth auth;
|
||||
}
|
||||
|
||||
public virtual bool Get(string id, object sender, AssetRetrieved handler)
|
||||
@@ -503,6 +511,7 @@ namespace OpenSim.Services.Connectors
|
||||
QueuedAssetRequest request = new QueuedAssetRequest();
|
||||
request.id = id;
|
||||
request.uri = uri;
|
||||
request.auth = m_Auth;
|
||||
m_requestQueue.Add(request);
|
||||
}
|
||||
}
|
||||
@@ -525,14 +534,17 @@ namespace OpenSim.Services.Connectors
|
||||
AssetBase asset = null;
|
||||
if (m_Cache != null)
|
||||
{
|
||||
if (!m_Cache.Get(uuidstr, out asset))
|
||||
return false;
|
||||
m_Cache.Get(uuidstr, out asset);
|
||||
}
|
||||
|
||||
if (asset == null)
|
||||
{
|
||||
IServiceAuth auth = null;
|
||||
if (type == 0)
|
||||
{
|
||||
uri = MapServer(uuidstr) + "/assets/" + uuidstr;
|
||||
auth = m_Auth;
|
||||
}
|
||||
else
|
||||
uri = uri + "/assets/" + uuidstr;
|
||||
|
||||
@@ -556,6 +568,7 @@ namespace OpenSim.Services.Connectors
|
||||
QueuedAssetRequest request = new QueuedAssetRequest();
|
||||
request.id = id;
|
||||
request.uri = uri;
|
||||
request.auth = m_Auth;
|
||||
m_requestQueue.Add(request);
|
||||
}
|
||||
}
|
||||
@@ -587,7 +600,7 @@ namespace OpenSim.Services.Connectors
|
||||
|
||||
try
|
||||
{
|
||||
AssetBase a = SynchronousRestObjectRequester.MakeRequest<int, AssetBase>("GET", r.uri, 0, 30000, m_Auth);
|
||||
AssetBase a = SynchronousRestObjectRequester.MakeRequest<int, AssetBase>("GET", r.uri, 0, 30000, r.auth);
|
||||
|
||||
if (a != null && m_Cache != null)
|
||||
m_Cache.Cache(a);
|
||||
@@ -641,11 +654,13 @@ namespace OpenSim.Services.Connectors
|
||||
{
|
||||
public string assetID;
|
||||
public int index;
|
||||
public IServiceAuth auth;
|
||||
|
||||
public AssetAndIndex(string assetID, int index)
|
||||
public AssetAndIndex(string assetID, int index, IServiceAuth auth)
|
||||
{
|
||||
this.assetID = assetID;
|
||||
this.index = index;
|
||||
this.auth = auth;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -660,8 +675,13 @@ namespace OpenSim.Services.Connectors
|
||||
int ltype = Util.ParseForeignAssetID(ids[i], out string lurl, out string luuidstr);
|
||||
if (ltype > 0)
|
||||
{
|
||||
IServiceAuth auth = null;
|
||||
|
||||
if (ltype == 0)
|
||||
{
|
||||
lurl = m_ServerURI;
|
||||
auth = m_Auth;
|
||||
}
|
||||
|
||||
List < AssetAndIndex > lst;
|
||||
if (!url2assets.TryGetValue(lurl, out lst))
|
||||
@@ -669,7 +689,7 @@ namespace OpenSim.Services.Connectors
|
||||
lst = new List<AssetAndIndex>();
|
||||
url2assets.Add(lurl, lst);
|
||||
}
|
||||
lst.Add(new AssetAndIndex(luuidstr, i));
|
||||
lst.Add(new AssetAndIndex(luuidstr, i, auth));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -678,7 +698,8 @@ namespace OpenSim.Services.Connectors
|
||||
{
|
||||
List<AssetAndIndex> curAssets = kvp.Value;
|
||||
string[] assetIDs = new string[curAssets.Count];
|
||||
for(int i = 0; i < assetIDs.Length;++i)
|
||||
IServiceAuth auth = curAssets[0].auth;
|
||||
for (int i = 0; i < assetIDs.Length;++i)
|
||||
assetIDs[i] = curAssets[i].assetID;
|
||||
|
||||
string uri = kvp.Key + "/get_assets_exist";
|
||||
@@ -686,7 +707,7 @@ namespace OpenSim.Services.Connectors
|
||||
bool[] curExist = null;
|
||||
try
|
||||
{
|
||||
curExist = SynchronousRestObjectRequester.MakeRequest<string[], bool[]>("POST", uri, assetIDs, m_Auth);
|
||||
curExist = SynchronousRestObjectRequester.MakeRequest<string[], bool[]>("POST", uri, assetIDs, auth);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
@@ -816,15 +837,19 @@ namespace OpenSim.Services.Connectors
|
||||
return asset.ID;
|
||||
}
|
||||
|
||||
IServiceAuth auth = null;
|
||||
if(type == 0)
|
||||
{
|
||||
uri = MapServer(uuidstr) + "/assets/";
|
||||
auth = m_Auth;
|
||||
}
|
||||
else
|
||||
uri += "/assets/";
|
||||
|
||||
string newID = null;
|
||||
try
|
||||
{
|
||||
newID = SynchronousRestObjectRequester.MakeRequest<AssetBase, string>("POST", uri, asset, 10000, m_Auth);
|
||||
newID = SynchronousRestObjectRequester.MakeRequest<AssetBase, string>("POST", uri, asset, 30000, auth);
|
||||
}
|
||||
catch
|
||||
{
|
||||
@@ -833,33 +858,12 @@ namespace OpenSim.Services.Connectors
|
||||
|
||||
if (string.IsNullOrEmpty(newID) || newID == stringUUIDZero)
|
||||
{
|
||||
//The asset upload failed, try later
|
||||
lock (m_sendRetries)
|
||||
{
|
||||
if (m_Cache == null)
|
||||
{
|
||||
if (m_sendRetries[0] == null)
|
||||
m_sendRetries[0] = new List<AssetBase>();
|
||||
m_sendRetries[0].Add(asset);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_sendCachedRetries[0] == null)
|
||||
m_sendCachedRetries[0] = new List<string>();
|
||||
m_sendCachedRetries[0].Add(asset.ID);
|
||||
}
|
||||
|
||||
m_log.WarnFormat("[Assets] Upload failed: {0} type {1} will retry later",
|
||||
asset.ID.ToString(), asset.Type.ToString());
|
||||
m_retryTimer.Start();
|
||||
}
|
||||
return string.Empty;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (newID != asset.ID)
|
||||
{
|
||||
// Placing this here, so that this work with old asset servers that don't send any reply back
|
||||
// SynchronousRestObjectRequester returns somethins that is not an empty string
|
||||
asset.ID = newID;
|
||||
if (m_Cache != null)
|
||||
m_Cache.Cache(asset);
|
||||
|
||||
Reference in New Issue
Block a user