in flume-hive-sink/src/main/java/org/apache/flume/sink/hive/HiveWriter.java [182:216]
public void flush(boolean rollToNext)
throws CommitException, TxnBatchException, TxnFailure, InterruptedException,
WriteException {
if (!batch.isEmpty()) {
writeEventBatchToSerializer();
batch.clear();
}
//0 Heart beat on TxnBatch
if (hearbeatNeeded) {
hearbeatNeeded = false;
heartBeat();
}
lastUsed = System.currentTimeMillis();
try {
//1 commit txn & close batch if needed
commitTxn();
if (txnBatch.remainingTransactions() == 0) {
closeTxnBatch();
txnBatch = null;
if (rollToNext) {
txnBatch = nextTxnBatch(recordWriter);
}
}
//2 roll to next Txn
if (rollToNext) {
LOG.debug("Switching to next Txn for {}", endPoint);
txnBatch.beginNextTransaction(); // does not block
}
} catch (StreamingException e) {
throw new TxnFailure(txnBatch, e);
}
}