public override void ExecutionComplete(DeploymentDetails details, List <Exception> exceptions) { try { base.ExecutionComplete(details, exceptions); } catch { } if (!_Ranges.ContainsKey(DeploymentControllerID)) { lock (_Ranges) if (!_Ranges.ContainsKey(DeploymentControllerID)) { _Ranges[DeploymentControllerID] = new List <SizeRange>(); } } lock (_Ranges[DeploymentControllerID]) { SizeRange range = _Ranges[DeploymentControllerID].FirstOrDefault(i => i.ActiveLoads.Exists(x => x.Loaded.Contains(details.InitiationSource))); if (range != null) { lock (range) { SizeRange.Load rem = range.ActiveLoads.FirstOrDefault(z => z.Loaded.Contains(details.InitiationSource)); if (rem != null) { rem.Loaded.Remove(details.InitiationSource); } } } } }
public override void BranchStatusUpdate(string address, BranchState state) { try { base.BranchStatusUpdate(address, state); } catch { } if (!_Ranges.ContainsKey(DeploymentControllerID)) { lock (_Ranges) if (!_Ranges.ContainsKey(DeploymentControllerID)) { _Ranges[DeploymentControllerID] = new List <SizeRange>(); } } lock (_Ranges[DeploymentControllerID]) { if (_Ranges[DeploymentControllerID].Count != MaxLoadByFileSize.Count) { _Ranges[DeploymentControllerID].Clear(); foreach (SizeRange range in MaxLoadByFileSize) { _Ranges[DeploymentControllerID].Add(range.Clone()); } } foreach (SizeRange range in _Ranges[DeploymentControllerID]) { lock (range) { if (state == BranchState.Online && !range.ActiveLoads.Exists(i => i.IP == address)) { range.ActiveLoads.Add(new SizeRange.Load(address)); } if (state != BranchState.Online) { SizeRange.Load rem = range.ActiveLoads.FirstOrDefault(i => i.IP == address); if (rem != null) { range.ActiveLoads.Remove(rem); } } } } } }
public override DeploymentDetails GenerateDeploymentDetails(IReadOnlyList <string> listPreprocessResult, string initiationSource, string recommendedBranchIP, IReadOnlyList <string> limitedToBranches) { try { Dictionary <string, long> col; lock (_KnownSizes) { if (!_KnownSizes.ContainsKey(DeploymentControllerID)) { _KnownSizes[DeploymentControllerID] = new Dictionary <string, long>(); } col = _KnownSizes[DeploymentControllerID]; } long sz = 0; lock (col) sz = col[initiationSource]; if (!_Ranges.ContainsKey(DeploymentControllerID)) { lock (_Ranges) if (!_Ranges.ContainsKey(DeploymentControllerID)) { _Ranges[DeploymentControllerID] = new List <SizeRange>(); } } SizeRange range = null; lock (_Ranges[DeploymentControllerID]) range = _Ranges[DeploymentControllerID].FirstOrDefault(i => i.MinMB <= sz && i.MaxMB >= sz); if (range == null) { return(null); } lock (range) { SizeRange.Load load = range.ActiveLoads.Where(i => i.IP == recommendedBranchIP).FirstOrDefault(); if (load != null && load.Loaded.Count < range.MaxLoadPerBranch) { DeploymentDetails ret = base.GenerateDeploymentDetails(listPreprocessResult, initiationSource, load.IP, limitedToBranches); if (ret != null) { load.Loaded.Add(initiationSource); load.LastAssignment = DateTime.UtcNow; } return(ret); } } } catch (Exception ex) { STEM.Sys.EventLog.WriteEntry("FileSizeSubsetController.GenerateDeploymentDetails", new Exception(InstructionSetTemplate + ": " + initiationSource, ex).ToString(), STEM.Sys.EventLog.EventLogEntryType.Error); } return(null); }