- java.lang.Object
-
- org.redkale.net.AsyncConnection
-
- 所有已实现的接口:
Closeable,AutoCloseable,Channel
public abstract class AsyncConnection extends Object implements Channel, AutoCloseable
详情见: https://redkale.org- 作者:
- zhangjx
-
-
字段概要
字段 修饰符和类型 字段 说明 protected intbufferCapacityprotected booleanclientModeprotected booleanconnectPendingprotected AsyncIOGroupioGroupprotected AsyncIOThreadioReadThreadprotected AsyncIOThreadioWriteThreadprotected booleanreadPendingprotected longreadTimeprotected SSLEnginesslEngineprotected booleanwritePendingprotected longwriteTime
-
构造器概要
构造器 限定符 构造器 说明 protectedAsyncConnection(boolean clientMode, AsyncIOGroup ioGroup, AsyncIOThread ioReadThread, AsyncIOThread ioWriteThread, int bufferCapacity, SSLBuilder sslBuilder, SSLContext sslContext)
-
方法概要
所有方法 实例方法 抽象方法 具体方法 修饰符和类型 方法 说明 booleanappendPipeline(int pipelineIndex, int pipelineCount, byte[] bs, int offset, int length)booleanappendPipeline(int pipelineIndex, int pipelineCount, byte[] headerContent, int headerOffset, int headerLength, byte[] bodyContent, int bodyOffset, int bodyLength)booleanappendPipeline(int pipelineIndex, int pipelineCount, ByteTuple array)booleanappendPipeline(int pipelineIndex, int pipelineCount, ByteTuple header, ByteTuple body)AsyncConnectionbeforeCloseListener(Consumer<AsyncConnection> beforeCloseListener)voidclearAttribute()voidclose()voiddispose()voidexecuteRead(Runnable command)voidexecuteRead(Runnable... commands)voidexecuteRead(Collection<Runnable> commands)voidexecuteWrite(Runnable command)voidexecuteWrite(Runnable... commands)voidexecuteWrite(Collection<Runnable> commands)<T> TgetAttribute(String name)Map<String,Object>getAttributes()longgetLastReadTime()longgetLastWriteTime()abstract SocketAddressgetLocalAddress()Consumer<ByteBuffer>getReadBufferConsumer()Supplier<ByteBuffer>getReadBufferSupplier()AsyncIOThreadgetReadIOThread()abstract SocketAddressgetRemoteAddress()<T> TgetSubobject()Consumer<ByteBuffer>getWriteBufferConsumer()Supplier<ByteBuffer>getWriteBufferSupplier()AsyncIOThreadgetWriteIOThread()booleanhasPipelineData()booleaninCurrReadThread()booleaninCurrWriteThread()booleanisReadPending()abstract booleanisTCP()booleanisWritePending()voidofferReadBuffer(ByteBuffer buffer)voidofferReadBuffers(ByteBuffer... buffers)voidofferWriteBuffer(ByteBuffer buffer)voidofferWriteBuffers(ByteBuffer... buffers)ByteBufferpollReadBuffer()protected ByteBufferpollReadSSLBuffer()ByteBufferpollWriteBuffer()ByteBufferpollWriteSSLBuffer()voidread(CompletionHandler<Integer,ByteBuffer> handler)protected abstract voidreadImpl(CompletionHandler<Integer,ByteBuffer> handler)voidreadInIOThread(CompletionHandler<Integer,ByteBuffer> handler)voidreadInIOThreadSafe(CompletionHandler<Integer,ByteBuffer> handler)voidreadRegister(CompletionHandler<Integer,ByteBuffer> handler)protected abstract voidreadRegisterImpl(CompletionHandler<Integer,ByteBuffer> handler)voidreadRegisterInIOThread(CompletionHandler<Integer,ByteBuffer> handler)voidreadRegisterInIOThreadSafe(CompletionHandler<Integer,ByteBuffer> handler)voidremoveAttribute(String name)voidsetAttribute(String name, Object value)abstract <T> booleansetOption(SocketOption<T> name, T value)voidsetReadBuffer(ByteBuffer buffer)protected voidsetReadSSLBuffer(ByteBuffer buffer)voidsetSubobject(Object value)abstract booleanshutdownInput()abstract booleanshutdownOutput()booleanssl()protected voidsslReadImpl(boolean handshake, CompletionHandler<Integer,ByteBuffer> handler)protected voidsslReadRegisterImpl(boolean handshake, CompletionHandler<Integer,ByteBuffer> handler)protected ByteBuffersslUnwrap(boolean handshake, ByteBuffer netBuffer)protected ByteBuffer[]sslWrap(boolean handshake, ByteBuffer appBuffer)protected ByteBuffer[]sslWrap(boolean handshake, ByteBuffer[] appBuffers, int offset, int length)protected booleansslWriteImpl(boolean handshake, ByteBuffer[] appBuffers, int offset, int length, Consumer<Throwable> callback)protected booleansslWriteImpl(boolean handshake, ByteBuffer appBuffer, Consumer<Throwable> callback)protected voidstartHandshake(Consumer<Throwable> callback)protected voidstartRead(CompletionHandler<Integer,ByteBuffer> handler)voidstartReadInIOThread(CompletionHandler<Integer,ByteBuffer> handler)abstract Set<SocketOption<?>>supportedOptions()StringtoString()voidwrite(byte[] headerContent, int headerOffset, int headerLength, byte[] bodyContent, int bodyOffset, int bodyLength, Object handlerAttachment, CompletionHandler handler)voidwrite(byte[] headerContent, int headerOffset, int headerLength, byte[] bodyContent, int bodyOffset, int bodyLength, CompletionHandler<Integer,Void> handler)voidwrite(byte[] bytes, int offset, int length, CompletionHandler<Integer,Void> handler)<A> voidwrite(byte[] bytes, A attachment, CompletionHandler<Integer,? super A> handler)voidwrite(byte[] bytes, CompletionHandler<Integer,Void> handler)<A> voidwrite(ByteBuffer[] srcs, int offset, int length, A attachment, CompletionHandler<Integer,? super A> handler)<A> voidwrite(ByteBuffer[] srcs, A attachment, CompletionHandler<Integer,? super A> handler)<A> voidwrite(ByteBuffer src, A attachment, CompletionHandler<Integer,? super A> handler)<A> voidwrite(ByteTuple array, A attachment, CompletionHandler<Integer,? super A> handler)voidwrite(ByteTuple array, CompletionHandler<Integer,Void> handler)voidwrite(ByteTuple header, ByteTuple body, CompletionHandler<Integer,Void> handler)protected abstract <A> voidwriteImpl(ByteBuffer[] srcs, int offset, int length, A attachment, CompletionHandler<Integer,? super A> handler)srcs写完才会回调protected abstract <A> voidwriteImpl(ByteBuffer src, A attachment, CompletionHandler<Integer,? super A> handler)src写完才会回调voidwriteInIOThread(byte[] headerContent, int headerOffset, int headerLength, byte[] bodyContent, int bodyOffset, int bodyLength, CompletionHandler<Integer,Void> handler)voidwriteInIOThread(byte[] bytes, int offset, int length, CompletionHandler<Integer,Void> handler)voidwriteInIOThread(byte[] bytes, CompletionHandler<Integer,Void> handler)<A> voidwriteInIOThread(ByteBuffer[] srcs, int offset, int length, A attachment, CompletionHandler<Integer,? super A> handler)<A> voidwriteInIOThread(ByteBuffer[] srcs, A attachment, CompletionHandler<Integer,? super A> handler)<A> voidwriteInIOThread(ByteBuffer src, A attachment, CompletionHandler<Integer,? super A> handler)voidwriteInIOThread(ByteTuple array, CompletionHandler<Integer,Void> handler)voidwriteInIOThread(ByteTuple header, ByteTuple body, CompletionHandler<Integer,Void> handler)<A> voidwritePipeline(A attachment, CompletionHandler<Integer,? super A> handler)voidwritePipeline(CompletionHandler<Integer,Void> handler)<A> voidwritePipelineInIOThread(A attachment, CompletionHandler<Integer,? super A> handler)voidwritePipelineInIOThread(CompletionHandler<Integer,Void> handler)
-
-
-
字段详细资料
-
sslEngine
protected SSLEngine sslEngine
-
readTime
protected volatile long readTime
-
writeTime
protected volatile long writeTime
-
connectPending
protected volatile boolean connectPending
-
readPending
protected volatile boolean readPending
-
writePending
protected volatile boolean writePending
-
ioGroup
protected final AsyncIOGroup ioGroup
-
clientMode
protected final boolean clientMode
-
bufferCapacity
protected final int bufferCapacity
-
ioReadThread
protected AsyncIOThread ioReadThread
-
ioWriteThread
protected AsyncIOThread ioWriteThread
-
-
构造器详细资料
-
AsyncConnection
protected AsyncConnection(boolean clientMode, AsyncIOGroup ioGroup, AsyncIOThread ioReadThread, AsyncIOThread ioWriteThread, int bufferCapacity, SSLBuilder sslBuilder, SSLContext sslContext)
-
-
方法详细资料
-
getReadBufferSupplier
public Supplier<ByteBuffer> getReadBufferSupplier()
-
getReadBufferConsumer
public Consumer<ByteBuffer> getReadBufferConsumer()
-
getWriteBufferSupplier
public Supplier<ByteBuffer> getWriteBufferSupplier()
-
getWriteBufferConsumer
public Consumer<ByteBuffer> getWriteBufferConsumer()
-
getLastReadTime
public final long getLastReadTime()
-
getLastWriteTime
public final long getLastWriteTime()
-
ssl
public final boolean ssl()
-
executeRead
public final void executeRead(Runnable command)
-
executeRead
public final void executeRead(Runnable... commands)
-
executeRead
public final void executeRead(Collection<Runnable> commands)
-
executeWrite
public final void executeWrite(Runnable command)
-
executeWrite
public final void executeWrite(Runnable... commands)
-
executeWrite
public final void executeWrite(Collection<Runnable> commands)
-
inCurrReadThread
public final boolean inCurrReadThread()
-
inCurrWriteThread
public final boolean inCurrWriteThread()
-
getReadIOThread
public final AsyncIOThread getReadIOThread()
-
getWriteIOThread
public final AsyncIOThread getWriteIOThread()
-
isTCP
public abstract boolean isTCP()
-
shutdownInput
public abstract boolean shutdownInput()
-
shutdownOutput
public abstract boolean shutdownOutput()
-
setOption
public abstract <T> boolean setOption(SocketOption<T> name, T value)
-
supportedOptions
public abstract Set<SocketOption<?>> supportedOptions()
-
getRemoteAddress
public abstract SocketAddress getRemoteAddress()
-
getLocalAddress
public abstract SocketAddress getLocalAddress()
-
readRegisterImpl
protected abstract void readRegisterImpl(CompletionHandler<Integer,ByteBuffer> handler)
-
readImpl
protected abstract void readImpl(CompletionHandler<Integer,ByteBuffer> handler)
-
writeImpl
protected abstract <A> void writeImpl(ByteBuffer src, A attachment, CompletionHandler<Integer,? super A> handler)
src写完才会回调- 类型参数:
A- A- 参数:
src- ByteBufferattachment- Ahandler- CompletionHandler- 另请参阅:
writeImpl(java.nio.ByteBuffer, java.lang.Object, java.nio.channels.CompletionHandler)
-
writeImpl
protected abstract <A> void writeImpl(ByteBuffer[] srcs, int offset, int length, A attachment, CompletionHandler<Integer,? super A> handler)
srcs写完才会回调- 类型参数:
A- A- 参数:
srcs- ByteBuffer[]offset- offsetlength- lengthattachment- Ahandler- CompletionHandler- 另请参阅:
writeImpl(java.nio.ByteBuffer[], int, int, java.lang.Object, java.nio.channels.CompletionHandler)
-
startRead
protected void startRead(CompletionHandler<Integer,ByteBuffer> handler)
-
startReadInIOThread
public final void startReadInIOThread(CompletionHandler<Integer,ByteBuffer> handler)
-
readRegister
public final void readRegister(CompletionHandler<Integer,ByteBuffer> handler)
-
readRegisterInIOThread
public final void readRegisterInIOThread(CompletionHandler<Integer,ByteBuffer> handler)
-
readRegisterInIOThreadSafe
public final void readRegisterInIOThreadSafe(CompletionHandler<Integer,ByteBuffer> handler)
-
read
public final void read(CompletionHandler<Integer,ByteBuffer> handler)
-
readInIOThread
public final void readInIOThread(CompletionHandler<Integer,ByteBuffer> handler)
-
readInIOThreadSafe
public final void readInIOThreadSafe(CompletionHandler<Integer,ByteBuffer> handler)
-
write
public final <A> void write(ByteBuffer src, A attachment, CompletionHandler<Integer,? super A> handler)
-
write
public final <A> void write(ByteBuffer[] srcs, int offset, int length, A attachment, CompletionHandler<Integer,? super A> handler)
-
write
public final <A> void write(ByteBuffer[] srcs, A attachment, CompletionHandler<Integer,? super A> handler)
-
write
public final void write(byte[] bytes, CompletionHandler<Integer,Void> handler)
-
write
public final <A> void write(byte[] bytes, A attachment, CompletionHandler<Integer,? super A> handler)
-
write
public final void write(byte[] bytes, int offset, int length, CompletionHandler<Integer,Void> handler)
-
write
public final void write(ByteTuple array, CompletionHandler<Integer,Void> handler)
-
write
public final <A> void write(ByteTuple array, A attachment, CompletionHandler<Integer,? super A> handler)
-
write
public final void write(ByteTuple header, ByteTuple body, CompletionHandler<Integer,Void> handler)
-
write
public void write(byte[] headerContent, int headerOffset, int headerLength, byte[] bodyContent, int bodyOffset, int bodyLength, CompletionHandler<Integer,Void> handler)
-
write
public void write(byte[] headerContent, int headerOffset, int headerLength, byte[] bodyContent, int bodyOffset, int bodyLength, Object handlerAttachment, CompletionHandler handler)
-
writeInIOThread
public final <A> void writeInIOThread(ByteBuffer src, A attachment, CompletionHandler<Integer,? super A> handler)
-
writeInIOThread
public final <A> void writeInIOThread(ByteBuffer[] srcs, int offset, int length, A attachment, CompletionHandler<Integer,? super A> handler)
-
writeInIOThread
public final <A> void writeInIOThread(ByteBuffer[] srcs, A attachment, CompletionHandler<Integer,? super A> handler)
-
writeInIOThread
public final void writeInIOThread(byte[] bytes, CompletionHandler<Integer,Void> handler)
-
writeInIOThread
public final void writeInIOThread(ByteTuple array, CompletionHandler<Integer,Void> handler)
-
writeInIOThread
public final void writeInIOThread(byte[] bytes, int offset, int length, CompletionHandler<Integer,Void> handler)
-
writeInIOThread
public final void writeInIOThread(ByteTuple header, ByteTuple body, CompletionHandler<Integer,Void> handler)
-
writeInIOThread
public final void writeInIOThread(byte[] headerContent, int headerOffset, int headerLength, byte[] bodyContent, int bodyOffset, int bodyLength, CompletionHandler<Integer,Void> handler)
-
setReadBuffer
public void setReadBuffer(ByteBuffer buffer)
-
hasPipelineData
public boolean hasPipelineData()
-
writePipeline
public final void writePipeline(CompletionHandler<Integer,Void> handler)
-
writePipeline
public <A> void writePipeline(A attachment, CompletionHandler<Integer,? super A> handler)
-
writePipelineInIOThread
public final void writePipelineInIOThread(CompletionHandler<Integer,Void> handler)
-
writePipelineInIOThread
public final <A> void writePipelineInIOThread(A attachment, CompletionHandler<Integer,? super A> handler)
-
appendPipeline
public final boolean appendPipeline(int pipelineIndex, int pipelineCount, ByteTuple array)
-
appendPipeline
public boolean appendPipeline(int pipelineIndex, int pipelineCount, byte[] bs, int offset, int length)
-
appendPipeline
public final boolean appendPipeline(int pipelineIndex, int pipelineCount, ByteTuple header, ByteTuple body)
-
appendPipeline
public boolean appendPipeline(int pipelineIndex, int pipelineCount, byte[] headerContent, int headerOffset, int headerLength, byte[] bodyContent, int bodyOffset, int bodyLength)
-
setReadSSLBuffer
protected void setReadSSLBuffer(ByteBuffer buffer)
-
pollReadSSLBuffer
protected ByteBuffer pollReadSSLBuffer()
-
pollReadBuffer
public ByteBuffer pollReadBuffer()
-
offerReadBuffer
public void offerReadBuffer(ByteBuffer buffer)
-
offerReadBuffers
public void offerReadBuffers(ByteBuffer... buffers)
-
offerWriteBuffer
public void offerWriteBuffer(ByteBuffer buffer)
-
offerWriteBuffers
public void offerWriteBuffers(ByteBuffer... buffers)
-
pollWriteSSLBuffer
public ByteBuffer pollWriteSSLBuffer()
-
pollWriteBuffer
public ByteBuffer pollWriteBuffer()
-
isReadPending
public boolean isReadPending()
-
isWritePending
public boolean isWritePending()
-
dispose
public void dispose()
-
beforeCloseListener
public AsyncConnection beforeCloseListener(Consumer<AsyncConnection> beforeCloseListener)
-
close
public void close() throws IOException- 指定者:
close在接口中AutoCloseable- 指定者:
close在接口中Channel- 指定者:
close在接口中Closeable- 抛出:
IOException
-
getSubobject
public final <T> T getSubobject()
-
setSubobject
public void setSubobject(Object value)
-
getAttribute
public final <T> T getAttribute(String name)
-
removeAttribute
public final void removeAttribute(String name)
-
clearAttribute
public final void clearAttribute()
-
sslUnwrap
protected ByteBuffer sslUnwrap(boolean handshake, ByteBuffer netBuffer) throws SSLException
- 抛出:
SSLException
-
sslReadImpl
protected void sslReadImpl(boolean handshake, CompletionHandler<Integer,ByteBuffer> handler)
-
sslReadRegisterImpl
protected void sslReadRegisterImpl(boolean handshake, CompletionHandler<Integer,ByteBuffer> handler)
-
sslWrap
protected ByteBuffer[] sslWrap(boolean handshake, ByteBuffer appBuffer) throws SSLException
- 抛出:
SSLException
-
sslWrap
protected ByteBuffer[] sslWrap(boolean handshake, ByteBuffer[] appBuffers, int offset, int length) throws SSLException
- 抛出:
SSLException
-
sslWriteImpl
protected boolean sslWriteImpl(boolean handshake, ByteBuffer appBuffer, Consumer<Throwable> callback) throws SSLException- 抛出:
SSLException
-
sslWriteImpl
protected boolean sslWriteImpl(boolean handshake, ByteBuffer[] appBuffers, int offset, int length, Consumer<Throwable> callback) throws SSLException- 抛出:
SSLException
-
-