library/src/main/java/com/kdgregory/aws/utils/cloudwatch/CloudWatchLogsUtil.java
/**
     *  Repeatedly attempts to read all events from one or more streams, returning
     *  either after the expected number of messages have been read or the specified
     *  timeout elapses. This is useful for integration tests that write events,
     *  because it will take several (perhaps 10s of) seconds before those events
     *  are available for reading.
     *  <p>
     *  If the reading thread is interrupted, it will return whatever events it's
     *  already read.
     *  <p>
     *  Events from all streams are combined together and sorted by timestamp. There
     *  is no way to discover the source stream from the event.
     *
     *  @param  client          AWS client used to retrieve events.
     *  @param  expectedCount   The expected number of events on the stream.
     *  @param  timeout         Total amount of time to attempt reads, in milliseconds.
     *  @param  delay           Milliseconds to sleep between attempts.
     *  @param  logGroupName    The name of the log group to read.
     *  @param  logStreamNames  Zero or more streams from the specified log group.
     */
Repeatedly attempts to read all events from one or more streams, returning
either after the expected number of messages have been read or the specified
timeout elapses. This is useful for integration tests that write events,
because it will take several (perhaps 10s of) seconds before those events
are available for reading.

If the reading thread is interrupted, it will return whatever events it's
already read.

Events from all streams are combined together and sorted by timestamp. There
is no way to discover the source stream from the event.

@param  client          AWS client used to retrieve events.
@param  expectedCount   The expected number of events on the stream.
@param  timeout         Total amount of time to attempt reads, in milliseconds.
@param  delay           Milliseconds to sleep between attempts.
@param  logGroupName    The name of the log group to read.
@param  logStreamNames  Zero or more streams from the specified log group.
Repeatedly attempts to read all events from one or more streams returning either after the expected number of messages have been read or the specified timeout elapses . This is useful for integration tests that write events because it will take several ( perhaps 10s of ) seconds before those events are available for reading . If the reading thread is interrupted it will return whatever events it ' s already read . Events from all streams are combined together and sorted by timestamp . There is no way to discover the source stream from the event . @param client AWS client used to retrieve events . @param expectedCount The expected number of events on the stream . @param timeout Total amount of time to attempt reads in milliseconds . @param delay Milliseconds to sleep between attempts . @param logGroupName The name of the log group to read . @param logStreamNames Zero or more streams from the specified log group .
public static List<OutputLogEvent> retrieveAllEvents(AWSLogs client, int expectedCount, long timeout, long delay, String logGroupName, String... logStreamNames)
    {
        List<OutputLogEvent> result = new ArrayList<>(expectedCount);
        long runUntil = System.currentTimeMillis() + timeout;
        while (System.currentTimeMillis() < runUntil)
        {
            result.clear();
            try
            {
                for (String logStreamName : logStreamNames)
                {
                    for (OutputLogEvent event : new LogStreamIterable(client, logGroupName, logStreamName))
                    {
                        result.add(event);
                    }
                }
                if (result.size() >= expectedCount)
                    break;
                Thread.sleep(delay);
            }
            catch (InterruptedException ex)
            {
                break;
            }
        }
        Collections.sort(result, new OutputLogEventComparator());
        return result;
    }
public static List < OutputLogEvent > retrieveAllEvents ( AWSLogs client , int expectedCount , long timeout , long delay , String logGroupName , String ... logStreamNames ) { List < OutputLogEvent > result = new ArrayList < > ( expectedCount ) ; long runUntil = System . currentTimeMillis ( ) + timeout ; while ( System . currentTimeMillis ( ) < runUntil ) { result . clear ( ) ; try { for ( String logStreamName : logStreamNames ) { for ( OutputLogEvent event : new LogStreamIterable ( client , logGroupName , logStreamName ) ) { result . add ( event ) ; } } if ( result . size ( ) >= expectedCount ) break ; Thread . sleep ( delay ) ; } catch ( InterruptedException ex ) { break ; } } Collections . sort ( result , new OutputLogEventComparator ( ) ) ; return result ; }
Repeatedly attempts to read all events from one or more streams, returning
  either after the expected number of messages have been read or the specified
  timeout elapses.
Repeatedly attempts to read all events from one or more streams returning either after the expected number of messages have been read or the specified timeout elapses .
// each time through the loop we read all events from all streams, so throw away previous results