public class Connection extends Object
| 限定符和类型 | 字段和说明 |
|---|---|
static io.netty.util.AttributeKey<Connection> |
CONNECTION
Attribute key for connection
|
static io.netty.util.AttributeKey<Integer> |
HEARTBEAT_COUNT
Attribute key for heartbeat count
|
static io.netty.util.AttributeKey<Boolean> |
HEARTBEAT_SWITCH
Attribute key for heartbeat switch for each connection
|
static io.netty.util.AttributeKey<ProtocolCode> |
PROTOCOL
Attribute key for protocol
|
static io.netty.util.AttributeKey<Byte> |
VERSION
Attribute key for version
|
| 构造器和说明 |
|---|
Connection(io.netty.channel.Channel channel)
Constructor
|
Connection(io.netty.channel.Channel channel,
ProtocolCode protocolCode,
byte version,
Url url) |
Connection(io.netty.channel.Channel channel,
ProtocolCode protocolCode,
Url url)
Constructor
|
Connection(io.netty.channel.Channel channel,
Url url)
Constructor
|
| 限定符和类型 | 方法和说明 |
|---|---|
void |
addIdPoolKeyMapping(Integer id,
String poolKey)
add Id to group Mapping
|
InvokeFuture |
addInvokeFuture(InvokeFuture future)
Add an InvokeFuture
|
void |
addPoolKey(String poolKey)
add a pool key to list
|
void |
clearAttributes()
Clear attribute.
|
void |
close()
Close the connection.
|
void |
decreaseRef()
decrease the reference count
|
Object |
getAttribute(String key)
Get attribute.
|
io.netty.channel.Channel |
getChannel()
Get the netty channel of the connection.
|
InvokeFuture |
getInvokeFuture(int id)
Get the InvokeFuture with invokeId of id.
|
ConcurrentHashMap<Integer,InvokeFuture> |
getInvokeFutureMap()
Getter method for property invokeFutureMap.
|
InetSocketAddress |
getLocalAddress()
Get the address of the local peer.
|
String |
getLocalIP()
Get the local IP.
|
int |
getLocalPort()
Get the local port.
|
Set<String> |
getPoolKeys()
get all pool keys
|
InetSocketAddress |
getRemoteAddress()
Get the address of the remote peer.
|
String |
getRemoteIP()
Get the remote IP.
|
int |
getRemotePort()
Get the remote port.
|
Url |
getUrl()
Getter method for property url.
|
void |
increaseRef()
increase the reference count
|
boolean |
isFine()
to check whether the connection is fine to use
|
boolean |
isInvokeFutureMapFinish()
Whether invokeFutures is completed
|
boolean |
noRef()
to check whether the reference count is 0
|
void |
onClose()
Do something when closing.
|
void |
removeAttribute(String key)
Remove attribute.
|
String |
removeIdPoolKeyMapping(Integer id)
remove id to group Mapping
|
InvokeFuture |
removeInvokeFuture(int id)
Remove InvokeFuture who's invokeId is id
|
void |
removePoolKey(String poolKey)
remove pool key
|
void |
setAttribute(String key,
Object value)
Set attribute key=value.
|
Object |
setAttributeIfAbsent(String key,
Object value)
set attribute if key absent.
|
public static final io.netty.util.AttributeKey<Connection> CONNECTION
public static final io.netty.util.AttributeKey<Integer> HEARTBEAT_COUNT
public static final io.netty.util.AttributeKey<Boolean> HEARTBEAT_SWITCH
public static final io.netty.util.AttributeKey<ProtocolCode> PROTOCOL
public static final io.netty.util.AttributeKey<Byte> VERSION
public Connection(io.netty.channel.Channel channel)
channel - associated channelpublic Connection(io.netty.channel.Channel channel,
Url url)
channel - associated channelurl - associated urlpublic Connection(io.netty.channel.Channel channel,
ProtocolCode protocolCode,
Url url)
channel - associated channelprotocolCode - ProtocolCodeurl - associated urlpublic Connection(io.netty.channel.Channel channel,
ProtocolCode protocolCode,
byte version,
Url url)
channel - associated channelprotocolCode - ProtocolCodeversion - protocol versionurl - associated urlpublic boolean isFine()
public void increaseRef()
public void decreaseRef()
public boolean noRef()
public InetSocketAddress getRemoteAddress()
public String getRemoteIP()
public int getRemotePort()
public InetSocketAddress getLocalAddress()
public String getLocalIP()
public int getLocalPort()
public io.netty.channel.Channel getChannel()
public InvokeFuture getInvokeFuture(int id)
id - invoke idpublic InvokeFuture addInvokeFuture(InvokeFuture future)
future - InvokeFuturepublic InvokeFuture removeInvokeFuture(int id)
id - invoke idpublic void onClose()
public void close()
public boolean isInvokeFutureMapFinish()
public void addPoolKey(String poolKey)
poolKey - connection pool keypublic void removePoolKey(String poolKey)
poolKey - connection pool keypublic Url getUrl()
public void addIdPoolKeyMapping(Integer id, String poolKey)
id - invoke idpoolKey - connection pool keypublic String removeIdPoolKeyMapping(Integer id)
id - connection pool keypublic void setAttribute(String key, Object value)
key - attribute keyvalue - attribute valuepublic Object setAttributeIfAbsent(String key, Object value)
key - attribute keyvalue - attribute valuepublic void removeAttribute(String key)
key - attribute keypublic Object getAttribute(String key)
key - attribute keypublic void clearAttributes()
public ConcurrentHashMap<Integer,InvokeFuture> getInvokeFutureMap()
Copyright © 2020. All rights reserved.