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)
// text = text.Remove(text.IndexOf("\n"));
// m_log.DebugFormat(
// "[CLIENT]: Placing request to send full info about prim {0} text {1} to client {2}",
// data.localID, text, Name);
// "[CLIENT]: Queueing send full info about prim {0}, attachment {1}, text {2} to client {3}",
// data.localID, data.attachment, text, Name);
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)
protected bool IsGroupMember(UUID groupID, UUID userID, ulong powers)
{
if (null == m_groupsModule)
return false;
GroupMembershipData gmd = m_groupsModule.GetMembershipData(groupID, userID);
if (gmd != null)
//DateTime t1 = DateTime.Now;
bool result = false;
if (null != m_groupsModule)
{
if (((gmd.GroupPowers != 0) && powers == 0) || (gmd.GroupPowers & powers) == powers)
return true;
GroupMembershipData gmd = m_groupsModule.GetMembershipData(groupID, userID);
if (gmd != null)
{
if (((gmd.GroupPowers != 0) && powers == 0) || (gmd.GroupPowers & powers) == powers)
result = true;
}
}
//m_log.DebugFormat("[PERMISSIONS]: Group member check took {0}", (DateTime.Now - t1).TotalMilliseconds);
return false;
return result;
}
/// <summary>

View File

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

View File

@ -1519,7 +1519,7 @@ namespace OpenSim.Region.Framework.Scenes
{
// if (IsAttachment)
// m_log.DebugFormat(
// "[SOG]: Sending part full update to {0} for {1} {2}", remoteClient.Name, part.Name, part.LocalId);
// "[SOG]: Sending part full update to {0} for {1} {2}", remoteClient.Name, part.Name, part.LocalId);
if (m_rootPart.UUID == part.UUID)
{
@ -2033,7 +2033,7 @@ namespace OpenSim.Region.Framework.Scenes
public void ScheduleGroupForFullUpdate()
{
// 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();
RootPart.ScheduleFullUpdate();
@ -2072,7 +2072,7 @@ namespace OpenSim.Region.Framework.Scenes
if (IsDeleted)
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();

View File

@ -29,6 +29,7 @@ using System;
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
using System.Text;
using Nwc.XmlRpc;
@ -42,6 +43,7 @@ using OpenMetaverse.StructuredData;
using OpenSim.Framework;
using OpenSim.Framework.Communications;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Services.Interfaces;
namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
{
@ -72,7 +74,9 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
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
// Should be reset per agent, on logon
// TODO: move this to Flotsam XmlRpc Service
@ -132,8 +136,18 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
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
m_memoryCache = new ExpiringCache<string, XmlRpcResponse>();
m_connectorEnabled = true;
}
}
@ -921,61 +935,94 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
/// </summary>
private Hashtable XmlRpcCall(UUID requestingAgentID, string function, Hashtable param)
{
string UserService;
UUID SessionID;
GetClientGroupRequestID(requestingAgentID, out UserService, out SessionID);
param.Add("RequestingAgentID", requestingAgentID.ToString());
param.Add("RequestingAgentUserService", UserService);
param.Add("RequestingSessionID", SessionID.ToString());
param.Add("ReadKey", m_groupReadKey);
param.Add("WriteKey", m_groupWriteKey);
if (m_debugEnabled)
{
m_log.Debug("[XMLRPCGROUPDATA] XmlRpcCall Params:");
foreach (string key in param.Keys)
{
m_log.DebugFormat("[XMLRPCGROUPDATA] {0} : {1}", key, param[key]);
}
}
IList parameters = new ArrayList();
parameters.Add(param);
ConfigurableKeepAliveXmlRpcRequest req;
req = new ConfigurableKeepAliveXmlRpcRequest(function, parameters, m_disableKeepAlive);
XmlRpcResponse resp = null;
string CacheKey = null;
try
// Only bother with the cache if it isn't disabled.
if (m_cacheTimeout > 0)
{
resp = req.Send(m_groupsServerURI, 10000);
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);
}
}
catch (Exception e)
if (resp == null)
{
string UserService;
UUID SessionID;
GetClientGroupRequestID(requestingAgentID, out UserService, out SessionID);
param.Add("RequestingAgentID", requestingAgentID.ToString());
param.Add("RequestingAgentUserService", UserService);
param.Add("RequestingSessionID", SessionID.ToString());
m_log.ErrorFormat("[XMLRPCGROUPDATA]: An error has occured while attempting to access the XmlRpcGroups server method: {0}", function);
m_log.ErrorFormat("[XMLRPCGROUPDATA]: {0} ", e.ToString());
if ((req != null) && (req.RequestResponse != null))
param.Add("ReadKey", m_groupReadKey);
param.Add("WriteKey", m_groupWriteKey);
if (m_debugEnabled)
{
foreach (string ResponseLine in req.RequestResponse.Split(new string[] { Environment.NewLine }, StringSplitOptions.None))
m_log.Debug("[XMLRPCGROUPDATA] XmlRpcCall Params:");
foreach (string key in param.Keys)
{
m_log.DebugFormat("[XMLRPCGROUPDATA] {0} : {1}", key, param[key]);
}
}
IList parameters = new ArrayList();
parameters.Add(param);
ConfigurableKeepAliveXmlRpcRequest req;
req = new ConfigurableKeepAliveXmlRpcRequest(function, parameters, m_disableKeepAlive);
try
{
m_log.ErrorFormat("[XMLRPCGROUPDATA]: {0} ", ResponseLine);
resp = req.Send(m_groupsServerURI, 10000);
if ((m_cacheTimeout > 0) && (CacheKey != null))
{
m_memoryCache.AddOrUpdate(CacheKey, resp, TimeSpan.FromSeconds(m_cacheTimeout));
}
}
}
foreach (string key in param.Keys)
catch (Exception e)
{
m_log.WarnFormat("[XMLRPCGROUPDATA]: {0} :: {1}", key, param[key].ToString());
m_log.ErrorFormat("[XMLRPCGROUPDATA]: An error has occured while attempting to access the XmlRpcGroups server method: {0}", function);
m_log.ErrorFormat("[XMLRPCGROUPDATA]: {0} ", e.ToString());
if ((req != null) && (req.RequestResponse != null))
{
foreach (string ResponseLine in req.RequestResponse.Split(new string[] { Environment.NewLine }, StringSplitOptions.None))
{
m_log.ErrorFormat("[XMLRPCGROUPDATA]: {0} ", ResponseLine);
}
}
foreach (string key in param.Keys)
{
m_log.WarnFormat("[XMLRPCGROUPDATA]: {0} :: {1}", key, param[key].ToString());
}
Hashtable respData = new Hashtable();
respData.Add("error", e.ToString());
return respData;
}
Hashtable respData = new Hashtable();
respData.Add("error", e.ToString());
return respData;
}