public abstract class AbstractNettyRemoting extends Object implements Disposable
| Modifier and Type | Field and Description |
|---|---|
protected ConcurrentHashMap<Integer,MessageFuture> |
futures
Obtain the return result through MessageFuture blocking.
|
protected PositiveAtomicCounter |
idGenerator
Id generator of this remoting
|
protected boolean |
isSending
The Is sending.
|
protected Object |
lock |
protected ThreadPoolExecutor |
messageExecutor
The Message executor.
|
protected long |
nowMills
The Now mills.
|
protected HashMap<Integer,Pair<RemotingProcessor,ExecutorService>> |
processorTable
This container holds all processors.
|
protected List<RpcHook> |
rpcHooks |
protected ScheduledExecutorService |
timerExecutor
The Timer executor.
|
| Constructor and Description |
|---|
AbstractNettyRemoting(ThreadPoolExecutor messageExecutor) |
| Modifier and Type | Method and Description |
|---|---|
protected RpcMessage |
buildRequestMessage(Object msg,
byte messageType) |
protected RpcMessage |
buildResponseMessage(RpcMessage rpcMessage,
Object msg,
byte messageType) |
void |
destroy() |
void |
destroyChannel(io.netty.channel.Channel channel) |
abstract void |
destroyChannel(String serverAddress,
io.netty.channel.Channel channel)
Destroy channel.
|
protected void |
doAfterRpcHooks(String remoteAddr,
RpcMessage request,
Object response) |
protected void |
doBeforeRpcHooks(String remoteAddr,
RpcMessage request) |
protected String |
getAddressFromChannel(io.netty.channel.Channel channel)
Gets address from channel.
|
protected String |
getAddressFromContext(io.netty.channel.ChannelHandlerContext ctx)
Gets address from context.
|
ConcurrentHashMap<Integer,MessageFuture> |
getFutures() |
String |
getGroup() |
int |
getNextMessageId() |
void |
init() |
protected void |
processMessage(io.netty.channel.ChannelHandlerContext ctx,
RpcMessage rpcMessage)
Rpc message processing.
|
protected void |
sendAsync(io.netty.channel.Channel channel,
RpcMessage rpcMessage)
rpc async request.
|
protected Object |
sendSync(io.netty.channel.Channel channel,
RpcMessage rpcMessage,
long timeoutMillis)
rpc sync request
Obtain the return result through MessageFuture blocking.
|
void |
setGroup(String group) |
protected final ScheduledExecutorService timerExecutor
protected final ThreadPoolExecutor messageExecutor
protected final PositiveAtomicCounter idGenerator
protected final ConcurrentHashMap<Integer,MessageFuture> futures
protected volatile long nowMills
protected final Object lock
protected volatile boolean isSending
protected final HashMap<Integer,Pair<RemotingProcessor,ExecutorService>> processorTable
MessageTypepublic AbstractNettyRemoting(ThreadPoolExecutor messageExecutor)
public void init()
public int getNextMessageId()
public ConcurrentHashMap<Integer,MessageFuture> getFutures()
public String getGroup()
public void setGroup(String group)
public void destroyChannel(io.netty.channel.Channel channel)
public void destroy()
destroy in interface Disposableprotected Object sendSync(io.netty.channel.Channel channel, RpcMessage rpcMessage, long timeoutMillis) throws TimeoutException
channel - netty channelrpcMessage - rpc messagetimeoutMillis - rpc communication timeoutTimeoutExceptionprotected void sendAsync(io.netty.channel.Channel channel,
RpcMessage rpcMessage)
channel - netty channelrpcMessage - rpc messageprotected RpcMessage buildRequestMessage(Object msg, byte messageType)
protected RpcMessage buildResponseMessage(RpcMessage rpcMessage, Object msg, byte messageType)
protected void processMessage(io.netty.channel.ChannelHandlerContext ctx,
RpcMessage rpcMessage)
throws Exception
ctx - Channel handler context.rpcMessage - rpc message.Exception - throws exception process message error.protected String getAddressFromContext(io.netty.channel.ChannelHandlerContext ctx)
ctx - the ctxprotected String getAddressFromChannel(io.netty.channel.Channel channel)
channel - the channelpublic abstract void destroyChannel(String serverAddress, io.netty.channel.Channel channel)
serverAddress - the server addresschannel - the channelprotected void doBeforeRpcHooks(String remoteAddr, RpcMessage request)
protected void doAfterRpcHooks(String remoteAddr, RpcMessage request, Object response)
Copyright © 2023 Seata. All rights reserved.