Search in sources :

Example 1 with FlushException

use of org.apache.distributedlog.exceptions.FlushException in project bookkeeper by apache.

the class BKLogSegmentWriter method flushIfNeeded.

// Based on transmit buffer size, immediate flush, etc., should we flush the current
// packet now.
void flushIfNeeded() throws BKTransmitException, WriteException, InvalidEnvelopedEntryException, LockingException, FlushException {
    if (outstandingBytes > transmissionThreshold) {
        // If flush delay is disabled, flush immediately, else schedule appropriately.
        if (0 == minDelayBetweenImmediateFlushMs) {
            checkStateAndTransmit();
        } else {
            scheduleFlushWithDelayIfNeeded(new Callable<Void>() {

                @Override
                public Void call() throws Exception {
                    checkStateAndTransmit();
                    return null;
                }
            }, transmitSchedFutureRefUpdater);
            // Timing here is not very important--the last flush failed and we should
            // indicate this to the caller. The next flush may succeed and unset the
            // scheduledFlushException in which case the next write will succeed (if the caller
            // hasn't already closed the writer).
            Exception exec = scheduledFlushExceptionUpdater.get(this);
            if (exec != null) {
                throw new FlushException("Last flush encountered an error while writing data to the backend", getLastTxId(), getLastTxIdAcknowledged(), exec);
            }
        }
    }
}
Also used : FlushException(org.apache.distributedlog.exceptions.FlushException) FlushException(org.apache.distributedlog.exceptions.FlushException) BKException(org.apache.bookkeeper.client.BKException) WriteException(org.apache.distributedlog.exceptions.WriteException) InvalidEnvelopedEntryException(org.apache.distributedlog.exceptions.InvalidEnvelopedEntryException) LockingException(org.apache.distributedlog.exceptions.LockingException) WriteCancelledException(org.apache.distributedlog.exceptions.WriteCancelledException) BKTransmitException(org.apache.distributedlog.exceptions.BKTransmitException) EndOfStreamException(org.apache.distributedlog.exceptions.EndOfStreamException) IOException(java.io.IOException) TransactionIdOutOfOrderException(org.apache.distributedlog.exceptions.TransactionIdOutOfOrderException) LogRecordTooLongException(org.apache.distributedlog.exceptions.LogRecordTooLongException)

Aggregations

IOException (java.io.IOException)1 BKException (org.apache.bookkeeper.client.BKException)1 BKTransmitException (org.apache.distributedlog.exceptions.BKTransmitException)1 EndOfStreamException (org.apache.distributedlog.exceptions.EndOfStreamException)1 FlushException (org.apache.distributedlog.exceptions.FlushException)1 InvalidEnvelopedEntryException (org.apache.distributedlog.exceptions.InvalidEnvelopedEntryException)1 LockingException (org.apache.distributedlog.exceptions.LockingException)1 LogRecordTooLongException (org.apache.distributedlog.exceptions.LogRecordTooLongException)1 TransactionIdOutOfOrderException (org.apache.distributedlog.exceptions.TransactionIdOutOfOrderException)1 WriteCancelledException (org.apache.distributedlog.exceptions.WriteCancelledException)1 WriteException (org.apache.distributedlog.exceptions.WriteException)1