Exemple #1
0
        private async Task DeleteServerWideTaskCommand(OngoingTaskType taskType)
        {
            var name = GetStringQueryString("name", required: true);

            using (ServerStore.ContextPool.AllocateOperationContext(out TransactionOperationContext context))
            {
                var deleteConfiguration = new DeleteServerWideTaskCommand.DeleteConfiguration
                {
                    TaskName = name,
                    Type     = taskType
                };

                var(newIndex, _) = await ServerStore.DeleteServerWideTaskAsync(deleteConfiguration, GetRaftRequestIdFromQuery());

                await ServerStore.WaitForCommitIndexChange(RachisConsensus.CommitIndexModification.GreaterOrEqual, newIndex);

                await using (var writer = new AsyncBlittableJsonTextWriter(context, ResponseBodyStream()))
                    using (context.OpenReadTransaction())
                    {
                        var deleteResponse = new ServerWideTaskResponse
                        {
                            Name             = name,
                            RaftCommandIndex = newIndex
                        };

                        HttpContext.Response.StatusCode = (int)HttpStatusCode.OK;
                        context.Write(writer, deleteResponse.ToJson());
                    }
            }
        }