/// <summary> /// Gets a list of all worker registrations of all workers that are not currently in a 'dead' state (time elapsed /// since the last heartbeat message is over the 'dead' threshold). /// </summary> /// <returns>List of registrations of all non-dead workers.</returns> public List <WorkerRegistration> GetNonDeadWorkerPool() { List <WorkerRegistration> result; TimeSpan timeoutSetting = new TimeSpan(0, 0, runtimeConfiguration.GetWorkerHeartbeatTimeout()); lock (registrationPool) { result = GetRegistrationPool().FindAll(o => !o.IsDead(timeoutSetting)); } return(result); }
/// <summary> /// Initialize Manager with default settings, and import from runtime configuration as necessary. /// </summary> /// <param name="runtimeConfiguration">Active runtime configuration settings profile.</param> public Manager(RuntimeConfiguration runtimeConfiguration) : base(runtimeConfiguration) { workerHeartbeatTimeout = new TimeSpan(0, 0, runtimeConfiguration.GetWorkerHeartbeatTimeout()); }
public void TestDeadWorkerNotInNonDeadPool() { DateTime deadTime = DateTime.Now.Subtract(new TimeSpan(0, 0, runtimeConfiguration.GetWorkerHeartbeatTimeout() + 1)); WorkerRegistration workerRegistration = new WorkerRegistration("test_name", null, 1000, deadTime); workerRegistrationPool.AddToPool(workerRegistration); List <WorkerRegistration> registrationList = workerRegistrationPool.GetNonDeadWorkerPool(); Assert.AreEqual(registrationList.Count, 0); Assert.That(!registrationList.Contains(workerRegistration)); }