public StartCriticalSectionRequest(TaskId taskId,
     string taskExecutionId,
     TaskDeathMode taskDeathMode,
     CriticalSectionType criticalSectionType)
     : base(taskId, taskExecutionId)
 {
     TaskDeathMode = taskDeathMode;
     Type = criticalSectionType;
 }
 public StartCriticalSectionRequest(TaskId taskId,
                                    string taskExecutionId,
                                    TaskDeathMode taskDeathMode,
                                    CriticalSectionType criticalSectionType)
     : base(taskId, taskExecutionId)
 {
     TaskDeathMode = taskDeathMode;
     Type          = criticalSectionType;
 }
        private void InsertNumericRangeTestData(TaskDeathMode taskDeathMode)
        {
            var now = DateTime.UtcNow;
            if (taskDeathMode == TaskDeathMode.Override)
                _taskExecution1 = _executionHelper.InsertOverrideTaskExecution(_taskDefinitionId, OneMinuteSpan, now.AddMinutes(-250), now.AddMinutes(-179));
            else
                _taskExecution1 = _executionHelper.InsertKeepAliveTaskExecution(_taskDefinitionId, TwentySecondSpan, FiveMinuteSpan, now.AddMinutes(-250), now.AddMinutes(-179));

            InsertNumericRangeBlocksTestData();
        }
 private FindDeadBlocksRequest CreateDeadBlockRequest(BlockType blockType, TaskDeathMode taskDeathMode, int blockCountLimit, int attemptLimit, int fromMinutesBack)
 {
     return(new FindDeadBlocksRequest(new TaskId(TestConstants.ApplicationName, TestConstants.TaskName),
                                      "1",
                                      blockType,
                                      DateTime.UtcNow.AddMinutes(fromMinutesBack),
                                      DateTime.UtcNow,
                                      blockCountLimit,
                                      taskDeathMode,
                                      attemptLimit));
 }
 public TaskExecutionStartRequest(TaskId taskId,
     TaskDeathMode taskDeathMode,
     int concurrencyLimit,
     short failedTaskRetryLimit,
     short deadTaskRetryLimit
     )
     : base(taskId)
 {
     TaskDeathMode = taskDeathMode;
     ConcurrencyLimit = concurrencyLimit;
     FailedTaskRetryLimit = failedTaskRetryLimit;
     DeadTaskRetryLimit = deadTaskRetryLimit;
 }
Example #6
0
 public TaskExecutionStartRequest(TaskId taskId,
                                  TaskDeathMode taskDeathMode,
                                  int concurrencyLimit,
                                  short failedTaskRetryLimit,
                                  short deadTaskRetryLimit
                                  )
     : base(taskId)
 {
     TaskDeathMode        = taskDeathMode;
     ConcurrencyLimit     = concurrencyLimit;
     FailedTaskRetryLimit = failedTaskRetryLimit;
     DeadTaskRetryLimit   = deadTaskRetryLimit;
 }
        private void InsertNumericRangeTestData(TaskDeathMode taskDeathMode)
        {
            var now = DateTime.UtcNow;

            if (taskDeathMode == TaskDeathMode.Override)
            {
                _taskExecution1 = _executionHelper.InsertOverrideTaskExecution(_taskDefinitionId, OneMinuteSpan, now.AddMinutes(-250), now.AddMinutes(-179));
            }
            else
            {
                _taskExecution1 = _executionHelper.InsertKeepAliveTaskExecution(_taskDefinitionId, TwentySecondSpan, FiveMinuteSpan, now.AddMinutes(-250), now.AddMinutes(-179));
            }

            InsertNumericRangeBlocksTestData();
        }
