Exemplo n.º 1
0
        protected override void CreateCacheHierarchy(CacheCapacity[] cacheCapacityList)
        {
            if (cacheCapacityList.Length != 2)
            {
                throw new Exception("CapacityList doesn't match SchedulerType");
            }

            RAMCache ram = new RAMCache(CacheMediumType.RAM.ToString(), cacheCapacityList[0], this.logger);

            FileCache file = new FileCache(CacheMediumType.File.ToString(), cacheCapacityList[1], this.logger);

            ram.PreviousCacheMedium = null;
            ram.NextCacheMedium = file;

            file.PreviousCacheMedium = ram;
            file.NextCacheMedium = null;

            this.mediums.Add(ram);

            this.mediums.Add(file);

            if (this.logger != null)
            {
                this.logger.Log("First medium is RAM, second medum is File.", Category.Debug, Priority.Low);
            }
        }
Exemplo n.º 2
0
        public MediumConfiguration(CacheMediumType type, CacheCapacity capacity, IReplacementAlgorithm algorithm)
        {
            this.type = type;

            this.capacity = capacity;

            this.algorithm = algorithm;
        }
Exemplo n.º 3
0
        public RAMCache(string name, CacheCapacity capacity, ILoggerFacade logger)
            : base(name, capacity, logger)
        {
            // if there is no capacity parameter initialized, do not use cache
            if (this.Capacity.IsEmpty() == true)
            {
                throw new Exception("Cache capacity is not initialized.");
            }

            this.cacheDictionary = new Dictionary<CacheKey, CacheValue>();
        }
Exemplo n.º 4
0
        public CacheMediumBase(string name, CacheCapacity capacity, ILoggerFacade logger)
        {
            this.logger = logger;

            if (this.logger != null)
            {
                this.logger.Log("Cache medium " + name + " instance is created.", Category.Info, Priority.Medium);
            }

            this.Capacity = capacity;

            this.name = name;
            this.algorithm = null;

            this.next = null;
            this.previous = null;

            this.algorithmData = new AlgorithmData();

            this.rwLock = new object();
        }
        private static CacheCapacity ParseCacheCapacity(XmlNode node)
        {
            XmlAttributeCollection attributes = node.Attributes;
            if (attributes == null || attributes.Count != 1)
            {
                throw new Exception("Capacity element is invalid.");
            }            

            if (attributes[0].Name == "Type")
            {
                CacheCapacity capacity = new CacheCapacity((Primary)Enum.Parse(typeof(Primary), attributes[0].Value));
                capacity.Count = long.Parse(node.InnerText);

                return capacity;
            }

            return null;
        }
Exemplo n.º 6
0
 public FileCache(string name,CacheCapacity capacity, ILoggerFacade logger)
     : base(name, capacity, logger)
 {
 }
Exemplo n.º 7
0
 public void UpdateCacheCapacity(CacheCapacity capacity)
 {
     this.capacity = capacity;
 }
Exemplo n.º 8
0
 protected abstract void CreateCacheHierarchy(CacheCapacity[] cacheCapacityList);