if (args.length != 1) {
System.err.println("USAGE: LogFormatter log_file");
System.exit(2);
}
FileInputStream fis = new FileInputStream(args[0]);
BinaryInputArchive logStream = BinaryInputArchive.getArchive(fis);
while (true) {
byte[] bytes = logStream.readBuffer("txnEntry");
if (bytes.length == 0) {
// Since we preallocate, we define EOF to be an
// empty transaction
throw new EOFException();
}
InputArchive ia = BinaryInputArchive
.getArchive(new ByteArrayInputStream(bytes));
TxnHeader hdr = new TxnHeader();
hdr.deserialize(ia, "hdr");
System.out.println(DateFormat.getDateTimeInstance(DateFormat.SHORT,
DateFormat.LONG).format(new Date(hdr.getTime()))
+ " session 0x"
+ Long.toHexString(hdr.getClientId())
+ ":"
+ hdr.getCxid()
+ " zxid 0x"
+ Long.toHexString(hdr.getZxid())
+ " " + TraceFormatter.op2String(hdr.getType()));
if (logStream.readByte("EOR") != 'B') {
LOG.error("Last transaction was partial.");
throw new EOFException("Last transaction was partial.");
}
}
}