backport xmlrpcgroups cache from master

0.6.9-post-fixes
Justin Clark-Casey (justincc) 2010-06-08 20:31:39 +01:00
parent 0524458069
commit 8b3b89ecf4
5 changed files with 114 additions and 61 deletions

View File

@ -3517,8 +3517,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
// if (text.IndexOf("\n") >= 0) // if (text.IndexOf("\n") >= 0)
// text = text.Remove(text.IndexOf("\n")); // text = text.Remove(text.IndexOf("\n"));
// m_log.DebugFormat( // m_log.DebugFormat(
// "[CLIENT]: Placing request to send full info about prim {0} text {1} to client {2}", // "[CLIENT]: Queueing send full info about prim {0}, attachment {1}, text {2} to client {3}",
// data.localID, text, Name); // data.localID, data.attachment, text, Name);
if (data.priority == double.NaN) if (data.priority == double.NaN)
{ {

View File

@ -411,18 +411,23 @@ namespace OpenSim.Region.CoreModules.World.Permissions
// with the powers requested (powers = 0 for no powers check) // with the powers requested (powers = 0 for no powers check)
protected bool IsGroupMember(UUID groupID, UUID userID, ulong powers) protected bool IsGroupMember(UUID groupID, UUID userID, ulong powers)
{ {
if (null == m_groupsModule) //DateTime t1 = DateTime.Now;
return false; bool result = false;
if (null != m_groupsModule)
{
GroupMembershipData gmd = m_groupsModule.GetMembershipData(groupID, userID); GroupMembershipData gmd = m_groupsModule.GetMembershipData(groupID, userID);
if (gmd != null) if (gmd != null)
{ {
if (((gmd.GroupPowers != 0) && powers == 0) || (gmd.GroupPowers & powers) == powers) if (((gmd.GroupPowers != 0) && powers == 0) || (gmd.GroupPowers & powers) == powers)
return true; result = true;
}
} }
return false; //m_log.DebugFormat("[PERMISSIONS]: Group member check took {0}", (DateTime.Now - t1).TotalMilliseconds);
return result;
} }
/// <summary> /// <summary>

View File

@ -116,6 +116,8 @@ namespace OpenSim.Region.Framework.Scenes
/// <param name="remoteClient"></param> /// <param name="remoteClient"></param>
public void RequestPrim(uint primLocalID, IClientAPI remoteClient) public void RequestPrim(uint primLocalID, IClientAPI remoteClient)
{ {
// m_log.DebugFormat("[SCENE]: {0} requested full update for {1}", remoteClient.Name, primLocalID);
List<EntityBase> EntityList = GetEntities(); List<EntityBase> EntityList = GetEntities();
foreach (EntityBase ent in EntityList) foreach (EntityBase ent in EntityList)
@ -124,7 +126,6 @@ namespace OpenSim.Region.Framework.Scenes
{ {
if (((SceneObjectGroup)ent).LocalId == primLocalID) if (((SceneObjectGroup)ent).LocalId == primLocalID)
{ {
// m_log.DebugFormat("[SCENE]: Received full update request for {0} from {1}", primLocalID, remoteClient.Name);
((SceneObjectGroup)ent).SendFullUpdateToClient(remoteClient); ((SceneObjectGroup)ent).SendFullUpdateToClient(remoteClient);
return; return;
} }

View File

@ -2033,7 +2033,7 @@ namespace OpenSim.Region.Framework.Scenes
public void ScheduleGroupForFullUpdate() public void ScheduleGroupForFullUpdate()
{ {
// if (IsAttachment) // if (IsAttachment)
// m_log.DebugFormat("[SOG]: Scheduling full update for {0} {1}", Name, UUID); // m_log.DebugFormat("[SOG]: Scheduling full update for {0} {1}", Name, LocalId);
checkAtTargets(); checkAtTargets();
RootPart.ScheduleFullUpdate(); RootPart.ScheduleFullUpdate();
@ -2072,7 +2072,7 @@ namespace OpenSim.Region.Framework.Scenes
if (IsDeleted) if (IsDeleted)
return; return;
// m_log.DebugFormat("[SOG]: Sending immediate full group update for {0} {1}", Name, UUID); // m_log.DebugFormat("[SOG]: Sending immediate full group update for {0} {1}", Name, LocalId);
RootPart.SendFullUpdateToAllClients(); RootPart.SendFullUpdateToAllClients();

View File

@ -29,6 +29,7 @@ using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Reflection; using System.Reflection;
using System.Text;
using Nwc.XmlRpc; using Nwc.XmlRpc;
@ -42,6 +43,7 @@ using OpenMetaverse.StructuredData;
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.Framework.Communications; using OpenSim.Framework.Communications;
using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Interfaces;
using OpenSim.Services.Interfaces;
namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
{ {
@ -72,6 +74,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
private bool m_debugEnabled = false; private bool m_debugEnabled = false;
private ExpiringCache<string, XmlRpcResponse> m_memoryCache;
private int m_cacheTimeout = 30;
// Used to track which agents are have dropped from a group chat session // Used to track which agents are have dropped from a group chat session
// Should be reset per agent, on logon // Should be reset per agent, on logon
@ -132,8 +136,18 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
m_debugEnabled = groupsConfig.GetBoolean("DebugEnabled", true); m_debugEnabled = groupsConfig.GetBoolean("DebugEnabled", true);
m_cacheTimeout = groupsConfig.GetInt("GroupsCacheTimeout", 30);
if (m_cacheTimeout == 0)
{
m_log.WarnFormat("[XMLRPC-GROUPS-CONNECTOR]: Groups Cache Disabled.");
}
else
{
m_log.InfoFormat("[XMLRPC-GROUPS-CONNECTOR]: Groups Cache Timeout set to {0}.", m_cacheTimeout);
}
// If we got all the config options we need, lets start'er'up // If we got all the config options we need, lets start'er'up
m_memoryCache = new ExpiringCache<string, XmlRpcResponse>();
m_connectorEnabled = true; m_connectorEnabled = true;
} }
} }
@ -920,6 +934,35 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
/// Encapsulate the XmlRpc call to standardize security and error handling. /// Encapsulate the XmlRpc call to standardize security and error handling.
/// </summary> /// </summary>
private Hashtable XmlRpcCall(UUID requestingAgentID, string function, Hashtable param) private Hashtable XmlRpcCall(UUID requestingAgentID, string function, Hashtable param)
{
XmlRpcResponse resp = null;
string CacheKey = null;
// Only bother with the cache if it isn't disabled.
if (m_cacheTimeout > 0)
{
if (!function.StartsWith("groups.get"))
{
// Any and all updates cause the cache to clear
m_memoryCache.Clear();
}
else
{
StringBuilder sb = new StringBuilder(requestingAgentID + function);
foreach (object key in param.Keys)
{
if (param[key] != null)
{
sb.AppendFormat(",{0}:{1}", key.ToString(), param[key].ToString());
}
}
CacheKey = sb.ToString();
m_memoryCache.TryGetValue(CacheKey, out resp);
}
}
if (resp == null)
{ {
string UserService; string UserService;
UUID SessionID; UUID SessionID;
@ -947,11 +990,14 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
ConfigurableKeepAliveXmlRpcRequest req; ConfigurableKeepAliveXmlRpcRequest req;
req = new ConfigurableKeepAliveXmlRpcRequest(function, parameters, m_disableKeepAlive); req = new ConfigurableKeepAliveXmlRpcRequest(function, parameters, m_disableKeepAlive);
XmlRpcResponse resp = null;
try try
{ {
resp = req.Send(m_groupsServerURI, 10000); resp = req.Send(m_groupsServerURI, 10000);
if ((m_cacheTimeout > 0) && (CacheKey != null))
{
m_memoryCache.AddOrUpdate(CacheKey, resp, TimeSpan.FromSeconds(m_cacheTimeout));
}
} }
catch (Exception e) catch (Exception e)
{ {
@ -977,6 +1023,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
respData.Add("error", e.ToString()); respData.Add("error", e.ToString());
return respData; return respData;
} }
}
if (resp.Value is Hashtable) if (resp.Value is Hashtable)