use of org.apache.jackrabbit.oak.segment.standby.codec.GetHeadResponse in project jackrabbit-oak by apache.
the class GetHeadRequestHandler method channelRead0.
@Override
protected void channelRead0(ChannelHandlerContext ctx, GetHeadRequest msg) throws Exception {
log.debug("Reading head for client {}", msg.getClientId());
String id = reader.readHeadRecordId();
if (id == null) {
log.debug("Head not found, discarding request from client {}", msg.getClientId());
return;
}
ctx.writeAndFlush(new GetHeadResponse(msg.getClientId(), id));
}
use of org.apache.jackrabbit.oak.segment.standby.codec.GetHeadResponse in project jackrabbit-oak by apache.
the class StandbyClient method getHead.
@Nullable
String getHead() throws InterruptedException {
channel.writeAndFlush(new GetHeadRequest(clientId));
GetHeadResponse response = headQueue.poll(readTimeoutMs, TimeUnit.MILLISECONDS);
if (response == null) {
return null;
}
return response.getHeadRecordId();
}
use of org.apache.jackrabbit.oak.segment.standby.codec.GetHeadResponse in project jackrabbit-oak by apache.
the class GetHeadRequestHandlerTest method successfulReadsShouldGenerateResponses.
@Test
public void successfulReadsShouldGenerateResponses() throws Exception {
StandbyHeadReader reader = mock(StandbyHeadReader.class);
when(reader.readHeadRecordId()).thenReturn("recordId");
EmbeddedChannel channel = new EmbeddedChannel(new GetHeadRequestHandler(reader));
channel.writeInbound(new GetHeadRequest("clientId"));
GetHeadResponse response = (GetHeadResponse) channel.readOutbound();
assertEquals("recordId", response.getHeadRecordId());
assertEquals("clientId", response.getClientId());
}
Aggregations