library/src/main/java/com/kdgregory/aws/utils/cloudwatch/CloudWatchLogsWriter.java
/**
     *  Given a list of sorted messages, builds a batch from the oldest messages
     *  (removing them from the list).
     */
Given a list of sorted messages, builds a batch from the oldest messages
(removing them from the list).
Given a list of sorted messages builds a batch from the oldest messages ( removing them from the list ) .
private List<QueuedMessage> extractBatch(LinkedList<QueuedMessage> sortedMessages)
    {
        LinkedList<QueuedMessage> batch = new LinkedList<QueuedMessage>();
        if (sortedMessages.isEmpty())
            return batch;
        long lastAllowedTimestamp = sortedMessages.getFirst().timestamp + 86399999;
        int batchMessages = 0;
        int batchBytes = 0;
        for (Iterator<QueuedMessage> srcItx = sortedMessages.iterator() ; srcItx.hasNext() ; )
        {
            QueuedMessage message = srcItx.next();
            batchMessages++;
            batchBytes += message.size + 26;
            if ((batchMessages > 10000) || (batchBytes > 1048576) || (message.timestamp > lastAllowedTimestamp))
                return batch;
            batch.add(message);
            srcItx.remove();
        }
        return batch;
    }
private List < QueuedMessage > extractBatch ( LinkedList < QueuedMessage > sortedMessages ) { LinkedList < QueuedMessage > batch = new LinkedList < QueuedMessage > ( ) ; if ( sortedMessages . isEmpty ( ) ) return batch ; long lastAllowedTimestamp = sortedMessages . getFirst ( ) . timestamp + 86399999 ; int batchMessages = 0 ; int batchBytes = 0 ; for ( Iterator < QueuedMessage > srcItx = sortedMessages . iterator ( ) ; srcItx . hasNext ( ) ; ) { QueuedMessage message = srcItx . next ( ) ; batchMessages ++ ; batchBytes += message . size + 26 ; if ( ( batchMessages > 10000 ) || ( batchBytes > 1048576 ) || ( message . timestamp > lastAllowedTimestamp ) ) return batch ; batch . add ( message ) ; srcItx . remove ( ) ; } return batch ; }
Given a list of sorted messages, builds a batch from the oldest messages
  (removing them from the list).
Given a list of sorted messages builds a batch from the oldest messages ( removing them from the list ) .