public PrefetchingBehavior(PrefetchingUser prefetchingUser, 
            WorkContext context, 
            BaseBatchSizeAutoTuner autoTuner, 
            string prefetchingUserDescription, 
            bool isDefault = false,
            Func<int> getPrefetchintBehavioursCount = null,
            Func<PrefetchingSummary> getPrefetcherSummary = null)
        {
            this.context = context;
            this.autoTuner = autoTuner;
            PrefetchingUser = prefetchingUser;
            this.userDescription = prefetchingUserDescription;
            this.IsDefault = isDefault;
            this.getPrefetchintBehavioursCount = getPrefetchintBehavioursCount ?? (() => 1);
            this.getPrefetcherSummary = getPrefetcherSummary ?? GetSummary;
            MemoryStatistics.RegisterLowMemoryHandler(this);
            LastTimeUsed = DateTime.MinValue;

            ingestMeter = context.MetricsCounters.DbMetrics.Meter("metrics",
                "ingest/sec", "In memory documents held by this prefetcher", TimeUnit.Seconds);
            returnedDocsMeter = context.MetricsCounters.DbMetrics.Meter("metrics",
                  "returned docs/sec", "Documents being served by this prefetcher", TimeUnit.Seconds);

            if (isDefault)
            {
                context.Database.TransactionalStorage.Batch(accessor =>
                {
                    recentEtag = accessor.Staleness.GetMostRecentDocumentEtag();
                });
            }
        }
		public PrefetchingBehavior(PrefetchingUser prefetchingUser, WorkContext context, BaseBatchSizeAutoTuner autoTuner)
		{
			this.context = context;
			this.autoTuner = autoTuner;
			PrefetchingUser = prefetchingUser;
			MemoryStatistics.RegisterLowMemoryHandler(this);
		}
Example #3
0
		public PrefetchingBehavior CreatePrefetchingBehavior(PrefetchingUser user, BaseBatchSizeAutoTuner autoTuner)
		{
			lock (this)
			{
				var newPrefetcher = new PrefetchingBehavior(user, workContext, autoTuner ?? new IndependentBatchSizeAutoTuner(workContext));

				prefetchingBehaviors = new List<PrefetchingBehavior>(prefetchingBehaviors)
				{
					newPrefetcher
				};

				return newPrefetcher;
			}
		}
Example #4
0
		public PrefetchingBehavior GetPrefetchingBehavior(PrefetchingUser user, BaseBatchSizeAutoTuner autoTuner)
		{
			PrefetchingBehavior value;
			if (prefetchingBehaviors.TryGetValue(user, out value))
				return value;
			lock (this)
			{
				if (prefetchingBehaviors.TryGetValue(user, out value))
					return value;

				value = new PrefetchingBehavior(workContext, autoTuner ?? new IndependentBatchSizeAutoTuner(workContext));

				prefetchingBehaviors = new Dictionary<PrefetchingUser, PrefetchingBehavior>(prefetchingBehaviors)
				{
					{user, value}
				};
				return value;
			}
		}
Example #5
0
        public PrefetchingBehavior CreatePrefetchingBehavior(PrefetchingUser user, BaseBatchSizeAutoTuner autoTuner, string prefetchingUserDescription, bool isDefault = false)
        {
            lock (this)
            {
                var newPrefetcher = 
                    new PrefetchingBehavior(user, 
                                            workContext, 
                                            autoTuner ?? new IndependentBatchSizeAutoTuner(workContext, user), 
                                            prefetchingUserDescription, 
                                            isDefault,
                                            GetPrefetchintBehavioursCount,
                                            GetPrefetchingBehaviourSummary);

                prefetchingBehaviors = new List<PrefetchingBehavior>(prefetchingBehaviors)
                {
                    newPrefetcher
                };

                return newPrefetcher;
            }
        }
Example #6
0
		public PrefetchingBehavior(WorkContext context, BaseBatchSizeAutoTuner autoTuner)
		{
			this.context = context;
			this.autoTuner = autoTuner;
		}
Example #7
0
 public PrefetchingBehavior(WorkContext context, BaseBatchSizeAutoTuner autoTuner)
 {
     this.context   = context;
     this.autoTuner = autoTuner;
 }