com.alipay.remoting
Class Connection

java.lang.Object
  extended by com.alipay.remoting.Connection

public class Connection
extends Object

An abstraction of socket channel.


Field Summary
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
 
Constructor Summary
Connection(io.netty.channel.Channel channel)
          Constructor
Connection(io.netty.channel.Channel channel, ProtocolCode protocolCode, byte version, Url url)
          Constructor
Connection(io.netty.channel.Channel channel, ProtocolCode protocolCode, Url url)
          Constructor
Connection(io.netty.channel.Channel channel, Url url)
          Constructor
 
Method Summary
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CONNECTION

public static final io.netty.util.AttributeKey<Connection> CONNECTION
Attribute key for connection


HEARTBEAT_COUNT

public static final io.netty.util.AttributeKey<Integer> HEARTBEAT_COUNT
Attribute key for heartbeat count


HEARTBEAT_SWITCH

public static final io.netty.util.AttributeKey<Boolean> HEARTBEAT_SWITCH
Attribute key for heartbeat switch for each connection


PROTOCOL

public static final io.netty.util.AttributeKey<ProtocolCode> PROTOCOL
Attribute key for protocol


VERSION

public static final io.netty.util.AttributeKey<Byte> VERSION
Attribute key for version

Constructor Detail

Connection

public Connection(io.netty.channel.Channel channel)
Constructor

Parameters:
channel -

Connection

public Connection(io.netty.channel.Channel channel,
                  Url url)
Constructor

Parameters:
channel -
url -

Connection

public Connection(io.netty.channel.Channel channel,
                  ProtocolCode protocolCode,
                  Url url)
Constructor

Parameters:
channel -
protocolCode -
url -

Connection

public Connection(io.netty.channel.Channel channel,
                  ProtocolCode protocolCode,
                  byte version,
                  Url url)
Constructor

Parameters:
channel -
protocolCode -
url -
Method Detail

isFine

public boolean isFine()
to check whether the connection is fine to use

Returns:

increaseRef

public void increaseRef()
increase the reference count


decreaseRef

public void decreaseRef()
decrease the reference count


noRef

public boolean noRef()
to check whether the reference count is 0

Returns:

getRemoteAddress

public InetSocketAddress getRemoteAddress()
Get the address of the remote peer.

Returns:

getRemoteIP

public String getRemoteIP()
Get the remote IP.

Returns:

getRemotePort

public int getRemotePort()
Get the remote port.

Returns:

getLocalAddress

public InetSocketAddress getLocalAddress()
Get the address of the local peer.

Returns:

getLocalIP

public String getLocalIP()
Get the local IP.

Returns:

getLocalPort

public int getLocalPort()
Get the local port.

Returns:

getChannel

public io.netty.channel.Channel getChannel()
Get the netty channel of the connection.

Returns:

getInvokeFuture

public InvokeFuture getInvokeFuture(int id)
Get the InvokeFuture with invokeId of id.

Parameters:
id -
Returns:

addInvokeFuture

public InvokeFuture addInvokeFuture(InvokeFuture future)
Add an InvokeFuture

Parameters:
future -
Returns:

removeInvokeFuture

public InvokeFuture removeInvokeFuture(int id)
Remove InvokeFuture who's invokeId is id

Parameters:
id -
Returns:

onClose

public void onClose()
Do something when closing.


close

public void close()
Close the connection.


isInvokeFutureMapFinish

public boolean isInvokeFutureMapFinish()
Whether invokeFutures is completed


addPoolKey

public void addPoolKey(String poolKey)
add a pool key to list

Parameters:
poolKey -

getPoolKeys

public Set<String> getPoolKeys()
get all pool keys


removePoolKey

public void removePoolKey(String poolKey)
remove pool key

Parameters:
poolKey -

getUrl

public Url getUrl()
Getter method for property url.

Returns:
property value of url

addIdPoolKeyMapping

public void addIdPoolKeyMapping(Integer id,
                                String poolKey)
add Id to group Mapping

Parameters:
id -
poolKey -

removeIdPoolKeyMapping

public String removeIdPoolKeyMapping(Integer id)
remove id to group Mapping

Parameters:
id -
Returns:

setAttribute

public void setAttribute(String key,
                         Object value)
Set attribute key=value.

Parameters:
key -
value -

setAttributeIfAbsent

public Object setAttributeIfAbsent(String key,
                                   Object value)
set attribute if key absent.

Parameters:
key -
value -
Returns:

removeAttribute

public void removeAttribute(String key)
Remove attribute.

Parameters:
key -

getAttribute

public Object getAttribute(String key)
Get attribute.

Parameters:
key -
Returns:

clearAttributes

public void clearAttributes()
Clear attribute.


getInvokeFutureMap

public ConcurrentHashMap<Integer,InvokeFuture> getInvokeFutureMap()
Getter method for property invokeFutureMap.

Returns:
property value of invokeFutureMap


Copyright © 2018. All rights reserved.