Esempio n. 1
0
        static void InitializeECommon()
        {
            _message      = new byte[int.Parse(ConfigurationManager.AppSettings["MessageSize"])];
            _mode         = ConfigurationManager.AppSettings["Mode"];
            _messageCount = int.Parse(ConfigurationManager.AppSettings["MessageCount"]);

            var logContextText = "mode: " + _mode;

            ECommonConfiguration
            .Create()
            .UseAutofac()
            .RegisterCommonComponents()
            .UseLog4Net()
            .RegisterUnhandledExceptionHandler()
            .BuildContainer();

            _logger             = ObjectContainer.Resolve <ILoggerFactory>().Create(typeof(Program).Name);
            _performanceService = ObjectContainer.Resolve <IPerformanceService>();
            var setting = new PerformanceServiceSetting
            {
                AutoLogging            = false,
                StatIntervalSeconds    = 1,
                PerformanceInfoHandler = x =>
                {
                    _logger.InfoFormat("{0}, {1}, totalCount: {2}, throughput: {3}, averageThrughput: {4}, rt: {5:F3}ms, averageRT: {6:F3}ms", _performanceService.Name, logContextText, x.TotalCount, x.Throughput, x.AverageThroughput, x.RT, x.AverageRT);
                }
            };

            _performanceService.Initialize(_performanceKey, setting);
            _performanceService.Start();
        }
Esempio n. 2
0
        static void InitializeEQueue()
        {
            ECommonConfiguration
            .Create()
            .UseAutofac()
            .RegisterCommonComponents()
            .UseLog4Net()
            .UseJsonNet()
            .RegisterUnhandledExceptionHandler()
            .RegisterEQueueComponents()
            .SetDefault <IQueueSelector, QueueAverageSelector>();

            _logger             = ObjectContainer.Resolve <ILoggerFactory>().Create(typeof(Program).Name);
            _performanceService = ObjectContainer.Resolve <IPerformanceService>();
            _mode = ConfigurationManager.AppSettings["Mode"];
            var logContextText = "mode: " + _mode;
            var setting        = new PerformanceServiceSetting
            {
                AutoLogging            = false,
                StatIntervalSeconds    = 1,
                PerformanceInfoHandler = x =>
                {
                    _logger.InfoFormat("{0}, {1}, totalCount: {2}, throughput: {3}, averageThrughput: {4}, rt: {5:F3}ms, averageRT: {6:F3}ms", _performanceService.Name, logContextText, x.TotalCount, x.Throughput, x.AverageThroughput, x.RT, x.AverageRT);
                }
            };

            _performanceService.Initialize("SendMessage", setting).Start();
        }
Esempio n. 3
0
        private void Initialize()
        {
            _client = _fluentSocketFactory.CreateClient(_option.Setting);
            var performanceServiceSetting = new PerformanceServiceSetting
            {
                AutoLogging            = false,
                StatIntervalSeconds    = 1,
                PerformanceInfoHandler = x =>
                {
                    _logger.LogInformation("{0}, {1}, totalCount: {2}, throughput: {3}, averageThrughput: {4}, rt: {5:F3}ms, averageRT: {6:F3}ms", _performanceService.Name, _performanceKey, x.TotalCount, x.Throughput, x.AverageThroughput, x.RT, x.AverageRT);
                }
            };

            _performanceService.Initialize(_performanceKey, performanceServiceSetting);
        }
Esempio n. 4
0
            public RequestHandler()
            {
                _logger             = ObjectContainer.Resolve <ILoggerFactory>().Create(GetType().FullName);
                _performanceService = ObjectContainer.Resolve <IPerformanceService>();
                var setting = new PerformanceServiceSetting
                {
                    AutoLogging            = false,
                    StatIntervalSeconds    = 1,
                    PerformanceInfoHandler = x =>
                    {
                        _logger.InfoFormat("{0}, totalCount: {1}, throughput: {2}, averageThrughput: {3}, rt: {4:F3}ms, averageRT: {5:F3}ms", _performanceService.Name, x.TotalCount, x.Throughput, x.AverageThroughput, x.RT, x.AverageRT);
                    }
                };

                _performanceService.Initialize(_performanceKey, setting);
                _performanceService.Start();
            }
        private void Initialize()
        {
            _server = _fluentSocketFactory.CreateServer(_option.Setting);
            var handler = _serviceProvider.CreateInstance <ServerRequestMessageHandler>();

            _server.RegisterRequestHandler(100, handler);

            var performanceServiceSetting = new PerformanceServiceSetting
            {
                AutoLogging            = false,
                StatIntervalSeconds    = 1,
                PerformanceInfoHandler = x =>
                {
                    _logger.LogInformation("{0}, {1}, totalCount: {2}, throughput: {3}, averageThrughput: {4}, rt: {5:F3}ms, averageRT: {6:F3}ms", _performanceService.Name, _performanceKey, x.TotalCount, x.Throughput, x.AverageThroughput, x.RT, x.AverageRT);
                }
            };

            _performanceService.Initialize(_performanceKey, performanceServiceSetting);
        }
Esempio n. 6
0
        private void Initialize()
        {
            _server = _fluentSocketFactory.CreateServer(_option.Setting);

            var sessionService = _serviceProvider.CreateInstance <CustomSessionService>(new Action <ISocketSession>(session =>
            {
                _socketSession     = session;
                _isClientConnected = true;
            }));

            _server.RegisterSessionService(sessionService);

            var performanceServiceSetting = new PerformanceServiceSetting
            {
                AutoLogging            = false,
                StatIntervalSeconds    = 1,
                PerformanceInfoHandler = x =>
                {
                    _logger.LogInformation("{0}, {1}, totalCount: {2}, throughput: {3}, averageThrughput: {4}, rt: {5:F3}ms, averageRT: {6:F3}ms", _performanceService.Name, _performanceKey, x.TotalCount, x.Throughput, x.AverageThroughput, x.RT, x.AverageRT);
                }
            };

            _performanceService.Initialize(_performanceKey, performanceServiceSetting);
        }