public synchronized boolean checkSize(final int sizeChecked){
  if (!started) {
    throw new IllegalStateException("TimedBuffer is not started");
  }
  if (sizeChecked > bufferSize) {
    throw new IllegalStateException("Can't write records bigger than the bufferSize(" + bufferSize + ") on the journal");
  }
  if (bufferLimit == 0 || buffer.writerIndex() + sizeChecked > bufferLimit) {
    flush();
    delayFlush=true;
    final int remainingInFile=bufferObserver.getRemainingBytes();
    if (sizeChecked > remainingInFile) {
      return false;
    }
 else {
      bufferLimit=Math.min(remainingInFile,bufferSize);
      return true;
    }
  }
 else {
    delayFlush=true;
    return true;
  }
}

public synchronized boolean checkSize ( final int sizeChecked ) { if ( ! started ) { throw new IllegalStateException ( "TimedBuffer is not started" ) ; } if ( sizeChecked > bufferSize ) { throw new IllegalStateException ( "Can't write records bigger than the bufferSize(" + bufferSize + ") on the journal" ) ; } if ( bufferLimit == 0 || buffer . writerIndex ( ) + sizeChecked > bufferLimit ) { flush ( ) ; delayFlush = true ; final int remainingInFile = bufferObserver . getRemainingBytes ( ) ; if ( sizeChecked > remainingInFile ) { return false ; } else { bufferLimit = Math . min ( remainingInFile , bufferSize ) ; return true ; } } else { delayFlush = true ; return true ; } }
verify if the size fits the buffer
