}
void replayLog(List<File> logs) throws IOException {
int total = 0;
int count = 0;
MultiMap transactionMap = new MultiValueMap();
LOG.info("Starting replay of " + logs);
for (File log : logs) {
LOG.info("Replaying " + log);
LogFile.SequentialReader reader = null;
try {
reader = new LogFile.SequentialReader(log);
Pair<Integer, TransactionEventRecord> entry;
FlumeEventPointer ptr;
// for puts the fileId is the fileID of the file they exist in
// for takes the fileId and offset are pointers to a put
int fileId = reader.getLogFileID();
while ((entry = reader.next()) != null) {
int offset = entry.getLeft();
TransactionEventRecord record = entry.getRight();
short type = record.getRecordType();
long trans = record.getTransactionID();
if (LOG.isDebugEnabled()) {
LOG.debug("record.getTimestamp() = " + record.getTimestamp()
+ ", lastCheckpoint = " + lastCheckpoint + ", fileId = "
+ fileId + ", offset = " + offset + ", type = "
+ TransactionEventRecord.getName(type) + ", transaction "
+ trans);
}
if (record.getTimestamp() > lastCheckpoint) {
if (type == TransactionEventRecord.Type.PUT.get()) {
ptr = new FlumeEventPointer(fileId, offset);
transactionMap.put(trans, ptr);
} else if (type == TransactionEventRecord.Type.TAKE.get()) {
Take take = (Take) record;
ptr = new FlumeEventPointer(take.getFileID(), take.getOffset());
transactionMap.put(trans, ptr);
} else if (type == TransactionEventRecord.Type.ROLLBACK.get()) {
transactionMap.remove(trans);
} else if (type == TransactionEventRecord.Type.COMMIT.get()) {
@SuppressWarnings("unchecked")
Collection<FlumeEventPointer> pointers =
(Collection<FlumeEventPointer>) transactionMap.remove(trans);
if (pointers != null && pointers.size() > 0) {
processCommit(((Commit) record).getType(), pointers);
count += pointers.size();
}
} else {