类 RpcClient
java.lang.Object
com.alibaba.nacos.common.remote.client.RpcClient
- 所有已实现的接口:
Closeable
- 直接已知子类:
GrpcClient
abstract remote client to connect to server.
- 版本:
- $Id: RpcClient.java, v 0.1 2020年07月13日 9:15 PM liuzunfei Exp $
- 作者:
- liuzunfei
-
嵌套类概要
嵌套类 -
字段概要
字段修饰符和类型字段说明protected com.alibaba.nacos.api.ability.ClientAbilitiesprotected ScheduledExecutorServiceprotected List<ConnectionEventListener>listener called where connection's status changed.protected Connectionprotected LinkedBlockingQueue<RpcClient.ConnectionEvent>protected AtomicReference<RpcClientStatus>protected List<ServerRequestHandler>handlers to process server push request. -
构造器概要
构造器构造器说明RpcClient(ServerListFactory serverListFactory)RpcClient(String name, ServerListFactory serverListFactory) -
方法概要
修饰符和类型方法说明voidasyncRequest(com.alibaba.nacos.api.remote.request.Request request, com.alibaba.nacos.api.remote.RequestCallBack callback)send async request.clientAbilities(com.alibaba.nacos.api.ability.ClientAbilities clientAbilities)init client abilities.abstract ConnectionconnectToServer(RpcClient.ServerInfo serverInfo)connect to server.protected RpcClient.ServerInfoabstract ConnectionTypeget connection type of this client.get current server.Getter method for property labels.getName()Getter method for property name.Getter method for property serverListFactory.protected com.alibaba.nacos.api.remote.response.ResponsehandleServerRequest(com.alibaba.nacos.api.remote.request.Request request)handle server request.booleancheck is this client is running.booleancheck is this client is shutdown.booleancheck is this client is initiated.init keepalive time.init labels.protected RpcClient.ServerInfoprotected voidNotify when client new connected.protected voidNotify when client disconnected.protected voidreconnect(RpcClient.ServerInfo recommendServerInfo, boolean onRequestFail)switch server .voidregisterConnectionListener(ConnectionEventListener connectionEventListener)Register connection handler.voidregisterServerRequestHandler(ServerRequestHandler serverRequestHandler)Register serverRequestHandler, the handler will handle the request from server side.com.alibaba.nacos.api.remote.response.Responserequest(com.alibaba.nacos.api.remote.request.Request request)send request.com.alibaba.nacos.api.remote.response.Responserequest(com.alibaba.nacos.api.remote.request.Request request, long timeoutMills)send request.com.alibaba.nacos.api.remote.RequestFuturerequestFuture(com.alibaba.nacos.api.remote.request.Request request)send async request.abstract intincrease offset of the nacos server port for the rpc server port.serverListFactory(ServerListFactory serverListFactory)init server list factory.only can init once.voidSetter method for property name.voidvoidshutdown()Shutdown the Resources, such as Thread Pool.voidstart()Start this client.voidprotected voidswitchServerAsync(RpcClient.ServerInfo recommendServerInfo, boolean onRequestFail)void
-
字段详细资料
-
eventLinkedBlockingQueue
-
rpcClientStatus
-
clientEventExecutor
-
currentConnection
-
labels
-
clientAbilities
protected com.alibaba.nacos.api.ability.ClientAbilities clientAbilities -
connectionEventListeners
listener called where connection's status changed. -
serverRequestHandlers
handlers to process server push request.
-
-
构造器详细资料
-
RpcClient
-
RpcClient
-
RpcClient
-
-
方法详细资料
-
clientAbilities
init client abilities.- 参数:
clientAbilities- clientAbilities.
-
serverListFactory
init server list factory.only can init once.- 参数:
serverListFactory- serverListFactory
-
labels
init labels.- 参数:
labels- labels
-
keepAlive
init keepalive time.- 参数:
keepAliveTime- keepAliveTimetimeUnit- timeUnit
-
notifyDisConnected
protected void notifyDisConnected()Notify when client disconnected. -
notifyConnected
protected void notifyConnected()Notify when client new connected. -
isWaitInitiated
public boolean isWaitInitiated()check is this client is initiated.- 返回:
- is wait initiated or not.
-
isRunning
public boolean isRunning()check is this client is running.- 返回:
- is running or not.
-
isShutdown
public boolean isShutdown()check is this client is shutdown.- 返回:
- is shutdown or not.
-
start
public final void start() throws com.alibaba.nacos.api.exception.NacosExceptionStart this client.- 抛出:
com.alibaba.nacos.api.exception.NacosException
-
shutdown
public void shutdown() throws com.alibaba.nacos.api.exception.NacosException从接口复制的说明:CloseableShutdown the Resources, such as Thread Pool. -
switchServerAsyncOnRequestFail
public void switchServerAsyncOnRequestFail() -
switchServerAsync
public void switchServerAsync() -
switchServerAsync
-
reconnect
switch server . -
getConnectionType
get connection type of this client.- 返回:
- ConnectionType.
-
rpcPortOffset
public abstract int rpcPortOffset()increase offset of the nacos server port for the rpc server port.- 返回:
- rpc port offset
-
getCurrentServer
get current server.- 返回:
- server info.
-
request
public com.alibaba.nacos.api.remote.response.Response request(com.alibaba.nacos.api.remote.request.Request request) throws com.alibaba.nacos.api.exception.NacosExceptionsend request.- 参数:
request- request.- 返回:
- response from server.
- 抛出:
com.alibaba.nacos.api.exception.NacosException
-
request
public com.alibaba.nacos.api.remote.response.Response request(com.alibaba.nacos.api.remote.request.Request request, long timeoutMills) throws com.alibaba.nacos.api.exception.NacosExceptionsend request.- 参数:
request- request.- 返回:
- response from server.
- 抛出:
com.alibaba.nacos.api.exception.NacosException
-
asyncRequest
public void asyncRequest(com.alibaba.nacos.api.remote.request.Request request, com.alibaba.nacos.api.remote.RequestCallBack callback) throws com.alibaba.nacos.api.exception.NacosExceptionsend async request.- 参数:
request- request.- 抛出:
com.alibaba.nacos.api.exception.NacosException
-
requestFuture
public com.alibaba.nacos.api.remote.RequestFuture requestFuture(com.alibaba.nacos.api.remote.request.Request request) throws com.alibaba.nacos.api.exception.NacosExceptionsend async request.- 参数:
request- request.- 返回:
- request future.
- 抛出:
com.alibaba.nacos.api.exception.NacosException
-
connectToServer
connect to server.- 参数:
serverInfo- server address to connect.- 返回:
- return connection when successfully connect to server, or null if failed.
- 抛出:
Exception- exception when fail to connect to server.
-
handleServerRequest
protected com.alibaba.nacos.api.remote.response.Response handleServerRequest(com.alibaba.nacos.api.remote.request.Request request)handle server request.- 参数:
request- request.- 返回:
- response.
-
registerConnectionListener
Register connection handler. Will be notified when inner connection's state changed.- 参数:
connectionEventListener- connectionEventListener
-
registerServerRequestHandler
Register serverRequestHandler, the handler will handle the request from server side.- 参数:
serverRequestHandler- serverRequestHandler
-
getName
Getter method for property name.- 返回:
- property value of name
-
setName
Setter method for property name.- 参数:
name- value to be assigned to property name
-
getServerListFactory
Getter method for property serverListFactory.- 返回:
- property value of serverListFactory
-
nextRpcServer
-
currentRpcServer
-
getLabels
Getter method for property labels.- 返回:
- property value of labels
-
getTenant
-
setTenant
-