change region asset connectors again. The new ini files must be used (should update automaticly). All region modes back, but testing needed, as usual. Left out automatic grid store retry, that needs better consideration (like on payed uploads). runprebuild, clearaot etc needed

This commit is contained in:
UbitUmarov
2020-10-28 09:16:36 +00:00
parent e86bd042bb
commit e4a922012a
10 changed files with 42 additions and 1478 deletions

View File

@@ -217,7 +217,7 @@ namespace OpenSim.Framework
catch (Exception ex)
{
errorMessage = ex.Message;
m_log.Debug("[WEB UTIL]: ServiceOSD error creating request " + ex.Message);
m_log.Debug("[WEB UTIL]: SvcOSD error creating request " + ex.Message);
return ErrorResponseMap(errorMessage);
}
@@ -291,7 +291,7 @@ namespace OpenSim.Framework
if (tickdiff > LongCallTime)
{
m_log.InfoFormat(
"[WEB UTIL]: ServiceOSD request {0} {1} {2} took {3}ms, {4}/{5}bytes",
"[WEB UTIL]: SvcOSD {0} {1} {2} took {3}ms, {4}/{5}bytes",
reqnum, method, url, tickdiff, sendlen, rcvlen );
}
else if (DebugLevel >= 4)
@@ -324,10 +324,10 @@ namespace OpenSim.Framework
result["_RawResult"] = OSD.FromString(response);
result["_Result"] = new OSDMap();
if (response.Equals("true",System.StringComparison.OrdinalIgnoreCase))
if (response.Equals("true", StringComparison.OrdinalIgnoreCase))
return result;
if (response.Equals("false",System.StringComparison.OrdinalIgnoreCase))
if (response.Equals("false", StringComparison.OrdinalIgnoreCase))
{
result["Success"] = OSD.FromBoolean(false);
result["success"] = OSD.FromBoolean(false);

View File

@@ -1,298 +0,0 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSimulator Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using log4net;
using Mono.Addins;
using Nini.Config;
using System;
using System.Reflection;
using OpenSim.Framework;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes;
using OpenSim.Services.Connectors;
using OpenSim.Services.Interfaces;
namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset
{
[Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "HGAssetBroker")]
public class HGAssetBroker : RegionBaseAssetServicesConnector, ISharedRegionModule, IAssetService
{
private static readonly ILog m_log = LogManager.GetLogger( MethodBase.GetCurrentMethod().DeclaringType);
private Scene m_aScene;
private bool m_Enabled = false;
private AssetPermissions m_AssetPerms;
public Type ReplaceableInterface
{
get { return null; }
}
public string Name
{
get { return "HGAssetBroker"; }
}
public HGAssetBroker() {}
public HGAssetBroker(IConfigSource config)
{
Initialise(config);
}
public void Initialise(IConfigSource source)
{
IConfig moduleConfig = source.Configs["Modules"];
if (moduleConfig != null)
{
string name = moduleConfig.GetString("AssetServices", "");
if (name == Name)
{
IConfig hgConfig = source.Configs["HGAssetService"];
if(hgConfig != null)
m_AssetPerms = new AssetPermissions(hgConfig); // it's ok if arg is null
baseInitialise(source);
m_Enabled = true;
m_log.Info("[HG ASSET CONNECTOR]: HG asset broker enabled");
}
}
}
public void PostInitialise()
{
}
public void Close()
{
}
public void AddRegion(Scene scene)
{
if (!m_Enabled)
return;
m_aScene = scene;
m_aScene.RegisterModuleInterface<IAssetService>(this);
}
public void RemoveRegion(Scene scene)
{
}
public void RegionLoaded(Scene scene)
{
if (!m_Enabled)
return;
if (m_Cache == null)
{
m_Cache = scene.RequestModuleInterface<IAssetCache>();
if (!(m_Cache is ISharedRegionModule))
m_Cache = null;
}
if (m_Cache != null)
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)
{
return id.Length > 0 && (id[0] == 'h' || id[0] == 'H');
}
public override AssetBase Get(string id)
{
//m_log.DebugFormat("[HG ASSET CONNECTOR]: Get {0}", id);
AssetBase asset = null;
if (IsHG(id))
{
asset = GetForeign(id);
if (asset != null)
{
// Now store it locally, if allowed
if (m_AssetPerms.AllowedImport(asset.Type))
base.Store(asset);
else
return null;
}
}
else
asset = base.Get(id);
return asset;
}
public AssetBase Get(string id, string ForeignAssetService)
{
// assumes id and ForeignAssetService are valid and resolved
AssetBase asset = null;
if (m_Cache != null)
{
m_Cache.Get(id, out asset); // negative cache is a fail on HG
}
if (asset == null)
{
asset = GetFromLocal(id);
if (asset == null)
{
asset = GetFromForeign(id, ForeignAssetService);
if (asset != null)
{
if (m_AssetPerms.AllowedImport(asset.Type))
base.Store(asset);
else
{
if (m_Cache != null)
m_Cache.CacheNegative(id);
return null;
}
}
else if (m_Cache != null)
m_Cache.CacheNegative(id);
}
else if (m_Cache != null)
m_Cache.Cache(asset);
}
return asset;
}
public override AssetMetadata GetMetadata(string id)
{
if (IsHG(id))
return GetForeignMetadata(id);
else
return base.GetMetadata(id);
}
public override byte[] GetData(string id)
{
if (IsHG(id))
return base.GetForeignData(id);
else
return base.GetData(id);
}
public override bool Get(string id, object sender, AssetRetrieved handler)
{
AssetBase asset = null;
if (m_Cache != null)
{
if (!m_Cache.Get(id, out asset))
return false;
}
if (asset != null)
{
Util.FireAndForget(delegate { handler(id, sender, asset); asset = null; }, null, "HGAssetBroker.GotFromCache");
return true;
}
if (IsHG(id))
{
return base.GetForeign(id, sender, delegate (string assetID, object s, AssetBase a)
{
if (m_Cache != null)
m_Cache.Cache(a);
handler(assetID, s, a);
a = null;
});
}
else
{
return base.Get(id, sender, delegate (string assetID, object s, AssetBase a)
{
if (m_Cache != null)
m_Cache.Cache(a);
handler(assetID, s, a);
a = null;
});
}
}
public override bool[] AssetsExist(string[] ids)
{
int numHG = 0;
foreach (string id in ids)
{
if (IsHG(id))
++numHG;
}
return numHG == 0 ? base.AssetsExist(ids) : base.ForeignAssetsExist(ids);
}
public override string Store(AssetBase asset)
{
if (asset.Local || asset.Temporary)
{
if (m_Cache != null)
m_Cache.Cache(asset);
return asset.ID;
}
string id;
if (IsHG(asset.ID))
{
if (m_AssetPerms.AllowedExport(asset.Type))
id = base.StoreForeign(asset);
else
return string.Empty;
return id;
}
id = base.Store(asset);
if (string.IsNullOrEmpty(id))
return string.Empty;
return id;
}
public override bool UpdateContent(string id, byte[] data)
{
if (IsHG(id))
return false;
return base.UpdateContent(id, data);
}
public override bool Delete(string id)
{
if (IsHG(id))
return false;
return base.Delete(id);
}
}
}

