Merge branch 'master' of ssh://opensimulator.org/var/git/opensim

user_profiles
Justin Clark-Casey (justincc) 2013-02-07 02:19:53 +00:00
commit 2c5d24d394
7 changed files with 120 additions and 15 deletions

View File

@ -73,6 +73,14 @@ namespace OpenSim.Framework
m_map = (OSDMap)OSDParser.DeserializeLLSDXml(rawXml); m_map = (OSDMap)OSDParser.DeserializeLLSDXml(rawXml);
} }
// WARNING: this is temporary for experimentation only, it will be removed!!!!
public OSDMap TopLevelMap
{
get { return m_map; }
set { m_map = value; }
}
public void ReadXml(XmlReader reader) public void ReadXml(XmlReader reader)
{ {
ReadXml(reader.ReadInnerXml()); ReadXml(reader.ReadInnerXml());

View File

@ -45,6 +45,7 @@ using System.Text.RegularExpressions;
using System.Xml; using System.Xml;
using System.Threading; using System.Threading;
using log4net; using log4net;
using log4net.Appender;
using Nini.Config; using Nini.Config;
using Nwc.XmlRpc; using Nwc.XmlRpc;
using OpenMetaverse; using OpenMetaverse;
@ -816,9 +817,22 @@ namespace OpenSim.Framework
return "."; return ".";
} }
public static string logFile()
{
foreach (IAppender appender in LogManager.GetRepository().GetAppenders())
{
if (appender is FileAppender)
{
return ((FileAppender)appender).File;
}
}
return "./OpenSim.log";
}
public static string logDir() public static string logDir()
{ {
return "."; return Path.GetDirectoryName(logFile());
} }
// From: http://coercedcode.blogspot.com/2008/03/c-generate-unique-filenames-within.html // From: http://coercedcode.blogspot.com/2008/03/c-generate-unique-filenames-within.html

View File

