/// <summary> /// Return the next available ExecutorId. /// For an executor to be available the following considions have to be met: /// - executor is dedicated /// - executor is conected /// - executor has no threads running or scheduled /// </summary> /// <returns></returns> protected ExecutorStorageView GetNextAvailableExecutor() { // [email protected]; gets next available executor without bias based upon position in executors list. ExecutorStorageView[] executors = store.GetExecutors(TriStateBoolean.True, TriStateBoolean.True); for (int i = 0; i < executors.Length; i++) { nextExecutorIndex++; if (nextExecutorIndex >= executors.Length) { nextExecutorIndex = 0; } ExecutorStorageView executor = executors[nextExecutorIndex]; int threadsOnExecutor = store.GetExecutorThreadCount(executor.ExecutorId, ThreadState.Ready, ThreadState.Scheduled, ThreadState.Started); if (threadsOnExecutor < executors[nextExecutorIndex].NumberOfCpu) { return(executor); } } return(null); }
/// <summary> /// Remove all executors from storage. /// /// </summary> /// <remarks> /// Q: What to do with applications that have running threads on any of the executors? /// A: This is a storage level function so we cannot stop the applications on the executors from here. /// </remarks> /// <param name="storage">Target storage where this maintanance will be performed.</param> public void RemoveAllExecutors(IManagerStorage storage) { ExecutorStorageView[] executors = storage.GetExecutors(); foreach (ExecutorStorageView executor in executors) { storage.DeleteExecutor(executor); } }
/// <summary> /// Remove all executors that have not been pinged since the given time. /// </summary> /// <param name="storage">Target storage where this maintanance will be performed.</param> /// <param name="pingTimeCutOff"></param> public void RemoveExecutors(IManagerStorage storage, DateTime pingTimeCutOff) { ExecutorStorageView[] executors = storage.GetExecutors(); foreach (ExecutorStorageView executor in executors) { if (executor.PingTime < pingTimeCutOff) { storage.DeleteExecutor(executor); } } }