Flushes the queue by sending all messages to Stackify
@param sender The LogMsgGroup sender
@return The number of messages sent to Stackify
@throws IOException
@throws HttpException
163896
public int flush(final LogSender sender) throws IOException, HttpException {

		int numSent = 0;
		int maxToSend = queue.size();

		if (0 < maxToSend) {
			AppIdentity appIdentity = appIdentityService.getAppIdentity();

			while (numSent < maxToSend) {

				// get the next batch of messages
				int batchSize = Math.min(maxToSend - numSent, MAX_BATCH);

				List<LogMsg> batch = new ArrayList<LogMsg>(batchSize);

				for (int i = 0; i < batchSize; ++i) {
					batch.add(queue.remove());
				}

				// build the log message group
				LogMsgGroup group = createLogMessageGroup(batch, platform, logger, envDetail, appIdentity);

				// send the batch to Stackify
				int httpStatus = sender.send(group);

				// if the batch failed to transmit, return the appropriate transmission status
				if (httpStatus != HttpURLConnection.HTTP_OK) {
					throw new HttpException(httpStatus);
				}

				// next iteration
				numSent += batchSize;
			}
		}

		return numSent;
	}
187247
protected boolean putToQueue(IQueueMessage<ID, DATA> msg) {
        try {
            BytesMessage message = getProducerSession().createBytesMessage();
            message.writeBytes(serialize(msg));
            getMessageProducer().send(message);
            return true;
        } catch (Exception e) {
            throw e instanceof QueueException ? (QueueException) e : new QueueException(e);
        }
    }
447917
@Override
  protected void flush(Buffer data, boolean isEnd)
  {
    if (isClosed()) {
      throw new IllegalStateException();
    }

    _request.outProxy().write(_request, data, isEnd);
    
    /*
    boolean isHeader = ! isCommitted();
    toCommitted();
    
    MessageResponseHttp2 message;
    
    TempBuffer next = head;
    TempBuffer tBuf = null;
    
    if (head != null) {
      int headLength = head.length();
    
      if (headLength > 0) {
        tBuf = head;
      
        next = TempBuffer.allocate();
      }
    }
    
    message = new MessageResponseHttp2(_request, tBuf, isHeader, isEnd);
    _request.getOutHttp().offer(message);
    
    return next;
    */
  }
283335
function flushQueue()
    {
        var queued = WebInspector.log.queued;
        if (!queued)
            return;

        for (var i = 0; i < queued.length; ++i)
            logMessage(queued[i]);

        delete WebInspector.log.queued;
    }
233502
def flush(self):
        ''''''
        # When profiling, we found that while there was some efficiency to be
        # gained elsewhere, the big performance hit is sending lots of small
        # messages at a time. In particular, consumers send many 'FIN' messages
        # which are very small indeed and the cost of dispatching so many system
        # calls is very high. Instead, we prefer to glom together many messages
        # into a single string to send at once.
        total = 0
        for sock in self.socket(blocking=False):
            # If there's nothing left in the out buffer, take whatever's in the
            # pending queue.
            #
            # When using SSL, if the socket throws 'SSL_WANT_WRITE', then the
            # subsequent send requests have to send the same buffer.
            pending = self._pending
            data = self._out_buffer or ''.join(
                pending.popleft() for _ in xrange(len(pending)))
            try:
                # Try to send as much of the first message as possible
                total = sock.send(data)
            except socket.error as exc:
                # Catch (errno, message)-type socket.errors
                if exc.args[0] not in self.WOULD_BLOCK_ERRS:
                    raise
                self._out_buffer = data
            else:
                self._out_buffer = None
            finally:
                if total < len(data):
                    # Save the rest of the message that could not be sent
                    self._pending.appendleft(data[total:])
        return total
469472
private void onSuspend(final List<Address> members) {
        Message msg = null;
        Collection<Address> participantsInFlush = null;
      synchronized (sharedLock) {
         flushCoordinator = localAddress;         

         // start FLUSH only on group members that we need to flush
         participantsInFlush = members;
         participantsInFlush.retainAll(currentView.getMembers());
         flushMembers.clear();
         flushMembers.addAll(participantsInFlush);
         flushMembers.removeAll(suspected);
         
          msg = new Message(null).src(localAddress).setBuffer(marshal(participantsInFlush, null))
            .putHeader(this.id, new FlushHeader(FlushHeader.START_FLUSH, currentViewId()));

      }
        if (participantsInFlush.isEmpty()) {
            flush_promise.setResult(SUCCESS_START_FLUSH);
        } else {
            down_prot.down(msg);
            if (log.isDebugEnabled())
                log.debug(localAddress + ": flush coordinator "
                        + " is starting FLUSH with participants " + participantsInFlush);
        }
    }