@ -35,6 +35,7 @@ namespace OpenSim.Region.Framework.Interfaces
public interface IJsonStoreModule public interface IJsonStoreModule
{ {
bool AttachObjectStore(UUID objectID);
bool CreateStore(string value, ref UUID result); bool CreateStore(string value, ref UUID result);
bool DestroyStore(UUID storeID); bool DestroyStore(UUID storeID);
bool TestStore(UUID storeID); bool TestStore(UUID storeID);

View File

@ -49,7 +49,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
private static readonly ILog m_log = private static readonly ILog m_log =
LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private OSD m_ValueStore; protected virtual OSD ValueStore { get; set; }
protected class TakeValueCallbackClass protected class TakeValueCallbackClass
{ {
@ -108,17 +108,18 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
/// ///
/// </summary> /// </summary>
// ----------------------------------------------------------------- // -----------------------------------------------------------------
public JsonStore() : this("") {} public JsonStore()
public JsonStore(string value)
{ {
m_TakeStore = new List<TakeValueCallbackClass>(); m_TakeStore = new List<TakeValueCallbackClass>();
m_ReadStore = new List<TakeValueCallbackClass>(); m_ReadStore = new List<TakeValueCallbackClass>();
}
public JsonStore(string value)
{
if (String.IsNullOrEmpty(value)) if (String.IsNullOrEmpty(value))
m_ValueStore = new OSDMap(); ValueStore = new OSDMap();
else else
m_ValueStore = OSDParser.DeserializeJson(value); ValueStore = OSDParser.DeserializeJson(value);
} }
// ----------------------------------------------------------------- // -----------------------------------------------------------------
@ -129,7 +130,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
public bool TestPath(string expr, bool useJson) public bool TestPath(string expr, bool useJson)
{ {
Stack<string> path = ParsePathExpression(expr); Stack<string> path = ParsePathExpression(expr);
OSD result = ProcessPathExpression(m_ValueStore,path); OSD result = ProcessPathExpression(ValueStore,path);
if (result == null) if (result == null)
return false; return false;
@ -148,7 +149,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
public bool GetValue(string expr, out string value, bool useJson) public bool GetValue(string expr, out string value, bool useJson)
{ {
Stack<string> path = ParsePathExpression(expr); Stack<string> path = ParsePathExpression(expr);
OSD result = ProcessPathExpression(m_ValueStore,path); OSD result = ProcessPathExpression(ValueStore,path);
return ConvertOutputValue(result,out value,useJson); return ConvertOutputValue(result,out value,useJson);
} }
@ -184,7 +185,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
Stack<string> path = ParsePathExpression(expr); Stack<string> path = ParsePathExpression(expr);
string pexpr = PathExpressionToKey(path); string pexpr = PathExpressionToKey(path);
OSD result = ProcessPathExpression(m_ValueStore,path); OSD result = ProcessPathExpression(ValueStore,path);
if (result == null) if (result == null)
{ {
m_TakeStore.Add(new TakeValueCallbackClass(pexpr,useJson,cback)); m_TakeStore.Add(new TakeValueCallbackClass(pexpr,useJson,cback));
@ -215,7 +216,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
Stack<string> path = ParsePathExpression(expr); Stack<string> path = ParsePathExpression(expr);
string pexpr = PathExpressionToKey(path); string pexpr = PathExpressionToKey(path);
OSD result = ProcessPathExpression(m_ValueStore,path); OSD result = ProcessPathExpression(ValueStore,path);
if (result == null) if (result == null)
{ {
m_ReadStore.Add(new TakeValueCallbackClass(pexpr,useJson,cback)); m_ReadStore.Add(new TakeValueCallbackClass(pexpr,useJson,cback));
@ -245,7 +246,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
Stack<string> path = ParsePathExpression(expr); Stack<string> path = ParsePathExpression(expr);
if (path.Count == 0) if (path.Count == 0)
{ {
m_ValueStore = ovalue; ValueStore = ovalue;
return true; return true;
} }
@ -254,7 +255,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
if (pexpr != "") if (pexpr != "")
pexpr += "."; pexpr += ".";
OSD result = ProcessPathExpression(m_ValueStore,path); OSD result = ProcessPathExpression(ValueStore,path);
if (result == null) if (result == null)
return false; return false;
@ -522,4 +523,41 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
return pkey; return pkey;
} }
} }
public class JsonObjectStore : JsonStore
{
private static readonly ILog m_log =
LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private Scene m_scene;
private UUID m_objectID;
protected override OSD ValueStore
{
get
{
SceneObjectPart sop = m_scene.GetSceneObjectPart(m_objectID);
if (sop == null)
{
// This is bad
return null;
}
return sop.DynAttrs.TopLevelMap;
}
// cannot set the top level
set
{
m_log.InfoFormat("[JsonStore] cannot set top level value in object store");
}
}
public JsonObjectStore(Scene scene, UUID oid) : base()
{
m_scene = scene;
m_objectID = oid;
}
}
} }

View File

@ -170,6 +170,34 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
#region ScriptInvocationInteface #region ScriptInvocationInteface
// -----------------------------------------------------------------
/// <summary>
///
/// </summary>
// -----------------------------------------------------------------
public bool AttachObjectStore(UUID objectID)
{
if (! m_enabled) return false;
SceneObjectPart sop = m_scene.GetSceneObjectPart(objectID);
if (sop == null)
{
m_log.InfoFormat("[JsonStore] unable to attach to unknown object; {0}",objectID);
return false;
}
lock (m_JsonValueStore)
{
if (m_JsonValueStore.ContainsKey(objectID))
return true;
JsonStore map = new JsonObjectStore(m_scene,objectID);
m_JsonValueStore.Add(objectID,map);
}
return true;
}
// ----------------------------------------------------------------- // -----------------------------------------------------------------
/// <summary> /// <summary>
/// ///

View File

@ -169,6 +169,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
m_comms.RegisterScriptInvocations(this); m_comms.RegisterScriptInvocations(this);
// m_comms.RegisterScriptInvocation(this, "JsonCreateStore"); // m_comms.RegisterScriptInvocation(this, "JsonCreateStore");
// m_comms.RegisterScriptInvocation(this, "JsonAttachObjectStore");
// m_comms.RegisterScriptInvocation(this, "JsonDestroyStore"); // m_comms.RegisterScriptInvocation(this, "JsonDestroyStore");
// m_comms.RegisterScriptInvocation(this, "JsonTestStore"); // m_comms.RegisterScriptInvocation(this, "JsonTestStore");
@ -214,6 +215,21 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
#endregion #endregion
#region ScriptInvocationInteface #region ScriptInvocationInteface
// -----------------------------------------------------------------
/// <summary>
///
/// </summary>
// -----------------------------------------------------------------
[ScriptInvocation]
public UUID JsonAttachObjectStore(UUID hostID, UUID scriptID)
{
UUID uuid = UUID.Zero;
if (! m_store.AttachObjectStore(hostID))
GenerateRuntimeError("Failed to create Json store");
return hostID;
}
// ----------------------------------------------------------------- // -----------------------------------------------------------------
/// <summary> /// <summary>
/// ///

View File

@ -420,7 +420,7 @@ namespace OpenSim.Region.UserStatistics
Encoding encoding = Encoding.ASCII; Encoding encoding = Encoding.ASCII;
int sizeOfChar = encoding.GetByteCount("\n"); int sizeOfChar = encoding.GetByteCount("\n");
byte[] buffer = encoding.GetBytes("\n"); byte[] buffer = encoding.GetBytes("\n");
string logfile = Util.logDir() + "/" + "OpenSim.log"; string logfile = Util.logFile();
FileStream fs = new FileStream(logfile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); FileStream fs = new FileStream(logfile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
Int64 tokenCount = 0; Int64 tokenCount = 0;
Int64 endPosition = fs.Length / sizeOfChar; Int64 endPosition = fs.Length / sizeOfChar;