} else if (request.startsWith(Messages.GET_SEGMENT)) {
String sid = request.substring(Messages.GET_SEGMENT.length());
log.debug("request segment id {}", sid);
UUID uuid = UUID.fromString(sid);
Segment s = null;
for (int i = 0; i < 10; i++) {
try {
s = store.readSegment(new SegmentId(store.getTracker(),
uuid.getMostSignificantBits(), uuid
.getLeastSignificantBits()));
} catch (IllegalStateException e) {
// segment not found
log.debug("waiting for segment. Got exception: " + e.getMessage());
TimeUnit.MILLISECONDS.sleep(1000);
}
if (s != null) break;
}
if (s != null) {
log.debug("sending segment " + sid + " to " + client);
ctx.writeAndFlush(s);
observer.didSendSegmentBytes(clientID, s.size());
return;
}
} else {
log.warn("Unknown request {}, ignoring.", request);
}