Exemple #1
0
        private int CheckLiveness(long nowNs)
        {
            if ((_timeOfLastKeepAliveNs + _keepAliveIntervalNs) - nowNs < 0)
            {
                long lastKeepAliveMs = _driverProxy.TimeOfLastDriverKeepaliveMs();

                if (_epochClock.Time() > (lastKeepAliveMs + _driverTimeoutMs))
                {
                    _isTerminating = true;
                    ForceCloseResources();

                    long keepAliveAgeMs = _epochClock.Time() - lastKeepAliveMs;

                    throw new DriverTimeoutException("MediaDriver keepalive age exceeded (ms): timeout= " +
                                                     _driverTimeoutMs + ", actual=" + keepAliveAgeMs);
                }

                _driverProxy.SendClientKeepalive();
                _timeOfLastKeepAliveNs = nowNs;

                return(1);
            }

            return(0);
        }
Exemple #2
0
        private int OnCheckTimeouts()
        {
            int  workCount = 0;
            long nowNs     = _nanoClock.NanoTime();

            if (nowNs < (_timeOfLastWorkNs + Aeron.IdleSleepNs))
            {
                return(workCount);
            }

            if (nowNs > (_timeOfLastWorkNs + _interServiceTimeoutNs))
            {
                OnClose();

                throw new ConductorServiceTimeoutException("Timeout between service calls over " + _interServiceTimeoutNs + "ns");
            }

            _timeOfLastWorkNs = nowNs;

            if (nowNs > (_timeOfLastKeepaliveNs + _keepAliveIntervalNs))
            {
                _driverProxy.SendClientKeepalive();
                CheckDriverHeartbeat();

                _timeOfLastKeepaliveNs = nowNs;
                workCount++;
            }

            if (nowNs > (_timeOfLastCheckResourcesNs + RESOURCE_TIMEOUT_NS))
            {
                List <IManagedResource> lingeringResources = _lingeringResources;
                for (int lastIndex = lingeringResources.Count - 1, i = lastIndex; i >= 0; i--)
                {
                    IManagedResource resource = lingeringResources[i];
                    if (nowNs > (resource.TimeOfLastStateChange() + RESOURCE_LINGER_NS))
                    {
                        ListUtil.FastUnorderedRemove(lingeringResources, i, lastIndex);
                        lastIndex--;
                        resource.Delete();
                    }
                }

                _timeOfLastCheckResourcesNs = nowNs;
                workCount++;
            }

            return(workCount);
        }
Exemple #3
0
        private int checkLiveness(long nowNs)
        {
            if (nowNs > (_timeOfLastKeepAliveNs + _keepAliveIntervalNs))
            {
                if (_epochClock.Time() > (_driverProxy.TimeOfLastDriverKeepaliveMs() + _driverTimeoutMs))
                {
                    OnClose();

                    throw new DriverTimeoutException("MediaDriver keepalive older than (ms): " + _driverTimeoutMs);
                }

                _driverProxy.SendClientKeepalive();
                _timeOfLastKeepAliveNs = nowNs;

                return(1);
            }

            return(0);
        }
Exemple #4
0
        private int OnCheckTimeouts()
        {
            var now    = _nanoClock.NanoTime();
            var result = 0;

            if (now > (_timeOfLastWork + _interServiceTimeoutNs))
            {
                OnClose();

                throw new ConductorServiceTimeoutException($"Timeout between service calls over {_interServiceTimeoutNs:D}ns");
            }

            _timeOfLastWork = now;

            if (now > (_timeOfLastKeepalive + _keepAliveIntervalNs))
            {
                _driverProxy.SendClientKeepalive();
                CheckDriverHeartbeat();

                _timeOfLastKeepalive = now;
                result++;
            }

            if (now > _timeOfLastCheckResources + ResourceTimeoutNs)
            {
                for (var i = _lingeringResources.Count - 1; i >= 0; i--)
                {
                    var resource = _lingeringResources[i];
                    if (now > (resource.TimeOfLastStateChange() + ResourceLingerNs))
                    {
                        _lingeringResources.RemoveAt(i);
                        resource.Delete();
                    }
                }

                _timeOfLastCheckResources = now;
                result++;
            }

            return(result);
        }
Exemple #5
0
        private int CheckLiveness(long nowNs)
        {
            if ((_timeOfLastKeepAliveNs + _keepAliveIntervalNs) - nowNs < 0)
            {
                if (_epochClock.Time() > (_driverProxy.TimeOfLastDriverKeepaliveMs() + _driverTimeoutMs))
                {
                    _isTerminating = true;

                    ForceCloseResources();
                    Thread.Yield();

                    throw new DriverTimeoutException("MediaDriver keepalive older than (ms): " + _driverTimeoutMs);
                }

                _driverProxy.SendClientKeepalive();
                _timeOfLastKeepAliveNs = nowNs;

                return(1);
            }

            return(0);
        }