public abstract class AsyncConnection
extends java.lang.Object
implements java.nio.channels.ReadableByteChannel, java.nio.channels.WritableByteChannel, java.lang.AutoCloseable
详情见: https://redkale.org
限定符和类型 | 字段和说明 |
---|---|
protected java.util.Map<java.lang.String,java.lang.Object> |
attributes |
protected java.util.function.Consumer<AsyncConnection> |
beforeCloseListener |
protected java.util.function.Consumer<java.nio.ByteBuffer> |
bufferConsumer |
protected java.util.function.Supplier<java.nio.ByteBuffer> |
bufferSupplier |
protected java.util.concurrent.atomic.AtomicLong |
closedCounter |
protected java.util.concurrent.atomic.AtomicInteger |
eventing |
protected java.util.concurrent.atomic.AtomicLong |
livingCounter |
protected java.nio.ByteBuffer |
readBuffer |
protected long |
readtime |
protected javax.net.ssl.SSLContext |
sslContext |
protected java.lang.Object |
subobject |
protected long |
writetime |
限定符 | 构造器和说明 |
---|---|
protected |
AsyncConnection(Context context) |
protected |
AsyncConnection(ObjectPool<java.nio.ByteBuffer> bufferPool,
javax.net.ssl.SSLContext sslContext) |
protected |
AsyncConnection(java.util.function.Supplier<java.nio.ByteBuffer> bufferSupplier,
java.util.function.Consumer<java.nio.ByteBuffer> bufferConsumer,
javax.net.ssl.SSLContext sslContext) |
限定符和类型 | 方法和说明 |
---|---|
AsyncConnection |
beforeCloseListener(java.util.function.Consumer<AsyncConnection> beforeCloseListener) |
void |
clearAttribute() |
void |
close() |
static AsyncConnection |
create(Context context,
java.nio.channels.AsynchronousSocketChannel ch) |
static AsyncConnection |
create(Context context,
java.nio.channels.AsynchronousSocketChannel ch,
java.net.SocketAddress addr0,
java.util.concurrent.atomic.AtomicLong livingCounter,
java.util.concurrent.atomic.AtomicLong closedCounter) |
static AsyncConnection |
create(Context context,
java.nio.channels.AsynchronousSocketChannel ch,
java.net.SocketAddress addr0,
int readTimeoutSeconds,
int writeTimeoutSeconds) |
static AsyncConnection |
create(Context context,
java.nio.channels.AsynchronousSocketChannel ch,
java.net.SocketAddress addr0,
int readTimeoutSeconds,
int writeTimeoutSeconds,
java.util.concurrent.atomic.AtomicLong livingCounter,
java.util.concurrent.atomic.AtomicLong closedCounter) |
static AsyncConnection |
create(Context context,
java.nio.channels.AsynchronousSocketChannel ch,
javax.net.ssl.SSLContext sslContext,
java.net.SocketAddress addr0,
int readTimeoutSeconds,
int writeTimeoutSeconds) |
static AsyncConnection |
create(Context context,
java.nio.channels.AsynchronousSocketChannel ch,
javax.net.ssl.SSLContext sslContext,
java.net.SocketAddress addr0,
int readTimeoutSeconds,
int writeTimeoutSeconds,
java.util.concurrent.atomic.AtomicLong livingCounter,
java.util.concurrent.atomic.AtomicLong closedCounter) |
static AsyncConnection |
create(ObjectPool<java.nio.ByteBuffer> bufferPool,
java.nio.channels.AsynchronousSocketChannel ch) |
static AsyncConnection |
create(ObjectPool<java.nio.ByteBuffer> bufferPool,
java.nio.channels.AsynchronousSocketChannel ch,
java.net.SocketAddress addr0,
int readTimeoutSeconds,
int writeTimeoutSeconds) |
static AsyncConnection |
create(ObjectPool<java.nio.ByteBuffer> bufferPool,
java.nio.channels.AsynchronousSocketChannel ch,
java.net.SocketAddress addr0,
int readTimeoutSeconds,
int writeTimeoutSeconds,
java.util.concurrent.atomic.AtomicLong livingCounter,
java.util.concurrent.atomic.AtomicLong closedCounter) |
static AsyncConnection |
create(ObjectPool<java.nio.ByteBuffer> bufferPool,
java.nio.channels.AsynchronousSocketChannel ch,
javax.net.ssl.SSLContext sslContext,
java.net.SocketAddress addr0,
int readTimeoutSeconds,
int writeTimeoutSeconds) |
static AsyncConnection |
create(ObjectPool<java.nio.ByteBuffer> bufferPool,
java.nio.channels.AsynchronousSocketChannel ch,
javax.net.ssl.SSLContext sslContext,
java.net.SocketAddress addr0,
int readTimeoutSeconds,
int writeTimeoutSeconds,
java.util.concurrent.atomic.AtomicLong livingCounter,
java.util.concurrent.atomic.AtomicLong closedCounter) |
static AsyncConnection |
create(ObjectPool<java.nio.ByteBuffer> bufferPool,
java.nio.channels.DatagramChannel ch,
java.net.SocketAddress addr,
boolean client0,
int readTimeoutSeconds0,
int writeTimeoutSeconds0) |
static AsyncConnection |
create(ObjectPool<java.nio.ByteBuffer> bufferPool,
java.nio.channels.DatagramChannel ch,
java.net.SocketAddress addr,
boolean client0,
int readTimeoutSeconds0,
int writeTimeoutSeconds0,
java.util.concurrent.atomic.AtomicLong livingCounter,
java.util.concurrent.atomic.AtomicLong closedCounter) |
static AsyncConnection |
create(ObjectPool<java.nio.ByteBuffer> bufferPool,
java.nio.channels.DatagramChannel ch,
javax.net.ssl.SSLContext sslContext,
java.net.SocketAddress addr,
boolean client0,
int readTimeoutSeconds0,
int writeTimeoutSeconds0) |
static AsyncConnection |
create(ObjectPool<java.nio.ByteBuffer> bufferPool,
java.nio.channels.DatagramChannel ch,
javax.net.ssl.SSLContext sslContext,
java.net.SocketAddress addr,
boolean client0,
int readTimeoutSeconds0,
int writeTimeoutSeconds0,
java.util.concurrent.atomic.AtomicLong livingCounter,
java.util.concurrent.atomic.AtomicLong closedCounter) |
static java.util.concurrent.CompletableFuture<AsyncConnection> |
createTCP(Context context,
java.nio.channels.AsynchronousChannelGroup group,
java.net.SocketAddress address,
int readTimeoutSeconds,
int writeTimeoutSeconds)
创建TCP协议客户端连接
|
static java.util.concurrent.CompletableFuture<AsyncConnection> |
createTCP(ObjectPool<java.nio.ByteBuffer> bufferPool,
java.nio.channels.AsynchronousChannelGroup group,
java.net.SocketAddress address,
int readTimeoutSeconds,
int writeTimeoutSeconds)
创建TCP协议客户端连接
|
static java.util.concurrent.CompletableFuture<AsyncConnection> |
createTCP(ObjectPool<java.nio.ByteBuffer> bufferPool,
java.nio.channels.AsynchronousChannelGroup group,
javax.net.ssl.SSLContext sslContext,
java.net.SocketAddress address,
int readTimeoutSeconds,
int writeTimeoutSeconds)
创建TCP协议客户端连接
|
static java.util.concurrent.CompletableFuture<AsyncConnection> |
createTCP(java.util.function.Supplier<java.nio.ByteBuffer> bufferSupplier,
java.util.function.Consumer<java.nio.ByteBuffer> bufferConsumer,
java.nio.channels.AsynchronousChannelGroup group,
javax.net.ssl.SSLContext sslContext,
java.net.SocketAddress address,
int readTimeoutSeconds,
int writeTimeoutSeconds)
创建TCP协议客户端连接
|
int |
decreEventing() |
void |
dispose() |
<T> T |
getAttribute(java.lang.String name) |
java.util.Map<java.lang.String,java.lang.Object> |
getAttributes() |
long |
getLastReadTime() |
long |
getLastWriteTime() |
abstract java.net.SocketAddress |
getLocalAddress() |
abstract int |
getReadTimeoutSeconds() |
abstract java.net.SocketAddress |
getRemoteAddress() |
<T> T |
getSubobject() |
abstract int |
getWriteTimeoutSeconds() |
int |
increEventing() |
abstract boolean |
isOpen() |
abstract boolean |
isTCP() |
void |
offerBuffer(java.nio.Buffer... buffers) |
void |
offerBuffer(java.nio.Buffer buffer) |
java.nio.ByteBuffer |
pollReadBuffer() |
java.nio.ByteBuffer |
pollWriteBuffer() |
abstract int |
read(java.nio.ByteBuffer dst) |
abstract void |
read(java.nio.channels.CompletionHandler<java.lang.Integer,java.nio.ByteBuffer> handler) |
abstract void |
read(long timeout,
java.util.concurrent.TimeUnit unit,
java.nio.channels.CompletionHandler<java.lang.Integer,java.nio.ByteBuffer> handler) |
void |
removeAttribute(java.lang.String name) |
void |
setAttribute(java.lang.String name,
java.lang.Object value) |
abstract <T> boolean |
setOption(java.net.SocketOption<T> name,
T value) |
void |
setReadBuffer(java.nio.Buffer buffer) |
abstract void |
setReadTimeoutSeconds(int readTimeoutSeconds) |
void |
setSubobject(java.lang.Object value) |
abstract void |
setWriteTimeoutSeconds(int writeTimeoutSeconds) |
abstract boolean |
shutdownInput() |
abstract boolean |
shutdownOutput() |
abstract java.util.Set<java.net.SocketOption<?>> |
supportedOptions() |
abstract int |
write(java.nio.ByteBuffer src) |
<A> void |
write(java.nio.ByteBuffer[] srcs,
A attachment,
java.nio.channels.CompletionHandler<java.lang.Integer,? super A> handler) |
abstract <A> void |
write(java.nio.ByteBuffer[] srcs,
int offset,
int length,
A attachment,
java.nio.channels.CompletionHandler<java.lang.Integer,? super A> handler) |
abstract <A> void |
write(java.nio.ByteBuffer src,
A attachment,
java.nio.channels.CompletionHandler<java.lang.Integer,? super A> handler) |
protected javax.net.ssl.SSLContext sslContext
protected java.util.Map<java.lang.String,java.lang.Object> attributes
protected java.lang.Object subobject
protected volatile long readtime
protected volatile long writetime
protected final java.util.function.Supplier<java.nio.ByteBuffer> bufferSupplier
protected final java.util.function.Consumer<java.nio.ByteBuffer> bufferConsumer
protected java.nio.ByteBuffer readBuffer
protected java.util.concurrent.atomic.AtomicLong livingCounter
protected java.util.concurrent.atomic.AtomicLong closedCounter
protected java.util.function.Consumer<AsyncConnection> beforeCloseListener
protected final java.util.concurrent.atomic.AtomicInteger eventing
protected AsyncConnection(Context context)
protected AsyncConnection(ObjectPool<java.nio.ByteBuffer> bufferPool, javax.net.ssl.SSLContext sslContext)
protected AsyncConnection(java.util.function.Supplier<java.nio.ByteBuffer> bufferSupplier, java.util.function.Consumer<java.nio.ByteBuffer> bufferConsumer, javax.net.ssl.SSLContext sslContext)
public final long getLastReadTime()
public final long getLastWriteTime()
public final int increEventing()
public final int decreEventing()
public abstract boolean isOpen()
isOpen
在接口中 java.nio.channels.Channel
public abstract boolean isTCP()
public abstract boolean shutdownInput()
public abstract boolean shutdownOutput()
public abstract <T> boolean setOption(java.net.SocketOption<T> name, T value)
public abstract java.util.Set<java.net.SocketOption<?>> supportedOptions()
public abstract java.net.SocketAddress getRemoteAddress()
public abstract java.net.SocketAddress getLocalAddress()
public abstract int getReadTimeoutSeconds()
public abstract int getWriteTimeoutSeconds()
public abstract void setReadTimeoutSeconds(int readTimeoutSeconds)
public abstract void setWriteTimeoutSeconds(int writeTimeoutSeconds)
public abstract int read(java.nio.ByteBuffer dst) throws java.io.IOException
read
在接口中 java.nio.channels.ReadableByteChannel
java.io.IOException
public abstract void read(java.nio.channels.CompletionHandler<java.lang.Integer,java.nio.ByteBuffer> handler)
public abstract void read(long timeout, java.util.concurrent.TimeUnit unit, java.nio.channels.CompletionHandler<java.lang.Integer,java.nio.ByteBuffer> handler)
public abstract int write(java.nio.ByteBuffer src) throws java.io.IOException
write
在接口中 java.nio.channels.WritableByteChannel
java.io.IOException
public abstract <A> void write(java.nio.ByteBuffer src, A attachment, java.nio.channels.CompletionHandler<java.lang.Integer,? super A> handler)
public final <A> void write(java.nio.ByteBuffer[] srcs, A attachment, java.nio.channels.CompletionHandler<java.lang.Integer,? super A> handler)
public abstract <A> void write(java.nio.ByteBuffer[] srcs, int offset, int length, A attachment, java.nio.channels.CompletionHandler<java.lang.Integer,? super A> handler)
public void setReadBuffer(java.nio.Buffer buffer)
public java.nio.ByteBuffer pollReadBuffer()
public void offerBuffer(java.nio.Buffer buffer)
public void offerBuffer(java.nio.Buffer... buffers)
public java.nio.ByteBuffer pollWriteBuffer()
public void dispose()
public AsyncConnection beforeCloseListener(java.util.function.Consumer<AsyncConnection> beforeCloseListener)
public void close() throws java.io.IOException
close
在接口中 java.io.Closeable
close
在接口中 java.lang.AutoCloseable
close
在接口中 java.nio.channels.Channel
java.io.IOException
public final <T> T getSubobject()
public void setSubobject(java.lang.Object value)
public void setAttribute(java.lang.String name, java.lang.Object value)
public final <T> T getAttribute(java.lang.String name)
public final void removeAttribute(java.lang.String name)
public final java.util.Map<java.lang.String,java.lang.Object> getAttributes()
public final void clearAttribute()
public static java.util.concurrent.CompletableFuture<AsyncConnection> createTCP(ObjectPool<java.nio.ByteBuffer> bufferPool, java.nio.channels.AsynchronousChannelGroup group, java.net.SocketAddress address, int readTimeoutSeconds, int writeTimeoutSeconds)
bufferPool
- ByteBuffer对象池address
- 连接点子group
- 连接AsynchronousChannelGroupreadTimeoutSeconds
- 读取超时秒数writeTimeoutSeconds
- 写入超时秒数public static java.util.concurrent.CompletableFuture<AsyncConnection> createTCP(Context context, java.nio.channels.AsynchronousChannelGroup group, java.net.SocketAddress address, int readTimeoutSeconds, int writeTimeoutSeconds)
context
- Contextaddress
- 连接点子group
- 连接AsynchronousChannelGroupreadTimeoutSeconds
- 读取超时秒数writeTimeoutSeconds
- 写入超时秒数public static java.util.concurrent.CompletableFuture<AsyncConnection> createTCP(ObjectPool<java.nio.ByteBuffer> bufferPool, java.nio.channels.AsynchronousChannelGroup group, javax.net.ssl.SSLContext sslContext, java.net.SocketAddress address, int readTimeoutSeconds, int writeTimeoutSeconds)
bufferPool
- ByteBuffer对象池address
- 连接点子sslContext
- SSLContextgroup
- 连接AsynchronousChannelGroupreadTimeoutSeconds
- 读取超时秒数writeTimeoutSeconds
- 写入超时秒数public static java.util.concurrent.CompletableFuture<AsyncConnection> createTCP(java.util.function.Supplier<java.nio.ByteBuffer> bufferSupplier, java.util.function.Consumer<java.nio.ByteBuffer> bufferConsumer, java.nio.channels.AsynchronousChannelGroup group, javax.net.ssl.SSLContext sslContext, java.net.SocketAddress address, int readTimeoutSeconds, int writeTimeoutSeconds)
bufferSupplier
- ByteBuffer生产器bufferConsumer
- ByteBuffer回收器address
- 连接点子sslContext
- SSLContextgroup
- 连接AsynchronousChannelGroupreadTimeoutSeconds
- 读取超时秒数writeTimeoutSeconds
- 写入超时秒数public static AsyncConnection create(ObjectPool<java.nio.ByteBuffer> bufferPool, java.nio.channels.DatagramChannel ch, java.net.SocketAddress addr, boolean client0, int readTimeoutSeconds0, int writeTimeoutSeconds0)
public static AsyncConnection create(ObjectPool<java.nio.ByteBuffer> bufferPool, java.nio.channels.DatagramChannel ch, java.net.SocketAddress addr, boolean client0, int readTimeoutSeconds0, int writeTimeoutSeconds0, java.util.concurrent.atomic.AtomicLong livingCounter, java.util.concurrent.atomic.AtomicLong closedCounter)
public static AsyncConnection create(ObjectPool<java.nio.ByteBuffer> bufferPool, java.nio.channels.DatagramChannel ch, javax.net.ssl.SSLContext sslContext, java.net.SocketAddress addr, boolean client0, int readTimeoutSeconds0, int writeTimeoutSeconds0)
public static AsyncConnection create(ObjectPool<java.nio.ByteBuffer> bufferPool, java.nio.channels.DatagramChannel ch, javax.net.ssl.SSLContext sslContext, java.net.SocketAddress addr, boolean client0, int readTimeoutSeconds0, int writeTimeoutSeconds0, java.util.concurrent.atomic.AtomicLong livingCounter, java.util.concurrent.atomic.AtomicLong closedCounter)
public static AsyncConnection create(Context context, java.nio.channels.AsynchronousSocketChannel ch)
public static AsyncConnection create(Context context, java.nio.channels.AsynchronousSocketChannel ch, java.net.SocketAddress addr0, java.util.concurrent.atomic.AtomicLong livingCounter, java.util.concurrent.atomic.AtomicLong closedCounter)
public static AsyncConnection create(Context context, java.nio.channels.AsynchronousSocketChannel ch, java.net.SocketAddress addr0, int readTimeoutSeconds, int writeTimeoutSeconds)
public static AsyncConnection create(Context context, java.nio.channels.AsynchronousSocketChannel ch, javax.net.ssl.SSLContext sslContext, java.net.SocketAddress addr0, int readTimeoutSeconds, int writeTimeoutSeconds)
public static AsyncConnection create(Context context, java.nio.channels.AsynchronousSocketChannel ch, java.net.SocketAddress addr0, int readTimeoutSeconds, int writeTimeoutSeconds, java.util.concurrent.atomic.AtomicLong livingCounter, java.util.concurrent.atomic.AtomicLong closedCounter)
public static AsyncConnection create(Context context, java.nio.channels.AsynchronousSocketChannel ch, javax.net.ssl.SSLContext sslContext, java.net.SocketAddress addr0, int readTimeoutSeconds, int writeTimeoutSeconds, java.util.concurrent.atomic.AtomicLong livingCounter, java.util.concurrent.atomic.AtomicLong closedCounter)
public static AsyncConnection create(ObjectPool<java.nio.ByteBuffer> bufferPool, java.nio.channels.AsynchronousSocketChannel ch)
public static AsyncConnection create(ObjectPool<java.nio.ByteBuffer> bufferPool, java.nio.channels.AsynchronousSocketChannel ch, java.net.SocketAddress addr0, int readTimeoutSeconds, int writeTimeoutSeconds)
public static AsyncConnection create(ObjectPool<java.nio.ByteBuffer> bufferPool, java.nio.channels.AsynchronousSocketChannel ch, javax.net.ssl.SSLContext sslContext, java.net.SocketAddress addr0, int readTimeoutSeconds, int writeTimeoutSeconds)
public static AsyncConnection create(ObjectPool<java.nio.ByteBuffer> bufferPool, java.nio.channels.AsynchronousSocketChannel ch, java.net.SocketAddress addr0, int readTimeoutSeconds, int writeTimeoutSeconds, java.util.concurrent.atomic.AtomicLong livingCounter, java.util.concurrent.atomic.AtomicLong closedCounter)
public static AsyncConnection create(ObjectPool<java.nio.ByteBuffer> bufferPool, java.nio.channels.AsynchronousSocketChannel ch, javax.net.ssl.SSLContext sslContext, java.net.SocketAddress addr0, int readTimeoutSeconds, int writeTimeoutSeconds, java.util.concurrent.atomic.AtomicLong livingCounter, java.util.concurrent.atomic.AtomicLong closedCounter)