public abstract class AbstractHttp2ClientTransport extends ClientTransport
| 限定符和类型 | 字段和说明 |
|---|---|
protected NettyChannel |
channel
Channel
|
protected AtomicInteger |
currentRequests
正在发送的调用数量
|
protected ProviderInfo |
providerInfo
服务端提供者信息
|
protected Http2ClientChannelHandler |
responseChannelHandler
Response channel handler
|
protected AtomicInteger |
streamId
StreamId, start from 3 (because 1 is setting stream)
|
transportConfig| 构造器和说明 |
|---|
AbstractHttp2ClientTransport(ClientTransportConfig transportConfig)
客户端配置
|
| 限定符和类型 | 方法和说明 |
|---|---|
protected void |
afterSend(RpcInternalContext context,
SofaRequest request)
调用后设置一些属性(注意,在异步的情况较多下)
|
ResponseFuture |
asyncSend(SofaRequest request,
int timeout)
异步调用
|
protected void |
beforeSend(RpcInternalContext context,
SofaRequest request)
调用前设置一些属性
|
protected void |
checkConnection() |
void |
connect()
建立长连接
|
protected io.netty.handler.codec.http.FullHttpRequest |
convertToHttpRequest(SofaRequest request) |
int |
currentRequests()
当前请求数
|
void |
destroy()
销毁(最好是通过工厂模式销毁,这样可以清理缓存)
|
void |
disconnect()
断开连接
|
protected ResponseFuture |
doInvokeAsync(SofaRequest request,
RpcInternalContext rpcContext,
int timeoutMillis)
异步调用
|
protected SofaResponse |
doInvokeSync(SofaRequest request,
int timeout)
同步调用
|
protected void |
doSend(SofaRequest request,
AbstractHttpClientHandler callback,
int timeoutMills) |
protected void |
flatCopyTo(String prefix,
Map<String,Object> sourceMap,
io.netty.handler.codec.http.HttpHeaders headers)
扁平化复制
|
AbstractChannel |
getChannel()
得到长连接
|
void |
handleRpcRequest(SofaRequest request)
客户端收到服务端的请求,可能是服务端Callback
|
boolean |
isAvailable()
是否可用(有可用的长连接)
|
InetSocketAddress |
localAddress()
本地地址
|
void |
oneWaySend(SofaRequest request,
int timeout)
单向调用
|
void |
receiveRpcResponse(SofaResponse response)
客户端收到异步响应
|
InetSocketAddress |
remoteAddress()
远程地址
|
protected int |
sendHttpRequest(io.netty.handler.codec.http.FullHttpRequest httpRequest,
AbstractHttpClientHandler callback) |
void |
setChannel(AbstractChannel channel)
设置长连接
|
SofaResponse |
syncSend(SofaRequest request,
int timeout)
同步调用
|
protected SofaTimeOutException |
timeoutException(SofaRequest request,
int timeout,
Throwable e) |
getConfigprotected final ProviderInfo providerInfo
protected final AtomicInteger streamId
protected volatile AtomicInteger currentRequests
protected NettyChannel channel
protected Http2ClientChannelHandler responseChannelHandler
public AbstractHttp2ClientTransport(ClientTransportConfig transportConfig)
transportConfig - 客户端配置public void connect()
ClientTransportconnect 在类中 ClientTransportpublic void disconnect()
ClientTransportdisconnect 在类中 ClientTransportpublic void destroy()
ClientTransportdestroy 在类中 ClientTransportpublic boolean isAvailable()
ClientTransportisAvailable 在类中 ClientTransportpublic void setChannel(AbstractChannel channel)
ClientTransportsetChannel 在类中 ClientTransportchannel - the channelpublic AbstractChannel getChannel()
ClientTransportgetChannel 在类中 ClientTransportpublic int currentRequests()
ClientTransportcurrentRequests 在类中 ClientTransportpublic ResponseFuture asyncSend(SofaRequest request, int timeout) throws SofaRpcException
ClientTransportasyncSend 在类中 ClientTransportrequest - 消息timeout - 超时时间SofaRpcException - SofaRpcExceptionprotected ResponseFuture doInvokeAsync(SofaRequest request, RpcInternalContext rpcContext, int timeoutMillis)
request - 请求对象rpcContext - RPC内置上下文timeoutMillis - 超时时间(毫秒)public SofaResponse syncSend(SofaRequest request, int timeout) throws SofaRpcException
ClientTransportsyncSend 在类中 ClientTransportrequest - 消息timeout - 超时时间SofaRpcException - SofaRpcExceptionprotected SofaResponse doInvokeSync(SofaRequest request, int timeout) throws InterruptedException, ExecutionException, TimeoutException
request - 请求对象timeout - 超时时间(毫秒)InterruptedException - 中断异常ExecutionException - 执行异常TimeoutException - 超时异常protected void doSend(SofaRequest request, AbstractHttpClientHandler callback, int timeoutMills)
protected io.netty.handler.codec.http.FullHttpRequest convertToHttpRequest(SofaRequest request)
protected int sendHttpRequest(io.netty.handler.codec.http.FullHttpRequest httpRequest,
AbstractHttpClientHandler callback)
public void oneWaySend(SofaRequest request, int timeout) throws SofaRpcException
ClientTransportoneWaySend 在类中 ClientTransportrequest - 消息timeout - 超时时间SofaRpcException - SofaRpcExceptionprotected void beforeSend(RpcInternalContext context, SofaRequest request)
context - RPC上下文request - 请求对象protected void afterSend(RpcInternalContext context, SofaRequest request)
context - RPC上下文request - 请求对象public void receiveRpcResponse(SofaResponse response)
ClientTransportreceiveRpcResponse 在类中 ClientTransportresponse - the responsepublic void handleRpcRequest(SofaRequest request)
ClientTransporthandleRpcRequest 在类中 ClientTransportrequest - the requestpublic InetSocketAddress remoteAddress()
ClientTransportremoteAddress 在类中 ClientTransportpublic InetSocketAddress localAddress()
ClientTransportlocalAddress 在类中 ClientTransportprotected void checkConnection()
throws SofaRpcException
SofaRpcExceptionprotected SofaTimeOutException timeoutException(SofaRequest request, int timeout, Throwable e)
Copyright © 2008–2018 The Ant Financial. All rights reserved.