public async static Task RefetchStatsData(IProducer <Null, string> p) { // Updating the containers with the new configurations right away and sending it out var updatedContainers = await DockerUpdater.FetchStatsData(); var overviewContainerUpdate = DockerUpdater.CreateStatsData(updatedContainers); await KafkaHelpers.SendMessageAsync(DockerUpdater.StatsTopic, overviewContainerUpdate, p); // Send response await KafkaHelpers.SendMessageAsync(_responseTopic, new ContainerResponse { ResponseStatusCode = 200, Message = ResponseMessageContracts.STATS_DATA_REFETCHED, ContainerIds = updatedContainers.Select(container => container.Id).ToArray() }, p); }
public async static Task UpdateConfigContainer(UpdateConfigContainerParameters parameters, IProducer <Null, string> p) { try { CancellationToken cancellation = new CancellationToken(); await client.Containers.UpdateContainerAsync(parameters.ContainerId, new ContainerUpdateParameters { BlkioWeight = parameters.BlkioWeight, Memory = parameters.MemoryLimit, MemoryReservation = parameters.MemoryParameters, MemorySwap = parameters.MemorySwapLimit, KernelMemory = parameters.KernelMemory, // RestartPolicy = parameters.RestartPolicy, TODO: CPUShares = parameters.CPUShares, CPUPeriod = parameters.CPUPeriod, CpusetCpus = parameters.CPUSetCPUs, CpusetMems = parameters.CPUSetMems }, cancellation); // Updating the containers with the new configurations right away and sending it out var updatedContainers = await DockerUpdater.FetchStatsData(); var overviewContainerUpdate = DockerUpdater.CreateStatsData(updatedContainers); await KafkaHelpers.SendMessageAsync(DockerUpdater.StatsTopic, overviewContainerUpdate, p); // Send response await KafkaHelpers.SendMessageAsync(_responseTopic, new ContainerResponse { ResponseStatusCode = 200, Message = ResponseMessageContracts.CONTAINER_CONFIGURATION_UPDATED, ContainerIds = new string[] { parameters.ContainerId } }, p); } catch (DockerApiException ex) { await KafkaHelpers.SendMessageAsync(_responseTopic, new ContainerResponse { ResponseStatusCode = 400, Message = ex.Message, ContainerIds = new string[] { parameters.ContainerId } }, p); } }