You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ratis.apache.org by "runzhiwang (Jira)" <ji...@apache.org> on 2020/11/12 12:49:00 UTC
[jira] [Comment Edited] (RATIS-1150) Return exception of
WritableByteChannel#write to client.
[ https://issues.apache.org/jira/browse/RATIS-1150?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17230597#comment-17230597 ]
runzhiwang edited comment on RATIS-1150 at 11/12/20, 12:48 PM:
---------------------------------------------------------------
[~szetszwo] Do you think we need to define another exception, such as DataStreamException, to represent all the exception happen before start transaction ? And wrap the DataStreamException in RaftClientRepy, and return it to client ?
was (Author: yjxxtd):
[~szetszwo] Do you think we need to define another exception, such as DataStreamException, to represent the exception happen before start transaction ? And wrap the DataStreamException in RaftClientRepy, and return it to client ?
> Return exception of WritableByteChannel#write to client.
> --------------------------------------------------------
>
> Key: RATIS-1150
> URL: https://issues.apache.org/jira/browse/RATIS-1150
> Project: Ratis
> Issue Type: Sub-task
> Reporter: runzhiwang
> Assignee: runzhiwang
> Priority: Major
>
> When primary or peer WritableByteChannel#write throw exception, we should return it to client.
> {code:java}
> static long writeTo(ByteBuf buf, DataStream stream) {
> final WritableByteChannel channel = stream.getWritableByteChannel();
> long byteWritten = 0;
> for (ByteBuffer buffer : buf.nioBuffers()) {
> try {
> byteWritten += channel.write(buffer);
> } catch (Throwable t) {
> throw new CompletionException(t);
> }
> }
> return byteWritten;
> }
> {code}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)