public ServerRequestResponseChannelActor(
        IRequestChannelConsumerProvider provider,
        int port,
        string name,
        int processorPoolSize,
        int maxBufferPoolSize,
        int maxMessageSize,
        long probeInterval,
        long probeTimeout)
    {
        _name = name;
        _port = port;
        var requestBufferPool = new ConsumerByteBufferPool(ElasticResourcePool <IConsumerByteBuffer, string> .Config.Of(maxBufferPoolSize), maxMessageSize);

        _processors = StartProcessors(provider, name, processorPoolSize, requestBufferPool, probeInterval, probeTimeout);

        try
        {
            Logger.Info($"{GetType().Name}: OPENING PORT: {port}");
            _channel = new Socket(SocketType.Stream, ProtocolType.Tcp);
            _channel.Bind(new IPEndPoint(IPAddress.Any, port));
            _channel.Listen(120);
        }
        catch (Exception e)
        {
            Logger.Error($"Failure opening socket because: {e.Message}", e);
            throw;
        }

        _cancellable = Stage.Scheduler.Schedule(SelfAs <IScheduled <object?> >(),
                                                null, TimeSpan.FromMilliseconds(100), TimeSpan.FromMilliseconds(probeInterval));
    }
示例#2
0
 protected abstract IServerRequestResponseChannel GetServer(
     Stage stage,
     IRequestChannelConsumerProvider provider,
     string name,
     int testPort,
     int processorPoolSize,
     int maxBufferPoolSize,
     int maxMessageSize,
     long probeInterval,
     long probeTimeout);
示例#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);
示例#4
0
 public static IServerRequestResponseChannel Start(
     Stage stage,
     IRequestChannelConsumerProvider provider,
     int port,
     string name,
     int processorPoolSize,
     int maxBufferPoolSize,
     int maxMessageSize,
     long probeInterval,
     long probeTimeout) =>
 stage.ActorFor <IServerRequestResponseChannel>(
     () => new ServerRequestResponseChannelActor(provider, port, name, processorPoolSize, maxBufferPoolSize, maxMessageSize, probeInterval, probeTimeout));
 public IServerRequestResponseChannel Start(Stage stage, IRequestChannelConsumerProvider provider, int port,
                                            string name, int processorPoolSize, int maxBufferPoolSize, int maxMessageSize, long probeInterval)
 {
     return(ServerRequestResponseChannelFactory.Start(
                stage,
                provider,
                port,
                name,
                processorPoolSize,
                maxMessageSize,
                maxMessageSize,
                probeInterval));
 }
示例#6
0
 public SocketChannelSelectionProcessorActor(
     IRequestChannelConsumerProvider provider,
     string name,
     int maxBufferPoolSize,
     int messageBufferSize,
     long probeInterval)
 {
     _provider          = provider;
     _name              = name;
     _messageBufferSize = messageBufferSize;
     _responder         = SelfAs <IResponseSenderChannel <Socket> >();
     _cancellable       = Stage.Scheduler.Schedule(SelfAs <IScheduled <object> >(),
                                                   null, TimeSpan.FromMilliseconds(100), TimeSpan.FromMilliseconds(probeInterval));
 }
示例#7
0
 public static IServerRequestResponseChannel Start(
     Stage stage,
     IAddress address,
     string mailboxName,
     IRequestChannelConsumerProvider provider,
     int port,
     string name,
     int processorPoolSize,
     int maxBufferPoolSize,
     int maxMessageSize,
     long probeInterval,
     long probeTimeout) =>
 stage.ActorFor <IServerRequestResponseChannel>(
     () => new ServerRequestResponseChannelActor(provider, port, name, processorPoolSize,
                                                 maxBufferPoolSize, maxMessageSize, probeInterval, probeTimeout), mailboxName, address.Name, address, stage.World.DefaultLogger);
