aeron-samples/src/main/java/io/aeron/samples/BacklogStat.java
public void print(final PrintStream out)
    {
        final StringBuilder builder = new StringBuilder();

        for (final Map.Entry<StreamCompositeKey, StreamBacklog> entry : snapshot().entrySet())
        {
            builder.setLength(0);
            final StreamCompositeKey key = entry.getKey();

            builder
                .append("sessionId=").append(key.sessionId())
                .append(" streamId=").append(key.streamId())
                .append(" channel=").append(key.channel())
                .append(" : ");


            final StreamBacklog streamBacklog = entry.getValue();
            if (streamBacklog.publisher() != null)
            {
                builder
                    .append("\n┌─for publisher ")
                    .append(streamBacklog.publisher().registrationId())
                    .append(" the last sampled position is ")
                    .append(streamBacklog.publisher().position())
                    .append(" (~")
                    .append(streamBacklog.publisher().remainingWindow())
                    .append(" bytes before back-pressure)");

                final Sender sender = streamBacklog.sender();
                if (sender != null)
                {
                    final long senderBacklog = sender.backlog(streamBacklog.publisher().position());

                    builder.append("\n└─sender ").append(sender.registrationId());

                    if (senderBacklog >= 0)
                    {
                        builder.append(" has to send ").append(senderBacklog).append(" bytes");
                    }
                    else
                    {
                        builder.append(" is at position ").append(sender.position());
                    }

                    builder.append(" (").append(sender.window()).append(" bytes remaining in the sender window)");
                }
                else
                {
                    builder.append("\n└─no sender yet...");
                }
            }

            if (streamBacklog.receiver() != null)
            {
                builder
                    .append("\n┌─receiver ")
                    .append(streamBacklog.receiver().registrationId())
                    .append(" is at position ")
                    .append(streamBacklog.receiver().position());

                final Iterator<Map.Entry<Long, Subscriber>> subscriberIterator =
                    streamBacklog.subscriberBacklogs().entrySet().iterator();

                while (subscriberIterator.hasNext())
                {
                    final Map.Entry<Long, Subscriber> subscriber = subscriberIterator.next();
                    builder
                        .append(subscriberIterator.hasNext() ? "\n├" : "\n└")
                        .append("─subscriber ")
                        .append(subscriber.getKey())
                        .append(" has ")
                        .append(subscriber.getValue().backlog(streamBacklog.receiver().highWaterMark()))
                        .append(" backlog bytes");
                }
            }

            builder.append('\n');
            out.println(builder);
        }
    }
public void print(final PrintStream out)
    {
        final StringBuilder builder = new StringBuilder();

        for (final Map.Entry<StreamCompositeKey, StreamBacklog> entry : snapshot().entrySet())
        {
            builder.setLength(0);
            final StreamCompositeKey key = entry.getKey();

            builder
                .append("sessionId=").append(key.sessionId())
                .append(" streamId=").append(key.streamId())
                .append(" channel=").append(key.channel())
                .append(" : ");


            final StreamBacklog streamBacklog = entry.getValue();
            if (streamBacklog.publisher() != null)
            {
                builder
                    .append("\n┌─for publisher ")
                    .append(streamBacklog.publisher().registrationId())
                    .append(" the last sampled position is ")
                    .append(streamBacklog.publisher().position())
                    .append(" (~")
                    .append(streamBacklog.publisher().remainingWindow())
                    .append(" bytes before back-pressure)");

                final Sender sender = streamBacklog.sender();
                if (sender != null)
                {
                    final long senderBacklog = sender.backlog(streamBacklog.publisher().position());

                    builder.append("\n└─sender ").append(sender.registrationId());

                    if (senderBacklog >= 0)
                    {
                        builder.append(" has to send ").append(senderBacklog).append(" bytes");
                    }
                    else
                    {
                        builder.append(" is at position ").append(sender.position());
                    }

                    builder.append(" (").append(sender.window()).append(" bytes remaining in the sender window)");
                }
                else
                {
                    builder.append("\n└─no sender yet...");
                }
            }

            if (streamBacklog.receiver() != null)
            {
                builder
                    .append("\n┌─receiver ")
                    .append(streamBacklog.receiver().registrationId())
                    .append(" is at position ")
                    .append(streamBacklog.receiver().position());

                final Iterator<Map.Entry<Long, Subscriber>> subscriberIterator =
                    streamBacklog.subscriberBacklogs().entrySet().iterator();

                while (subscriberIterator.hasNext())
                {
                    final Map.Entry<Long, Subscriber> subscriber = subscriberIterator.next();
                    builder
                        .append(subscriberIterator.hasNext() ? "\n├" : "\n└")
                        .append("─subscriber ")
                        .append(subscriber.getKey())
                        .append(" has ")
                        .append(subscriber.getValue().backlog(streamBacklog.receiver().highWaterMark()))
                        .append(" backlog bytes");
                }
            }

            builder.append('\n');
            out.println(builder);
        }
    }
