public void Start(IScene scene) { m_scene = scene; m_dataStore = m_scene.Simian.GetAppModule<IDataStore>(); if (m_dataStore == null) { m_log.Error("LLPrimitiveLoader requires an IDataStore"); return; } m_primMesher = m_scene.GetSceneModule<IPrimMesher>(); if (m_primMesher == null) { m_log.Error("LLPrimitiveLoader requires an IPrimMesher"); return; } m_writeQueue = new ThrottledQueue<UUID, PrimSerialization>(5, 1000 * 30, true, SerializationHandler); m_writeQueue.Start(); m_scene.OnEntityAddOrUpdate += EntityAddOrUpdateHandler; m_scene.OnEntityRemove += EntityRemoveHandler; Deserialize(); }
public void ThrottledQueueAddAfterTest() { Dictionary<int, string> values = new Dictionary<int, string>(); values[1] = "a"; values[2] = "b"; values[3] = "c"; float eventsPerSecond; int timerIntervalMS; AutoResetEvent finishedEvent = new AutoResetEvent(false); int count = 0; eventsPerSecond = 1.0f; timerIntervalMS = 1000; ThrottledQueue<int, string> eq = new ThrottledQueue<int, string>(eventsPerSecond, timerIntervalMS, true, delegate(string value) { Console.WriteLine("Dequeued: " + value); if (++count == values.Count) finishedEvent.Set(); } ); int start = Environment.TickCount; eq.Start(); foreach (KeyValuePair<int, string> kvp in values) eq.Add(kvp.Key, kvp.Value); Assert.IsTrue(finishedEvent.WaitOne(5000), "Timed out with " + (values.Count - count) + " pending events"); int elapsed = Environment.TickCount - start; Assert.IsTrue(elapsed >= 3000, "Expected 3000ms to pass, only " + elapsed + " passed"); }
public void Start(IScene scene) { m_scene = scene; m_dataStore = m_scene.Simian.GetAppModule <IDataStore>(); if (m_dataStore == null) { m_log.Error("LLPrimitiveLoader requires an IDataStore"); return; } m_primMesher = m_scene.GetSceneModule <IPrimMesher>(); if (m_primMesher == null) { m_log.Error("LLPrimitiveLoader requires an IPrimMesher"); return; } m_scriptEngine = m_scene.GetSceneModule <ILSLScriptEngine>(); m_writeQueue = new ThrottledQueue <UUID, PrimSerialization>(5, 1000 * 30, true, SerializationHandler); m_writeQueue.Start(); m_scene.OnEntityAddOrUpdate += EntityAddOrUpdateHandler; m_scene.OnEntityRemove += EntityRemoveHandler; Deserialize(); }
public void ThrottledQueueSlowEventsTest() { Dictionary <int, string> values = new Dictionary <int, string>(); values[1] = "a"; values[2] = "b"; values[3] = "c"; values[4] = "d"; values[5] = "e"; float eventsPerSecond; int timerIntervalMS; AutoResetEvent finishedEvent = new AutoResetEvent(false); int count = 0; eventsPerSecond = 0.25f; timerIntervalMS = 1000; ThrottledQueue <int, string> eq = new ThrottledQueue <int, string>(eventsPerSecond, timerIntervalMS, true, delegate(string value) { Console.WriteLine("Dequeued: " + value); if (++count == values.Count) { finishedEvent.Set(); } } ); int start = Util.TickCount(); eq.Start(); foreach (KeyValuePair <int, string> kvp in values) { eq.Add(kvp.Key, kvp.Value); } Assert.IsTrue(finishedEvent.WaitOne(4000), "Timed out with " + (values.Count - count) + " pending events"); int elapsed = Util.TickCount() - start; Assert.IsTrue(elapsed >= 2000, "Expected 2000ms to pass, only " + elapsed + " passed"); }
public void ThrottledQueueNoFlushTest() { Dictionary <int, string> values = new Dictionary <int, string>(); values[1] = "a"; values[2] = "b"; values[3] = "c"; values[4] = "d"; values[5] = "e"; values[6] = "f"; values[7] = "g"; float eventsPerSecond; int timerIntervalMS; int count = 0; eventsPerSecond = 1.0f; timerIntervalMS = 1000; ThrottledQueue <int, string> eq = new ThrottledQueue <int, string>(eventsPerSecond, timerIntervalMS, true, delegate(string value) { Console.WriteLine("Dequeued: " + value); ++count; } ); int start = Util.TickCount(); eq.Start(); foreach (KeyValuePair <int, string> kvp in values) { eq.Add(kvp.Key, kvp.Value); } Thread.Sleep(1500); eq.Stop(false); Assert.IsTrue(count == 1, "Attempted to skip flush but instead dequeued " + count + " events total"); }
public void Start(IScene scene) { m_scene = scene; m_lastCameraPositions = new Dictionary <uint, Vector3>(); m_borderCrossThrottles = new Dictionary <UUID, int>(); // Create an AABB for this scene that extends beyond the borders by BORDER_CROSS_THRESHOLD // that is used to check for border crossings m_borderCrossAABB = new AABB(Vector3.Zero, new Vector3(scene.MaxPosition - scene.MinPosition)); m_borderCrossAABB.Min -= new Vector3(BORDER_CROSS_THRESHOLD, BORDER_CROSS_THRESHOLD, BORDER_CROSS_THRESHOLD); m_borderCrossAABB.Max += new Vector3(BORDER_CROSS_THRESHOLD, BORDER_CROSS_THRESHOLD, BORDER_CROSS_THRESHOLD); m_scheduler = m_scene.Simian.GetAppModule <IScheduler>(); if (m_scheduler == null) { m_log.Warn("Neighbors requires an IScheduler"); return; } m_httpServer = m_scene.Simian.GetAppModule <IHttpServer>(); if (m_httpServer == null) { m_log.Warn("Neighbors requires an IHttpServer"); return; } m_udp = m_scene.GetSceneModule <LLUDP>(); if (m_udp == null) { m_log.Warn("Neighbors requires an LLUDP"); return; } m_userClient = m_scene.Simian.GetAppModule <IUserClient>(); if (m_userClient == null) { m_log.Warn("Neighbors requires an IUserClient"); return; } m_gridClient = scene.Simian.GetAppModule <IGridClient>(); // Add neighbor messaging handlers string urlFriendlySceneName = WebUtil.UrlEncode(scene.Name); string regionPath = "/regions/" + urlFriendlySceneName; m_httpServer.AddHandler("POST", null, regionPath + "/region/online", true, true, RegionOnlineHandler); m_httpServer.AddHandler("POST", null, regionPath + "/region/offline", true, true, RegionOfflineHandler); m_httpServer.AddHandler("POST", null, regionPath + "/child_avatar/update", true, true, ChildAvatarUpdateHandler); m_scene.AddPublicCapability("region/online", m_httpServer.HttpAddress.Combine(regionPath + "/region/online")); m_scene.AddPublicCapability("region/offline", m_httpServer.HttpAddress.Combine(regionPath + "/region/offline")); m_scene.AddPublicCapability("child_avatar/update", m_httpServer.HttpAddress.Combine(regionPath + "/child_avatar/update")); // Track local scenes going up and down m_sceneFactory = scene.Simian.GetAppModule <ISceneFactory>(); if (m_sceneFactory != null) { m_sceneFactory.OnSceneStart += SceneStartHandler; m_sceneFactory.OnSceneStop += SceneStopHandler; } m_scene.OnPresenceAdd += PresenceAddHandler; m_scene.OnEntityAddOrUpdate += EntityAddOrUpdateHandler; m_childUpdates = new ThrottledQueue <uint, IScenePresence>(5.0f, 200, true, SendChildUpdate); m_childUpdates.Start(); }
public void Start(IScene scene) { m_scene = scene; m_lastCameraPositions = new Dictionary<uint, Vector3>(); m_borderCrossThrottles = new Dictionary<UUID, int>(); // Create an AABB for this scene that extends beyond the borders by BORDER_CROSS_THRESHOLD // that is used to check for border crossings m_borderCrossAABB = new AABB(Vector3.Zero, new Vector3(scene.MaxPosition - scene.MinPosition)); m_borderCrossAABB.Min -= new Vector3(BORDER_CROSS_THRESHOLD, BORDER_CROSS_THRESHOLD, BORDER_CROSS_THRESHOLD); m_borderCrossAABB.Max += new Vector3(BORDER_CROSS_THRESHOLD, BORDER_CROSS_THRESHOLD, BORDER_CROSS_THRESHOLD); m_scheduler = m_scene.Simian.GetAppModule<IScheduler>(); if (m_scheduler == null) { m_log.Warn("Neighbors requires an IScheduler"); return; } m_httpServer = m_scene.Simian.GetAppModule<IHttpServer>(); if (m_httpServer == null) { m_log.Warn("Neighbors requires an IHttpServer"); return; } m_udp = m_scene.GetSceneModule<LLUDP>(); if (m_udp == null) { m_log.Warn("Neighbors requires an LLUDP"); return; } m_userClient = m_scene.Simian.GetAppModule<IUserClient>(); if (m_userClient == null) { m_log.Warn("Neighbors requires an IUserClient"); return; } m_gridClient = scene.Simian.GetAppModule<IGridClient>(); // Add neighbor messaging handlers string urlFriendlySceneName = WebUtil.UrlEncode(scene.Name); string regionPath = "/regions/" + urlFriendlySceneName; m_httpServer.AddHandler("POST", null, regionPath + "/region/online", true, true, RegionOnlineHandler); m_httpServer.AddHandler("POST", null, regionPath + "/region/offline", true, true, RegionOfflineHandler); m_httpServer.AddHandler("POST", null, regionPath + "/child_avatar/update", true, true, ChildAvatarUpdateHandler); m_scene.AddPublicCapability("region/online", m_httpServer.HttpAddress.Combine(regionPath + "/region/online")); m_scene.AddPublicCapability("region/offline", m_httpServer.HttpAddress.Combine(regionPath + "/region/offline")); m_scene.AddPublicCapability("child_avatar/update", m_httpServer.HttpAddress.Combine(regionPath + "/child_avatar/update")); // Track local scenes going up and down m_sceneFactory = scene.Simian.GetAppModule<ISceneFactory>(); if (m_sceneFactory != null) { m_sceneFactory.OnSceneStart += SceneStartHandler; m_sceneFactory.OnSceneStop += SceneStopHandler; } m_scene.OnPresenceAdd += PresenceAddHandler; m_scene.OnEntityAddOrUpdate += EntityAddOrUpdateHandler; m_childUpdates = new ThrottledQueue<uint, IScenePresence>(5.0f, 200, true, SendChildUpdate); m_childUpdates.Start(); }
public void ThrottledQueueNoFlushTest() { Dictionary<int, string> values = new Dictionary<int, string>(); values[1] = "a"; values[2] = "b"; values[3] = "c"; values[4] = "d"; values[5] = "e"; values[6] = "f"; values[7] = "g"; float eventsPerSecond; int timerIntervalMS; int count = 0; eventsPerSecond = 1.0f; timerIntervalMS = 1000; ThrottledQueue<int, string> eq = new ThrottledQueue<int, string>(eventsPerSecond, timerIntervalMS, true, delegate(string value) { Console.WriteLine("Dequeued: " + value); ++count; } ); int start = Environment.TickCount; eq.Start(); foreach (KeyValuePair<int, string> kvp in values) eq.Add(kvp.Key, kvp.Value); Thread.Sleep(1500); eq.Stop(false); Assert.IsTrue(count == 1, "Attempted to skip flush but instead dequeued " + count + " events total"); }
public bool Start(Simian simian) { m_simian = simian; int serializeSeconds = DEFAULT_SERIALIZATION_INTERVAL; string executingDir = Util.ExecutingDirectory(); m_storeDirectory = Path.Combine(executingDir, DEFAULT_STORE_DIRECTORY); IConfig config = simian.Config.Configs["FileDataStore"]; if (config != null) { string configPath = config.GetString("Path", DEFAULT_STORE_DIRECTORY); string tempPath = config.GetString("TempPath", DEFAULT_TEMP_STORE_DIRECTORY); serializeSeconds = config.GetInt("SaveInterval", DEFAULT_SERIALIZATION_INTERVAL); if (Path.IsPathRooted(configPath)) m_storeDirectory = configPath; else m_storeDirectory = Path.Combine(executingDir, configPath); if (Path.IsPathRooted(tempPath)) m_tempStoreDirectory = tempPath; else m_tempStoreDirectory = Path.Combine(executingDir, tempPath); } if (!Directory.Exists(m_storeDirectory)) { try { Directory.CreateDirectory(m_storeDirectory); } catch (Exception ex) { m_log.Error("Failed to create local file store directory " + m_storeDirectory + ": " + ex.Message); return false; } } m_log.Debug("Serialization interval set to " + serializeSeconds + " seconds"); m_pendingSerialization = new ThrottledQueue<string, SerializedData>(0.1f, serializeSeconds * 1000, true, SerializeHandler); m_pendingSerialization.Start(); return true; }
public bool Start(Simian simian) { m_simian = simian; int serializeSeconds = DEFAULT_SERIALIZATION_INTERVAL; // Regular expression to replace invalid path and filename characters m_invalidPathCharsRegex = "[" + Regex.Escape(new string(Path.GetInvalidFileNameChars()) + new string(Path.GetInvalidPathChars())) + "]"; string executingDir = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); m_storeDirectory = Path.Combine(executingDir, DEFAULT_STORE_DIRECTORY); IConfig config = simian.Config.Configs["FileDataStore"]; if (config != null) { string configPath = config.GetString("Path", DEFAULT_STORE_DIRECTORY); string tempPath = config.GetString("TempPath", DEFAULT_TEMP_STORE_DIRECTORY); serializeSeconds = config.GetInt("SaveInterval", DEFAULT_SERIALIZATION_INTERVAL); if (Path.IsPathRooted(configPath)) m_storeDirectory = configPath; else m_storeDirectory = Path.Combine(executingDir, configPath); if (Path.IsPathRooted(tempPath)) m_tempStoreDirectory = tempPath; else m_tempStoreDirectory = Path.Combine(executingDir, tempPath); } if (!Directory.Exists(m_storeDirectory)) { try { Directory.CreateDirectory(m_storeDirectory); } catch (Exception ex) { m_log.Error("Failed to create local file store directory " + m_storeDirectory + ": " + ex.Message); return false; } } m_log.Debug("Serialization interval set to " + serializeSeconds + " seconds"); m_pendingSerialization = new ThrottledQueue<string, SerializedData>(0.1f, serializeSeconds * 1000, true, SerializeHandler); m_pendingSerialization.Start(); return true; }