625796
public void sendEventsFromQueue() {
        if (null == queue || stopSending) {
            return;
        }
        LOG.fine("Scheduler called for sending events");

        int packageSize = getEventsPerMessageCall();

        while (!queue.isEmpty()) {
            final List<Event> list = new ArrayList<Event>();
            int i = 0;
            while (i < packageSize && !queue.isEmpty()) {
                Event event = queue.remove();
                if (event != null && !filter(event)) {
                    list.add(event);
                    i++;
                }
            }
            if (list.size() > 0) {
                executor.execute(new Runnable() {
                    public void run() {
                        try {
                            sendEvents(list);
                        } catch (MonitoringException e) {
                            e.logException(Level.SEVERE);
                        }
                    }
                });

            }
        }

    }
568859
def flush(self):
        
        local_sender = self.sender
        if not local_sender:
            return
        while True:
            # get at most send_buffer_size items and send them
            data = []
            while len(data) < local_sender.send_buffer_size:
                item = self.get()
                if not item:
                    break
                data.append(item)
            if len(data) == 0:
                break
            local_sender.send(data)
1319044
public void flush(Writer out)
         throws IOException
    {
        writeHtmlHead(out);
        writeBodyTag(out);
        super.flush(out);
    }
440553
public void flush()
        throws IOException
    {
        try
        {
            if (!_commited)
            {
                _commited=true;
                if (_commitObserver!=null)
                    _commitObserver.outputNotify(this,OutputObserver.__COMMITING,null);
            }
            
            wrapBuffer();
            
            // Add headers
            if (_httpMessageWriter.size()>0)
            {
                prewrite(_httpMessageWriter.getBuf(),0,_httpMessageWriter.size());
                _httpMessageWriter.resetWriter();
            }
            
            if (size()>0)
                writeTo(_out);
        }
        catch (IOException e)
        {
            throw new EOFException(e);
        }
        finally
        {
            reset(_preReserve);
        }
    }
752433
@Override
    public void flush()
    {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(this, tc, "flush");
        // Cleanup any pending NACK alarms.  Since we're flushing we don't
        // care about these anymore.
        synchronized (pendingAlarms)
        {
            for (Iterator i = getAlarms(this); i.hasNext();)
            {
                NRTExpiryHandle next = (NRTExpiryHandle) i.next();
                next.timer.cancel();
                i.remove();
            }
        }

        // SIB0115
        // If nack alarms are cancelled then deregister the health state for detected gaps
        getControlAdapter().getHealthState().deregister(HealthStateListener.GAP_DETECTED_STATE);

        // We shouldn't be flushed if we have pending unacked data.  But
        // just as a sanity check, throw an exception here if we have
        // something undelivered.
        if (oststream
                        .containsState(
                                       new TickRange(TickRange.Unknown, 0, RangeList.INFINITY),
                                       TickRange.Value)
            || oststream.containsState(
                                       new TickRange(TickRange.Unknown, 0, RangeList.INFINITY),
                                       TickRange.Uncommitted))
        {
            //TODO: throw some interesting exception
        }
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(tc, "flush");
    }
953817
public void sendConsoleMessage(Level level, String msg) {
        if (!(getServerCaller() instanceof UnitTestServerCaller)) {
            getLogger().log(level, msg);
        }
    }
1236510
@Override
    public void flush(int requestNumber) {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(this, tc, "flush", "" + requestNumber);

        // Locate the browser session to use.
        BrowserSession browserSession = mainConsumer.getBrowserSession();
        SIBusMessage msg = null;

        // Browse the next message and send it to the client.
        try {
            msg = getNextMessage(browserSession, getConversation(), (short) requestNumber);
            if (msg != null)
                sendMessage(msg);

            // Send a response to the browse request.
            try {
                getConversation().send(poolManager.allocate(),
                                       JFapChannelConstants.SEG_FLUSH_SESS_R,
                                       requestNumber,
                                       Conversation.PRIORITY_LOWEST,
                                       true,
                                       ThrottlingPolicy.BLOCK_THREAD,
                                       null);
            } catch (SIException e) {
                FFDCFilter.processException(e, CLASS_NAME + ".flush",
                                            CommsConstants.CATBROWSECONSUMER_FLUSH_01,
                                            this);

                SibTr.error(tc, "COMMUNICATION_ERROR_SICO2012", e);

                // Nothing else we can do at this point as the comms exception suggests that the
                // conversation is dead, anyway.
            }

        } catch (OperationFailedException e) {
            // No FFDC code needed
            if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled())
                SibTr.exception(this, tc, e);
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(this, tc, "flush");
    }
