Package com.mongodb.internal.connection
Class AsynchronousSocketChannelStream
- java.lang.Object
-
- com.mongodb.internal.connection.AsynchronousSocketChannelStream
-
- All Implemented Interfaces:
BufferProvider,Stream
public final class AsynchronousSocketChannelStream extends java.lang.Object implements Stream
-
-
Constructor Summary
Constructors Constructor Description AsynchronousSocketChannelStream(ServerAddress serverAddress, SocketSettings settings, BufferProvider bufferProvider, java.nio.channels.AsynchronousChannelGroup group)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Closes the connection.ServerAddressgetAddress()The address that this stream is connected to.ByteBufgetBuffer(int size)Gets a buffer with the givens capacity.java.nio.channels.AsynchronousChannelGroupgetGroup()ServerAddressgetServerAddress()SocketSettingsgetSettings()booleanisClosed()Returns the closed state of the connectionvoidopen()Open the stream.voidopenAsync(AsyncCompletionHandler<java.lang.Void> handler)Open the stream asynchronously.ByteBufread(int numBytes)Read from the stream, blocking until the requested number of bytes have been read.voidreadAsync(int numBytes, AsyncCompletionHandler<ByteBuf> handler)Read from the stream, asynchronously.voidwrite(java.util.List<ByteBuf> buffers)Write each buffer in the list to the stream in order, blocking until all are completely written.voidwriteAsync(java.util.List<ByteBuf> buffers, AsyncCompletionHandler<java.lang.Void> handler)Write each buffer in the list to the stream in order, asynchronously.
-
-
-
Constructor Detail
-
AsynchronousSocketChannelStream
public AsynchronousSocketChannelStream(ServerAddress serverAddress, SocketSettings settings, BufferProvider bufferProvider, java.nio.channels.AsynchronousChannelGroup group)
-
-
Method Detail
-
getBuffer
public ByteBuf getBuffer(int size)
Description copied from interface:BufferProviderGets a buffer with the givens capacity.- Specified by:
getBufferin interfaceBufferProvider- Parameters:
size- the size required for the buffer- Returns:
- a ByteBuf with the given size, which is now owned by the caller and must be released.
-
open
public void open() throws java.io.IOExceptionDescription copied from interface:StreamOpen the stream.
-
openAsync
public void openAsync(AsyncCompletionHandler<java.lang.Void> handler)
Description copied from interface:StreamOpen the stream asynchronously.
-
write
public void write(java.util.List<ByteBuf> buffers) throws java.io.IOException
Description copied from interface:StreamWrite each buffer in the list to the stream in order, blocking until all are completely written.
-
read
public ByteBuf read(int numBytes) throws java.io.IOException
Description copied from interface:StreamRead from the stream, blocking until the requested number of bytes have been read.
-
writeAsync
public void writeAsync(java.util.List<ByteBuf> buffers, AsyncCompletionHandler<java.lang.Void> handler)
Description copied from interface:StreamWrite each buffer in the list to the stream in order, asynchronously. This method should return immediately, and invoke the given callback on completion.- Specified by:
writeAsyncin interfaceStream- Parameters:
buffers- the buffers to writehandler- invoked when the read operation has completed
-
readAsync
public void readAsync(int numBytes, AsyncCompletionHandler<ByteBuf> handler)Description copied from interface:StreamRead from the stream, asynchronously. This method should return immediately, and invoke the given callback when the number of requested bytes have been read.
-
getAddress
public ServerAddress getAddress()
Description copied from interface:StreamThe address that this stream is connected to.- Specified by:
getAddressin interfaceStream- Returns:
- the address
-
isClosed
public boolean isClosed()
Description copied from interface:StreamReturns the closed state of the connection
-
getServerAddress
public ServerAddress getServerAddress()
-
getSettings
public SocketSettings getSettings()
-
getGroup
public java.nio.channels.AsynchronousChannelGroup getGroup()
-
-