示例#1
0
        public SocketRequestResponseChannelTest(ITestOutputHelper output)
        {
            var converter = new Converter(output);

            Console.SetOut(converter);

            _world = World.StartWithDefaults("test-request-response-channel");

            _buffer = new MemoryStream(1024);
            var logger   = ConsoleLogger.TestInstance();
            var provider = new TestRequestChannelConsumerProvider();

            _serverConsumer = (TestRequestChannelConsumer)provider.Consumer;

            _server = ServerRequestResponseChannelFactory.Start(
                _world.Stage,
                provider,
                _testPort,
                "test-server",
                1,
                PoolSize,
                10240,
                10L);

            _clientConsumer = new TestResponseChannelConsumer();

            _client = new BasicClientRequestResponseChannel(Address.From(Host.Of("localhost"), _testPort, AddressType.None),
                                                            _clientConsumer, PoolSize, 10240, logger);

            ++_testPort;
        }
示例#2
0
        public ServerActor(
            Resources resources,
            Filters filters,
            int port,
            Configuration.SizingConf sizing,
            Configuration.TimingConf timing,
            string channelMailboxTypeName)
        {
            var start = DateExtensions.GetCurrentMillis();

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

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

                _dispatcherPool = new IDispatcher[sizing.DispatcherPoolSize];

                for (int idx = 0; idx < sizing.DispatcherPoolSize; ++idx)
                {
                    _dispatcherPool[idx] = Dispatcher.StartWith(Stage, resources);
                }

                _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);
            }
        }
示例#3
0
 protected override IServerRequestResponseChannel GetServer(Stage stage, IRequestChannelConsumerProvider provider, string name,
                                                            int testPort, int processorPoolSize, int maxBufferPoolSize, int maxMessageSize, long probeInterval, long probeTimeout) =>
 ServerRequestResponseChannelFactory.Start(
     stage,
     provider,
     testPort,
     "test-server",
     processorPoolSize,
     maxBufferPoolSize,
     maxMessageSize,
     probeInterval,
     probeTimeout);
    //=========================================
    // ServerRequestResponseChannel
    //=========================================

    IServerRequestResponseChannel IServerRequestResponseChannel.Start(
        Stage stage,
        IRequestChannelConsumerProvider provider,
        int port,
        string name,
        int processorPoolSize,
        int maxBufferPoolSize,
        int maxMessageSize,
        long probeInterval,
        long probeTimeout)
    {
        return(ServerRequestResponseChannelFactory.Start(stage, provider, port, name, processorPoolSize,
                                                         maxBufferPoolSize, maxMessageSize, probeInterval, probeTimeout));
    }