예제 #1
0
        public SyncEndpointExecutor(Endpoint endpoint, ICheckpointer checkpointer, EndpointExecutorConfig config)
        {
            Preconditions.CheckNotNull(endpoint);
            Preconditions.CheckNotNull(config);

            this.checkpointer = Preconditions.CheckNotNull(checkpointer);
            this.machine      = new EndpointExecutorFsm(endpoint, checkpointer, config);
            this.cts          = new CancellationTokenSource();
            this.closed       = new AtomicBoolean();
            this.sync         = new AsyncLock();
        }
 public StoringAsyncEndpointExecutor(Endpoint endpoint,
                                     ICheckpointer checkpointer,
                                     EndpointExecutorConfig config,
                                     AsyncEndpointExecutorOptions options,
                                     IMessageStore messageStore)
 {
     Preconditions.CheckNotNull(endpoint);
     Preconditions.CheckNotNull(config);
     this.checkpointer    = Preconditions.CheckNotNull(checkpointer);
     this.options         = Preconditions.CheckNotNull(options);
     this.machine         = new EndpointExecutorFsm(endpoint, checkpointer, config);
     this.messageStore    = messageStore;
     this.sendMessageTask = Task.Run(this.SendMessagesPump);
 }
예제 #3
0
 public StoringAsyncEndpointExecutor(
     Endpoint endpoint,
     ICheckpointerFactory checkpointerFactory,
     EndpointExecutorConfig config,
     AsyncEndpointExecutorOptions options,
     IMessageStore messageStore)
 {
     this.Endpoint            = Preconditions.CheckNotNull(endpoint);
     this.checkpointerFactory = Preconditions.CheckNotNull(checkpointerFactory);
     this.config           = Preconditions.CheckNotNull(config);
     this.options          = Preconditions.CheckNotNull(options);
     this.messageStore     = messageStore;
     this.sendMessageTask  = Task.Run(this.SendMessagesPump);
     this.prioritiesToFsms = new AtomicReference <ImmutableDictionary <uint, EndpointExecutorFsm> >(ImmutableDictionary <uint, EndpointExecutorFsm> .Empty);
 }
        public StoringAsyncEndpointExecutor(
            Endpoint endpoint,
            IList <uint> priorities,
            ICheckpointer checkpointer,
            EndpointExecutorConfig config,
            AsyncEndpointExecutorOptions options,
            IMessageStore messageStore)
        {
            Preconditions.CheckNotNull(endpoint);
            Preconditions.CheckNotNull(config);
            Preconditions.CheckNotNull(priorities);
            Preconditions.CheckArgument(priorities.Count != 0);
            this.checkpointer    = Preconditions.CheckNotNull(checkpointer);
            this.options         = Preconditions.CheckNotNull(options);
            this.machine         = new EndpointExecutorFsm(endpoint, checkpointer, config);
            this.messageStore    = messageStore;
            this.sendMessageTask = Task.Run(this.SendMessagesPump);

            this.UpdatePriorities(priorities);
        }
예제 #5
0
        public AsyncEndpointExecutor(Endpoint endpoint, ICheckpointer checkpointer, EndpointExecutorConfig config, AsyncEndpointExecutorOptions options)
        {
            Preconditions.CheckNotNull(endpoint);
            Preconditions.CheckNotNull(config);
            this.checkpointer = Preconditions.CheckNotNull(checkpointer);
            this.cts          = new CancellationTokenSource();
            this.options      = Preconditions.CheckNotNull(options);
            this.machine      = new EndpointExecutorFsm(endpoint, checkpointer, config);
            this.closed       = new AtomicBoolean();

            // The three size variables below adjust the following parameters:
            //    1. MaxMessagesPerTask - the maximum number of messages the batch block will process before yielding
            //    2. BoundedCapacity - the size of the batch blocks input buffer
            //    3. BatchBlock ctor - the maximum size of each batch emitted by the block (can be smaller because of the timer)
            var batchOptions = new GroupingDataflowBlockOptions
            {
                MaxMessagesPerTask = MaxMessagesPerTask,
                BoundedCapacity    = options.BatchSize
            };
            var batchBlock = new BatchBlock <IMessage>(options.BatchSize, batchOptions);

            this.batchTimer = new Timer(Trigger, batchBlock, options.BatchTimeout, options.BatchTimeout);

            var processOptions = new ExecutionDataflowBlockOptions
            {
                BoundedCapacity = 1
            };
            var process = new ActionBlock <IMessage[]>(this.MessagesAction, processOptions);

            var linkOptions = new DataflowLinkOptions {
                PropagateCompletion = true
            };

            batchBlock.LinkTo(process, linkOptions);

            this.head = batchBlock;
            this.tail = process;
        }
