Source:
private ForceLedgerResponse getForceLedgerResponse() { final long startTimeNanos = MathUtils.nowInNano(); ForceLedgerRequest forceLedgerRequest = request.getForceLedgerRequest(); long ledgerId = forceLedgerRequest.getLedgerId(); final ForceLedgerResponse.Builder forceLedgerResponse = ForceLedgerResponse.newBuilder().setLedgerId(ledgerId); if (!isVersionCompatible()) { forceLedgerResponse.setStatus(StatusCode.EBADVERSION); return forceLedgerResponse.build(); } BookkeeperInternalCallbacks.WriteCallback wcb = new BookkeeperInternalCallbacks.WriteCallback() { @Override public void writeComplete(int rc, long ledgerId, long entryId, BookieSocketAddress addr, Object ctx) { if (BookieProtocol.EOK == rc) { requestProcessor.getForceLedgerStats() .registerSuccessfulEvent(MathUtils.elapsedNanos(startTimeNanos), TimeUnit.NANOSECONDS); } else { requestProcessor.getForceLedgerStats() .registerFailedEvent(MathUtils.elapsedNanos(startTimeNanos), TimeUnit.NANOSECONDS); } StatusCode status; switch (rc) { case BookieProtocol.EOK: status = StatusCode.EOK; break; case BookieProtocol.EIO: status = StatusCode.EIO; break; default: status = StatusCode.EUA; break; } forceLedgerResponse.setStatus(status); Response.Builder response = Response.newBuilder() .setHeader(getHeader()) .setStatus(forceLedgerResponse.getStatus()) .setForceLedgerResponse(forceLedgerResponse); Response resp = response.build(); sendResponse(status, resp, requestProcessor.getForceLedgerRequestStats()); } }; StatusCode status = null; try { requestProcessor.getBookie().forceLedger(ledgerId, wcb, channel); status = StatusCode.EOK; } catch (Throwable t) { logger.error("Unexpected exception while forcing ledger : ", ledgerId, t); status = StatusCode.EBADREQ; } if (!status.equals(StatusCode.EOK)) { forceLedgerResponse.setStatus(status); return forceLedgerResponse.build(); } return null; }

Target:
private ForceLedgerResponse getForceLedgerResponse() { final long startTimeNanos = MathUtils.nowInNano(); ForceLedgerRequest forceLedgerRequest = request.getForceLedgerRequest(); long ledgerId = forceLedgerRequest.getLedgerId(); final ForceLedgerResponse.Builder forceLedgerResponse = ForceLedgerResponse.newBuilder().setLedgerId(ledgerId); if (!isVersionCompatible()) { forceLedgerResponse.setStatus(StatusCode.EBADVERSION); return forceLedgerResponse.build(); } BookkeeperInternalCallbacks.WriteCallback wcb = (int rc, long ledgerId1, long entryId, BookieSocketAddress addr, Object ctx) -> { checkArgument(entryId == Bookie.METAENTRY_ID_FORCE_LEDGER, "entryId must be METAENTRY_ID_FORCE_LEDGER but was {}", entryId); checkArgument(ledgerId1 == ledgerId, "ledgerId must be but was {}", ledgerId, ledgerId1); if (BookieProtocol.EOK == rc) { requestProcessor.getForceLedgerStats() .registerSuccessfulEvent(MathUtils.elapsedNanos(startTimeNanos), TimeUnit.NANOSECONDS); } else { requestProcessor.getForceLedgerStats() .registerFailedEvent(MathUtils.elapsedNanos(startTimeNanos), TimeUnit.NANOSECONDS); } StatusCode status; switch (rc) { case BookieProtocol.EOK: status = StatusCode.EOK; break; case BookieProtocol.EIO: status = StatusCode.EIO; break; default: status = StatusCode.EUA; break; } forceLedgerResponse.setStatus(status); Response.Builder response = Response.newBuilder() .setHeader(getHeader()) .setStatus(forceLedgerResponse.getStatus()) .setForceLedgerResponse(forceLedgerResponse); Response resp = response.build(); sendResponse(status, resp, requestProcessor.getForceLedgerRequestStats()); }; StatusCode status = null; try { requestProcessor.getBookie().forceLedger(ledgerId, wcb, channel); status = StatusCode.EOK; } catch (Throwable t) { logger.error("Unexpected exception while forcing ledger : ", ledgerId, t); status = StatusCode.EBADREQ; } if (!status.equals(StatusCode.EOK)) { forceLedgerResponse.setStatus(status); return forceLedgerResponse.build(); } return null; }