Exemplo n.º 1
0
        private long lastNumHits;           // for stats

        internal AdaptiveDirectoryCacheMaintainer(
            LocalGrainDirectory router,
            AdaptiveGrainDirectoryCache <TValue> cache,
            Func <List <ActivationAddress>, TValue> updateFunc,
            IInternalGrainFactory grainFactory,
            ExecutorService executorService,
            ILoggerFactory loggerFactory)
            : base(executorService, loggerFactory)
        {
            this.updateFunc   = updateFunc;
            this.grainFactory = grainFactory;
            this.router       = router;
            this.cache        = cache;

            lastNumAccesses = 0;
            lastNumHits     = 0;
            OnFault         = FaultBehavior.RestartOnFault;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Gets the list of grains (all owned by the same silo) and produces a new list
        /// of tuples, where each tuple holds the grain and its generation counter currently stored in the cache
        /// </summary>
        /// <param name="grains">List of grains owned by the same silo</param>
        /// <returns>List of grains in input along with their generation counters stored in the cache </returns>
        private List <Tuple <GrainId, int> > BuildGrainAndETagList(IEnumerable <GrainId> grains)
        {
            var grainAndETagList = new List <Tuple <GrainId, int> >();

            foreach (GrainId grain in grains)
            {
                // NOTE: should this be done with TryGet? Won't Get invoke the LRU getter function?
                AdaptiveGrainDirectoryCache <TValue> .GrainDirectoryCacheEntry entry = cache.Get(grain);

                if (entry != null)
                {
                    grainAndETagList.Add(new Tuple <GrainId, int>(grain, entry.ETag));
                }
                else
                {
                    // this may happen only if the LRU cache is full and decided to drop this grain
                    // while we try to refresh it
                    Log.Warn(ErrorCode.Runtime_Error_100199, "Grain {0} disappeared from the cache during maintainance", grain);
                }
            }

            return(grainAndETagList);
        }