public async Task <IActionResult> GetResourceDetails([FromBody] MonitoringResourceRequest monitoringResourceRequest) { if (!ValidationHelper.IsValidateResources(monitoringResourceRequest, out string message)) { return(BadRequest(new { Message = message })); } IResourceDetails resourceDetails = ReflectionHelper.GetInstanceByNamespace(monitoringResourceRequest.Namespace); var response = await resourceDetails.GetResourceDetails(monitoringResourceRequest); return(Ok(response)); }
public async Task <IActionResult> GetResourceSummary([FromQuery] string Namespace, [FromQuery] string region) { if (!ValidationHelper.IsValidateSummary(Namespace, out string message)) { return(BadRequest(new { Message = message })); } IResourceDetails resourceDetails = ReflectionHelper.GetInstanceByNamespace(Namespace); var response = await resourceDetails.GetResources(region); return(Ok(response)); }
/// <summary> /// Check resources for updates /// </summary> /// <param name="resources">A list of resources to be checked</param> /// <param name="singleMonitoringData">Signle instance of ResourceMonitoringData to use if present (use class-wide dict instead)</param> private void CheckResourcesForUpdates(IEnumerable <IResource> resources, ResourceMonitoringData singleMonitoringData) { HashSet <IResource> updatedResources = new HashSet <IResource>(); foreach (IResource resource in resources) { IResourceDetails newDetails = GetFileDetails(resource); if (newDetails == null) { ULSLogging.LogTraceTag(0x238208cc /* tag_9669m */, Categories.ConfigurationDataSet, Levels.Warning, "Failed to load resource details for '{0}'", resource.Name); continue; } bool updated; if (m_resourceDetails.TryGetValue(resource, out IResourceDetails currentDetails) && currentDetails != null) { updated = !string.Equals(currentDetails.SHA256Hash, newDetails.SHA256Hash, StringComparison.Ordinal); } else { // it is the first time we load this resource updated = true; } if (updated) { // No explicit synchronization was added here for the following reason: // the worst thing that can happed is two parallel threads consider the same resource // updated and both call the ResourceMonitoringData.CallHandlerIfNecessary // That method on its own ensures in-order execution of handlers m_resourceDetails.AddOrUpdate(resource, newDetails, (res, oldDetails) => newDetails); updatedResources.Add(resource); } } NotifyHandlers(updatedResources, singleMonitoringData); }