Merge branch 'melanie'

httptests
Melanie Thielker 2017-02-01 16:34:49 +00:00
commit 202fcc7d6f
21 changed files with 158 additions and 96 deletions

View File

@ -47,8 +47,9 @@ namespace OpenSim.Framework
/// Get an asset by its id.
/// </summary>
/// <param name='id'></param>
/// <returns>null if the asset does not exist.</returns>
AssetBase Get(string id);
/// <param name='asset'>Will be set to null if no asset was found</param>
/// <returns>False if the asset has been negative-cached</returns>
bool Get(string id, out AssetBase asset);
/// <summary>
/// Check whether an asset with the specified id exists in the cache.

View File

@ -47,6 +47,8 @@ namespace OpenSim.Framework.Monitoring
// Subcommand used to list other stats.
public const string ListSubCommand = "list";
public static string StatsPassword { get; set; }
// All subcommands
public static HashSet<string> SubCommands = new HashSet<string> { AllSubCommand, ListSubCommand };
@ -302,6 +304,17 @@ namespace OpenSim.Framework.Monitoring
int response_code = 200;
string contenttype = "text/json";
if (StatsPassword != String.Empty && (!request.ContainsKey("pass") || request["pass"].ToString() != StatsPassword))
{
responsedata["int_response_code"] = response_code;
responsedata["content_type"] = "text/plain";
responsedata["keepalive"] = false;
responsedata["str_response_string"] = "Access denied";
responsedata["access_control_allow_origin"] = "*";
return responsedata;
}
string pCategoryName = StatsManager.AllSubCommand;
string pContainerName = StatsManager.AllSubCommand;
string pStatName = StatsManager.AllSubCommand;

View File