public void print ( final PrintStream out ) { final StringBuilder builder = new StringBuilder ( ) ; for ( final Map . Entry < StreamCompositeKey , StreamBacklog > entry : snapshot ( ) . entrySet ( ) ) { builder . setLength ( 0 ) ; final StreamCompositeKey key = entry . getKey ( ) ; builder . append ( "sessionId=" ) . append ( key . sessionId ( ) ) . append ( " streamId=" ) . append ( key . streamId ( ) ) . append ( " channel=" ) . append ( key . channel ( ) ) . append ( " : " ) ; final StreamBacklog streamBacklog = entry . getValue ( ) ; if ( streamBacklog . publisher ( ) != null ) { builder . append ( "\n┌─for publisher ") . append ( streamBacklog . publisher ( ) . registrationId ( ) ) . append ( " the last sampled position is " ) . append ( streamBacklog . publisher ( ) . position ( ) ) . append ( " (~" ) . append ( streamBacklog . publisher ( ) . remainingWindow ( ) ) . append ( " bytes before back-pressure)" ) ; final Sender sender = streamBacklog . sender ( ) ; if ( sender != null ) { final long senderBacklog = sender . backlog ( streamBacklog . publisher ( ) . position ( ) ) ; builder . append ( "\n└─sender ").ap p e nd(sen d er.reg i strationId()); if ( senderBacklog >= 0 ) { builder . append ( " has to send " ) . append ( senderBacklog ) . append ( " bytes" ) ; } else { builder . append ( " is at position " ) . append ( sender . position ( ) ) ; } builder . append ( " (" ) . append ( sender . window ( ) ) . append ( " bytes remaining in the sender window)" ) ; } else { builder . append ( "\n└─no sender yet..."); } } if ( streamBacklog . receiver ( ) != null ) { builder . append ( "\n┌─receiver ") . append ( streamBacklog . receiver ( ) . registrationId ( ) ) . append ( " is at position " ) . append ( streamBacklog . receiver ( ) . position ( ) ) ; final Iterator < Map . Entry < Long , Subscriber > > subscriberIterator = streamBacklog . subscriberBacklogs ( ) . entrySet ( ) . iterator ( ) ; while ( subscriberIterator . hasNext ( ) ) { final Map . Entry < Long , Subscriber > subscriber = subscriberIterator . next ( ) ; builder . append ( subscriberIterator . hasNext ( ) ? "\n├" : " n└") . append ( "─subscriber ") . append ( subscriber . getKey ( ) ) . append ( " has " ) . append ( subscriber . getValue ( ) . backlog ( streamBacklog . receiver ( ) . highWaterMark ( ) ) ) . append ( " backlog bytes" ) ; } } builder . append ( ' ' ) ; out . println ( builder ) ; } }
Print a snapshot of the stream backlog with some explanation to a {@link PrintStream}.
<p>
Each stream will be printed in its own section.

@param out to which the stream backlog will be written.
Print a snapshot of the stream backlog with some explanation to a { @link PrintStream } . <p > Each stream will be printed in its own section .