[ 
https://issues.apache.org/jira/browse/HBASE-14490?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14908069#comment-14908069
 ] 

Zephyr Guo commented on HBASE-14490:
------------------------------------

What is the meaning of “contain garbage”?
We have a buffer that 4 bytes.First, we read 4 bytes of data.Then we reuse 
buffer to read 2 bytes of data.Finally, buffer contain 2 bytes of garbage.Do 
you means that?

> [RpcServer] reuse buffer and more stricter code
> -----------------------------------------------
>
>                 Key: HBASE-14490
>                 URL: https://issues.apache.org/jira/browse/HBASE-14490
>             Project: HBase
>          Issue Type: Improvement
>          Components: IPC/RPC
>    Affects Versions: 2.0.0
>            Reporter: Zephyr Guo
>            Assignee: Zephyr Guo
>         Attachments: HBASE-14490-v1.patch, Test.java
>
>
> 1.Reuse buffer to read request.
> It's not necessary free data's buffer for each request.It can cause memory 
> fragmentation.
> 2.There are hidden trouble in socket IO with non-blocking mode.
> We just use *channel.read(byteBuffer)* to read data of 
> request(byteBuffer.limit=dataLength).We need *dataLength* bytes but read 
> maybe not fill the *byteBuffer*.
> The link is the *read(byteBuffer)* method 
> describe:http://docs.oracle.com/javase/7/docs/api/java/nio/channels/SocketChannel.html#read(java.nio.ByteBuffer)
> I write a sample to test it(Test.java).
> 3.*channelIO()* method return value
> More stricter return value.
> So I rewrite *channelIO*.It can work well with non-blocking and back small 
> IO(size<NIO_BUFFER_LIMIT) or large.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to