Source:
<code>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); <START> boolean isRecoveryRead = r.getReadRequest().hasFlag() <END> && (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); } } } }</code><technical_language>this some function a test case cover it</technical_language>

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); } } }