Example #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);
        }
Example #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @SuppressWarnings("unchecked") private org.neo4j.util.concurrent.AsyncApply sendDownstream(long ticket, Object batch, org.neo4j.util.concurrent.AsyncApply downstreamAsync)
        private AsyncApply SendDownstream(long ticket, object batch, AsyncApply downstreamAsync)
        {
            if (Guarantees(Step_Fields.ORDER_SEND_DOWNSTREAM))
            {
                AsyncApply async = DownstreamWorkSync.applyAsync(new SendDownstream(ticket, batch, DownstreamIdleTime));
                if (downstreamAsync != null)
                {
                    try
                    {
                        downstreamAsync.Await();
                        async.Await();
                        return(null);
                    }
                    catch (ExecutionException e)
                    {
                        IssuePanic(e.InnerException);
                    }
                }
                else
                {
                    return(async);
                }
            }
            else
            {
                DownstreamIdleTime.add(DownstreamConflict.receive(ticket, batch));
                DoneBatches.incrementAndGet();
            }
            return(null);
        }