@InterfaceAudience.LimitedPrivate(value="HDFS") public class DomainSocket extends Object implements Closeable
DomainSocket
for more information about UNIX domain sockets.Modifier and Type | Class and Description |
---|---|
class |
DomainSocket.DomainChannel |
class |
DomainSocket.DomainInputStream
Input stream for UNIX domain sockets.
|
class |
DomainSocket.DomainOutputStream
Output stream for UNIX domain sockets.
|
Modifier and Type | Field and Description |
---|---|
static int |
RECEIVE_BUFFER_SIZE |
static int |
RECEIVE_TIMEOUT |
static int |
SEND_BUFFER_SIZE |
static int |
SEND_TIMEOUT |
Modifier and Type | Method and Description |
---|---|
DomainSocket |
accept()
Accept a new UNIX domain connection.
|
static DomainSocket |
bindAndListen(String path)
Create a new DomainSocket listening on the given path.
|
void |
close()
Close the Socket.
|
static DomainSocket |
connect(String path)
Create a new DomainSocket connected to the given path.
|
static void |
disableBindPathValidation()
Disable validation of the server bind paths.
|
int |
getAttribute(int type) |
DomainSocket.DomainChannel |
getChannel() |
static String |
getEffectivePath(String path,
int port)
Given a path and a port, compute the effective path by replacing
occurrences of _PORT with the port.
|
DomainSocket.DomainInputStream |
getInputStream() |
static String |
getLoadingFailureReason()
Return true only if UNIX domain sockets are available.
|
DomainSocket.DomainOutputStream |
getOutputStream() |
String |
getPath() |
boolean |
isOpen()
Return true if the file descriptor is currently open.
|
int |
receiveFileDescriptors(FileDescriptor[] descriptors,
byte[] jbuf,
int offset,
int length)
Receive some FileDescriptor objects from the process on the other side of
this socket.
|
int |
recvFileInputStreams(FileInputStream[] streams,
byte[] buf,
int offset,
int length)
Receive some FileDescriptor objects from the process on the other side of
this socket, and wrap them in FileInputStream objects.
|
void |
sendFileDescriptors(FileDescriptor[] descriptors,
byte[] jbuf,
int offset,
int length)
Send some FileDescriptor objects to the process on the other side of this
socket.
|
void |
setAttribute(int type,
int size) |
String |
toString() |
public static final int SEND_BUFFER_SIZE
public static final int RECEIVE_BUFFER_SIZE
public static final int SEND_TIMEOUT
public static final int RECEIVE_TIMEOUT
public static String getLoadingFailureReason()
public static void disableBindPathValidation()
public static String getEffectivePath(String path, int port)
path
- The source pathport
- Port number to usepublic static DomainSocket bindAndListen(String path) throws IOException
path
- The path to bind and listen on.IOException
public DomainSocket accept() throws IOException
IOException
- If there was an I/O error
performing the accept-- such as the
socket being closed from under us.SocketTimeoutException
- If the accept timed out.public static DomainSocket connect(String path) throws IOException
path
- The path to connect to.IOException
public boolean isOpen()
public String getPath()
public DomainSocket.DomainInputStream getInputStream()
public DomainSocket.DomainOutputStream getOutputStream()
public DomainSocket.DomainChannel getChannel()
public void setAttribute(int type, int size) throws IOException
IOException
public int getAttribute(int type) throws IOException
IOException
public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
IOException
public void sendFileDescriptors(FileDescriptor[] descriptors, byte[] jbuf, int offset, int length) throws IOException
descriptors
- The file descriptors to send.jbuf
- Some bytes to send. You must send at least
one byte.offset
- The offset in the jbuf array to start at.length
- Length of the jbuf array to use.IOException
public int receiveFileDescriptors(FileDescriptor[] descriptors, byte[] jbuf, int offset, int length) throws IOException
descriptors
- (output parameter) Array of FileDescriptors.
We will fill as many slots as possible with file
descriptors passed from the remote process. The
other slots will contain NULL.jbuf
- (output parameter) Buffer to read into.
The UNIX domain sockets API requires you to read
at least one byte from the remote process, even
if all you care about is the file descriptors
you will receive.offset
- Offset into the byte buffer to load datalength
- Length of the byte buffer to use for dataIOException
- if there was an I/O error.public int recvFileInputStreams(FileInputStream[] streams, byte[] buf, int offset, int length) throws IOException
DomainSocket#recvFileInputStreams(ByteBuffer)
IOException
Copyright © 2013 Apache Software Foundation. All rights reserved.