}
final ChannelBuffer buffer = (ChannelBuffer) e.getMessage();
final int rc;
final long ledgerId, entryId;
final PacketHeader header;
try {
header = PacketHeader.fromInt(buffer.readInt());
rc = buffer.readInt();
ledgerId = buffer.readLong();
entryId = buffer.readLong();
} catch (IndexOutOfBoundsException ex) {
LOG.error("Unparseable response from bookie: " + addr, ex);
return;
}
executor.submitOrdered(ledgerId, new SafeRunnable() {
@Override
public void safeRun() {
switch (header.getOpCode()) {
case BookieProtocol.ADDENTRY:
handleAddResponse(ledgerId, entryId, rc);
break;
case BookieProtocol.READENTRY:
handleReadResponse(ledgerId, entryId, rc, buffer);
break;
default:
LOG.error("Unexpected response, type: " + header.getOpCode()
+ " received from bookie: " + addr + " , ignoring");
}
}
});
}