Exemplo n.º 1
0
        private async Task <bool> CheckCounter(IBatchProducerGrain producer, ISampleStreaming_ConsumerGrain consumer, bool assertIsTrue)
        {
            var numProduced = await producer.GetNumberProduced();

            var numConsumed = await consumer.GetNumberConsumed();

            return(await CheckCounter(numProduced, numConsumed, assertIsTrue));
        }
Exemplo n.º 2
0
        private async Task <bool> CheckCounter(IBatchProducerGrain producer, IMultipleSubscriptionConsumerGrain consumer,
                                               StreamSubscriptionHandle <int> handler, bool assertIsTrue)
        {
            var numProduced = await producer.GetNumberProduced();

            var consumers = await consumer.GetNumberConsumed();

            var numConsumed = consumers[handler];

            _logger.Info("Checking now for handler for stream: {0}", handler.StreamIdentity.ToString());

            return(await CheckCounter(numProduced, numConsumed, assertIsTrue));
        }
Exemplo n.º 3
0
        private async Task <bool> CheckCounter(IBatchProducerGrain producer, IMultipleSubscriptionConsumerGrain consumer, int consumersCount,
                                               bool assertIsTrue)
        {
            var numProduced = await producer.GetNumberProduced();

            var numConsumed = await consumer.GetNumberConsumed();

            if (assertIsTrue)
            {
                Assert.IsTrue(numProduced > 0, "No messages produced");
                Assert.AreEqual(consumersCount, numConsumed.Count, "Number of consumers is incorrect");

                foreach (int consumed in numConsumed.Values)
                {
                    Assert.AreEqual(numProduced, consumed, "Produced and consumed counts do not match");
                }
            }
            else if (numProduced <= 0 ||
                     numConsumed.Count != consumersCount ||
                     numConsumed.Values.Any(consumed => consumed != numProduced))
            {
                if (numProduced <= 0)
                {
                    _logger.Info("Noting produced yet..");
                }
                if (numConsumed.Count != consumersCount)
                {
                    _logger.Info("Consumer num doesn't match yet..");
                }
                foreach (var consumed in numConsumed.Values)
                {
                    if (consumed != numProduced)
                    {
                        _logger.Info("numProduced != consumed: Produced and consumed counts do not match. numProduced = {0}, consumed = {1}",
                                     numProduced, consumed);
                    }
                }

                return(false);
            }

            _logger.Info("All counts are equal. numProduced = {0}, consumersCount = {1}, Total consumed = {2}", numProduced, consumersCount, numConsumed.Values.Sum());

            return(true);
        }
        private async Task<bool> CheckCounter(IBatchProducerGrain producer, IMultipleSubscriptionConsumerGrain consumer, int consumersCount,
            bool assertIsTrue)
        {
            var numProduced = await producer.GetNumberProduced();
            var numConsumed = await consumer.GetNumberConsumed();

            if (assertIsTrue)
            {
                Assert.IsTrue(numProduced > 0, "No messages produced");
                Assert.AreEqual(consumersCount, numConsumed.Count, "Number of consumers is incorrect" );

                foreach (int consumed in numConsumed.Values)
                {
                    Assert.AreEqual(numProduced, consumed, "Produced and consumed counts do not match");
                }
            }
            else if (numProduced <= 0 ||
                     numConsumed.Count != consumersCount ||
                     numConsumed.Values.Any(consumed => consumed != numProduced))
            {
                if (numProduced <= 0)
                {
                    _logger.Info("Noting produced yet..");
                }
                if (numConsumed.Count != consumersCount)
                {
                    _logger.Info("Consumer num doesn't match yet..");
                }
                foreach (var consumed in numConsumed.Values)
                {
                    if (consumed != numProduced)
                    {
                        _logger.Info("numProduced != consumed: Produced and consumed counts do not match. numProduced = {0}, consumed = {1}",
                            numProduced, consumed);
                    }
                }

                return false;
            }

            _logger.Info("All counts are equal. numProduced = {0}, consumersCount = {1}, Total consumed = {2}", numProduced, consumersCount, numConsumed.Values.Sum());

            return true;
        }
        private async Task<bool> CheckCounter(IBatchProducerGrain producer, IConsumerGrain consumer, bool assertIsTrue)
        {
            var numProduced = await producer.GetNumberProduced();
            var numConsumed = await consumer.GetNumberConsumed();

            return await CheckCounter(numProduced, numConsumed, assertIsTrue);
        }
        private async Task<bool> CheckCounter(IBatchProducerGrain producer, IMultipleSubscriptionConsumerGrain consumer,
            StreamSubscriptionHandle<int> handler, bool assertIsTrue)
        {
            var numProduced = await producer.GetNumberProduced();
            var consumers = await consumer.GetNumberConsumed();
            var numConsumed = consumers[handler];
            
            _logger.Info("Checking now for handler for stream: {0}", handler.StreamIdentity.ToString());

            return await CheckCounter(numProduced, numConsumed, assertIsTrue);
        }