Пример #1
0
        private ResourceReservation GetReservation(WorkItem workItem, SystemWorkloadBase systemWorkload, ResourceReservationContext context, IEnumerable <ResourceKey> resources, out ResourceKey throttledResource)
        {
            throttledResource = null;
            ResourceReservation result;

            if (CommonUtils.ServiceIsStopping || this.IsInFinalization || workItem is UnthrottledWorkItem)
            {
                result = context.GetUnthrottledReservation(systemWorkload);
            }
            else
            {
                result = context.GetReservation(systemWorkload, resources, out throttledResource);
            }
            return(result);
        }
Пример #2
0
 public SystemTaskBase GetTask(LoadBalanceWorkload workload, ResourceReservationContext context)
 {
     lock (this.requestQueueLock)
     {
         this.BlockedTaskCount = 0;
         if (this.requests.Count == 0)
         {
             return(null);
         }
         for (int i = 0; i < this.requests.Count; i++)
         {
             IRequest request = this.requests[i];
             if (request.IsBlocked)
             {
                 this.BlockedTaskCount++;
             }
             else if (request.ShouldCancel(this.settings.IdleRunDelay))
             {
                 request.Abort();
                 DatabaseRequestLog.Write(request);
                 this.requests.RemoveAt(i);
                 i--;
             }
             else
             {
                 ResourceKey         obj2;
                 ResourceReservation reservation = context.GetReservation(workload, request.Resources, out obj2);
                 if (reservation != null)
                 {
                     this.requests.RemoveAt(i);
                     return(new LoadBalanceTask(workload, reservation, request));
                 }
                 if (ProcessorResourceKey.Local.Equals(obj2))
                 {
                     this.BlockedTaskCount = this.requests.Count;
                     break;
                 }
                 this.BlockedTaskCount++;
             }
         }
     }
     return(null);
 }
        protected override SystemTaskBase GetTask(ResourceReservationContext context)
        {
            List <Guid> list = null;
            Guid        guid = this.lastProcessedDriverGuid;

            lock (this.instanceLock)
            {
                TimeBasedAssistantTask        timeBasedAssistantTask = null;
                List <TimeBasedAssistantTask> list2 = new List <TimeBasedAssistantTask>();
                foreach (SystemTaskBase systemTaskBase in this.tasksWaitingExecution)
                {
                    TimeBasedAssistantTask    timeBasedAssistantTask2 = (TimeBasedAssistantTask)systemTaskBase;
                    IEnumerable <ResourceKey> resourceDependencies    = timeBasedAssistantTask2.ResourceDependencies;
                    if (resourceDependencies != null)
                    {
                        ResourceReservation reservation = context.GetReservation(this, resourceDependencies);
                        if (reservation != null)
                        {
                            timeBasedAssistantTask2.ResourceReservation = reservation;
                            timeBasedAssistantTask = timeBasedAssistantTask2;
                            break;
                        }
                    }
                    else
                    {
                        list2.Add(timeBasedAssistantTask2);
                    }
                }
                foreach (TimeBasedAssistantTask value in list2)
                {
                    this.tasksWaitingExecution.Remove(value);
                }
                if (timeBasedAssistantTask != null)
                {
                    this.tasksWaitingExecution.Remove(timeBasedAssistantTask);
                    return(timeBasedAssistantTask);
                }
            }
            TimeBasedDatabaseDriver nextDriver;
            ResourceReservation     reservation2;

            for (;;)
            {
                nextDriver = this.Controller.GetNextDriver(guid);
                if (nextDriver == null)
                {
                    break;
                }
                guid = nextDriver.DatabaseInfo.Guid;
                if (list != null && list.Contains(guid))
                {
                    goto Block_4;
                }
                if (!nextDriver.HasTask())
                {
                    ExTraceGlobals.TimeBasedAssistantControllerTracer.TraceDebug <Guid, LocalizedString>((long)this.GetHashCode(), "Skipping database '{0}' for assistant '{1}'. There is no task to execute.", guid, this.Controller.TimeBasedAssistantType.Name);
                }
                else
                {
                    IEnumerable <ResourceKey> resourceDependencies2 = nextDriver.ResourceDependencies;
                    if (resourceDependencies2 != null)
                    {
                        reservation2 = context.GetReservation(this, resourceDependencies2);
                        if (reservation2 != null)
                        {
                            goto IL_1E1;
                        }
                        ExTraceGlobals.TimeBasedAssistantControllerTracer.TraceDebug <Guid, LocalizedString>((long)this.GetHashCode(), "Skipping database '{0}' for assistant '{1}'. Dependent resources are not currently available for this assistant.", guid, this.Controller.TimeBasedAssistantType.Name);
                    }
                    else
                    {
                        ExTraceGlobals.TimeBasedAssistantControllerTracer.TraceDebug <Guid, LocalizedString>((long)this.GetHashCode(), "The driver for database {0} assistant {1} did not return any resource dependencies. This is possible only when the driver is not started. Skipping tasks from this driver.", guid, this.Controller.TimeBasedAssistantType.Name);
                    }
                }
                if (list == null)
                {
                    list = new List <Guid>();
                }
                list.Add(guid);
            }
            ExTraceGlobals.TimeBasedAssistantControllerTracer.TraceDebug <LocalizedString>((long)this.GetHashCode(), "There are no drivers available for the assistant controller '{0}' at this time. No task available for execution.", this.Controller.TimeBasedAssistantType.Name);
            return(null);

Block_4:
            ExTraceGlobals.TimeBasedAssistantControllerTracer.TraceDebug <LocalizedString>((long)this.GetHashCode(), "Could not find any tasks to execute for the assistant controller '{0}'. No task available for execution.", this.Controller.TimeBasedAssistantType.Name);
            return(null);

IL_1E1:
            ExTraceGlobals.TimeBasedAssistantControllerTracer.TraceDebug <Guid, LocalizedString>((long)this.GetHashCode(), "A task is available for execution on database {0} for assistant {1}. Submitting the task to RUBS for execution", guid, this.Controller.TimeBasedAssistantType.Name);
            this.lastProcessedDriverGuid = guid;
            return(new TimeBasedAssistantTask(this, nextDriver, reservation2));
        }