示例#8
0
 public SocketChannelSelectionProcessorActor(
     IRequestChannelConsumerProvider provider,
     string name,
     IResourcePool <IConsumerByteBuffer, string> requestBufferPool,
     long probeInterval,
     long probeTimeout)
 {
     _provider          = provider;
     _name              = name;
     _requestBufferPool = requestBufferPool;
     _probeTimeout      = probeTimeout;
     _contexts          = new List <Context>();
     _responder         = SelfAs <IResponseSenderChannel>();
     _cancellable       = Stage.Scheduler.Schedule(SelfAs <IScheduled <object?> >(),
                                                   null, TimeSpan.FromMilliseconds(100), TimeSpan.FromMilliseconds(probeInterval));
 }
 IServerRequestResponseChannel IServerRequestResponseChannel.Start(
     Stage stage,
     IAddress address,
     string mailboxName,
     IRequestChannelConsumerProvider provider,
     int port,
     string name,
     int processorPoolSize,
     int maxBufferPoolSize,
     int maxMessageSize,
     long probeInterval,
     long probeTimeout)
 {
     return(ServerRequestResponseChannelFactory.Start(stage, address, mailboxName, provider, port, name, processorPoolSize,
                                                      maxBufferPoolSize, maxMessageSize, probeInterval, probeTimeout));
 }
    private ISocketChannelSelectionProcessor[] StartProcessors(
        IRequestChannelConsumerProvider provider,
        string name,
        int processorPoolSize,
        IResourcePool <IConsumerByteBuffer, string> requestBufferPool,
        long probeInterval,
        long probeTimeout)
    {
        var processors = new ISocketChannelSelectionProcessor[processorPoolSize];

        for (var idx = 0; idx < processors.Length; ++idx)
        {
            processors[idx] = ChildActorFor <ISocketChannelSelectionProcessor>(
                () => new SocketChannelSelectionProcessorActor(provider, $"{name}-processor-{idx}", requestBufferPool, probeInterval, probeTimeout));
        }

        return(processors);
    }
示例#11
0
        public static IServerRequestResponseChannel Start(
            Stage stage,
            IRequestChannelConsumerProvider provider,
            int port,
            string name,
            int processorPoolSize,
            int maxBufferPoolSize,
            int maxMessageSize,
            long probeInterval)
        {
            var parameters = Definition.Parameters(provider, port, name, processorPoolSize, maxBufferPoolSize, maxMessageSize, probeInterval);

            var channel =
                stage.ActorFor <IServerRequestResponseChannel>(
                    Definition.Has <ServerRequestResponseChannelActor>(parameters));

            return(channel);
        }
示例#12
0
        private ISocketChannelSelectionProcessor[] StartProcessors(
            IRequestChannelConsumerProvider provider,
            string name,
            int processorPoolSize,
            int maxBufferPoolSize,
            int maxMessageSize,
            long probeInterval)
        {
            var processors = new ISocketChannelSelectionProcessor[processorPoolSize];

            for (int idx = 0; idx < processors.Length; ++idx)
            {
                processors[idx] = ChildActorFor <ISocketChannelSelectionProcessor>(
                    Definition.Has <SocketChannelSelectionProcessorActor>(
                        Definition.Parameters(provider, $"{name}-processor-{idx}", maxBufferPoolSize, maxMessageSize, probeInterval)));
            }

            return(processors);
        }
示例#13
0
        public static IServerRequestResponseChannel Start(
            Stage stage,
            IAddress address,
            string mailboxName,
            IRequestChannelConsumerProvider provider,
            int port,
            string name,
            int processorPoolSize,
            int maxBufferPoolSize,
            int maxMessageSize,
            long probeInterval,
            long probeTimeout)
        {
            var parameters = Definition.Parameters(provider, port, name, processorPoolSize, maxBufferPoolSize, maxMessageSize, probeInterval, probeTimeout);

            var channel =
                stage.ActorFor <IServerRequestResponseChannel>(
                    Definition.Has <ServerRequestResponseChannelActor>(parameters, mailboxName, address.Name),
                    address, stage.World.DefaultLogger);

            return(channel);
        }