1017779
public void flush() {
        logger.info(String.format("(%s) Flush, buffer size: %d", detectorImpl.getName(), queue.size()));
        while(queue.size()>0)
            detectorImpl.fireEvent(queue.poll());
    }
785399
@Override
    public void flush() throws IOException {

        if (_callback != null) {
            if (!this._isReady) {
                if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                    Tr.debug(tc, "Cannot flush stream , output not ready: " + this);
                }
                return;
            }
            else {
                validate();
                flushBuffers();
            }
        }
        else {
            super.flush();
        }

    }
529032
@Override
    @FFDCIgnore({ IOException.class })
    public void flushBuffers() throws IOException {

        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(tc, "Flushing buffers: " + this);
        }

        if (this.isc.getResponse() == null) {
            IOException x = new IOException("response Object(s) (e.g. getObjectFactory()) are null");
            throw x;
        }

        if (!this.isc.getResponse().isCommitted()) {
            if (obs != null && !this.WCheadersWritten) {
                if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                    Tr.debug(tc, "obs  ->" + obs);
                }
                obs.alertOSFirstFlush();
            }

            this.isc.getResponse().setCommitted();
        }

        if (this.ignoreFlush) {
            this.ignoreFlush = false;
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, "Ignoring first flush attempt");
            }
            return;
        }

        final boolean writingBody = (hasBufferedContent());
        // flip the last buffer for the write...
        if (writingBody && null != this.output[this.outputIndex]) {
            this.output[this.outputIndex].flip();
        }
        try {
            WsByteBuffer[] content = (writingBody) ? this.output : null;
            if (isClosed() || this.isClosing) {
                if (!hasFinished) { //if we've already called finishResponseMessage - don't call again
                    // on a closed stream, use the final write api
                    this.isc.finishResponseMessage(content);
                    this.isClosing = false;
                    this.hasFinished = true;
                }
            } else {
                // else use the partial body api
                this.isc.sendResponseBody(content);
            }
        } catch (MessageSentException mse) {
            FFDCFilter.processException(mse, getClass().getName(),
                                        "flushBuffers", new Object[] { this, this.isc });
            if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) {
                Tr.event(tc, "Invalid state, message-sent-exception received; " + this.isc);
            }
            this.error = new IOException("Invalid state");
            throw this.error;
        } catch (IOException ioe) {
            // no FFDC required
            this.error = ioe;
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, "Received exception during write: " + ioe);
            }
            Throwable th = ioe.getCause();
            if (th instanceof FlowControlException || th instanceof StreamClosedException) {
                // http/2 stream write failed - we don't want to pass this back up to FFDC
                Tr.debug(tc, "HTTP/2 stream could not write; setting error on this output stream");
                return;
            }
            throw ioe;
        } finally {
            this.bytesWritten += this.bufferedCount;
            if (this.contentLengthSet) {
                this.bytesRemaining -= this.bufferedCount;
            }
            this.bufferedCount = 0;
            this.outputIndex = 0;
            // Note: this logic only works for sync writes
            if (writingBody) {
                this.output[0].clear();
                for (int i = 1; i < this.output.length; i++) {
                    if (null != this.output[i]) {
                        // mark them empty so later writes don't mistake them
                        // as having content
                        this.output[i].position(0);
                        this.output[i].limit(0);
                    }
                }
            }
        }
    }
827837
private function flush()
    {
        $keepWriting = true;
        while ($keepWriting) {
            $message = $this->messages[0]['message'];
            $promise = $this->messages[0]['promise'];

            $bytesWritten = @fwrite($this->output, $message);

            if ($bytesWritten > 0) {
                $message = substr($message, $bytesWritten);
            }

            // Determine if this message was completely sent
            if (strlen($message) === 0) {
                array_shift($this->messages);

                // This was the last message in the queue, remove the write handler.
                if (count($this->messages) === 0) {
                    Loop\removeWriteStream($this->output);
                    $keepWriting = false;
                }

                $promise->fulfill();
            } else {
                $this->messages[0]['message'] = $message;
                $keepWriting = false;
            }
        }
    }