public abstract class AbstractProxyClientTransport extends ClientTransport
| 限定符和类型 | 字段和说明 |
|---|---|
protected AtomicInteger |
currentRequests
正在发送的调用数量
|
protected InetSocketAddress |
localAddress
本地地址
|
protected InetSocketAddress |
remoteAddress
远程地址
|
transportConfig| 构造器和说明 |
|---|
AbstractProxyClientTransport(ClientTransportConfig transportConfig)
构造函数
|
| 限定符和类型 | 方法和说明 |
|---|---|
protected void |
afterSend(RpcInternalContext context,
SofaRequest request)
调用后设置一些属性(注意,在异步的情况较多下)
|
ResponseFuture |
asyncSend(SofaRequest message,
int timeout)
异步调用
|
protected void |
beforeSend(RpcInternalContext context,
SofaRequest request)
调用前设置一些属性
|
protected abstract Object |
buildProxy(ClientTransportConfig transportConfig)
构造远程调用代理
|
void |
connect()
建立长连接
|
protected SofaRpcException |
convertToRpcException(InvocationTargetException e)
转换调用出现的异常为RPC异常
|
int |
currentRequests()
当前请求数
|
void |
destroy()
销毁(最好是通过工厂模式销毁,这样可以清理缓存)
|
void |
disconnect()
断开连接
|
protected SofaResponse |
doInvokeSync(SofaRequest request,
int timeoutMillis)
同步调用
|
AbstractChannel |
getChannel()
得到长连接
|
protected abstract Method |
getMethod(SofaRequest request)
构造远程调用代理
|
void |
handleRpcRequest(SofaRequest request)
客户端收到服务端的请求,可能是服务端Callback
|
boolean |
isAvailable()
是否可用(有可用的长连接)
|
InetSocketAddress |
localAddress()
本地地址
|
void |
oneWaySend(SofaRequest message,
int timeout)
单向调用
|
void |
receiveRpcResponse(SofaResponse response)
客户端收到异步响应
|
InetSocketAddress |
remoteAddress()
远程地址
|
void |
setChannel(AbstractChannel channel)
设置长连接
|
SofaResponse |
syncSend(SofaRequest request,
int timeout)
同步调用
|
getConfigprotected InetSocketAddress localAddress
protected InetSocketAddress remoteAddress
protected volatile AtomicInteger currentRequests
public AbstractProxyClientTransport(ClientTransportConfig transportConfig)
transportConfig - 客户端配置protected abstract Object buildProxy(ClientTransportConfig transportConfig) throws SofaRpcException
transportConfig - the transport configSofaRpcException - the exceptionpublic 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 message, int timeout) throws SofaRpcException
ClientTransportasyncSend 在类中 ClientTransportmessage - 消息timeout - 超时时间SofaRpcException - SofaRpcExceptionprotected abstract Method getMethod(SofaRequest request) throws SofaRpcException
request - 请求dioxideSofaRpcException - the exceptionpublic SofaResponse syncSend(SofaRequest request, int timeout) throws SofaRpcException
ClientTransportsyncSend 在类中 ClientTransportrequest - 消息timeout - 超时时间SofaRpcException - SofaRpcExceptionprotected SofaResponse doInvokeSync(SofaRequest request, int timeoutMillis) throws InvocationTargetException, IllegalAccessException
request - 请求对象timeoutMillis - 超时时间(毫秒)InvocationTargetException - 反射调用异常IllegalAccessExceptionprotected void beforeSend(RpcInternalContext context, SofaRequest request)
context - RPC上下文request - 请求对象protected void afterSend(RpcInternalContext context, SofaRequest request)
context - RPC上下文request - 请求对象protected SofaRpcException convertToRpcException(InvocationTargetException e)
e - 代理类包装的原因public void oneWaySend(SofaRequest message, int timeout) throws SofaRpcException
ClientTransportoneWaySend 在类中 ClientTransportmessage - 消息timeout - 超时时间SofaRpcException - SofaRpcExceptionpublic void receiveRpcResponse(SofaResponse response)
ClientTransportreceiveRpcResponse 在类中 ClientTransportresponse - the responsepublic void handleRpcRequest(SofaRequest request)
ClientTransporthandleRpcRequest 在类中 ClientTransportrequest - the requestpublic InetSocketAddress remoteAddress()
ClientTransportremoteAddress 在类中 ClientTransportpublic InetSocketAddress localAddress()
ClientTransportlocalAddress 在类中 ClientTransportCopyright © 2008–2018 The Ant Financial. All rights reserved.