You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@hbase.apache.org by "chenglei (Jira)" <ji...@apache.org> on 2023/06/12 08:43:00 UTC

[jira] [Assigned] (HBASE-27924) Remove duplicate code for NettyHBaseSaslRpcServerHandler and make the sentByte metrics more accurate

     [ https://issues.apache.org/jira/browse/HBASE-27924?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

chenglei reassigned HBASE-27924:
--------------------------------

    Assignee: chenglei

> Remove duplicate code for NettyHBaseSaslRpcServerHandler and make the sentByte metrics more accurate
> ----------------------------------------------------------------------------------------------------
>
>                 Key: HBASE-27924
>                 URL: https://issues.apache.org/jira/browse/HBASE-27924
>             Project: HBase
>          Issue Type: Bug
>          Components: netty, rpc, security
>    Affects Versions: 2.6.0, 3.0.0-alpha-4, 4.0.0-alpha-1
>            Reporter: chenglei
>            Assignee: chenglei
>            Priority: Major
>
> {{NettyHBaseSaslRpcServerHandler.doResponse}}  and  {{ServerRpcConnection.doRawSaslReply}} are very similar, I think we could replace {{NettyHBaseSaslRpcServerHandler.doResponse}}  with {{ServerRpcConnection.doRawSaslReply}}: 
> {code:java}
> private void doResponse(ChannelHandlerContext ctx, SaslStatus status, Writable rv,
>     String errorClass, String error) throws IOException {
>     // In my testing, have noticed that sasl messages are usually
>     // in the ballpark of 100-200. That's why the initial capacity is 256.
>     ByteBuf resp = ctx.alloc().buffer(256);
>     try (ByteBufOutputStream out = new ByteBufOutputStream(resp)) {
>       out.writeInt(status.state); // write status
>       if (status == SaslStatus.SUCCESS) {
>         rv.write(out);
>       } else {
>         WritableUtils.writeString(out, errorClass);
>         WritableUtils.writeString(out, error);
>       }
>     }
>     NettyFutureUtils.safeWriteAndFlush(ctx, resp);
>   }
> {code}
> {code:java}
> protected final void doRawSaslReply(SaslStatus status, Writable rv, String errorClass,
>     String error) throws IOException {
>     BufferChain bc;
>     // In my testing, have noticed that sasl messages are usually
>     // in the ballpark of 100-200. That's why the initial capacity is 256.
>     try (ByteBufferOutputStream saslResponse = new ByteBufferOutputStream(256);
>       DataOutputStream out = new DataOutputStream(saslResponse)) {
>       out.writeInt(status.state); // write status
>       if (status == SaslStatus.SUCCESS) {
>         rv.write(out);
>       } else {
>         WritableUtils.writeString(out, errorClass);
>         WritableUtils.writeString(out, error);
>       }
>       bc = new BufferChain(saslResponse.getByteBuffer());
>     }
>     doRespond(() -> bc);
>   }
> {code}
> At the same time, {{NettyHBaseSaslRpcServerHandler.doResponse}}  sends ByteBuf directly , so  it would not handled by the logic in  {{NettyRpcServerResponseEncoder.write}}, which would update the {{MetricsHBaseServer.sentBytes}}.  Using   {{ServerRpcConnection.doRawSaslReply}} uniformly would make the {{MetricsHBaseServer.sentBytes}} more accurate.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)