//
final Context context = new Context(this.binlogFileName);
while(isRunning() && is.available() > 0) {
try {
//
final BinlogEventV4HeaderImpl header = new BinlogEventV4HeaderImpl();
header.setTimestamp(is.readLong(4) * 1000L);
header.setEventType(is.readInt(1));
header.setServerId(is.readLong(4));
header.setEventLength(is.readInt(4));
header.setNextPosition(is.readLong(4));
header.setFlags(is.readInt(2));
header.setTimestampOfReceipt(System.currentTimeMillis());
is.setReadLimit((int)(header.getEventLength() - header.getHeaderLength())); // Ensure the event boundary
if(isVerbose() && LOGGER.isInfoEnabled()) {
LOGGER.info("read an event, header: {}", header);
}
//
if(this.stopPosition > 0 && header.getPosition() > this.stopPosition) {
break;
}
// Parse the event body
if(this.eventFilter != null && !this.eventFilter.accepts(header, context)) {
this.defaultParser.parse(is, header, context);
} else {
BinlogEventParser parser = getEventParser(header.getEventType());
if(parser == null) parser = this.defaultParser;
parser.parse(is, header, context);
}
// Ensure the packet boundary
if(is.available() != 0) {
throw new NestableRuntimeException("assertion failed, available: " + is.available() + ", event type: " + header.getEventType());
}
} catch(Exception e) {
IOUtils.closeQuietly(is);
throw e;
} finally {