Example #1
0
        private LimitValue GetMaxEnqueuedRequestLimit()
        {
            if (maxEnqueuedRequestsLimit != null)
            {
                return(maxEnqueuedRequestsLimit);
            }
            if (GrainInstanceType != null)
            {
                string limitName = CodeGeneration.GrainInterfaceData.IsStatelessWorker(GrainInstanceType)
                    ? LimitNames.LIMIT_MAX_ENQUEUED_REQUESTS_STATELESS_WORKER
                    : LimitNames.LIMIT_MAX_ENQUEUED_REQUESTS;
                maxEnqueuedRequestsLimit = LimitManager.GetLimit(limitName); // Cache for next time
                return(maxEnqueuedRequestsLimit);
            }

            return(LimitManager.GetLimit(LimitNames.LIMIT_MAX_ENQUEUED_REQUESTS));
        }
Example #2
0
        internal WorkItemGroup(OrleansTaskScheduler sched, ISchedulingContext schedulingContext)
        {
            masterScheduler      = sched;
            SchedulingContext    = schedulingContext;
            state                = WorkGroupStatus.Waiting;
            workItems            = new Queue <Task>();
            lockable             = new Object();
            totalItemsEnQueued   = 0;
            totalItemsProcessed  = 0;
            totalQueuingDelay    = TimeSpan.Zero;
            quantumExpirations   = 0;
            TaskRunner           = new ActivationTaskScheduler(this);
            MaxPendingItemsLimit = LimitManager.GetLimit(LimitNames.LIMIT_MAX_PENDING_ITEMS);
            log = IsSystem ? TraceLogger.GetLogger("Scheduler." + Name + ".WorkItemGroup", TraceLogger.LoggerType.Runtime) : appLogger;

            if (StatisticsCollector.CollectShedulerQueuesStats)
            {
                queueTracking = new QueueTrackingStatistic("Scheduler." + SchedulingContext.Name);
                queueTracking.OnStartExecution();
            }

            if (StatisticsCollector.CollectPerWorkItemStats)
            {
                workItemGroupStatisticsNumber = SchedulerStatisticsGroup.RegisterWorkItemGroup(SchedulingContext.Name, SchedulingContext,
                                                                                               () =>
                {
                    var sb = new StringBuilder();
                    lock (lockable)
                    {
                        sb.Append("QueueLength = " + WorkItemCount);
                        sb.Append(String.Format(", State = {0}", state));
                        if (state == WorkGroupStatus.Runnable)
                        {
                            sb.Append(String.Format("; oldest item is {0} old", workItems.Count >= 0 ? workItems.Peek().ToString() : "null"));
                        }
                    }
                    return(sb.ToString());
                });
            }
        }