private async Task <Result> DeleteConfigsWithProcessors(string flowName, IEnumerable <IFlowDeploymentProcessor> processors) { Ensure.NotNull(flowName, "flowName"); // Ensure no other generation process is going with the same flow with generation locks per flows var generationLock = this.GenerationLocks.GetLock(flowName); if (generationLock == null) { return(new FailedResult($"config for flow '{flowName}' is being generated, please try again later.")); } using (generationLock) { using (Logger.BeginScope(("datax/runtimeConfigGeneration/flowConfigsDelete", new Dictionary <string, string>() { { "flowName", flowName } }))) { // Call Storage client to get back the associated flow config var config = await FlowData.GetByName(flowName); Ensure.NotNull(config, "config", $"could not find flow for flow name:'{flowName}'"); // Initialize a deploy session var session = new FlowDeploymentSession(config); // Run through a chain of processors await processors.ChainTask(p => p.Delete(session)); // Return result return(session.Result); } } }
/// <summary> /// Save a flow with the gui input /// </summary> /// <param name="flowConfig"></param> /// <returns></returns> public async Task <Result> SaveFlowConfig(FlowGuiConfig flowConfig) { var config = await ConfigBuilder.Build(flowConfig); var existingFlow = await FlowData.GetByName(config.Name); Result result = null; if (existingFlow != null) { existingFlow.Gui = config.Gui; existingFlow.CommonProcessor.Template = config.CommonProcessor.Template; existingFlow.CommonProcessor.SparkJobTemplateRef = config.CommonProcessor.SparkJobTemplateRef; existingFlow.DisplayName = config.DisplayName; config = existingFlow; result = await FlowData.UpdateGuiForFlow(config.Name, config.Gui); if (result.IsSuccess) { result = await FlowData.UpdateCommonProcessorForFlow(config.Name, config.CommonProcessor); } } else { result = await this.FlowData.Upsert(config); } if (result.IsSuccess) { // pass the generated config back with the result var properties = new Dictionary <string, object>() { { FlowConfigPropertyName, config } }; if (result.Properties != null) { result.Properties.AppendDictionary(properties); } else { result.Properties = properties; } } return(result); }
/// <summary> /// Update the last processed time for a batch job in the config /// </summary> /// <returns></returns> private async Task <Result> UpdateLastProcessedTime(FlowConfig config, int index, long value) { var existingFlow = await FlowData.GetByName(config.Name).ConfigureAwait(false); Result result = null; if (existingFlow != null) { var gui = config.GetGuiConfig(); var batch = gui.BatchList[index]; batch.Properties.LastProcessedTime = value.ToString(CultureInfo.InvariantCulture); config.Gui = JObject.FromObject(gui); result = await FlowData.UpdateGuiForFlow(config.Name, config.Gui).ConfigureAwait(false); } return(result); }
/// <summary> /// Disable a batch job in the config /// </summary> /// <returns></returns> private async Task <Result> DisableBatchConfig(FlowConfig config, int index) { var existingFlow = await FlowData.GetByName(config.Name).ConfigureAwait(false); Result result = null; if (existingFlow != null) { var gui = config.GetGuiConfig(); var batch = gui.BatchList[index]; batch.Disabled = true; config.Gui = JObject.FromObject(gui); result = await FlowData.UpdateGuiForFlow(config.Name, config.Gui).ConfigureAwait(false); } return(result); }