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

Colin Patrick McCabe commented on HDFS-5746:
--------------------------------------------

See here for some notes about the strategy for 5182: 
https://issues.apache.org/jira/browse/HDFS-5182?focusedCommentId=13866545&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-13866545

* Add SharedFileDescriptorFactory.  This is a class which can produce anonymous 
shared memory segments suitable for passing from the DataNode to the DFSClient 
via file descriptor passing.  It would have been nice to do this without JNI, 
but unfortunately we don't have {{open(O_EXCL)}} support in JDK6, which we're 
still supporting.  There is {{NativeIO#open}}, but it doesn't allow me to 
cleanly separate {{EEXIST}} errors from other errors (the error gets turned 
into a textual exception which I don't want to parse).  Also there may be some 
symlink issues with the JDK6 java APIs for listing files in a directory, etc.  
Overall, the native implementation was just easier.  This is something we 
should probably revisit with JDK7, of course.

* Add {{NativeIO#mmap}} and {{NativeIO#munmap}}.  Although it would be nicer to 
use {{FileChannel#map}}, there is no public interface to get access to the 
virtual memory address of a {{MappedByteBuffer}}, and I needed that.  Luckily, 
the amount of code needed to just call mmap is really small.

* I didn't want to duplicate the code used to stuff a reference count + closed 
bit into {{DomainSocket#refCount}}, so I factored it out into 
{{CloseableReferenceCount}}.  This class is now used in both DomainSocket and 
{{ShortCircuitSharedMemorySegment}}.

* {{DomainSocketWatcher}} is a thread which calls poll() in a loop.  This will 
be used to detect when a DFSClient has closed and its shared memory segments 
can be closed, by detecting when their associated DomainSockets are closed.  I 
used poll() here rather than select() since select() has some limitations with 
high-numbered file descriptors on some platforms.  Also, poll's interface is a 
bit simpler.  It would have been nice to use Java NIO for this, but 
{{DomainSocket}} is not integrated with NIO.  poll() doesn't scale as well as 
epoll() and other platform-specific functions, but we don't need it to, since 
this just for handling clients closing, which should be a relatively infrequent 
event.  We're not using this for handling every packet sent through a webserver 
or something.

* {{ShortCircuitSharedMemorySegment}} is entirely in Java, using 
{{sun.misc.Unsafe}} for the anchor / unanchor / etc. operations.  This is 
preferrable to using JNI for this, since {{Unsafe#compareAndSwap}} will be 
inlined by the JVM.  (Thanks to [~tlipcon] for pointing out the existence of 
these functions).

> add ShortCircuitSharedMemorySegment
> -----------------------------------
>
>                 Key: HDFS-5746
>                 URL: https://issues.apache.org/jira/browse/HDFS-5746
>             Project: Hadoop HDFS
>          Issue Type: Sub-task
>          Components: datanode, hdfs-client
>            Reporter: Colin Patrick McCabe
>            Assignee: Colin Patrick McCabe
>             Fix For: 3.0.0
>
>
> Add ShortCircuitSharedMemorySegment, which will be used to communicate 
> information between the datanode and the client about whether a replica is 
> mlocked.



--
This message was sent by Atlassian JIRA
(v6.1.5#6160)

Reply via email to