예제 #1
0
        public async Task polling_client_should_not_miss_data(int parallelism, bool autopolling)
        {
            _logger.LogDebug("Starting with {Parallelism} workers and Autopolling {Autopolling}", parallelism, autopolling);

            var sequenceChecker = new StrictSequenceChecker($"Workers {parallelism} autopolling {autopolling}");
            var poller          = new PollingClient(Store, 0, sequenceChecker, this.LoggerFactory)
            {
                PollingIntervalMilliseconds = 0,
                HoleDetectionTimeout        = 1000
            };

            if (autopolling)
            {
                poller.Start();
                _logger.LogDebug("Started Polling");
            }

            const int range = 1000;

            var producer = new ActionBlock <int>(async i =>
            {
                await Store.AppendAsync("p", i, "demo", "op#" + i).ConfigureAwait(false);
            }, new ExecutionDataflowBlockOptions()
            {
                MaxDegreeOfParallelism = parallelism
            });

            _logger.LogDebug("Started pushing data: {elements} elements", range);

            foreach (var i in Enumerable.Range(1, range))
            {
                Assert.True(await producer.SendAsync(i).ConfigureAwait(false));
            }

            producer.Complete();
            await producer.Completion.ConfigureAwait(false);

            _logger.LogDebug("Data pushed");

            if (autopolling)
            {
                _logger.LogDebug("Stopping poller");
                await poller.Stop();

                _logger.LogDebug("Poller stopped");
            }

            // read to end
            _logger.LogDebug("Polling to end");
            var timeout = new CancellationTokenSource(60000);
            await poller.Poll(timeout.Token).ConfigureAwait(false);

            _logger.LogDebug("Polling to end - done");

            Assert.True(poller.Position == sequenceChecker.Position, "Sequence " + sequenceChecker.Position + " != Position " + poller.Position);
            Assert.True(range == poller.Position, "Poller @" + poller.Position);
            Assert.True(range == sequenceChecker.Position, "Sequence @" + sequenceChecker.Position);
        }
예제 #2
0
        public async Task should_read_from_position(long start, long expected)
        {
            await Store.AppendAsync("a", 1, "1").ConfigureAwait(false);

            await Store.AppendAsync("a", 2, "2").ConfigureAwait(false);

            await Store.AppendAsync("a", 3, "3").ConfigureAwait(false);

            var recorder = new AllPartitionsRecorder();
            var client   = new PollingClient(Store, start, recorder, LoggerFactory);

            await client.Poll(5000).ConfigureAwait(false);

            Assert.Equal(expected, recorder.Length);
        }
예제 #3
0
        //		[InlineData(3, 3)] @@TODO enable tombstone!
        public async Task poller_should_skip_missing_chunks(long missing, long expected)
        {
            await Store.AppendAsync("a", 1, "1").ConfigureAwait(false);

            await Store.AppendAsync("a", 2, "2").ConfigureAwait(false);

            await Store.AppendAsync("a", 3, "3").ConfigureAwait(false);

            await Store.DeleteAsync("a", missing, missing).ConfigureAwait(false);

            var recored = new AllPartitionsRecorder();
            var poller  = new PollingClient(Store, 0, recored, this.LoggerFactory)
            {
                HoleDetectionTimeout = 100
            };

            var cts = new CancellationTokenSource(20000);

            await poller.Poll(cts.Token).ConfigureAwait(false);

            await poller.Poll(cts.Token).ConfigureAwait(false);

            Assert.Equal(expected, poller.Position);
        }
예제 #4
0
 public Task PollToEnd()
 {
     return(_poller.Poll());
 }
예제 #5
0
 /// <summary>
 /// Add a manual poll command, this is an async function so it return
 /// Task.
 /// </summary>
 public Task PollAsync()
 {
     //Add poll command if there are no other poll command in queuel
     return(_innerClient.Poll());
 }
예제 #6
0
 public void Poll()
 {
     _pollingClient.Poll();
 }