Example #1
0
        public ServerActor(
            Resources resources,
            Filters filters,
            int port,
            int dispatcherPoolSize)
        {
            var start = DateExtensions.GetCurrentMillis();

            _filters = filters;
            _world   = Stage.World;
            _requestsMissingContent = new Dictionary <string, RequestResponseHttpContext>();
            _maxMessageSize         = 0;

            try
            {
                _dispatcherPool = new AgentDispatcherPool(Stage, resources, dispatcherPoolSize);

                var end = DateExtensions.GetCurrentMillis();

                Logger.Info($"Server {ServerName} is listening on port: {port} started in {end - start} ms");

                LogResourceMappings(resources);
            }
            catch (Exception e)
            {
                var message = $"Failed to start server because: {e.Message}";
                Logger.Error(message, e);
                throw new InvalidOperationException(message);
            }
        }
Example #2
0
        public ServerActor(
            Resources resources,
            Filters filters,
            int port,
            Configuration.SizingConf sizing,
            Configuration.TimingConf timing,
            string channelMailboxTypeName)
        {
            var start = DateExtensions.GetCurrentMillis();

            _filters = filters;
            _world   = Stage.World;
            _requestsMissingContent = new Dictionary <string, RequestResponseHttpContext>();
            _maxMessageSize         = sizing.MaxMessageSize;

            try
            {
                _responseBufferPool = new ConsumerByteBufferPool(
                    ElasticResourcePool <IConsumerByteBuffer, string> .Config.Of(sizing.MaxBufferPoolSize),
                    sizing.MaxMessageSize);

                _dispatcherPool = new ServerDispatcherPool(Stage, resources, sizing.DispatcherPoolSize);

                _channel =
                    ServerRequestResponseChannelFactory.Start(
                        Stage,
                        Stage.World.AddressFactory.WithHighId(ChannelName),
                        channelMailboxTypeName,
                        this,
                        port,
                        ChannelName,
                        sizing.ProcessorPoolSize,
                        sizing.MaxBufferPoolSize,
                        sizing.MaxMessageSize,
                        timing.ProbeInterval,
                        timing.ProbeTimeout);

                var end = DateExtensions.GetCurrentMillis();

                Logger.Info($"Server {ServerName} is listening on port: {port} started in {end - start} ms");

                _requestMissingContentTimeout = timing.RequestMissingContentTimeout;

                LogResourceMappings(resources);
            }
            catch (Exception e)
            {
                var message = $"Failed to start server because: {e.Message}";
                Logger.Error(message, e);
                throw new InvalidOperationException(message);
            }
        }