Source:
private void processReadRequestV3(final BookkeeperProtocol.Request r, final Channel c) { ExecutorService lpThreadPool = null == longPollThreadPool ? null : longPollThreadPool.chooseThread(c); ReadEntryProcessorV3 read; if (RequestUtils.isLongPollReadRequest(r.getReadRequest())) { read = new LongPollReadEntryProcessorV3( r, c, this, fenceThreadPool, lpThreadPool, requestTimer); if (null == longPollThreadPool) { read.run(); } else { longPollThreadPool.submitOrdered(r.getReadRequest().getLedgerId(), read); } } else { read = new ReadEntryProcessorV3(r, c, this, fenceThreadPool); boolean isRecoveryRead = r.getReadRequest().hasFlag() && (r.getReadRequest().getFlag() == BookkeeperProtocol.ReadRequest.Flag.RECOVERY_READ || r.getReadRequest().getFlag() == BookkeeperProtocol.ReadRequest.Flag.FENCE_LEDGER); if (null == readThreadPool || isRecoveryRead) { read.run(); } else { try { readThreadPool.submitOrdered(r.getReadRequest().getLedgerId(), read); } catch (RejectedExecutionException e) { if (LOG.isDebugEnabled()) { LOG.debug("Failed to process request to read entry at {}:{}. Too many pending requests", r.getReadRequest().getLedgerId(), r.getReadRequest().getEntryId()); } BookkeeperProtocol.ReadResponse.Builder readResponse = BookkeeperProtocol.ReadResponse.newBuilder() .setLedgerId(r.getAddRequest().getLedgerId()) .setEntryId(r.getAddRequest().getEntryId()) .setStatus(BookkeeperProtocol.StatusCode.ETOOMANYREQUESTS); BookkeeperProtocol.Response.Builder response = BookkeeperProtocol.Response.newBuilder() .setHeader(read.getHeader()) .setStatus(readResponse.getStatus()) .setReadResponse(readResponse); BookkeeperProtocol.Response resp = response.build(); read.sendResponse(readResponse.getStatus(), resp, readRequestStats); } } } }

Target:
private void processReadRequestV3(final BookkeeperProtocol.Request r, final Channel c) { ExecutorService fenceThread = null == highPriorityThreadPool ? null : highPriorityThreadPool.chooseThread(c); final ReadEntryProcessorV3 read; final OrderedSafeExecutor threadPool; if (RequestUtils.isLongPollReadRequest(r.getReadRequest())) { ExecutorService lpThread = null == longPollThreadPool ? null : longPollThreadPool.chooseThread(c); read = new LongPollReadEntryProcessorV3(r, c, this, fenceThread, lpThread, requestTimer); threadPool = longPollThreadPool; } else { read = new ReadEntryProcessorV3(r, c, this, fenceThread); boolean isHighPriority = RequestUtils.isHighPriority(r) || hasFlag(r.getReadRequest(), BookkeeperProtocol.ReadRequest.Flag.FENCE_LEDGER); if (isHighPriority) { threadPool = highPriorityThreadPool; } else { threadPool = readThreadPool; } } if (null == threadPool) { read.run(); } else { try { threadPool.submitOrdered(r.getReadRequest().getLedgerId(), read); } catch (RejectedExecutionException e) { if (LOG.isDebugEnabled()) { LOG.debug("Failed to process request to read entry at {}:{}. Too many pending requests", r.getReadRequest().getLedgerId(), r.getReadRequest().getEntryId()); } BookkeeperProtocol.ReadResponse.Builder readResponse = BookkeeperProtocol.ReadResponse.newBuilder() .setLedgerId(r.getAddRequest().getLedgerId()) .setEntryId(r.getAddRequest().getEntryId()) .setStatus(BookkeeperProtocol.StatusCode.ETOOMANYREQUESTS); BookkeeperProtocol.Response.Builder response = BookkeeperProtocol.Response.newBuilder() .setHeader(read.getHeader()) .setStatus(readResponse.getStatus()) .setReadResponse(readResponse); BookkeeperProtocol.Response resp = response.build(); read.sendResponse(readResponse.getStatus(), resp, readRequestStats); } } }