aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authorDr Scofield2009-01-28 09:22:12 +0000
committerDr Scofield2009-01-28 09:22:12 +0000
commita3ac702941bbae92ca5a3ed452eb3d417bf30f0b (patch)
tree3a827866b274b86447cc7b2237a7182d95270879 /OpenSim/Region
parentAdd in a stub for llSHA1String. I believe it is the only one new (diff)
downloadopensim-SC-a3ac702941bbae92ca5a3ed452eb3d417bf30f0b.zip
opensim-SC-a3ac702941bbae92ca5a3ed452eb3d417bf30f0b.tar.gz
opensim-SC-a3ac702941bbae92ca5a3ed452eb3d417bf30f0b.tar.bz2
opensim-SC-a3ac702941bbae92ca5a3ed452eb3d417bf30f0b.tar.xz
From: Christopher Yeoh <yeohc@au1.ibm.com>
Adding Oarfileloaded and EmptyScriptCompileQueue event support which allows (with a module) for programmatic notification of when a region objects and scripts are up and running after a server start or load-oar.
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/Environment/Modules/World/Archiver/ArchiveReadRequest.cs92
-rw-r--r--OpenSim/Region/Environment/Scenes/EventManager.cs31
-rw-r--r--OpenSim/Region/ScriptEngine/XEngine/XEngine.cs24
3 files changed, 110 insertions, 37 deletions
diff --git a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveReadRequest.cs b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveReadRequest.cs
index ce293e4..ee4323c 100644
--- a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveReadRequest.cs
+++ b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveReadRequest.cs
@@ -53,6 +53,7 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
53 53
54 private Scene m_scene; 54 private Scene m_scene;
55 private Stream m_loadStream; 55 private Stream m_loadStream;
56 private string m_errorMessage;
56 57
57 /// <summary> 58 /// <summary>
58 /// Used to cache lookups for valid uuids. 59 /// Used to cache lookups for valid uuids.
@@ -63,6 +64,7 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
63 { 64 {
64 m_scene = scene; 65 m_scene = scene;
65 m_loadStream = new GZipStream(GetStream(loadPath), CompressionMode.Decompress); 66 m_loadStream = new GZipStream(GetStream(loadPath), CompressionMode.Decompress);
67 m_errorMessage = String.Empty;
66 } 68 }
67 69
68 public ArchiveReadRequest(Scene scene, Stream loadStream) 70 public ArchiveReadRequest(Scene scene, Stream loadStream)
@@ -82,62 +84,76 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
82 84
83 private void DearchiveRegion0DotStar() 85 private void DearchiveRegion0DotStar()
84 { 86 {
85 TarArchiveReader archive = new TarArchiveReader(m_loadStream); 87 int successfulAssetRestores = 0;
88 int failedAssetRestores = 0;
89 List<string> serialisedSceneObjects = new List<string>();
86 90
87 //AssetsDearchiver dearchiver = new AssetsDearchiver(m_scene.AssetCache); 91 try
92 {
93 TarArchiveReader archive = new TarArchiveReader(m_loadStream);
88 94
89 List<string> serialisedSceneObjects = new List<string>(); 95 //AssetsDearchiver dearchiver = new AssetsDearchiver(m_scene.AssetCache);
90 string filePath = "ERROR";
91 96
92 int successfulAssetRestores = 0; 97 string filePath = "ERROR";
93 int failedAssetRestores = 0;
94 98
95 byte[] data; 99 byte[] data;
96 TarArchiveReader.TarEntryType entryType; 100 TarArchiveReader.TarEntryType entryType;
97 101
98 while ((data = archive.ReadEntry(out filePath, out entryType)) != null) 102 while ((data = archive.ReadEntry(out filePath, out entryType)) != null)
99 {
100 //m_log.DebugFormat(
101 // "[ARCHIVER]: Successfully read {0} ({1} bytes)}", filePath, data.Length);
102 if (TarArchiveReader.TarEntryType.TYPE_DIRECTORY == entryType)
103 { 103 {
104 m_log.WarnFormat("[ARCHIVER]: Ignoring directory entry {0}", 104 //m_log.DebugFormat(
105 filePath); 105 // "[ARCHIVER]: Successfully read {0} ({1} bytes)}", filePath, data.Length);
106 } 106 if (TarArchiveReader.TarEntryType.TYPE_DIRECTORY == entryType)
107 else if (filePath.StartsWith(ArchiveConstants.OBJECTS_PATH)) 107 {
108 { 108 m_log.WarnFormat("[ARCHIVER]: Ignoring directory entry {0}",
109 serialisedSceneObjects.Add(m_asciiEncoding.GetString(data)); 109 filePath);
110 } 110 }
111 else if (filePath.StartsWith(ArchiveConstants.OBJECTS_PATH))
112 {
113 serialisedSceneObjects.Add(m_asciiEncoding.GetString(data));
114 }
111// else if (filePath.Equals(ArchiveConstants.ASSETS_METADATA_PATH)) 115// else if (filePath.Equals(ArchiveConstants.ASSETS_METADATA_PATH))
112// { 116// {
113// string xml = m_asciiEncoding.GetString(data); 117// string xml = m_asciiEncoding.GetString(data);
114// dearchiver.AddAssetMetadata(xml); 118// dearchiver.AddAssetMetadata(xml);
115// } 119// }
116 else if (filePath.StartsWith(ArchiveConstants.ASSETS_PATH)) 120 else if (filePath.StartsWith(ArchiveConstants.ASSETS_PATH))
117 { 121 {
118 if (LoadAsset(filePath, data)) 122 if (LoadAsset(filePath, data))
119 successfulAssetRestores++; 123 successfulAssetRestores++;
120 else 124 else
121 failedAssetRestores++; 125 failedAssetRestores++;
122 } 126 }
123 else if (filePath.StartsWith(ArchiveConstants.TERRAINS_PATH)) 127 else if (filePath.StartsWith(ArchiveConstants.TERRAINS_PATH))
124 { 128 {
125 LoadTerrain(filePath, data); 129 LoadTerrain(filePath, data);
126 } 130 }
127 else if (filePath.StartsWith(ArchiveConstants.SETTINGS_PATH)) 131 else if (filePath.StartsWith(ArchiveConstants.SETTINGS_PATH))
128 { 132 {
129 LoadRegionSettings(filePath, data); 133 LoadRegionSettings(filePath, data);
134 }
130 } 135 }
131 }
132 136
133 //m_log.Debug("[ARCHIVER]: Reached end of archive"); 137 //m_log.Debug("[ARCHIVER]: Reached end of archive");
134 138
135 archive.Close(); 139 archive.Close();
140 }
141 catch (Exception e)
142 {
143 m_log.ErrorFormat(
144 "[ARCHIVER]: Error loading oar file. Exception was: {0}", e);
145 m_errorMessage += e.ToString();
146 m_scene.EventManager.TriggerOarFileLoaded(m_errorMessage);
147 return;
148 }
136 149
137 m_log.InfoFormat("[ARCHIVER]: Restored {0} assets", successfulAssetRestores); 150 m_log.InfoFormat("[ARCHIVER]: Restored {0} assets", successfulAssetRestores);
138 151
139 if (failedAssetRestores > 0) 152 if (failedAssetRestores > 0)
153 {
140 m_log.ErrorFormat("[ARCHIVER]: Failed to load {0} assets", failedAssetRestores); 154 m_log.ErrorFormat("[ARCHIVER]: Failed to load {0} assets", failedAssetRestores);
155 m_errorMessage += String.Format("Failed to load {0} assets", failedAssetRestores);
156 }
141 157
142 m_log.Info("[ARCHIVER]: Clearing all existing scene objects"); 158 m_log.Info("[ARCHIVER]: Clearing all existing scene objects");
143 m_scene.DeleteAllSceneObjects(); 159 m_scene.DeleteAllSceneObjects();
@@ -217,6 +233,8 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
217 { 233 {
218 sceneObject.CreateScriptInstances(0, true, m_scene.DefaultScriptEngine, 0); 234 sceneObject.CreateScriptInstances(0, true, m_scene.DefaultScriptEngine, 0);
219 } 235 }
236 m_scene.EventManager.TriggerOarFileLoaded(m_errorMessage);
237
220 } 238 }
221 239
222 /// <summary> 240 /// <summary>
diff --git a/OpenSim/Region/Environment/Scenes/EventManager.cs b/OpenSim/Region/Environment/Scenes/EventManager.cs
index b493f84..1543bf0 100644
--- a/OpenSim/Region/Environment/Scenes/EventManager.cs
+++ b/OpenSim/Region/Environment/Scenes/EventManager.cs
@@ -266,6 +266,21 @@ namespace OpenSim.Region.Environment.Scenes
266 public delegate float SunLindenHour(); 266 public delegate float SunLindenHour();
267 public event SunLindenHour OnGetSunLindenHour; 267 public event SunLindenHour OnGetSunLindenHour;
268 268
269 /// <summary>
270 /// Called when oar file has finished loading, although
271 /// the scripts may not have started yet
272 /// Message is non empty string if there were problems loading the oar file
273 /// </summary>
274 public delegate void OarFileLoaded(string message);
275 public event OarFileLoaded OnOarFileLoaded;
276
277 /// <summary>
278 /// Called when the script compile queue becomes empty
279 /// Returns the number of scripts which failed to start
280 /// </summary>
281 public delegate void EmptyScriptCompileQueue(int numScriptsFailed, string message);
282 public event EmptyScriptCompileQueue OnEmptyScriptCompileQueue;
283
269 public class MoneyTransferArgs : EventArgs 284 public class MoneyTransferArgs : EventArgs
270 { 285 {
271 public UUID sender; 286 public UUID sender;
@@ -399,6 +414,8 @@ namespace OpenSim.Region.Environment.Scenes
399 private SunLindenHour handlerSunGetLindenHour = null; 414 private SunLindenHour handlerSunGetLindenHour = null;
400 private OnSetRootAgentSceneDelegate handlerSetRootAgentScene = null; 415 private OnSetRootAgentSceneDelegate handlerSetRootAgentScene = null;
401 416
417 private OarFileLoaded handlerOarFileLoaded = null;
418 private EmptyScriptCompileQueue handlerEmptyScriptCompileQueue = null;
402 419
403 public void TriggerGetScriptRunning(IClientAPI controllingClient, UUID objectID, UUID itemID) 420 public void TriggerGetScriptRunning(IClientAPI controllingClient, UUID objectID, UUID itemID)
404 { 421 {
@@ -902,6 +919,20 @@ namespace OpenSim.Region.Environment.Scenes
902 return 6; 919 return 6;
903 } 920 }
904 921
922 public void TriggerOarFileLoaded(string message)
923 {
924 handlerOarFileLoaded = OnOarFileLoaded;
925 if (handlerOarFileLoaded != null)
926 handlerOarFileLoaded(message);
927 }
928
929 public void TriggerEmptyScriptCompileQueue(int numScriptsFailed, string message)
930 {
931 handlerEmptyScriptCompileQueue = OnEmptyScriptCompileQueue;
932 if (handlerEmptyScriptCompileQueue != null)
933 handlerEmptyScriptCompileQueue(numScriptsFailed, message);
934 }
935
905 public void TriggerScriptCollidingStart(uint localId, ColliderArgs colliders) 936 public void TriggerScriptCollidingStart(uint localId, ColliderArgs colliders)
906 { 937 {
907 handlerCollidingStart = OnScriptColliderStart; 938 handlerCollidingStart = OnScriptColliderStart;
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
index 30ce79b..fc76d0b 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
+++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
@@ -71,6 +71,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine
71 private ThreadPriority m_Prio; 71 private ThreadPriority m_Prio;
72 private bool m_Enabled = false; 72 private bool m_Enabled = false;
73 private bool m_InitialStartup = true; 73 private bool m_InitialStartup = true;
74 private int m_ScriptFailCount; // Number of script fails since compile queue was last empty
75 private string m_ScriptErrorMessage;
74 76
75// disable warning: need to keep a reference to XEngine.EventManager 77// disable warning: need to keep a reference to XEngine.EventManager
76// alive to avoid it being garbage collected 78// alive to avoid it being garbage collected
@@ -149,6 +151,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine
149 public void Initialise(Scene scene, IConfigSource configSource) 151 public void Initialise(Scene scene, IConfigSource configSource)
150 { 152 {
151 m_ScriptConfig = configSource.Configs["XEngine"]; 153 m_ScriptConfig = configSource.Configs["XEngine"];
154 m_ScriptFailCount = 0;
155 m_ScriptErrorMessage = String.Empty;
152 156
153 if (m_ScriptConfig == null) 157 if (m_ScriptConfig == null)
154 { 158 {
@@ -417,6 +421,13 @@ namespace OpenSim.Region.ScriptEngine.XEngine
417 { 421 {
418 m_InitialStartup = false; 422 m_InitialStartup = false;
419 System.Threading.Thread.Sleep(15000); 423 System.Threading.Thread.Sleep(15000);
424 lock (m_CompileQueue)
425 {
426 if (m_CompileQueue.Count==0)
427 // No scripts on region, so won't get triggered later
428 // by the queue becoming empty so we trigger it here
429 m_Scene.EventManager.TriggerEmptyScriptCompileQueue(0, String.Empty);
430 }
420 } 431 }
421 432
422 Object o; 433 Object o;
@@ -443,6 +454,9 @@ namespace OpenSim.Region.ScriptEngine.XEngine
443 else 454 else
444 { 455 {
445 m_CurrentCompile = null; 456 m_CurrentCompile = null;
457 m_Scene.EventManager.TriggerEmptyScriptCompileQueue(m_ScriptFailCount,
458 m_ScriptErrorMessage);
459 m_ScriptFailCount = 0;
446 } 460 }
447 } 461 }
448 return null; 462 return null;
@@ -468,12 +482,18 @@ namespace OpenSim.Region.ScriptEngine.XEngine
468 if (part == null) 482 if (part == null)
469 { 483 {
470 Log.Error("[Script] SceneObjectPart unavailable. Script NOT started."); 484 Log.Error("[Script] SceneObjectPart unavailable. Script NOT started.");
485 m_ScriptErrorMessage += "SceneObjectPart unavailable. Script NOT started.\n";
486 m_ScriptFailCount++;
471 return false; 487 return false;
472 } 488 }
473 489
474 TaskInventoryItem item = part.Inventory.GetInventoryItem(itemID); 490 TaskInventoryItem item = part.Inventory.GetInventoryItem(itemID);
475 if (item == null) 491 if (item == null)
492 {
493 m_ScriptErrorMessage += "Can't find script inventory item.\n";
494 m_ScriptFailCount++;
476 return false; 495 return false;
496 }
477 497
478 UUID assetID = item.AssetID; 498 UUID assetID = item.AssetID;
479 499
@@ -499,6 +519,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine
499 try 519 try
500 { 520 {
501 // DISPLAY ERROR INWORLD 521 // DISPLAY ERROR INWORLD
522 m_ScriptErrorMessage += "Failed to compile: " + e.Message.ToString();
523 m_ScriptFailCount++;
502 string text = "Error compiling script:\n" + e.Message.ToString(); 524 string text = "Error compiling script:\n" + e.Message.ToString();
503 if (text.Length > 1000) 525 if (text.Length > 1000)
504 text = text.Substring(0, 1000); 526 text = text.Substring(0, 1000);
@@ -567,6 +589,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine
567 catch (Exception e) 589 catch (Exception e)
568 { 590 {
569 m_log.ErrorFormat("[XEngine] Exception creating app domain:\n {0}", e.ToString()); 591 m_log.ErrorFormat("[XEngine] Exception creating app domain:\n {0}", e.ToString());
592 m_ScriptErrorMessage += "Exception creating app domain:\n";
593 m_ScriptFailCount++;
570 return false; 594 return false;
571 } 595 }
572 } 596 }