public void uploadChunk(String location, ByteBuffer chunk)
throws TException {
TimeCacheMap<Object, Object> uploaders = data.getUploaders();
Object obj = uploaders.get(location);
if (obj == null) {
throw new TException(
"File for that location does not exist (or timed out) "
+ location);
}
try {
if (obj instanceof WritableByteChannel) {
WritableByteChannel channel = (WritableByteChannel) obj;
channel.write(chunk);
uploaders.put(location, channel);
} else {
throw new TException("Object isn't WritableByteChannel for "
+ location);
}
} catch (IOException e) {
String errMsg = " WritableByteChannel write filed when uploadChunk "
+ location;
LOG.error(errMsg);
throw new TException(e);
}
}