use of com.bonree.brfs.disknode.InputResult in project BRFS by zhangnianli.
the class WriteMessageHandler method handle.
@Override
public void handle(DiskMessage msg, HandleResultCallback callback) {
HandleResult handleResult = new HandleResult();
try {
LOG.debug("WRITE [{}], data length[{}]", msg.getFilePath(), msg.getData().length);
nodeManager.writeAsync(msg.getFilePath(), msg.getData(), new InputEventCallback() {
@Override
public void completeError(Throwable t) {
handleResult.setSuccess(false);
handleResult.setCause(t);
callback.completed(handleResult);
}
@Override
public void complete(InputResult result) {
handleResult.setSuccess(true);
WriteResult writeResult = new WriteResult();
writeResult.setOffset(result.getOffset());
writeResult.setSize(result.getSize());
try {
handleResult.setData(ProtoStuffUtils.serialize(writeResult));
} catch (IOException e) {
e.printStackTrace();
}
callback.completed(handleResult);
}
});
} catch (Exception e) {
handleResult.setSuccess(false);
handleResult.setCause(e);
callback.completed(handleResult);
}
}
Aggregations