예제 #6
0
        public Task <IEndpointExecutor> CreateAsync(Endpoint endpoint, IList <uint> _, ICheckpointer checkpointer, EndpointExecutorConfig endpointExecutorConfig)
        {
            IEndpointExecutor executor = new SyncEndpointExecutor(endpoint, checkpointer, endpointExecutorConfig);

            return(Task.FromResult(executor));
        }
예제 #7
0
 public SyncEndpointExecutorFactory(EndpointExecutorConfig config)
 {
     this.config = Preconditions.CheckNotNull(config);
 }
        public Task <IEndpointExecutor> CreateAsync(Endpoint endpoint, ICheckpointer checkpointer, EndpointExecutorConfig endpointExecutorConfig)
        {
            IEndpointExecutor executor = new AsyncEndpointExecutor(endpoint, checkpointer, endpointExecutorConfig, this.options);

            return(Task.FromResult(executor));
        }
 public AsyncEndpointExecutorFactory(EndpointExecutorConfig config, AsyncEndpointExecutorOptions options)
 {
     this.config  = Preconditions.CheckNotNull(config);
     this.options = Preconditions.CheckNotNull(options);
 }
예제 #10
0
        public async Task <IEndpointExecutor> CreateAsync(Endpoint endpoint, IList <uint> _, ICheckpointerFactory checkpointerFactory, EndpointExecutorConfig endpointExecutorConfig)
        {
            ICheckpointer checkpointer = await checkpointerFactory.CreateAsync(endpoint.Id);

            IEndpointExecutor executor = new AsyncEndpointExecutor(endpoint, checkpointer, endpointExecutorConfig, this.options);

            return(executor);
        }
예제 #11
0
        public async Task <IEndpointExecutor> CreateAsync(Endpoint endpoint, ICheckpointer checkpointer, EndpointExecutorConfig endpointExecutorConfig)
        {
            Preconditions.CheckNotNull(endpoint, nameof(endpoint));
            Preconditions.CheckNotNull(checkpointer, nameof(checkpointer));
            Preconditions.CheckNotNull(endpointExecutorConfig, nameof(endpointExecutorConfig));

            await this.messageStore.AddEndpoint(endpoint.Id);

            IEndpointExecutor endpointExecutor = new StoringAsyncEndpointExecutor(endpoint, checkpointer, endpointExecutorConfig, this.options, this.messageStore);

            return(endpointExecutor);
        }
예제 #12
0
 public StoringAsyncEndpointExecutorFactory(EndpointExecutorConfig config, AsyncEndpointExecutorOptions options, IMessageStore messageStore)
 {
     this.config       = Preconditions.CheckNotNull(config, nameof(config));
     this.options      = Preconditions.CheckNotNull(options, nameof(options));
     this.messageStore = Preconditions.CheckNotNull(messageStore, nameof(messageStore));
 }
예제 #13
0
        public async Task <IEndpointExecutor> CreateAsync(Endpoint endpoint, IList <uint> priorities, ICheckpointerFactory checkpointerFactory, EndpointExecutorConfig endpointExecutorConfig)
        {
            Preconditions.CheckNotNull(endpoint, nameof(endpoint));
            Preconditions.CheckNotNull(checkpointerFactory, nameof(checkpointerFactory));
            Preconditions.CheckNotNull(endpointExecutorConfig, nameof(endpointExecutorConfig));

            var endpointExecutor = new StoringAsyncEndpointExecutor(endpoint, checkpointerFactory, endpointExecutorConfig, this.options, this.messageStore);
            await endpointExecutor.UpdatePriorities(priorities, Option.None <Endpoint>());

            return(endpointExecutor);
        }