class EventBuffer extends Object
ROLLBACK or COMMIT. The incoming events are either
supposed to be in transaction or out-of-transaction. When out-of-transaction they are sent directly into
the destination handler. When in transaction the event goes through the buffering.
The reason for the buffering is that the binlog contains rolled back transactions in some cases. E.g. that's the case when a temporary table is dropped (see DBZ-390). For rolled back transactions we may not propagate any of the contained events, hence the buffering is applied.
The transaction start is identified by a BEGIN event. Transaction is ended either by COMMIT
event or by XID an event.
If there are more events that can fit to the buffer then:
| Modifier and Type | Field and Description |
|---|---|
private Queue<com.github.shyiko.mysql.binlog.event.Event> |
buffer |
private int |
capacity |
private BinlogReader.BinlogPosition |
forwardTillPosition
Contains the position of the last event belonging to the transaction that has not fit into
the buffer.
|
private BinlogReader.BinlogPosition |
largeTxNotBufferedPosition
Contains the position of the first event that has not fit into the buffer.
|
private static org.slf4j.Logger |
LOGGER |
private BinlogReader |
reader |
private boolean |
txStarted |
| Constructor and Description |
|---|
EventBuffer(int capacity,
BinlogReader reader) |
| Modifier and Type | Method and Description |
|---|---|
void |
add(com.github.shyiko.mysql.binlog.event.Event event)
An entry point to the buffer that should be used by BinlogReader to push events.
|
private void |
addToBuffer(com.github.shyiko.mysql.binlog.event.Event event)
Adds an event to the buffer if there is a space available.
|
private void |
beginTransaction(com.github.shyiko.mysql.binlog.event.Event event) |
private void |
clear()
Cleans-up the buffer after the transaction is either thrown away or streamed into a Kafka topic
|
private void |
completeTransaction(boolean wellFormed,
com.github.shyiko.mysql.binlog.event.Event event)
Sends all events from the buffer int a final handler.
|
private void |
consumeEvent(com.github.shyiko.mysql.binlog.event.Event event) |
private boolean |
isInBufferFullMode() |
private boolean |
isReplayingEventsBeyondBufferCapacity()
Whether we are replaying TX events from binlog that have not fit into the buffer before
|
private void |
rollbackTransaction() |
private void |
switchToBufferFullMode() |
private static final org.slf4j.Logger LOGGER
private final int capacity
private final Queue<com.github.shyiko.mysql.binlog.event.Event> buffer
private final BinlogReader reader
private boolean txStarted
private BinlogReader.BinlogPosition largeTxNotBufferedPosition
private BinlogReader.BinlogPosition forwardTillPosition
public EventBuffer(int capacity,
BinlogReader reader)
public void add(com.github.shyiko.mysql.binlog.event.Event event)
event - to be stored in the bufferprivate boolean isReplayingEventsBeyondBufferCapacity()
private void addToBuffer(com.github.shyiko.mysql.binlog.event.Event event)
event - private void switchToBufferFullMode()
private boolean isInBufferFullMode()
private void consumeEvent(com.github.shyiko.mysql.binlog.event.Event event)
private void beginTransaction(com.github.shyiko.mysql.binlog.event.Event event)
private void completeTransaction(boolean wellFormed,
com.github.shyiko.mysql.binlog.event.Event event)
wellFormed - event - private void rollbackTransaction()
private void clear()
Copyright © 2017 JBoss by Red Hat. All rights reserved.