Exemplo n.º 1
0
        /// <summary>
        /// This deletes the kernelId as specified
        /// </summary>
        /// <param name="subscriptionId">subscriptionId that is passed in from the frontend</param>
        /// <param name="kernelId">kernelId that needs to be deleted</param>
        /// <param name="flowName">flowName</param>
        /// <returns>Returns success or failure after the delete kernel api is called</returns>
        private async Task <ApiResult> DeleteKernelHelper(string subscriptionId, string kernelId, string flowName)

        {
            // validate KernelId can't be null
            if (string.IsNullOrEmpty(kernelId))
            {
                _logger.LogError("No Kernel found to delete");
                return(ApiResult.CreateError("No Kernel found to delete"));
            }

            try
            {
                KernelService kernelService = CreateKernelService(flowName);
                var           result        = await kernelService.DeleteKernelAsync(kernelId);

                if (!(result.Error.HasValue && result.Error.Value))
                {
                    //Passing in false as the last parameter since this is a delete call and the entry needs to be deleted from the blob
                    await kernelService.UpdateGarbageCollectKernelBlob(kernelId, "", "", _engineEnvironment.OpsBlobConnectionString, Path.Combine(_engineEnvironment.OpsDiagnosticPath, _GarbageCollectBlobName), false);
                }
                return(result);
            }
            catch (Exception ex)
            {
                _logger.LogError(ex.Message);
                return(ApiResult.CreateError(ex.Message));
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// CreateAndInitializeKernelHelper is the helper that does the heavy listing for creating and initializing the kernel
        /// </summary>
        /// <param name="rawSchema">rawSchema as passed in from the frontend</param>
        /// <param name="userId">userId as passed in from the frontend</param>
        /// <param name="flowId">flowId as passed in from the frontend</param>
        /// <param name="sampleDataPath">sampleDataPath where the sample data is stored</param>
        /// <param name="normalizationSnippet">normalizationSnippet as passed in from the frontend</param>
        /// <param name="referenceDatas">referenceDatas as passed in from the frontend</param>
        /// <param name="functions">functions as passed in from the frontend</param>
        /// <returns></returns>
        private async Task <ApiResult> CreateAndInitializeKernelHelper(string rawSchema, string userId, string flowId, string sampleDataPath, string normalizationSnippet, List <ReferenceDataObject> referenceDatas, List <FunctionObject> functions)
        {
            try
            {
                //Create the xml with the scala steps to execute to initialize the kernel
                DiagnosticInputhelper(rawSchema, sampleDataPath, normalizationSnippet, flowId);

                KernelService kernelService = CreateKernelService(flowId);
                var           response      = await kernelService.GarbageCollectListOfKernels(_engineEnvironment.OpsBlobConnectionString, Path.Combine(_engineEnvironment.OpsDiagnosticPath, _GarbageCollectBlobName));

                response = await kernelService.CreateKernelAsync();

                if (response.Error.HasValue && response.Error.Value)
                {
                    return(ApiResult.CreateError(response.Message));
                }
                string kernelId = response.Result.ToString();

                response = await kernelService.UpdateGarbageCollectKernelBlob(kernelId, userId, flowId, _engineEnvironment.OpsBlobConnectionString, Path.Combine(_engineEnvironment.OpsDiagnosticPath, _GarbageCollectBlobName), true);

                if (response.Error.HasValue && response.Error.Value)
                {
                    await kernelService.DeleteKernelAsync(kernelId);

                    return(ApiResult.CreateError(response.Message));
                }

                if (_engineEnvironment.EngineFlowConfig.SparkType == Config.ConfigDataModel.Constants.SparkTypeDataBricks)
                {
                    kernelService.MountStorage(_engineEnvironment.EngineFlowConfig.OpsStorageAccountName, _engineEnvironment.EngineFlowConfig.SparkKeyVaultName, sampleDataPath, kernelId);
                }

                response = await kernelService.CreateandInitializeKernelAsync(kernelId, SetupSteps, false, referenceDatas, functions);

                if (response.Error.HasValue && response.Error.Value)
                {
                    _logger.LogError(response.Message);
                    return(ApiResult.CreateError(response.Message));
                }
                else
                {
                    return(ApiResult.CreateSuccess(response.Result));
                }
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, ex.Message);
                return(ApiResult.CreateError(ex.Message));
            }
        }