View File

@@ -1,121 +0,0 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSimulator Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using log4net;
using Mono.Addins;
using System;
using System.Collections.Generic;
using System.Reflection;
using Nini.Config;
using OpenSim.Framework;
using OpenSim.Services.Connectors;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes;
using OpenSim.Services.Interfaces;
namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset
{
[Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "RemoteAssetServicesConnector")]
public class RemoteAssetServicesConnector : RegionBaseAssetServicesConnector, ISharedRegionModule, IAssetService
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private bool m_Enabled = false;
public Type ReplaceableInterface
{
get { return null; }
}
public string Name
{
get { return "RemoteAssetServicesConnector"; }
}
public void Initialise(IConfigSource source)
{
IConfig moduleConfig = source.Configs["Modules"];
if (moduleConfig != null)
{
string name = moduleConfig.GetString("AssetServices", "");
if (name == Name)
{
baseInitialise(source);
m_Enabled = true;
m_log.Info("[ASSET CONNECTOR]: Remote assets enabled");
}
}
}
public void PostInitialise()
{
}
public void Close()
{
}
public void AddRegion(Scene scene)
{
if (!m_Enabled)
return;
scene.RegisterModuleInterface<IAssetService>(this);
}
public void RemoveRegion(Scene scene)
{
}
public void RegionLoaded(Scene scene)
{
if (!m_Enabled)
return;
if (m_Cache == null)
{
m_Cache = scene.RequestModuleInterface<IAssetCache>();
// Since we are a shared module and scene data is not
// available for every method, the cache must be shared, too
//
if (!(m_Cache is ISharedRegionModule))
m_Cache = null;
}
if (m_Cache != null)
m_log.InfoFormat("[ASSET CONNECTOR]: Enabled remote assets with caching for region {0}", scene.RegionInfo.RegionName);
else
m_log.InfoFormat("[ASSET CONNECTOR]: Enabled remote assets without caching for region {0}", scene.RegionInfo.RegionName);
}
public AssetBase Get(string id, string ForeignAssetService)
{
return Get(id); // no hg
}
}
}

