Package org.apache.hadoop.net.unix
Class DomainSocketWatcher
java.lang.Object
org.apache.hadoop.net.unix.DomainSocketWatcher
- All Implemented Interfaces:
Closeable,AutoCloseable
The DomainSocketWatcher watches a set of domain sockets to see when they
become readable, or closed. When one of those events happens, it makes a
callback.
See
DomainSocket for more information about UNIX domain sockets.-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(DomainSocket sock, DomainSocketWatcher.Handler handler) Add a socket.voidclose()Close the DomainSocketWatcher and wait for its thread to terminate.static StringbooleanisClosed()voidremove(DomainSocket sock) Remove a socket.toString()
-
Constructor Details
-
DomainSocketWatcher
- Throws:
IOException
-
-
Method Details
-
getLoadingFailureReason
-
close
Close the DomainSocketWatcher and wait for its thread to terminate. If there is more than one close, all but the first will be ignored.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
isClosed
@VisibleForTesting public boolean isClosed() -
add
Add a socket.- Parameters:
sock- The socket to add. It is an error to re-add a socket that we are already watching.handler- The handler to associate with this socket. This may be called any time after this function is called.
-
remove
Remove a socket. Its handler will be called.- Parameters:
sock- The socket to remove.
-
toString
-