Merge branch 'master' into httptests

This commit is contained in:
UbitUmarov
2016-11-16 13:07:23 +00:00
42 changed files with 788 additions and 7947 deletions

View File

@@ -45,10 +45,6 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
private static readonly ILog m_log = LogManager.GetLogger(
MethodBase.GetCurrentMethod().DeclaringType);
protected Timer m_logTimer = new Timer(10000);
protected List<GridInstantMessage> m_logData = new List<GridInstantMessage>();
protected string m_restUrl;
/// <value>
/// Is this module enabled?
/// </value>
@@ -68,12 +64,9 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
"InstantMessageModule", "InstantMessageModule") !=
"InstantMessageModule")
return;
m_restUrl = config.Configs["Messaging"].GetString("LogURL", String.Empty);
}
m_enabled = true;
m_logTimer.AutoReset = false;
m_logTimer.Elapsed += LogTimerElapsed;
}
public virtual void AddRegion(Scene scene)
@@ -153,20 +146,17 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
}
#endregion
/*
public virtual void OnViewerInstantMessage(IClientAPI client, GridInstantMessage im)
{
im.fromAgentName = client.FirstName + " " + client.LastName;
OnInstantMessage(client, im);
}
*/
public virtual void OnInstantMessage(IClientAPI client, GridInstantMessage im)
{
byte dialog = im.dialog;
if (client != null && dialog == (byte)InstantMessageDialog.MessageFromAgent)
LogInstantMesssage(im);
if (dialog != (byte)InstantMessageDialog.MessageFromAgent
&& dialog != (byte)InstantMessageDialog.StartTyping
&& dialog != (byte)InstantMessageDialog.StopTyping
@@ -243,35 +233,5 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
//
OnInstantMessage(null, msg);
}
protected virtual void LogInstantMesssage(GridInstantMessage im)
{
if (m_logData.Count < 20)
{
// Restart the log write timer
m_logTimer.Stop();
}
if (!m_logTimer.Enabled)
m_logTimer.Start();
lock (m_logData)
{
m_logData.Add(im);
}
}
protected virtual void LogTimerElapsed(object source, ElapsedEventArgs e)
{
lock (m_logData)
{
if (m_restUrl != String.Empty && m_logData.Count > 0)
{
bool success = SynchronousRestObjectRequester.MakeRequest<List<GridInstantMessage>, bool>("POST", m_restUrl + "/LogMessages/", m_logData);
if (!success)
m_log.ErrorFormat("[INSTANT MESSAGE]: Failed to save log data");
}
m_logData.Clear();
}
}
}
}

View File

