public async Task <IList <IRepairTask> > GetRepairTaskListAsync(
            Guid activityId,
            string taskIdFilter = null,
            RepairTaskStateFilter stateFilter = RepairTaskStateFilter.Default,
            string executorFilter             = null)
        {
            //var startTime = DateTimeOffset.UtcNow;

            try
            {
                // TODO, using the overload without timeout and cancellation token for now since there is some max timeout limit
                // being exercised somewhere. if timeout provided is more than that, repair task creation fails
                RepairTaskList repairTaskList = await repairManager.GetRepairTaskListAsync(taskIdFilter, stateFilter, executorFilter).ConfigureAwait(false);

                var repairTasks = new List <IRepairTask>(repairTaskList.Count);
                foreach (var repairTask in repairTaskList)
                {
                    repairTasks.Add(new ServiceFabricRepairTask(repairTask));
                }

                //activityLogger.LogOperation(activityId, startTime);

                return(repairTasks);
            }
            catch (Exception ex)
            {
                traceType.WriteWarning("Unable to get repair task list. Errors: {0}", ex.GetMessage());
                //activityLogger.LogOperation(activityId, startTime, OperationResult.Failure, ex);
                throw;
            }
        }
 /// <summary>
 /// <para>Gets a list of repair tasks matching all of the given filters.</para>
 /// </summary>
 /// <param name="taskIdFilter">
 /// <para>The repair task ID prefix to be matched.  If null, no filter is applied to the task ID.</para>
 /// </param>
 /// <param name="stateFilter">
 /// <para>A bitwise combination of state filter values that specify which task states should be included in the list.</para>
 /// </param>
 /// <param name="executorFilter">
 /// <para>The name of the repair executor whose claimed tasks should be included in the list. If null, no filter is applied to the executor name.</para>
 /// </param>
 /// <returns>
 /// <para>The list of repair tasks matching all of the given filters.</para>
 /// </returns>
 public Task <RepairTaskList> GetRepairTaskListAsync(
     string taskIdFilter,
     RepairTaskStateFilter stateFilter,
     string executorFilter)
 {
     return(this.GetRepairTaskListAsync(taskIdFilter, stateFilter, executorFilter, FabricClient.DefaultTimeout, CancellationToken.None));
 }
        private async Task <IEnumerable <RepairTask> > GetRepairList(RepairTaskStateFilter stateFilter, TimeSpan timeout, CancellationToken token)
        {
            var repairTaskList = await this.repairManagementClient.GetRepairTaskListAsync(
                string.Empty,
                stateFilter,
                string.Empty,
                timeout,
                token);

            return(repairTaskList.Where(task => task.Executor.StartsWith(ExecutorPrefix) && !string.IsNullOrWhiteSpace(task.ExecutorData)));
        }
示例#4
0
 internal RepairTaskQueryDescription(
     RepairScopeIdentifier scope,
     string taskIdFilter,
     RepairTaskStateFilter stateFilter,
     string executorFilter)
 {
     this.Scope          = scope;
     this.TaskIdFilter   = taskIdFilter;
     this.StateFilter    = stateFilter;
     this.ExecutorFilter = executorFilter;
 }
