- java.lang.Object
-
- org.redkale.net.AsyncConnection
-
- 所有已实现的接口:
Closeable
,AutoCloseable
,Channel
public abstract class AsyncConnection extends Object implements Channel, AutoCloseable
详情见: https://redkale.org- 作者:
- zhangjx
-
-
字段概要
字段 修饰符和类型 字段 说明 protected int
bufferCapacity
protected boolean
clientMode
protected boolean
connectPending
protected AsyncIOGroup
ioGroup
protected AsyncIOThread
ioReadThread
protected AsyncIOThread
ioWriteThread
protected boolean
readPending
protected long
readTime
protected SSLEngine
sslEngine
protected boolean
writePending
protected long
writeTime
-
构造器概要
构造器 限定符 构造器 说明 protected
AsyncConnection(boolean clientMode, AsyncIOGroup ioGroup, AsyncIOThread ioReadThread, AsyncIOThread ioWriteThread, int bufferCapacity, SSLBuilder sslBuilder, SSLContext sslContext)
-
方法概要
所有方法 实例方法 抽象方法 具体方法 修饰符和类型 方法 说明 boolean
appendPipeline(int pipelineIndex, int pipelineCount, byte[] bs, int offset, int length)
boolean
appendPipeline(int pipelineIndex, int pipelineCount, byte[] headerContent, int headerOffset, int headerLength, byte[] bodyContent, int bodyOffset, int bodyLength)
boolean
appendPipeline(int pipelineIndex, int pipelineCount, ByteTuple array)
boolean
appendPipeline(int pipelineIndex, int pipelineCount, ByteTuple header, ByteTuple body)
AsyncConnection
beforeCloseListener(Consumer<AsyncConnection> beforeCloseListener)
void
clearAttribute()
void
close()
void
dispose()
void
executeRead(Runnable command)
void
executeRead(Runnable... commands)
void
executeRead(Collection<Runnable> commands)
void
executeWrite(Runnable command)
void
executeWrite(Runnable... commands)
void
executeWrite(Collection<Runnable> commands)
<T> T
getAttribute(String name)
Map<String,Object>
getAttributes()
long
getLastReadTime()
long
getLastWriteTime()
abstract SocketAddress
getLocalAddress()
Consumer<ByteBuffer>
getReadBufferConsumer()
Supplier<ByteBuffer>
getReadBufferSupplier()
AsyncIOThread
getReadIOThread()
abstract SocketAddress
getRemoteAddress()
<T> T
getSubobject()
Consumer<ByteBuffer>
getWriteBufferConsumer()
Supplier<ByteBuffer>
getWriteBufferSupplier()
AsyncIOThread
getWriteIOThread()
boolean
hasPipelineData()
boolean
inCurrReadThread()
boolean
inCurrWriteThread()
boolean
isReadPending()
abstract boolean
isTCP()
boolean
isWritePending()
void
offerReadBuffer(ByteBuffer buffer)
void
offerReadBuffers(ByteBuffer... buffers)
void
offerWriteBuffer(ByteBuffer buffer)
void
offerWriteBuffers(ByteBuffer... buffers)
ByteBuffer
pollReadBuffer()
protected ByteBuffer
pollReadSSLBuffer()
ByteBuffer
pollWriteBuffer()
ByteBuffer
pollWriteSSLBuffer()
void
read(CompletionHandler<Integer,ByteBuffer> handler)
protected abstract void
readImpl(CompletionHandler<Integer,ByteBuffer> handler)
void
readInIOThread(CompletionHandler<Integer,ByteBuffer> handler)
void
readInIOThreadSafe(CompletionHandler<Integer,ByteBuffer> handler)
void
readRegister(CompletionHandler<Integer,ByteBuffer> handler)
protected abstract void
readRegisterImpl(CompletionHandler<Integer,ByteBuffer> handler)
void
readRegisterInIOThread(CompletionHandler<Integer,ByteBuffer> handler)
void
readRegisterInIOThreadSafe(CompletionHandler<Integer,ByteBuffer> handler)
void
removeAttribute(String name)
void
setAttribute(String name, Object value)
abstract <T> boolean
setOption(SocketOption<T> name, T value)
void
setReadBuffer(ByteBuffer buffer)
protected void
setReadSSLBuffer(ByteBuffer buffer)
void
setSubobject(Object value)
abstract boolean
shutdownInput()
abstract boolean
shutdownOutput()
boolean
ssl()
protected void
sslReadImpl(boolean handshake, CompletionHandler<Integer,ByteBuffer> handler)
protected void
sslReadRegisterImpl(boolean handshake, CompletionHandler<Integer,ByteBuffer> handler)
protected ByteBuffer
sslUnwrap(boolean handshake, ByteBuffer netBuffer)
protected ByteBuffer[]
sslWrap(boolean handshake, ByteBuffer appBuffer)
protected ByteBuffer[]
sslWrap(boolean handshake, ByteBuffer[] appBuffers, int offset, int length)
protected boolean
sslWriteImpl(boolean handshake, ByteBuffer[] appBuffers, int offset, int length, Consumer<Throwable> callback)
protected boolean
sslWriteImpl(boolean handshake, ByteBuffer appBuffer, Consumer<Throwable> callback)
protected void
startHandshake(Consumer<Throwable> callback)
protected void
startRead(CompletionHandler<Integer,ByteBuffer> handler)
void
startReadInIOThread(CompletionHandler<Integer,ByteBuffer> handler)
abstract Set<SocketOption<?>>
supportedOptions()
String
toString()
void
write(byte[] headerContent, int headerOffset, int headerLength, byte[] bodyContent, int bodyOffset, int bodyLength, Object handlerAttachment, CompletionHandler handler)
void
write(byte[] headerContent, int headerOffset, int headerLength, byte[] bodyContent, int bodyOffset, int bodyLength, CompletionHandler<Integer,Void> handler)
void
write(byte[] bytes, int offset, int length, CompletionHandler<Integer,Void> handler)
<A> void
write(byte[] bytes, A attachment, CompletionHandler<Integer,? super A> handler)
void
write(byte[] bytes, CompletionHandler<Integer,Void> handler)
<A> void
write(ByteBuffer[] srcs, int offset, int length, A attachment, CompletionHandler<Integer,? super A> handler)
<A> void
write(ByteBuffer[] srcs, A attachment, CompletionHandler<Integer,? super A> handler)
<A> void
write(ByteBuffer src, A attachment, CompletionHandler<Integer,? super A> handler)
<A> void
write(ByteTuple array, A attachment, CompletionHandler<Integer,? super A> handler)
void
write(ByteTuple array, CompletionHandler<Integer,Void> handler)
void
write(ByteTuple header, ByteTuple body, CompletionHandler<Integer,Void> handler)
protected abstract <A> void
writeImpl(ByteBuffer[] srcs, int offset, int length, A attachment, CompletionHandler<Integer,? super A> handler)
srcs写完才会回调protected abstract <A> void
writeImpl(ByteBuffer src, A attachment, CompletionHandler<Integer,? super A> handler)
src写完才会回调void
writeInIOThread(byte[] headerContent, int headerOffset, int headerLength, byte[] bodyContent, int bodyOffset, int bodyLength, CompletionHandler<Integer,Void> handler)
void
writeInIOThread(byte[] bytes, int offset, int length, CompletionHandler<Integer,Void> handler)
void
writeInIOThread(byte[] bytes, CompletionHandler<Integer,Void> handler)
<A> void
writeInIOThread(ByteBuffer[] srcs, int offset, int length, A attachment, CompletionHandler<Integer,? super A> handler)
<A> void
writeInIOThread(ByteBuffer[] srcs, A attachment, CompletionHandler<Integer,? super A> handler)
<A> void
writeInIOThread(ByteBuffer src, A attachment, CompletionHandler<Integer,? super A> handler)
void
writeInIOThread(ByteTuple array, CompletionHandler<Integer,Void> handler)
void
writeInIOThread(ByteTuple header, ByteTuple body, CompletionHandler<Integer,Void> handler)
<A> void
writePipeline(A attachment, CompletionHandler<Integer,? super A> handler)
void
writePipeline(CompletionHandler<Integer,Void> handler)
<A> void
writePipelineInIOThread(A attachment, CompletionHandler<Integer,? super A> handler)
void
writePipelineInIOThread(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
-
-