View File

@@ -46,9 +46,10 @@ namespace OpenSim.Services.Connectors
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
protected IAssetCache m_Cache = null;
public readonly object ConnectorLock = new object();
protected IAssetCache m_Cache = null;
private string m_ServerURI = string.Empty;
private delegate void AssetRetrievedEx(AssetBase asset);
@@ -64,7 +65,8 @@ namespace OpenSim.Services.Connectors
public AssetServicesConnector(string serverURI)
{
m_ServerURI = serverURI.TrimEnd('/');
OSHHTPHost tmp = new OSHHTPHost(serverURI, true);
m_ServerURI = tmp.IsResolvedHost ? tmp.URI : null;
}
public AssetServicesConnector(IConfigSource source)
@@ -138,7 +140,7 @@ namespace OpenSim.Services.Connectors
return null;
}
if (asset == null || asset.Data == null || asset.Data.Length == 0)
if (asset == null && m_ServerURI != null)
{
string uri = m_ServerURI + "/assets/" + id;
@@ -171,10 +173,11 @@ namespace OpenSim.Services.Connectors
return fullAsset.Metadata;
}
string uri =m_ServerURI + "/assets/" + id + "/metadata";
if (m_ServerURI == null)
return null;
AssetMetadata asset = SynchronousRestObjectRequester.MakeRequest<int, AssetMetadata>("GET", uri, 0, m_Auth);
return asset;
string uri = m_ServerURI + "/assets/" + id + "/metadata";
return SynchronousRestObjectRequester.MakeRequest<int, AssetMetadata>("GET", uri, 0, m_Auth);
}
@@ -189,6 +192,9 @@ namespace OpenSim.Services.Connectors
return fullAsset.Data;
}
if (m_ServerURI == null)
return null;
using (RestClient rc = new RestClient(m_ServerURI))
{
rc.AddResourcePath("assets/" + id + "/Data");
@@ -212,7 +218,7 @@ namespace OpenSim.Services.Connectors
return false;
}
if (asset == null)
if (asset == null && m_ServerURI != null)
{
string uri = m_ServerURI + "/assets/" + id;
@@ -290,6 +296,9 @@ namespace OpenSim.Services.Connectors
public virtual bool[] AssetsExist(string[] ids)
{
if (m_ServerURI == null)
return null;
string uri = m_ServerURI + "/get_assets_exist";
bool[] exist = null;
@@ -350,6 +359,9 @@ namespace OpenSim.Services.Connectors
return asset.ID;
}
if (m_ServerURI == null)
return null;
string uri = m_ServerURI + "/assets/";
string newID = null;
@@ -383,10 +395,14 @@ namespace OpenSim.Services.Connectors
public virtual bool UpdateContent(string id, byte[] data)
{
if (m_ServerURI == null)
return false;
AssetBase asset = null;
m_Cache?.Get(id, out asset);
if (asset == null)
{
AssetMetadata metadata = GetMetadata(id);
@@ -410,6 +426,9 @@ namespace OpenSim.Services.Connectors
public virtual bool Delete(string id)
{
if (m_ServerURI == null)
return false;
string uri = m_ServerURI + "/assets/" + id;
if (SynchronousRestObjectRequester.MakeRequest<int, bool>("DELETE", uri, 0, m_Auth))

View File

@@ -27,14 +27,10 @@
using log4net;
using Nini.Config;
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Reflection;
using System.Web;
using OpenSim.Framework;
using OpenSim.Services.Interfaces;
using OpenSim.Services.Connectors.Hypergrid;
using OpenMetaverse;
namespace OpenSim.Services.Connectors
@@ -42,7 +38,7 @@ namespace OpenSim.Services.Connectors
public class HGAssetServiceConnector : IAssetService
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private ExpiringCacheOS<string, AssetServicesConnector> m_connectors = new ExpiringCacheOS<string, AssetServicesConnector>(120000);
private ExpiringCacheOS<string, AssetServicesConnector> m_connectors = new ExpiringCacheOS<string, AssetServicesConnector>(60000);
public HGAssetServiceConnector(IConfigSource source)
{
@@ -67,10 +63,8 @@ namespace OpenSim.Services.Connectors
AssetServicesConnector connector = null;
lock (m_connectors)
{
if (!m_connectors.TryGetValue(url, 120000, out connector))
if (!m_connectors.TryGetValue(url, 60000, out connector))
{
// Still not as flexible as I would like this to be,
// but good enough for now
connector = new AssetServicesConnector(url);
m_connectors.Add(url, connector);
}
@@ -88,7 +82,6 @@ namespace OpenSim.Services.Connectors
IAssetService connector = GetConnector(url);
return connector.Get(assetID);
}
return null;
}
@@ -108,7 +101,6 @@ namespace OpenSim.Services.Connectors
IAssetService connector = GetConnector(url);
return connector.GetCached(assetID);
}
return null;
}
@@ -159,11 +151,6 @@ namespace OpenSim.Services.Connectors
public virtual bool[] AssetsExist(string[] ids)
{
// This method is a bit complicated because it works even if the assets belong to different
// servers; that requires sending separate requests to each server.
// Group the assets by the server they belong to
var url2assets = new Dictionary<string, List<AssetAndIndex>>();
for (int i = 0; i < ids.Length; i++)

View File

@@ -8,7 +8,7 @@
Include-Common = "config-include/GridCommon.ini"
[Modules]
AssetServices = "RemoteAssetServicesConnector"
AssetServices = "RegionAssetConnector"
InventoryServices = "RemoteXInventoryServicesConnector"
GridServices = "RemoteGridServicesConnector"
AvatarServices = "RemoteAvatarServicesConnector"
@@ -38,6 +38,9 @@
[EstateDataStore]
LocalServiceModule = "OpenSim.Services.EstateService.dll:EstateDataService"
[AssetService]
LocalGridAssetService = "OpenSim.Services.Connectors.dll:AssetServicesConnector"
[GridService]
LocalServiceModule = "OpenSim.Services.GridService.dll:GridService"
; for the LocalGridServicesConnector which is used by the Remote one

View File

@@ -11,7 +11,7 @@
WorldMapModule = "HGWorldMap"
[Modules]
AssetServices = "HGAssetBroker"
AssetServices = "RegionAssetConnector"
InventoryServices = "HGInventoryBroker"
GridServices = "RemoteGridServicesConnector"
AvatarServices = "RemoteAvatarServicesConnector"

View File

@@ -5,7 +5,7 @@
;;
[Modules]
AssetServices = "LocalAssetServicesConnector"
AssetServices = "RegionAssetConnector"
InventoryServices = "LocalInventoryServicesConnector"
NeighbourServices = "NeighbourServicesOutConnector"
AuthenticationServices = "LocalAuthenticationServicesConnector"
@@ -37,6 +37,8 @@
[AssetService]
LocalServiceModule = "OpenSim.Services.AssetService.dll:AssetService"
; For RegionAssetConnector
LocalGridAssetService = "OpenSim.Services.Connectors.dll:AssetService"
[InventoryService]
LocalServiceModule = "OpenSim.Services.InventoryService.dll:XInventoryService"

View File

@@ -8,7 +8,7 @@
WorldMapModule = "HGWorldMap"
[Modules]
AssetServices = "HGAssetBroker"
AssetServices = "RegionAssetConnector"
InventoryServices = "HGInventoryBroker"
NeighbourServices = "NeighbourServicesOutConnector"
AuthenticationServices = "LocalAuthenticationServicesConnector"
@@ -53,7 +53,7 @@
[AssetService]
LocalServiceModule = "OpenSim.Services.AssetService.dll:AssetService"
; For HGAssetBroker
; For RegionAssetConnector
LocalGridAssetService = "OpenSim.Services.AssetService.dll:AssetService"
HypergridAssetService = "OpenSim.Services.Connectors.dll:HGAssetServiceConnector"