|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.thrift.transport.TTransport
org.apache.thrift.transport.TNonblockingTransport
org.apache.thrift.transport.TNonblockingSocket
public class TNonblockingSocket
Transport for use with async client.
Constructor Summary | |
---|---|
TNonblockingSocket(java.nio.channels.SocketChannel socketChannel)
Constructor that takes an already created socket. |
|
TNonblockingSocket(java.lang.String host,
int port)
|
|
TNonblockingSocket(java.lang.String host,
int port,
int timeout)
Create a new nonblocking socket transport that will be connected to host:port. |
Method Summary | |
---|---|
void |
close()
Closes the socket. |
boolean |
finishConnect()
Non-blocking connection completion. |
void |
flush()
Noop. |
java.nio.channels.SocketChannel |
getSocketChannel()
Returns a reference to the underlying SocketChannel. |
boolean |
isOpen()
Checks whether the socket is connected. |
void |
open()
Do not call, the implementation provides its own lazy non-blocking connect. |
int |
read(byte[] buf,
int off,
int len)
Reads from the underlying input stream if not null. |
int |
read(java.nio.ByteBuffer buffer)
Perform a nonblocking read into buffer. |
java.nio.channels.SelectionKey |
registerSelector(java.nio.channels.Selector selector,
int interests)
Register the new SocketChannel with our Selector, indicating we'd like to be notified when it's ready for I/O. |
void |
setTimeout(int timeout)
Sets the socket timeout, although this implementation never uses blocking operations so it is unused. |
boolean |
startConnect()
Non-blocking connection initialization. |
void |
write(byte[] buf,
int off,
int len)
Writes to the underlying output stream if not null. |
int |
write(java.nio.ByteBuffer buffer)
Perform a nonblocking write of the data in buffer; |
Methods inherited from class org.apache.thrift.transport.TTransport |
---|
consumeBuffer, getBuffer, getBufferPosition, getBytesRemainingInBuffer, peek, readAll, write |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public TNonblockingSocket(java.lang.String host, int port) throws java.io.IOException
java.io.IOException
public TNonblockingSocket(java.lang.String host, int port, int timeout) throws java.io.IOException
host
- port
-
TTransportException
java.io.IOException
public TNonblockingSocket(java.nio.channels.SocketChannel socketChannel) throws java.io.IOException
socketChannel
- Already created SocketChannel object
java.io.IOException
- if there is an error setting up the streamsMethod Detail |
---|
public java.nio.channels.SelectionKey registerSelector(java.nio.channels.Selector selector, int interests) throws java.io.IOException
registerSelector
in class TNonblockingTransport
selector
-
java.io.IOException
public void setTimeout(int timeout)
timeout
- Milliseconds timeoutpublic java.nio.channels.SocketChannel getSocketChannel()
public boolean isOpen()
isOpen
in class TTransport
public void open() throws TTransportException
open
in class TTransport
TTransportException
- if the transport could not be openedpublic int read(java.nio.ByteBuffer buffer) throws java.io.IOException
read
in class TNonblockingTransport
java.io.IOException
public int read(byte[] buf, int off, int len) throws TTransportException
read
in class TTransport
buf
- Array to read intooff
- Index to start reading atlen
- Maximum number of bytes to read
TTransportException
- if there was an error reading datapublic int write(java.nio.ByteBuffer buffer) throws java.io.IOException
write
in class TNonblockingTransport
java.io.IOException
public void write(byte[] buf, int off, int len) throws TTransportException
write
in class TTransport
buf
- The output data bufferoff
- The offset to start writing fromlen
- The number of bytes to write
TTransportException
- if there was an error writing datapublic void flush() throws TTransportException
flush
in class TTransport
TTransportException
- if there was an error writing out data.public void close()
close
in class TTransport
public boolean startConnect() throws java.io.IOException
startConnect
in class TNonblockingTransport
java.io.IOException
SocketChannel.connect(SocketAddress remote)
public boolean finishConnect() throws java.io.IOException
finishConnect
in class TNonblockingTransport
java.io.IOException
SocketChannel.finishConnect()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |