in bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/ReadEntryProcessor.java [60:128]
protected void processPacket() {
if (LOG.isDebugEnabled()) {
LOG.debug("Received new read request: {}", request);
}
if (!requestHandler.ctx().channel().isOpen()) {
if (LOG.isDebugEnabled()) {
LOG.debug("Dropping read request for closed channel: {}", requestHandler.ctx().channel());
}
requestProcessor.onReadRequestFinish();
recycle();
return;
}
int errorCode = BookieProtocol.EOK;
long startTimeNanos = MathUtils.nowInNano();
ReferenceCounted data = null;
try {
CompletableFuture<Boolean> fenceResult = null;
if (request.isFencing()) {
LOG.warn("Ledger: {} fenced by: {}", request.getLedgerId(),
requestHandler.ctx().channel().remoteAddress());
if (request.hasMasterKey()) {
fenceResult = requestProcessor.getBookie().fenceLedger(request.getLedgerId(),
request.getMasterKey());
} else {
LOG.error("Password not provided, Not safe to fence {}", request.getLedgerId());
throw BookieException.create(BookieException.Code.UnauthorizedAccessException);
}
}
data = readData();
if (LOG.isDebugEnabled()) {
LOG.debug("##### Read entry ##### -- ref-count: {}", data.refCnt());
}
if (fenceResult != null) {
handleReadResultForFenceRead(fenceResult, data, startTimeNanos);
return;
}
} catch (Bookie.NoLedgerException e) {
if (LOG.isDebugEnabled()) {
LOG.debug("Error reading {}", request, e);
}
errorCode = BookieProtocol.ENOLEDGER;
} catch (Bookie.NoEntryException e) {
if (LOG.isDebugEnabled()) {
LOG.debug("Error reading {}", request, e);
}
errorCode = BookieProtocol.ENOENTRY;
} catch (IOException e) {
if (LOG.isDebugEnabled()) {
LOG.debug("Error reading {}", request, e);
}
errorCode = BookieProtocol.EIO;
} catch (BookieException.DataUnknownException e) {
LOG.error("Ledger {} is in an unknown state", request.getLedgerId(), e);
errorCode = BookieProtocol.EUNKNOWNLEDGERSTATE;
} catch (BookieException e) {
LOG.error("Unauthorized access to ledger {}", request.getLedgerId(), e);
errorCode = BookieProtocol.EUA;
} catch (Throwable t) {
LOG.error("Unexpected exception reading at {}:{} : {}", request.getLedgerId(), request.getEntryId(),
t.getMessage(), t);
errorCode = BookieProtocol.EBADREQ;
}
if (LOG.isTraceEnabled()) {
LOG.trace("Read entry rc = {} for {}", errorCode, request);
}
sendResponse(data, errorCode, startTimeNanos);
}