diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/Scene.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Scene.cs | 126 |
1 files changed, 123 insertions, 3 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index a6ee40a..aeca7df 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs | |||
@@ -36,6 +36,7 @@ using System.Timers; | |||
36 | using System.Xml; | 36 | using System.Xml; |
37 | using Nini.Config; | 37 | using Nini.Config; |
38 | using OpenMetaverse; | 38 | using OpenMetaverse; |
39 | using OpenMetaverse.Packets; | ||
39 | using OpenMetaverse.Imaging; | 40 | using OpenMetaverse.Imaging; |
40 | using OpenSim.Framework; | 41 | using OpenSim.Framework; |
41 | using OpenSim.Services.Interfaces; | 42 | using OpenSim.Services.Interfaces; |
@@ -87,8 +88,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
87 | protected List<RegionInfo> m_regionRestartNotifyList = new List<RegionInfo>(); | 88 | protected List<RegionInfo> m_regionRestartNotifyList = new List<RegionInfo>(); |
88 | protected List<RegionInfo> m_neighbours = new List<RegionInfo>(); | 89 | protected List<RegionInfo> m_neighbours = new List<RegionInfo>(); |
89 | 90 | ||
90 | public volatile bool BordersLocked = false; | 91 | private volatile int m_bordersLocked = 0; |
91 | 92 | public bool BordersLocked | |
93 | { | ||
94 | get { return m_bordersLocked == 1; } | ||
95 | set | ||
96 | { | ||
97 | if (value == true) | ||
98 | m_bordersLocked = 1; | ||
99 | else | ||
100 | m_bordersLocked = 0; | ||
101 | } | ||
102 | } | ||
92 | public List<Border> NorthBorders = new List<Border>(); | 103 | public List<Border> NorthBorders = new List<Border>(); |
93 | public List<Border> EastBorders = new List<Border>(); | 104 | public List<Border> EastBorders = new List<Border>(); |
94 | public List<Border> SouthBorders = new List<Border>(); | 105 | public List<Border> SouthBorders = new List<Border>(); |
@@ -397,6 +408,73 @@ namespace OpenSim.Region.Framework.Scenes | |||
397 | 408 | ||
398 | #endregion | 409 | #endregion |
399 | 410 | ||
411 | #region BinaryStats | ||
412 | |||
413 | public class StatLogger | ||
414 | { | ||
415 | public DateTime StartTime; | ||
416 | public string Path; | ||
417 | public System.IO.BinaryWriter Log; | ||
418 | } | ||
419 | static StatLogger m_statLog = null; | ||
420 | static TimeSpan m_statLogPeriod = TimeSpan.FromSeconds(300); | ||
421 | static string m_statsDir = String.Empty; | ||
422 | static Object m_statLockObject = new Object(); | ||
423 | private void LogSimStats(SimStats stats) | ||
424 | { | ||
425 | SimStatsPacket pack = new SimStatsPacket(); | ||
426 | pack.Region = new SimStatsPacket.RegionBlock(); | ||
427 | pack.Region.RegionX = stats.RegionX; | ||
428 | pack.Region.RegionY = stats.RegionY; | ||
429 | pack.Region.RegionFlags = stats.RegionFlags; | ||
430 | pack.Region.ObjectCapacity = stats.ObjectCapacity; | ||
431 | //pack.Region = //stats.RegionBlock; | ||
432 | pack.Stat = stats.StatsBlock; | ||
433 | pack.Header.Reliable = false; | ||
434 | |||
435 | // note that we are inside the reporter lock when called | ||
436 | DateTime now = DateTime.Now; | ||
437 | |||
438 | // hide some time information into the packet | ||
439 | pack.Header.Sequence = (uint)now.Ticks; | ||
440 | |||
441 | lock (m_statLockObject) // m_statLog is shared so make sure there is only executer here | ||
442 | { | ||
443 | try | ||
444 | { | ||
445 | if (m_statLog == null || now > m_statLog.StartTime + m_statLogPeriod) | ||
446 | { | ||
447 | // First log file or time has expired, start writing to a new log file | ||
448 | if (m_statLog != null && m_statLog.Log != null) | ||
449 | { | ||
450 | m_statLog.Log.Close(); | ||
451 | } | ||
452 | m_statLog = new StatLogger(); | ||
453 | m_statLog.StartTime = now; | ||
454 | m_statLog.Path = (m_statsDir.Length > 0 ? m_statsDir + System.IO.Path.DirectorySeparatorChar.ToString() : "") | ||
455 | + String.Format("stats-{0}.log", now.ToString("yyyyMMddHHmmss")); | ||
456 | m_statLog.Log = new BinaryWriter(File.Open(m_statLog.Path, FileMode.Append, FileAccess.Write)); | ||
457 | } | ||
458 | |||
459 | // Write the serialized data to disk | ||
460 | if (m_statLog != null && m_statLog.Log != null) | ||
461 | m_statLog.Log.Write(pack.ToBytes()); | ||
462 | } | ||
463 | catch (Exception ex) | ||
464 | { | ||
465 | m_log.Error("statistics gathering failed: " + ex.Message, ex); | ||
466 | if (m_statLog != null && m_statLog.Log != null) | ||
467 | { | ||
468 | m_statLog.Log.Close(); | ||
469 | } | ||
470 | m_statLog = null; | ||
471 | } | ||
472 | } | ||
473 | return; | ||
474 | } | ||
475 | |||
476 | #endregion | ||
477 | |||
400 | #region Constructors | 478 | #region Constructors |
401 | 479 | ||
402 | public Scene(RegionInfo regInfo, AgentCircuitManager authen, | 480 | public Scene(RegionInfo regInfo, AgentCircuitManager authen, |
@@ -582,6 +660,38 @@ namespace OpenSim.Region.Framework.Scenes | |||
582 | } | 660 | } |
583 | 661 | ||
584 | m_log.Info("[SCENE]: Using the " + m_update_prioritization_scheme + " prioritization scheme"); | 662 | m_log.Info("[SCENE]: Using the " + m_update_prioritization_scheme + " prioritization scheme"); |
663 | |||
664 | #region BinaryStats | ||
665 | |||
666 | try | ||
667 | { | ||
668 | IConfig statConfig = m_config.Configs["Statistics.Binary"]; | ||
669 | if (statConfig.Contains("enabled") && statConfig.GetBoolean("enabled")) | ||
670 | { | ||
671 | if (statConfig.Contains("collect_region_stats")) | ||
672 | { | ||
673 | if (statConfig.GetBoolean("collect_region_stats")) | ||
674 | { | ||
675 | // if enabled, add us to the event. If not enabled, I won't get called | ||
676 | StatsReporter.OnSendStatsResult += LogSimStats; | ||
677 | } | ||
678 | } | ||
679 | if (statConfig.Contains("region_stats_period_seconds")) | ||
680 | { | ||
681 | m_statLogPeriod = TimeSpan.FromSeconds(statConfig.GetInt("region_stats_period_seconds")); | ||
682 | } | ||
683 | if (statConfig.Contains("stats_dir")) | ||
684 | { | ||
685 | m_statsDir = statConfig.GetString("stats_dir"); | ||
686 | } | ||
687 | } | ||
688 | } | ||
689 | catch | ||
690 | { | ||
691 | // if it doesn't work, we don't collect anything | ||
692 | } | ||
693 | |||
694 | #endregion BinaryStats | ||
585 | } | 695 | } |
586 | catch | 696 | catch |
587 | { | 697 | { |
@@ -1043,7 +1153,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1043 | TimeSpan SinceLastFrame = DateTime.UtcNow - m_lastupdate; | 1153 | TimeSpan SinceLastFrame = DateTime.UtcNow - m_lastupdate; |
1044 | physicsFPS = 0f; | 1154 | physicsFPS = 0f; |
1045 | 1155 | ||
1046 | maintc = maintc = otherMS = Environment.TickCount; | 1156 | maintc = otherMS = Environment.TickCount; |
1047 | int tmpFrameMS = maintc; | 1157 | int tmpFrameMS = maintc; |
1048 | 1158 | ||
1049 | // Increment the frame counter | 1159 | // Increment the frame counter |
@@ -4273,6 +4383,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
4273 | return m_sceneGraph.GetSceneObjectPart(fullID); | 4383 | return m_sceneGraph.GetSceneObjectPart(fullID); |
4274 | } | 4384 | } |
4275 | 4385 | ||
4386 | /// <summary> | ||
4387 | /// Get a scene object group that contains the prim with the given local id | ||
4388 | /// </summary> | ||
4389 | /// <param name="localID"></param> | ||
4390 | /// <returns>null if no scene object group containing that prim is found</returns> | ||
4391 | public SceneObjectGroup GetGroupByPrim(uint localID) | ||
4392 | { | ||
4393 | return m_sceneGraph.GetGroupByPrim(localID); | ||
4394 | } | ||
4395 | |||
4276 | public bool TryGetAvatar(UUID avatarId, out ScenePresence avatar) | 4396 | public bool TryGetAvatar(UUID avatarId, out ScenePresence avatar) |
4277 | { | 4397 | { |
4278 | return m_sceneGraph.TryGetAvatar(avatarId, out avatar); | 4398 | return m_sceneGraph.TryGetAvatar(avatarId, out avatar); |