Search in sources :

Example 1 with BKPacketHeader

use of org.apache.bookkeeper.proto.BookkeeperProtocol.BKPacketHeader in project bookkeeper by apache.

the class PerChannelBookieClient method readV3Response.

private void readV3Response(final Response response) {
    final BKPacketHeader header = response.getHeader();
    final CompletionValue completionValue = completionObjects.get(newCompletionKey(header.getTxnId(), header.getOperation()));
    if (null == completionValue) {
        // Unexpected response, so log it. The txnId should have been present.
        if (LOG.isDebugEnabled()) {
            LOG.debug("Unexpected response received from bookie : " + addr + " for type : " + header.getOperation() + " and txnId : " + header.getTxnId());
        }
    } else {
        long orderingKey = completionValue.ledgerId;
        executor.executeOrdered(orderingKey, new SafeRunnable() {

            @Override
            public void safeRun() {
                completionValue.handleV3Response(response);
            }

            @Override
            public String toString() {
                return String.format("HandleResponse(Txn=%d, Type=%s, Entry=(%d, %d))", header.getTxnId(), header.getOperation(), completionValue.ledgerId, completionValue.entryId);
            }
        });
    }
    completionObjects.remove(newCompletionKey(header.getTxnId(), header.getOperation()));
}
Also used : SafeRunnable(org.apache.bookkeeper.util.SafeRunnable) ByteString(com.google.protobuf.ByteString) BKPacketHeader(org.apache.bookkeeper.proto.BookkeeperProtocol.BKPacketHeader)

Aggregations

ByteString (com.google.protobuf.ByteString)1 BKPacketHeader (org.apache.bookkeeper.proto.BookkeeperProtocol.BKPacketHeader)1 SafeRunnable (org.apache.bookkeeper.util.SafeRunnable)1