@ -113,7 +113,8 @@ namespace OpenSim.Framework
{
if (dataCache.Check(item.TextureID.ToString()))
{
AssetBase assetItem = dataCache.Get(item.TextureID.ToString());
AssetBase assetItem;
dataCache.Get(item.TextureID.ToString(), out assetItem);
if (assetItem != null)
{
itemmap.Add("assetdata", OSD.FromBinary(assetItem.Data));

View File

@ -211,6 +211,7 @@ namespace OpenSim
if (managedStatsURI != String.Empty)
{
string urlBase = String.Format("/{0}/", managedStatsURI);
StatsManager.StatsPassword = managedStatsPassword;
MainServer.Instance.AddHTTPHandler(urlBase, StatsManager.HandleStatsRequest);
m_log.InfoFormat("[OPENSIM] Enabling remote managed stats fetch. URL = {0}", urlBase);
}

View File

@ -88,6 +88,7 @@ namespace OpenSim
public string userStatsURI = String.Empty;
public string managedStatsURI = String.Empty;
public string managedStatsPassword = String.Empty;
protected bool m_autoCreateClientStack = true;
@ -239,6 +240,7 @@ namespace OpenSim
m_permsModules = new List<string>(permissionModules.Split(','));
managedStatsURI = startupConfig.GetString("ManagedStatsRemoteFetchURI", String.Empty);
managedStatsPassword = startupConfig.GetString("ManagedStatsRemoteFetchPassword", String.Empty);
}
// Load the simulation data service

View File

@ -369,7 +369,8 @@ namespace OpenSim.Region.CoreModules.Agent.TextureSender
else if (Cache != null)
{
string assetName = "j2kCache_" + AssetId.ToString();
AssetBase layerDecodeAsset = Cache.Get(assetName);
AssetBase layerDecodeAsset;
Cache.Get(assetName, out layerDecodeAsset);
if (layerDecodeAsset != null)
{

View File

@ -260,10 +260,9 @@ namespace OpenSim.Region.CoreModules.Asset
/// Cache doesn't guarantee in any situation that asset is stored to it.
/// </para>
/// </remarks>
public AssetBase Get(string id)
public bool Get(string id, out AssetBase assetBase)
{
m_getCount++;
AssetBase assetBase;
if (m_cache.TryGetValue(id, out assetBase))
m_hitCount++;
@ -284,7 +283,7 @@ namespace OpenSim.Region.CoreModules.Asset
// if (null == assetBase)
// m_log.DebugFormat("[CENOME ASSET CACHE]: Asset {0} not in cache", id);
return assetBase;
return true;
}
#endregion

View File

@ -115,7 +115,10 @@ namespace OpenSim.Region.CoreModules.Asset
public bool Check(string id)
{
// XXX This is probably not an efficient implementation.
return Get(id) != null;
AssetBase asset;
if (!Get(id, out asset))
return false;
return asset != null;
}
public void Cache(AssetBase asset)
@ -129,9 +132,10 @@ namespace OpenSim.Region.CoreModules.Asset
// We don't do negative caching
}
public AssetBase Get(string id)
public bool Get(string id, out AssetBase asset)
{
return (AssetBase)m_Cache.Get(id);
asset = (AssetBase)m_Cache.Get(id);
return true;
}
public void Expire(string id)

View File

@ -474,6 +474,8 @@ namespace OpenSim.Region.CoreModules.Asset
{
using (FileStream stream = File.Open(filename, FileMode.Open, FileAccess.Read, FileShare.Read))
{
if (stream.Length == 0) // Empty file will trigger exception below
return null;
BinaryFormatter bformatter = new BinaryFormatter();
asset = (AssetBase)bformatter.Deserialize(stream);
@ -531,15 +533,26 @@ namespace OpenSim.Region.CoreModules.Asset
return found;
}
// For IAssetService
public AssetBase Get(string id)
{
AssetBase asset;
Get(id, out asset);
return asset;
}
public bool Get(string id, out AssetBase asset)
{
asset = null;
m_Requests++;
object dummy;
if (m_negativeCache.TryGetValue(id, out dummy))
return null;
{
return false;
}
AssetBase asset = null;
asset = GetFromWeakReference(id);
if (asset != null && m_updateFileTimeOnCacheHit)
{
@ -578,13 +591,7 @@ namespace OpenSim.Region.CoreModules.Asset
GenerateCacheHitReport().ForEach(l => m_log.InfoFormat("[FLOTSAM ASSET CACHE]: {0}", l));
}
if(asset == null)
{
}
return asset;
return true;
}
public bool Check(string id)
@ -599,7 +606,9 @@ namespace OpenSim.Region.CoreModules.Asset
public AssetBase GetCached(string id)
{
return Get(id);
AssetBase asset;
Get(id, out asset);
return asset;
}
public void Expire(string id)
@ -1227,19 +1236,23 @@ namespace OpenSim.Region.CoreModules.Asset
public AssetMetadata GetMetadata(string id)
{
AssetBase asset = Get(id);
AssetBase asset;
Get(id, out asset);
return asset.Metadata;
}
public byte[] GetData(string id)
{
AssetBase asset = Get(id);
AssetBase asset;
Get(id, out asset);
return asset.Data;
}
public bool Get(string id, object sender, AssetRetrieved handler)
{
AssetBase asset = Get(id);
AssetBase asset;
if (!Get(id, out asset))
return false;
handler(id, sender, asset);
return true;
}
@ -1270,7 +1283,9 @@ namespace OpenSim.Region.CoreModules.Asset
public bool UpdateContent(string id, byte[] data)
{
AssetBase asset = Get(id);
AssetBase asset;
if (!Get(id, out asset))
return false;
asset.Data = data;
Cache(asset);
return true;

View File

@ -131,14 +131,15 @@ namespace OpenSim.Region.CoreModules.Asset
// We don't do negative caching
}
public AssetBase Get(string id)
public bool Get(string id, out AssetBase asset)
{
Object asset = null;
m_Cache.TryGet(id, out asset);
Object a = null;
m_Cache.TryGet(id, out a);
Debug(asset);
Debug(a);
return (AssetBase)asset;
asset = (AssetBase)a;
return true;
}
public void Expire(string id)

View File

@ -299,7 +299,8 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
if (bakedTextureFace == null)
continue;
AssetBase asset = cache.Get(bakedTextureFace.TextureID.ToString());
AssetBase asset;
cache.Get(bakedTextureFace.TextureID.ToString(), out asset);
if (asset != null && asset.Local)
{

View File

@ -248,22 +248,16 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
if (scene == null)
scene = m_SceneList[0];
// Avination new code
// SendReply reply = SynchronousRestObjectRequester.MakeRequest<GridInstantMessage, SendReply>(
// "POST", m_RestURL+"/SaveMessage/?scope=" +
// scene.RegionInfo.ScopeID.ToString(), im);
// current opensim and osgrid compatible
bool success = SynchronousRestObjectRequester.MakeRequest<GridInstantMessage, bool>(
"POST", m_RestURL+"/SaveMessage/", im, 10000);
// current opensim and osgrid compatible end
SendReply reply = SynchronousRestObjectRequester.MakeRequest<GridInstantMessage, SendReply>(
"POST", m_RestURL+"/SaveMessage/?scope=" +
scene.RegionInfo.ScopeID.ToString(), im);
if (im.dialog == (byte)InstantMessageDialog.MessageFromAgent)
{
IClientAPI client = FindClient(new UUID(im.fromAgentID));
if (client == null)
return;
/* Avination new code
if (reply.Message == String.Empty)
reply.Message = "User is not logged in. " + (reply.Success ? "Message saved." : "Message not saved");
@ -296,16 +290,6 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
reply.Message,
false, new Vector3()));
}
*/
// current opensim and osgrid compatible
client.SendInstantMessage(new GridInstantMessage(
null, new UUID(im.toAgentID),
"System", new UUID(im.fromAgentID),
(byte)InstantMessageDialog.MessageFromAgent,
"User is not logged in. "+
(success ? "Message saved." : "Message not saved"),
false, new Vector3()));
// current opensim and osgrid compatible end
}
}
}

View File

@ -149,7 +149,7 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles
if (profileConfig == null)
{
m_log.Debug("[PROFILES]: UserProfiles disabled, no configuration");
//m_log.Debug("[PROFILES]: UserProfiles disabled, no configuration");
Enabled = false;
return;
}

View File

@ -83,17 +83,17 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
LogManager.GetLogger(
MethodBase.GetCurrentMethod().DeclaringType);
private Dictionary<UUID, UrlData> m_RequestMap =
protected Dictionary<UUID, UrlData> m_RequestMap =
new Dictionary<UUID, UrlData>();
private Dictionary<string, UrlData> m_UrlMap =
protected Dictionary<string, UrlData> m_UrlMap =
new Dictionary<string, UrlData>();
private uint m_HttpsPort = 0;
private IHttpServer m_HttpServer = null;
private IHttpServer m_HttpsServer = null;
protected uint m_HttpsPort = 0;
protected IHttpServer m_HttpServer = null;
protected IHttpServer m_HttpsServer = null;
public string ExternalHostNameForLSL { get; private set; }
public string ExternalHostNameForLSL { get; protected set; }
/// <summary>
/// The default maximum number of urls
@ -107,7 +107,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
public Type ReplaceableInterface
{
get { return null; }
get { return typeof(IUrlModule); }
}
public string Name
@ -453,7 +453,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
}
private void RemoveUrl(UrlData data)
protected void RemoveUrl(UrlData data)
{
if (data.isSsl)
m_HttpsServer.RemoveHTTPHandler("", "/lslhttps/"+data.urlcode.ToString()+"/");
@ -461,7 +461,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
m_HttpServer.RemoveHTTPHandler("", "/lslhttp/"+data.urlcode.ToString()+"/");
}
private Hashtable NoEvents(UUID requestID, UUID sessionID)
protected Hashtable NoEvents(UUID requestID, UUID sessionID)
{
Hashtable response = new Hashtable();
UrlData url;
@ -499,7 +499,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
return response;
}
private bool HasEvents(UUID requestID, UUID sessionID)
protected bool HasEvents(UUID requestID, UUID sessionID)
{
UrlData url=null;
@ -530,7 +530,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
}
}
}
private Hashtable GetEvents(UUID requestID, UUID sessionID)
protected Hashtable GetEvents(UUID requestID, UUID sessionID)
{
UrlData url = null;
RequestData requestData = null;
@ -735,7 +735,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
}
}
private void OnScriptReset(uint localID, UUID itemID)
protected void OnScriptReset(uint localID, UUID itemID)
{
ScriptRemoved(itemID);
}

