예제 #1
0
        private void AwaitResponse(long correlationId, string expectedChannel)
        {
            _driverException = null;
            var deadlineNs = _nanoClock.NanoTime() + _driverTimeoutNs;

            do
            {
                if (null == _driverAgentInvoker)
                {
                    Aeron.Sleep(1);
                }
                else
                {
                    _driverAgentInvoker.Invoke();
                }

                DoWork(correlationId, expectedChannel);

                if (_driverListener.LastReceivedCorrelationId() == correlationId)
                {
                    if (null != _driverException)
                    {
                        throw _driverException;
                    }

                    return;
                }
            } while (_nanoClock.NanoTime() < deadlineNs);

            throw new DriverTimeoutException("No response from driver wihtout timeout");
        }
예제 #2
0
 protected void InvokeAeronClient()
 {
     if (null != aeronClientInvoker)
     {
         aeronClientInvoker.Invoke();
     }
 }
예제 #3
0
        private void AwaitResponse(long correlationId)
        {
            _driverException = null;
            var nowNs      = _nanoClock.NanoTime();
            var deadlineNs = nowNs + _driverTimeoutNs;

            CheckTimeouts(nowNs);

            _awaitingIdleStrategy.Reset();
            do
            {
                if (null == _driverAgentInvoker)
                {
                    _awaitingIdleStrategy.Idle();
                }
                else
                {
                    _driverAgentInvoker.Invoke();
                }

                Service(correlationId);

                if (_driverEventsAdapter.ReceivedCorrelationId == correlationId)
                {
                    _stashedChannel = null;

                    RegistrationException ex = _driverException;
                    if (null != _driverException)
                    {
                        _driverException = null;
                        throw ex;
                    }

                    return;
                }

                try
                {
                    Thread.Sleep(1);
                }
                catch (ThreadInterruptedException)
                {
                    _isTerminating = true;
                    throw new AgentTerminationException("thread interrupted");
                }
            } while (deadlineNs - _nanoClock.NanoTime() > 0);

            throw new DriverTimeoutException("no response from MediaDriver within (ms):" + _driverTimeoutMs);
        }
예제 #4
0
        private bool OfferWithTimeout(int length, AgentInvoker aeronClientInvoker)
        {
            retryIdleStrategy.Reset();

            long deadlineNs = nanoClock.NanoTime() + connectTimeoutNs;

            while (true)
            {
                long result;
                if ((result = publication.Offer(buffer, 0, MessageHeaderEncoder.ENCODED_LENGTH + length)) > 0)
                {
                    return(true);
                }

                if (null != aeronClientInvoker)
                {
                    aeronClientInvoker.Invoke();
                }

                if (result == Publication.CLOSED)
                {
                    throw new System.InvalidOperationException("connection to the archive has been closed");
                }

                if (result == Publication.MAX_POSITION_EXCEEDED)
                {
                    throw new System.InvalidOperationException("publication failed due to max position being reached");
                }

                if (nanoClock.NanoTime() > deadlineNs)
                {
                    return(false);
                }

                retryIdleStrategy.Idle();
            }
        }
예제 #5
0
 protected void InvokeAgentClient()
 {
     aeronAgentInvoker?.Invoke();
 }
예제 #6
0
 protected void InvokeAeronClient()
 {
     aeronClientInvoker?.Invoke();
 }