use of io.pravega.shared.protocol.netty.RequestProcessor in project pravega by pravega.
the class ServerConnectionInboundHandler method channelRead.
@Override
public void channelRead(ChannelHandlerContext ctx, Object msg) {
Request cmd = (Request) msg;
log.debug("Processing request: {}", cmd);
RequestProcessor requestProcessor = processor.get();
if (requestProcessor == null) {
throw new IllegalStateException("No command processor set for connection");
}
cmd.process(requestProcessor);
}
use of io.pravega.shared.protocol.netty.RequestProcessor in project pravega by pravega.
the class PravegaRequestProcessor method readSegment.
// endregion
// region RequestProcessor Implementation
@Override
public void readSegment(ReadSegment readSegment) {
Timer timer = new Timer();
final String segment = readSegment.getSegment();
if (!verifyToken(segment, readSegment.getOffset(), readSegment.getDelegationToken(), READ, "Read Segment")) {
return;
}
final int readSize = min(MAX_READ_SIZE, max(TYPE_PLUS_LENGTH_SIZE, readSegment.getSuggestedLength()));
long trace = LoggerHelpers.traceEnter(log, "readSegment", readSegment);
segmentStore.read(segment, readSegment.getOffset(), readSize, TIMEOUT).thenAccept(readResult -> {
LoggerHelpers.traceLeave(log, "readSegment", trace, readResult);
handleReadResult(readSegment, readResult);
DYNAMIC_LOGGER.incCounterValue(nameFromSegment(SEGMENT_READ_BYTES, segment), readResult.getConsumedLength());
readStreamSegment.reportSuccessEvent(timer.getElapsed());
}).exceptionally(ex -> handleException(readSegment.getOffset(), segment, "Read segment", ex));
}
Aggregations