Example #8
0
 public FindDeadBlocksRequest(TaskId taskId,
                              string taskExecutionId,
                              BlockType blockType,
                              DateTime searchPeriodBegin,
                              DateTime searchPeriodEnd,
                              int blockCountLimit,
                              TaskDeathMode taskDeathMode,
                              int retryLimit)
     : base(taskId, taskExecutionId, blockType)
 {
     SearchPeriodBegin = searchPeriodBegin;
     SearchPeriodEnd   = searchPeriodEnd;
     BlockCountLimit   = blockCountLimit;
     TaskDeathMode     = taskDeathMode;
     RetryLimit        = retryLimit;
 }
 public FindDeadBlocksRequest(TaskId taskId,
     string taskExecutionId,
     BlockType blockType,
     DateTime searchPeriodBegin,
     DateTime searchPeriodEnd,
     int blockCountLimit,
     TaskDeathMode taskDeathMode,
     int retryLimit)
     : base(taskId, taskExecutionId, blockType)
 {
     SearchPeriodBegin = searchPeriodBegin;
     SearchPeriodEnd = searchPeriodEnd;
     BlockCountLimit = blockCountLimit;
     TaskDeathMode = taskDeathMode;
     RetryLimit = retryLimit;
 }
        public async Task <TaskExecutionMetaResponse> GetLastExecutionMetasAsync(TaskExecutionMetaRequest taskExecutionMetaRequest)
        {
            var response       = new TaskExecutionMetaResponse();
            var taskDefinition = await _taskRepository.EnsureTaskDefinitionAsync(taskExecutionMetaRequest.TaskId).ConfigureAwait(false);

            using (var connection = await CreateNewConnectionAsync(taskExecutionMetaRequest.TaskId).ConfigureAwait(false))
            {
                var command = connection.CreateCommand();
                command.CommandTimeout = ConnectionStore.Instance.GetConnection(taskExecutionMetaRequest.TaskId).QueryTimeoutSeconds;
                command.CommandText    = TaskQueryBuilder.GetLastExecutionQuery;
                command.Parameters.Add("Top", SqlDbType.Int).Value = taskExecutionMetaRequest.ExecutionsToRetrieve;
                command.Parameters.Add("TaskDefinitionId", SqlDbType.Int).Value = taskDefinition.TaskDefinitionId;

                using (var reader = await command.ExecuteReaderAsync().ConfigureAwait(false))
                {
                    while (await reader.ReadAsync().ConfigureAwait(false))
                    {
                        var executionMeta = new TaskExecutionMetaItem();
                        executionMeta.StartedAt = (DateTime)reader["StartedAt"];

                        if (reader["CompletedAt"] != DBNull.Value)
                        {
                            executionMeta.CompletedAt = (DateTime)reader["CompletedAt"];

                            bool failed  = (bool)reader["Failed"];
                            bool blocked = (bool)reader["Blocked"];

                            if (failed)
                            {
                                executionMeta.Status = TaskExecutionStatus.Failed;
                            }
                            else if (blocked)
                            {
                                executionMeta.Status = TaskExecutionStatus.Blocked;
                            }
                            else
                            {
                                executionMeta.Status = TaskExecutionStatus.Completed;
                            }
                        }
                        else
                        {
                            TaskDeathMode taskDeathMode = (TaskDeathMode)(byte)reader["TaskDeathMode"];
                            if (taskDeathMode == TaskDeathMode.KeepAlive)
                            {
                                var lastKeepAlive      = (DateTime)reader["LastKeepAlive"];
                                var keepAliveThreshold = (TimeSpan)reader["KeepAliveDeathThreshold"];
                                var dbServerUtcNow     = (DateTime)reader["DbServerUtcNow"];

                                var timeSinceLastKeepAlive = dbServerUtcNow - lastKeepAlive;
                                if (timeSinceLastKeepAlive > keepAliveThreshold)
                                {
                                    executionMeta.Status = TaskExecutionStatus.Dead;
                                }
                                else
                                {
                                    executionMeta.Status = TaskExecutionStatus.InProgress;
                                }
                            }
                        }

                        if (reader["ExecutionHeader"] != DBNull.Value)
                        {
                            executionMeta.Header = reader["ExecutionHeader"].ToString();
                        }

                        if (reader["ReferenceValue"] != DBNull.Value)
                        {
                            executionMeta.ReferenceValue = reader["ReferenceValue"].ToString();
                        }

                        response.Executions.Add(executionMeta);
                    }
                }
            }

            return(response);
        }
 private FindDeadBlocksRequest CreateDeadBlockRequest(BlockType blockType, TaskDeathMode taskDeathMode, int blockCountLimit)
 {
     return(CreateDeadBlockRequest(blockType, taskDeathMode, blockCountLimit, 3, -300));
 }
 private FindDeadBlocksRequest CreateDeadBlockRequest(BlockType blockType, TaskDeathMode taskDeathMode, int blockCountLimit, int attemptLimit, int fromMinutesBack)
 {
     return new FindDeadBlocksRequest(new TaskId(TestConstants.ApplicationName, TestConstants.TaskName),
         "1",
         blockType,
         DateTime.UtcNow.AddMinutes(fromMinutesBack),
         DateTime.UtcNow,
         blockCountLimit,
         taskDeathMode,
         attemptLimit);
 }
 private FindDeadBlocksRequest CreateDeadBlockRequest(BlockType blockType, TaskDeathMode taskDeathMode, int blockCountLimit)
 {
     return CreateDeadBlockRequest(blockType, taskDeathMode, blockCountLimit, 3, -300);
 }