@Override
protected void handleCursorRequest(CursorRequestMessage request,
Channel channel) {
try {
Cursor c = null;
if (request.isSetCursorId()) {
c = syncManager.getCursor(request.getCursorId());
} else {
c = syncManager.newCursor(request.getStoreName());
}
if (c == null) {
throw new SyncException("Unrecognized cursor");
}
CursorResponseMessage m = new CursorResponseMessage();
AsyncMessageHeader header = new AsyncMessageHeader();
header.setTransactionId(request.getHeader().getTransactionId());
m.setHeader(header);
m.setCursorId(c.getCursorId());
if (request.isClose()) {
syncManager.closeCursor(c);
} else {
int i = 0;
while (i < 50 && c.hasNext()) {
Entry<ByteArray, List<Versioned<byte[]>>> e = c.next();
m.addToValues(TProtocolUtil.getTKeyedValues(e.getKey(),
e.getValue()));
i += 1;
}