예제 #1
0
 public PerformanceCounterInterceptor(CustomPerformanceCounterManager performanceCounterManager)
 {
     _PerformanceManager = performanceCounterManager;
 }
예제 #2
0
        /// <summary>
        /// Fires when the windows service starts.
        /// </summary>
        /// <param name="args">The arguments passed, if any.</param>
        protected override void OnStart(string[] args)
        {
            _logger.Info("Cache Host is starting", "Cache Host is starting");

            // Configure the thread pool's minimum threads
            ThreadPool.SetMinThreads(128, 128);

            _logger.Info("Cache Host is starting", "Verifying settings");

            try
            {
                var port = CacheHostConfigurationSection.Settings.Port;

                // Configure the custom performance counter manager
                var customPerformanceCounterManager = new CustomPerformanceCounterManager(string.Format("port:{0}", port), false);

                // Initialize the mem cache container instance
                var physicalMemoryLimitPercentage = CacheHostConfigurationSection.Settings.CacheMemoryLimitPercentage;

                IMemCache memCache;
                var memoryCache = new MemCache("Dache", physicalMemoryLimitPercentage, customPerformanceCounterManager);

                if (CacheHostConfigurationSection.Settings.StorageProvider == typeof(GZipMemCache))
                {
                    memCache = new GZipMemCache(memoryCache);
                }
                else
                {
                    memCache = memoryCache;
                }

                // Initialize the tag routing table
                var tagRoutingTable = new TagRoutingTable();

                // Initialize the cache host server
                var maximumConnections = CacheHostConfigurationSection.Settings.MaximumConnections;
                var cacheHostServer = new CacheHostServer(memCache, tagRoutingTable, port, maximumConnections, 1024);

                // Initialize the cache host information poller
                var cacheHostInformationPoller = new CacheHostInformationPoller(memCache, customPerformanceCounterManager, 1000);

                // Instantiate the cache host engine
                _cacheHostEngine = new CacheHostEngine(cacheHostInformationPoller, cacheHostServer);
            }
            catch (Exception ex)
            {
                // The inner exception has the actual details of the configuration error
                if (ex.InnerException != null && ex.InnerException.Message != null && ex.InnerException.Message.StartsWith("The value for the property", StringComparison.OrdinalIgnoreCase))
                {
                    ex = ex.InnerException;
                }

                // Log the error
                _logger.Error("Cache Host failed to start", ex.Message);

                // Stop the service
                Stop();
            }

            _logger.Info("Cache Host is starting", "Settings verified successfully");

            _cacheHostEngine.Start();
        }
예제 #3
0
 public abstract void ApplyPerformanceCounter(CustomPerformanceCounterManager manager);