View File

@ -85,12 +85,12 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Profile
public LocalUserProfilesServicesConnector()
{
m_log.Debug("[LOCAL USERPROFILES SERVICE CONNECTOR]: LocalUserProfileServicesConnector no params");
//m_log.Debug("[LOCAL USERPROFILES SERVICE CONNECTOR]: LocalUserProfileServicesConnector no params");
}
public LocalUserProfilesServicesConnector(IConfigSource source)
{
m_log.Debug("[LOCAL USERPROFILES SERVICE CONNECTOR]: LocalUserProfileServicesConnector instantiated directly.");
//m_log.Debug("[LOCAL USERPROFILES SERVICE CONNECTOR]: LocalUserProfileServicesConnector instantiated directly.");
InitialiseService(source);
}
@ -104,7 +104,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Profile
IConfig config = source.Configs[ConfigName];
if (config == null)
{
m_log.Error("[LOCAL USERPROFILES SERVICE CONNECTOR]: UserProfilesService missing from OpenSim.ini");
//m_log.Error("[LOCAL USERPROFILES SERVICE CONNECTOR]: UserProfilesService missing from OpenSim.ini");
return;
}
@ -225,4 +225,4 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Profile
}
#endregion
}
}
}

View File

@ -209,7 +209,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset
if (m_Cache != null)
{
asset = m_Cache.Get(id);
if (!m_Cache.Get(id, out asset))
return null;
if (asset != null)
return asset;
@ -238,8 +239,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset
public AssetBase GetCached(string id)
{
AssetBase asset = null;
if (m_Cache != null)
return m_Cache.Get(id);
m_Cache.Get(id, out asset);
return null;
}
@ -250,8 +252,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset
if (m_Cache != null)
{
if (m_Cache != null)
m_Cache.Get(id);
if (!m_Cache.Get(id, out asset))
return null;
if (asset != null)
return asset.Metadata;
@ -273,8 +275,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset
if (m_Cache != null)
{
if (m_Cache != null)
m_Cache.Get(id);
if (!m_Cache.Get(id, out asset))
return null;
if (asset != null)
return asset.Data;
@ -292,7 +294,10 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset
AssetBase asset = null;
if (m_Cache != null)
asset = m_Cache.Get(id);
{
if (!m_Cache.Get(id, out asset))
return false;
}
if (asset != null)
{
@ -382,7 +387,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset
AssetBase asset = null;
if (m_Cache != null)
asset = m_Cache.Get(id);
m_Cache.Get(id, out asset);
if (asset != null)
{

View File

@ -158,7 +158,10 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset
AssetBase asset = null;
if (m_Cache != null)
asset = m_Cache.Get(id);
{
if (!m_Cache.Get(id, out asset))
return null;
}
if (asset == null)
{
@ -177,17 +180,21 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset
{
// m_log.DebugFormat("[LOCAL ASSET SERVICES CONNECTOR]: Cache request for {0}", id);
AssetBase asset = null;
if (m_Cache != null)
return m_Cache.Get(id);
m_Cache.Get(id, out asset);
return null;
return asset;
}
public AssetMetadata GetMetadata(string id)
{
AssetBase asset = null;
if (m_Cache != null)
asset = m_Cache.Get(id);
{
if (!m_Cache.Get(id, out asset))
return null;
}
if (asset != null)
return asset.Metadata;
@ -210,7 +217,10 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset
AssetBase asset = null;
if (m_Cache != null)
asset = m_Cache.Get(id);
{
if (!m_Cache.Get(id, out asset))
return null;
}
if (asset != null)
return asset.Data;
@ -232,7 +242,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset
if (m_Cache != null)
{
AssetBase asset = m_Cache.Get(id);
AssetBase asset;
if (!m_Cache.Get(id, out asset))
return false;
if (asset != null)
{
@ -287,7 +299,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset
{
AssetBase asset = null;
if (m_Cache != null)
m_Cache.Get(id);
m_Cache.Get(id, out asset);
if (asset != null)
{
asset.Data = data;

View File

@ -329,7 +329,7 @@ namespace OpenSim.Region.OptionalModules.Materials
AssetBase matAsset = m_scene.AssetService.Get(id.ToString());
if (matAsset == null || matAsset.Data == null || matAsset.Data.Length == 0 )
{
m_log.WarnFormat("[Materials]: Prim \"{0}\" ({1}) contains unknown material ID {2}", part.Name, part.UUID, id);
//m_log.WarnFormat("[Materials]: Prim \"{0}\" ({1}) contains unknown material ID {2}", part.Name, part.UUID, id);
return;
}

View File

@ -454,7 +454,7 @@ namespace OpenSim.Region.PhysicsModule.ubODEMeshing
if (physicsParms == null)
{
m_log.WarnFormat("[MESH]: unknown mesh type for prim {0}",primName);
//m_log.WarnFormat("[MESH]: unknown mesh type for prim {0}",primName);
return false;
}
@ -712,7 +712,7 @@ namespace OpenSim.Region.PhysicsModule.ubODEMeshing
else
{
// if neither mesh or decomposition present, warn and use convex
m_log.WarnFormat("[MESH]: Data for PRIM shape type ( mesh or decomposition) not found for prim {0}",primName);
//m_log.WarnFormat("[MESH]: Data for PRIM shape type ( mesh or decomposition) not found for prim {0}",primName);
}
}
vs.Clear();

View File

@ -243,8 +243,12 @@ namespace OpenSim.Services.Connectors
string uri = MapServer(id) + "/assets/" + id;
AssetBase asset = null;
if (m_Cache != null)
asset = m_Cache.Get(id);
{
if (!m_Cache.Get(id, out asset))
return null;
}
if (asset == null || asset.Data == null || asset.Data.Length == 0)
{
@ -275,17 +279,22 @@ namespace OpenSim.Services.Connectors
{
// m_log.DebugFormat("[ASSET SERVICE CONNECTOR]: Cache request for {0}", id);
AssetBase asset = null;
if (m_Cache != null)
return m_Cache.Get(id);
{
m_Cache.Get(id, out asset);
}
return null;
return asset;
}
public AssetMetadata GetMetadata(string id)
{
if (m_Cache != null)
{
AssetBase fullAsset = m_Cache.Get(id);
AssetBase fullAsset;
if (!m_Cache.Get(id, out fullAsset))
return null;
if (fullAsset != null)
return fullAsset.Metadata;
@ -301,7 +310,9 @@ namespace OpenSim.Services.Connectors
{
if (m_Cache != null)
{
AssetBase fullAsset = m_Cache.Get(id);
AssetBase fullAsset;
if (!m_Cache.Get(id, out fullAsset))
return null;
if (fullAsset != null)
return fullAsset.Data;
@ -389,7 +400,10 @@ namespace OpenSim.Services.Connectors
AssetBase asset = null;
if (m_Cache != null)
asset = m_Cache.Get(id);
{
if (!m_Cache.Get(id, out asset))
return false;
}
if (asset == null || asset.Data == null || asset.Data.Length == 0)
{
@ -590,7 +604,7 @@ namespace OpenSim.Services.Connectors
AssetBase asset = null;
if (m_Cache != null)
asset = m_Cache.Get(id);
m_Cache.Get(id, out asset);
if (asset == null)
{

View File

@ -136,7 +136,9 @@ namespace OpenSim.Services.Connectors.SimianGrid
// Cache fetch
if (m_cache != null)
{
AssetBase asset = m_cache.Get(id);
AssetBase asset;
if (!m_cache.Get(id, out asset))
return null;
if (asset != null)
return asset;
}
@ -147,8 +149,9 @@ namespace OpenSim.Services.Connectors.SimianGrid
public AssetBase GetCached(string id)
{
AssetBase asset;
if (m_cache != null)
return m_cache.Get(id);
m_cache.Get(id, out asset);
return null;
}
@ -169,7 +172,9 @@ namespace OpenSim.Services.Connectors.SimianGrid
// Cache fetch
if (m_cache != null)
{
AssetBase asset = m_cache.Get(id);
AssetBase asset;
if (!m_cache.Get(id, out asset))
return null;
if (asset != null)
return asset.Metadata;
}
@ -212,7 +217,10 @@ namespace OpenSim.Services.Connectors.SimianGrid
// Cache fetch
if (m_cache != null)
{
AssetBase asset = m_cache.Get(id);
AssetBase asset;
if (!m_cache.Get(id, out asset))
return false;
if (asset != null)
{
handler(id, sender, asset);