示例#5
0
        public Task <IList <IRepairTask> > GetRepairTaskListAsync(
            Guid activityId,
            string taskIdFilter = null,
            RepairTaskStateFilter stateFilter = RepairTaskStateFilter.Default,
            string executorFilter             = null)
        {
            IList <IRepairTask> matchingRepairTasks = new List <IRepairTask>();

            foreach (var rt in repairTasks.Values)
            {
                if (taskIdFilter != null && !rt.TaskId.StartsWith(taskIdFilter, StringComparison.OrdinalIgnoreCase))
                {
                    continue;
                }

                if (executorFilter != null)
                {
                    if (rt.Executor == null)
                    {
                        continue;
                    }

                    if (!rt.Executor.StartsWith(executorFilter, StringComparison.OrdinalIgnoreCase))
                    {
                        continue;
                    }
                }

                if (stateFilter != RepairTaskStateFilter.Default)
                {
                    var stateMask = (RepairTaskStateFilter)rt.State;
                    if (stateMask != stateFilter)
                    {
                        continue;
                    }
                }

                matchingRepairTasks.Add(rt);
            }

            return(Task.FromResult(matchingRepairTasks));
        }
            /// <summary>
            /// <para>Gets a list of repair tasks matching all of the given filters.</para>
            /// </summary>
            /// <param name="taskIdFilter">
            /// <para>The repair task ID prefix to be matched.  If null, no filter is applied to the task ID.</para>
            /// </param>
            /// <param name="stateFilter">
            /// <para>A bitwise combination of state filter values that specify which task states should be included in the list.</para>
            /// </param>
            /// <param name="executorFilter">
            /// <para>The name of the repair executor whose claimed tasks should be included in the list. If null, no filter is applied to the executor name.</para>
            /// </param>
            /// <param name="timeout">
            /// <para>The maximum amount of time Service Fabric will allow this operation to continue before returning a <see cref="System.TimeoutException" />.</para>
            /// </param>
            /// <param name="cancellationToken">
            /// <para>The optional cancellation token that the operation is observing. It can be used to send a notification that the operation should be canceled. Note that cancellation is advisory and that the operation may still be completed even if it is cancelled.</para>
            /// </param>
            /// <returns>
            /// <para>The list of repair tasks matching all of the given filters.</para>
            /// </returns>
            public Task <RepairTaskList> GetRepairTaskListAsync(
                string taskIdFilter,
                RepairTaskStateFilter stateFilter,
                string executorFilter,
                TimeSpan timeout,
                CancellationToken cancellationToken)
            {
                this.fabricClient.ThrowIfDisposed();
                var queryDescription = new RepairTaskQueryDescription(
                    DefaultScope,
                    taskIdFilter,
                    stateFilter,
                    executorFilter);

                return(Utility.WrapNativeAsyncInvokeInMTA <RepairTaskList>(
                           callback => this.GetRepairTaskListAsyncBeginWrapper(queryDescription, timeout, callback),
                           this.GetRepairTaskListAsyncEndWrapper,
                           cancellationToken,
                           "RepairManagementClient.GetRepairTaskListAsync"));
            }
示例#7
0
 public Task <IList <IRepairTask> > GetRepairTaskListAsync(Guid activityId, string taskIdFilter = null, RepairTaskStateFilter stateFilter = RepairTaskStateFilter.Default, string executorFilter = null)
 {
     return(Task.FromResult((IList <IRepairTask>) new List <IRepairTask>()));
 }
示例#8
0
        /// <summary>
        /// Gets repair task for the node specified
        /// </summary>
        /// <param name="fc">Fabric client to carry out ServiceFabric operations</param>
        /// <param name="nodeName">Node for which repair task is queried</param>
        /// <param name="timeout">Timeout for operation</param>
        /// <param name="cancellationToken">Cancellation token to cancel this async operation</param>
        /// <param name="taskFilter">Optional parameter to specify filter when searching repair tasks for current node</param>
        /// <returns>A Task representing the asnyc operation, result of task would be <see cref="RepairTask"/></returns>
        internal static async Task <RepairTask> GetRepairTaskForNode(FabricClient fc, string nodeName, TimeSpan timeout,
                                                                     CancellationToken cancellationToken, RepairTaskStateFilter taskFilter = RepairTaskStateFilter.Active)
        {
            var taskIdPrefix = String.Format("{0}_{1}_", TaskIdPrefix, nodeName);
            var repairTasks  = await fc.RepairManager.GetRepairTaskListAsync(taskIdPrefix,
                                                                             taskFilter,
                                                                             ExecutorName, timeout, cancellationToken);

            ServiceEventSource.Current.InfoMessage("{0} repair tasks found for node {1}", repairTasks.Count, nodeName);
            if (repairTasks.Count > 0)
            {
                RepairTask oldestActiveTask = repairTasks.Aggregate(
                    (curMin, task) => (task.CreatedTimestamp < curMin.CreatedTimestamp ? task : curMin));
                ServiceEventSource.Current.VerboseMessage(String.Format("Oldest active repair task = {0} found in {1} state",
                                                                        oldestActiveTask.TaskId, oldestActiveTask.State));
                return(oldestActiveTask);
            }

            return(null);
        }
示例#9
0
 public Task <IList <IRepairTask> > GetRepairTaskListAsync(Guid activityId, string taskIdFilter = null, RepairTaskStateFilter stateFilter = RepairTaskStateFilter.Default, string executorFilter = null)
 {
     return(this.GetRepairTaskListAsyncHandler(taskIdFilter, stateFilter, executorFilter));
 }
示例#10
0
 public Task <IList <IRepairTask> > GetRepairTaskListAsync(Guid activityId, string taskIdFilter = null, RepairTaskStateFilter stateFilter = RepairTaskStateFilter.Default, string executorFilter = null)
 {
     throw new NotImplementedException();
 }