@@ -154,14 +154,12 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts
{
bool inCache = false;
UserAccount account;
lock(m_Cache)
account = m_Cache.Get(userID, out inCache);
account = m_Cache.Get(userID, out inCache);
if (inCache)
return account;
account = UserAccountService.GetUserAccount(scopeID, userID);
lock(m_Cache)
m_Cache.Cache(userID, account);
m_Cache.Cache(userID, account);
return account;
}
@@ -170,15 +168,13 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts
{
bool inCache = false;
UserAccount account;
lock(m_Cache)
account = m_Cache.Get(firstName + " " + lastName, out inCache);
account = m_Cache.Get(firstName + " " + lastName, out inCache);
if (inCache)
return account;
account = UserAccountService.GetUserAccount(scopeID, firstName, lastName);
if (account != null)
lock(m_Cache)
m_Cache.Cache(account.PrincipalID, account);
m_Cache.Cache(account.PrincipalID, account);
return account;
}
@@ -201,8 +197,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts
{
if(UUID.TryParse(id, out uuid))
{
lock(m_Cache)
account = m_Cache.Get(uuid, out inCache);
account = m_Cache.Get(uuid, out inCache);
if (inCache)
ret.Add(account);
else
@@ -216,12 +211,13 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts
List<UserAccount> ext = UserAccountService.GetUserAccounts(scopeID, missing);
if(ext != null && ext.Count > 0)
{
ret.AddRange(ext);
foreach(UserAccount acc in ext)
{
if(acc != null)
lock(m_Cache)
m_Cache.Cache(acc.PrincipalID, acc);
{
ret.Add(acc);
m_Cache.Cache(acc.PrincipalID, acc);
}
}
}
return ret;

View File

@@ -128,8 +128,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts
// flags, title, etc. And country, don't forget country!
private void OnNewClient(IClientAPI client)
{
lock(m_Cache)
m_Cache.Remove(client.Name);
m_Cache.Remove(client.Name);
}
#region Overwritten methods from IUserAccountService
@@ -138,15 +137,12 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts
{
bool inCache = false;
UserAccount account;
lock(m_Cache)
account = m_Cache.Get(userID, out inCache);
account = m_Cache.Get(userID, out inCache);
if (inCache)
return account;
account = base.GetUserAccount(scopeID, userID);
lock(m_Cache)
if(account != null)
m_Cache.Cache(userID, account);
m_Cache.Cache(userID, account);
return account;
}
@@ -155,15 +151,13 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts
{
bool inCache = false;
UserAccount account;
lock(m_Cache)
account = m_Cache.Get(firstName + " " + lastName, out inCache);
account = m_Cache.Get(firstName + " " + lastName, out inCache);
if (inCache)
return account;
account = base.GetUserAccount(scopeID, firstName, lastName);
if (account != null)
lock(m_Cache)
m_Cache.Cache(account.PrincipalID, account);
m_Cache.Cache(account.PrincipalID, account);
return account;
}
@@ -181,8 +175,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts
{
if(UUID.TryParse(id, out uuid))
{
lock(m_Cache)
account = m_Cache.Get(uuid, out inCache);
account = m_Cache.Get(uuid, out inCache);
if (inCache)
accs.Add(account);
else
@@ -195,16 +188,16 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts
List<UserAccount> ext = base.GetUserAccounts(scopeID, missing);
if(ext != null && ext.Count >0 )
{
accs.AddRange(ext);
foreach(UserAccount acc in ext)
{
if(acc != null)
lock(m_Cache)
m_Cache.Cache(acc.PrincipalID, acc);
{
accs.Add(acc);
m_Cache.Cache(acc.PrincipalID, acc);
}
}
}
}
return accs;
}

View File

@@ -36,7 +36,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts
{
public class UserAccountCache : IUserAccountCacheModule
{
private const double CACHE_EXPIRATION_SECONDS = 120000.0; // 33 hours!
private const double CACHE_EXPIRATION_SECONDS = 3600.0; // 1 hour!
private const double CACHE_NULL_EXPIRATION_SECONDS = 600; // 10minutes
// private static readonly ILog m_log =
// LogManager.GetLogger(
@@ -44,6 +45,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts
private ExpiringCache<UUID, UserAccount> m_UUIDCache;
private ExpiringCache<string, UUID> m_NameCache;
private object accessLock = new object();
public UserAccountCache()
{
@@ -54,60 +56,77 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts
public void Cache(UUID userID, UserAccount account)
{
// Cache even null accounts
m_UUIDCache.AddOrUpdate(userID, account, CACHE_EXPIRATION_SECONDS);
if (account != null)
m_NameCache.AddOrUpdate(account.Name, account.PrincipalID, CACHE_EXPIRATION_SECONDS);
lock(accessLock)
{
if (account == null)
m_UUIDCache.AddOrUpdate(userID, null, CACHE_NULL_EXPIRATION_SECONDS);
else
{
m_UUIDCache.AddOrUpdate(userID, account, CACHE_EXPIRATION_SECONDS);
m_NameCache.AddOrUpdate(account.Name, account.PrincipalID, CACHE_EXPIRATION_SECONDS);
}
//m_log.DebugFormat("[USER CACHE]: cached user {0}", userID);
}
}
public void Invalidate(UUID userID)
{
m_UUIDCache.Remove(userID);
lock(accessLock)
m_UUIDCache.Remove(userID);
}
public UserAccount Get(UUID userID, out bool inCache)
{
UserAccount account = null;
inCache = false;
if (m_UUIDCache.TryGetValue(userID, out account))
lock(accessLock)
{
//m_log.DebugFormat("[USER CACHE]: Account {0} {1} found in cache", account.FirstName, account.LastName);
inCache = true;
return account;
if (m_UUIDCache.TryGetValue(userID, out account))
{
//m_log.DebugFormat("[USER CACHE]: Account {0} {1} found in cache", account.FirstName, account.LastName);
inCache = true;
return account;
}
}
return null;
}
public UserAccount Get(string name, out bool inCache)
{
inCache = false;
if (!m_NameCache.Contains(name))
return null;
lock(accessLock)
{
if (!m_NameCache.Contains(name))
return null;
UserAccount account = null;
UUID uuid = UUID.Zero;
if (m_NameCache.TryGetValue(name, out uuid))
if (m_UUIDCache.TryGetValue(uuid, out account))
UserAccount account = null;
UUID uuid = UUID.Zero;
if (m_NameCache.TryGetValue(name, out uuid))
{
inCache = true;
return account;
if (m_UUIDCache.TryGetValue(uuid, out account))
{
inCache = true;
return account;
}
}
}
return null;
}
public void Remove(string name)
{
if (!m_NameCache.Contains(name))
return;
UUID uuid = UUID.Zero;
if (m_NameCache.TryGetValue(name, out uuid))
lock(accessLock)
{
m_NameCache.Remove(name);
m_UUIDCache.Remove(uuid);
if (!m_NameCache.Contains(name))
return;
UUID uuid = UUID.Zero;
if (m_NameCache.TryGetValue(name, out uuid))
{
m_NameCache.Remove(name);
m_UUIDCache.Remove(uuid);
}
}
}
}

View File

@@ -920,7 +920,7 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands
return false;
}
string rawConsoleEndVector = rawComponents.Skip(2).Take(1).Single();
string rawConsoleEndVector = rawComponents.Skip(1).Take(1).Single();
if (!ConsoleUtil.TryParseConsoleMaxVector(rawConsoleEndVector, out endVector))
{