/// <summary>
 ///     Configures an expiry-time cache of the given maximum age in seconds and purge interval in seconds.
 ///     <para />
 ///     Specifies the cache reference type to be weak references. Weak reference cache entries become
 ///     eligible for garbage collection and are removed from cache when the garbage collection requires so.
 /// </summary>
 /// <param name="maxAgeSeconds">
 ///     is the maximum number of seconds before a method invocation result is considered stale
 ///     (also known as time-to-live)
 /// </param>
 /// <param name="purgeIntervalSeconds">is the interval at which the runtime purges stale data from the cache</param>
 public void SetExpiryTimeCache(
     double maxAgeSeconds,
     double purgeIntervalSeconds)
 {
     DataCacheDesc = new ConfigurationCommonCacheExpiryTime(
         maxAgeSeconds,
         purgeIntervalSeconds,
         CacheReferenceType.DEFAULT);
 }
Пример #2
0
        /// <summary>
        /// Creates a cache implementation for the strategy as defined by the cache descriptor.
        /// </summary>
        /// <param name="cacheDesc">cache descriptor</param>
        /// <param name="agentInstanceContext">agent instance context</param>
        /// <param name="streamNum">stream number</param>
        /// <param name="scheduleCallbackId">callback id</param>
        /// <returns>data cache implementation</returns>
        public HistoricalDataCache GetDataCache(
            ConfigurationCommonCache cacheDesc,
            AgentInstanceContext agentInstanceContext,
            int streamNum,
            int scheduleCallbackId)
        {
            if (cacheDesc == null) {
                return new HistoricalDataCacheNullImpl();
            }

            if (cacheDesc is ConfigurationCommonCacheLRU) {
                ConfigurationCommonCacheLRU lruCache = (ConfigurationCommonCacheLRU) cacheDesc;
                return new HistoricalDataCacheLRUImpl(lruCache.Size);
            }

            if (cacheDesc is ConfigurationCommonCacheExpiryTime) {
                ConfigurationCommonCacheExpiryTime expCache = (ConfigurationCommonCacheExpiryTime) cacheDesc;
                return MakeTimeCache(expCache, agentInstanceContext, streamNum, scheduleCallbackId);
            }

            throw new IllegalStateException("Cache implementation class not configured");
        }
        public HistoricalEventViewableMethod(
            HistoricalEventViewableMethodFactory factory,
            PollExecStrategy pollExecStrategy,
            AgentInstanceContext agentInstanceContext)
            : base(factory, pollExecStrategy, agentInstanceContext)

        {
            try {
                ConfigurationCommonMethodRef configCache =
                    agentInstanceContext.ImportServiceRuntime.GetConfigurationMethodRef(factory.ConfigurationName);
                ConfigurationCommonCache dataCacheDesc = configCache != null ? configCache.DataCacheDesc : null;
                this.DataCache = agentInstanceContext.HistoricalDataCacheFactory.GetDataCache(
                    dataCacheDesc,
                    agentInstanceContext,
                    factory.StreamNumber,
                    factory.ScheduleCallbackId);
            }
            catch (EPException) {
                throw;
            }
            catch (Exception e) {
                throw new EPException("Failed to obtain cache: " + e.Message, e);
            }
        }
 /// <summary>
 ///     Configures a LRU cache of the given size for the method invocation.
 /// </summary>
 /// <param name="size">is the maximum number of entries before method invocation results are evicted</param>
 public void SetLRUCache(int size)
 {
     DataCacheDesc = new ConfigurationCommonCacheLRU(size);
 }