public int DoWork()
        {
            int workCount = 0;

            if (CheckForClockTick())
            {
                PollServiceAdapter();
                workCount += 1;
            }

            if (null != logAdapter)
            {
                int polled = logAdapter.Poll();

                if (0 == polled)
                {
                    if (logAdapter.IsDone())
                    {
                        logAdapter.Dispose();
                        logAdapter = null;
                    }
                }

                workCount += polled;
            }

            return(workCount);
        }
Exemple #2
0
        public int DoWork()
        {
            int workCount = 0;

            if (CheckForClockTick())
            {
                PollServiceAdapter();
                workCount += 1;
            }

            if (null != logAdapter)
            {
                int polled = logAdapter.Poll();

                if (0 == polled)
                {
                    if (logAdapter.IsConsumed(aeron.CountersReader()))
                    {
                        _consensusModuleProxy.Ack(logAdapter.Position(), ackId++, serviceId);
                        logAdapter.Dispose();
                        logAdapter = null;
                    }
                    else if (logAdapter.IsImageClosed())
                    {
                        logAdapter.Dispose();
                        logAdapter = null;
                    }
                }

                workCount += polled;
            }

            return(workCount);
        }
        private void ConsumeImage(Image image, BoundedLogAdapter adapter)
        {
            while (true)
            {
                int workCount = adapter.Poll();
                if (workCount == 0)
                {
                    if (adapter.IsConsumed(aeron.CountersReader()))
                    {
                        _consensusModuleProxy.Ack(image.Position(), ackId++, serviceId);
                        break;
                    }

                    if (image.Closed)
                    {
                        throw new ClusterException("unexpected close of replay");
                    }
                }

                Idle(workCount);
            }
        }
Exemple #4
0
        public int DoWork()
        {
            int workCount = 0;

            long nowMs = epochClock.Time();

            if (cachedEpochClock.Time() != nowMs)
            {
                cachedEpochClock.Update(nowMs);
                markFile.UpdateActivityTimestamp(nowMs);
                CheckHealthAndUpdateHeartbeat(nowMs);
                workCount += serviceControlAdapter.Poll();

                if (newActiveLogEvent != null)
                {
                    JoinActiveLog();
                }
            }

            workCount += null != logAdapter?logAdapter.Poll() : 0;

            return(workCount);
        }
Exemple #5
0
        private void ConsumeImage(Image image, BoundedLogAdapter adapter)
        {
            while (true)
            {
                int workCount = adapter.Poll();
                if (workCount == 0)
                {
                    if (image.Closed)
                    {
                        if (!image.IsEndOfStream())
                        {
                            throw new InvalidOperationException("unexpected close of replay");
                        }

                        break;
                    }

                    CheckInterruptedStatus();
                }

                idleStrategy.Idle(workCount);
            }
        }
Exemple #6
0
        public int DoWork()
        {
            int workCount = 0;

            if (CheckForClockTick())
            {
                PollServiceAdapter();
                workCount += 1;
            }

            if (null != logAdapter.Image())
            {
                int polled = logAdapter.Poll(commitPosition.Get());
                if (0 == polled && logAdapter.IsDone())
                {
                    CloseLog();
                }

                workCount += polled;
            }

            return(workCount);
        }