// /** // * File: CheckTask.cs // * Author: haraldwolff // * // * This file and it's content is copyrighted by the Author and / or copyright holder. // * Any use wihtout proper permission is illegal and may lead to legal actions. // * // * // **/ using System; using ln.types.threads; using ln.skyscanner.entities; using ln.logging; using Newtonsoft.Json; using ln.types.odb; using System.Linq; using System.Collections.Generic; namespace ln.skyscanner.checks { public class CheckJob : PoolJob { [JsonIgnore] public Node Node { get; } Dictionary checkStates = new Dictionary(); public CheckJob(Node node) { Name = String.Format("Interval check: {0} [{1}]",node.UniqueIdentity,node.PrimaryIP.ToString()); Node = node; } public override void Prepare() { Query stateQuery = Query.Equals("Node", Node.ID); SkyCheckState[] skyCheckStates = SkyScanner.Instance.Entities.SkyCheckStates.Query(stateQuery).ToArray(); foreach (SkyCheckState checkState in skyCheckStates) { checkStates.Add(checkState.CheckName, checkState); } foreach (SkyCheck check in SkyCheck.SkyChecks) if (!checkStates.ContainsKey(check.Name) && check.IsValid(Node)) { checkStates.Add(check.Name, check.PrepareCheckState(SkyScanner.Instance.Checker, Node)); SkyScanner.Instance.Entities.SkyCheckStates.Insert(checkStates[check.Name]); } } public override void RunJob() { SkyCheck[] checks = SkyCheck.SkyChecks; for (int n=0;n