@Extension(value="bolt") public class BoltClientTransport extends ClientTransport
| 限定符和类型 | 字段和说明 |
|---|---|
protected com.alipay.remoting.Connection |
connection
Connection的实时状态
因为一个url在bolt里对应多个connect的,但是我们禁用,只保留一个 |
protected static com.alipay.sofa.rpc.transport.bolt.BoltClientConnectionManager |
connectionManager
Connection manager for reuse connection
|
protected AtomicInteger |
currentRequests
正在发送的调用数量
|
protected static com.alipay.remoting.rpc.RpcClient |
RPC_CLIENT
Bolt rpc client
|
protected com.alipay.remoting.Url |
url
bolt需要的URL的缓存
|
transportConfig| 限定符 | 构造器和说明 |
|---|---|
protected |
BoltClientTransport(ClientTransportConfig transportConfig)
Instant BoltClientTransport
|
| 限定符和类型 | 方法和说明 |
|---|---|
protected void |
afterSend(RpcInternalContext context,
com.alipay.remoting.InvokeContext invokeContext,
SofaRequest request)
调用后设置一些属性(注意,在异步的情况较多下)
|
ResponseFuture |
asyncSend(SofaRequest request,
int timeout)
异步调用
|
protected void |
beforeSend(RpcInternalContext context,
SofaRequest request)
调用前设置一些属性
|
protected void |
checkConnection() |
void |
connect()
建立长连接
|
protected com.alipay.remoting.Url |
convertProviderToUrl(ClientTransportConfig transportConfig,
ProviderInfo providerInfo)
For convert provider to bolt url.
|
protected SofaRpcException |
convertToRpcException(Exception e)
转换调用出现的异常为RPC异常
|
protected com.alipay.remoting.InvokeContext |
createInvokeContext(SofaRequest request) |
int |
currentRequests()
当前请求数
|
void |
destroy()
销毁(最好是通过工厂模式销毁,这样可以清理缓存)
|
void |
disconnect()
断开连接
|
protected ResponseFuture |
doInvokeAsync(SofaRequest request,
RpcInternalContext rpcContext,
com.alipay.remoting.InvokeContext invokeContext,
int timeoutMillis)
异步调用
|
protected SofaResponse |
doInvokeSync(SofaRequest request,
com.alipay.remoting.InvokeContext invokeContext,
int timeoutMillis)
同步调用
|
protected void |
doOneWay(SofaRequest request,
com.alipay.remoting.InvokeContext invokeContext,
int timeoutMillis)
同步调用
|
AbstractChannel |
getChannel()
得到长连接
|
void |
handleRpcRequest(SofaRequest request)
客户端收到服务端的请求,可能是服务端Callback
|
boolean |
isAvailable()
是否可用(有可用的长连接)
|
InetSocketAddress |
localAddress()
本地地址
|
void |
oneWaySend(SofaRequest request,
int timeout)
单向调用
|
protected void |
putToContextIfNotNull(com.alipay.remoting.InvokeContext invokeContext,
String oldKey,
RpcInternalContext context,
String key) |
void |
receiveRpcResponse(SofaResponse response)
客户端收到异步响应
|
InetSocketAddress |
remoteAddress()
远程地址
|
void |
setChannel(AbstractChannel channel)
设置长连接
|
SofaResponse |
syncSend(SofaRequest request,
int timeout)
同步调用
|
getConfigprotected static final com.alipay.remoting.rpc.RpcClient RPC_CLIENT
protected static com.alipay.sofa.rpc.transport.bolt.BoltClientConnectionManager connectionManager
protected final com.alipay.remoting.Url url
protected volatile com.alipay.remoting.Connection connection
protected volatile AtomicInteger currentRequests
protected BoltClientTransport(ClientTransportConfig transportConfig)
transportConfig - 客户端配置protected com.alipay.remoting.Url convertProviderToUrl(ClientTransportConfig transportConfig, ProviderInfo providerInfo)
transportConfig - ClientTransportConfigproviderInfo - ProviderInfopublic 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, com.alipay.remoting.InvokeContext invokeContext, int timeoutMillis) throws com.alipay.remoting.exception.RemotingException, InterruptedException
request - 请求对象rpcContext - RPC内置上下文invokeContext - 调用上下文timeoutMillis - 超时时间(毫秒)com.alipay.remoting.exception.RemotingException - 远程调用异常InterruptedException - 中断异常public SofaResponse syncSend(SofaRequest request, int timeout) throws SofaRpcException
ClientTransportsyncSend 在类中 ClientTransportrequest - 消息timeout - 超时时间SofaRpcException - SofaRpcExceptionprotected SofaResponse doInvokeSync(SofaRequest request, com.alipay.remoting.InvokeContext invokeContext, int timeoutMillis) throws com.alipay.remoting.exception.RemotingException, InterruptedException
request - 请求对象invokeContext - 调用上下文timeoutMillis - 超时时间(毫秒)com.alipay.remoting.exception.RemotingException - 远程调用异常InterruptedException - 中断异常public void oneWaySend(SofaRequest request, int timeout) throws SofaRpcException
ClientTransportoneWaySend 在类中 ClientTransportrequest - 消息timeout - 超时时间SofaRpcException - SofaRpcExceptionprotected void doOneWay(SofaRequest request, com.alipay.remoting.InvokeContext invokeContext, int timeoutMillis) throws com.alipay.remoting.exception.RemotingException, InterruptedException
request - 请求对象invokeContext - 调用上下文timeoutMillis - 超时时间(毫秒)com.alipay.remoting.exception.RemotingException - 远程调用异常InterruptedException - 中断异常protected SofaRpcException convertToRpcException(Exception e)
e - 异常protected com.alipay.remoting.InvokeContext createInvokeContext(SofaRequest request)
protected void beforeSend(RpcInternalContext context, SofaRequest request)
context - RPC上下文request - 请求对象protected void afterSend(RpcInternalContext context, com.alipay.remoting.InvokeContext invokeContext, SofaRequest request)
context - RPC上下文invokeContext - bolt调用上下文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 void putToContextIfNotNull(com.alipay.remoting.InvokeContext invokeContext,
String oldKey,
RpcInternalContext context,
String key)
Copyright © 2008–2018 The Ant Financial. All rights reserved.