Beispiel #1
0
//JAVA TO C# CONVERTER WARNING: 'final' parameters are ignored unless the option to convert to C# 7.2 'in' parameters is selected:
//ORIGINAL LINE: public long receive(final long ticket, final T batch)
        public override long Receive(long ticket, T batch)
        {
            // Don't go too far ahead
            IncrementQueue();
            long nanoTime = nanoTime();

            _executor.submit(sender =>
            {
                AssertHealthy();
                sender.initialize(ticket);
                try
                {
                    long startTime = nanoTime();
                    Process(batch, sender);
                    if (DownstreamConflict == null)
                    {
                        // No batches were emitted so we couldn't track done batches in that way.
                        // We can see that we're the last step so increment here instead
                        DoneBatches.incrementAndGet();
                        Control.recycle(batch);
                    }
                    TotalProcessingTime.add(nanoTime() - startTime - sender.sendTime);

                    DecrementQueue();
                    CheckNotifyEndDownstream();
                }
                catch (Exception e)
                {
                    IssuePanic(e);
                }
            });
            return(nanoTime() - nanoTime);
        }
Beispiel #2
0
 /// <summary>
 /// Called from <seealso cref="process()"/>, reports progress so that statistics are updated appropriately.
 /// </summary>
 /// <param name="amount"> number of items processed since last call to this method. </param>
 protected internal virtual void Progress(long amount)
 {
     _batch += ( int )amount;
     if (_batch >= _batchSize)
     {
         int batches = _batch / _batchSize;
         _batch %= _batchSize;
         DoneBatches.addAndGet(batches);
         long time = nanoTime();
         TotalProcessingTime.add(time - _lastProcessingTimestamp);
         _lastProcessingTimestamp = time;
     }
 }
Beispiel #3
0
        /// <summary>
        /// Forms batches out of some sort of data stream and sends these batches downstream.
        /// </summary>
        protected internal override void Process()
        {
            object batch;

            while (true)
            {
                long startTime = nanoTime();
                batch = NextBatchOrNull(DoneBatches.get(), BatchSize);
                if (batch == null)
                {
                    break;
                }

                TotalProcessingTime.add(nanoTime() - startTime);
                SendDownstream(batch);
                AssertHealthy();
            }
        }