类 RpcClient

java.lang.Object
com.alibaba.nacos.common.remote.client.RpcClient
所有已实现的接口:
Closeable
直接已知子类:
GrpcClient

public abstract class RpcClient extends Object implements Closeable
abstract remote client to connect to server.
版本:
$Id: RpcClient.java, v 0.1 2020年07月13日 9:15 PM liuzunfei Exp $
作者:
liuzunfei
  • 字段详细资料

  • 构造器详细资料

  • 方法详细资料

    • init

      protected void init()
    • serverListFactory

      public RpcClient serverListFactory(ServerListFactory serverListFactory)
      init server list factory. only can init once.
      参数:
      serverListFactory - serverListFactory
    • notifyDisConnected

      protected void notifyDisConnected(Connection connection)
      Notify when client disconnected.
      参数:
      connection - connection has disconnected
    • notifyConnected

      protected void notifyConnected(Connection connection)
      Notify when client new connected.
      参数:
      connection - connection has 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.
    • onServerListChange

      public void onServerListChange()
      check if current connected server is in server list, if not switch server.
    • start

      public final void start() throws com.alibaba.nacos.api.exception.NacosException
      Start this client.
      抛出:
      com.alibaba.nacos.api.exception.NacosException
    • afterReset

      protected void afterReset(com.alibaba.nacos.api.remote.request.ConnectResetRequest request)
      . invoke after receiving reset request
      参数:
      request - request for resetting
    • shutdown

      public void shutdown() throws com.alibaba.nacos.api.exception.NacosException
      从接口复制的说明: Closeable
      Shutdown the Resources, such as Thread Pool.
      指定者:
      shutdown 在接口中 Closeable
      抛出:
      com.alibaba.nacos.api.exception.NacosException - exception.
    • switchServerAsyncOnRequestFail

      public void switchServerAsyncOnRequestFail()
    • switchServerAsync

      public void switchServerAsync()
    • switchServerAsync

      protected void switchServerAsync(RpcClient.ServerInfo recommendServerInfo, boolean onRequestFail)
    • reconnect

      protected void reconnect(RpcClient.ServerInfo recommendServerInfo, boolean onRequestFail)
      switch server .
    • getConnectionType

      public abstract ConnectionType 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

      public RpcClient.ServerInfo 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.NacosException
      send 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.NacosException
      send 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.NacosException
      send 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.NacosException
      send async request.
      参数:
      request - request.
      返回:
      request future.
      抛出:
      com.alibaba.nacos.api.exception.NacosException
    • connectToServer

      public abstract Connection connectToServer(RpcClient.ServerInfo serverInfo) throws Exception
      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

      public void registerConnectionListener(ConnectionEventListener connectionEventListener)
      Register connection handler. Will be notified when inner connection's state changed.
      参数:
      connectionEventListener - connectionEventListener
    • registerServerRequestHandler

      public void registerServerRequestHandler(ServerRequestHandler serverRequestHandler)
      Register serverRequestHandler, the handler will handle the request from server side.
      参数:
      serverRequestHandler - serverRequestHandler
    • getName

      public String getName()
      Getter method for property name.
      返回:
      property value of name
    • getServerListFactory

      public ServerListFactory getServerListFactory()
      Getter method for property serverListFactory.
      返回:
      property value of serverListFactory
    • nextRpcServer

      protected RpcClient.ServerInfo nextRpcServer()
    • currentRpcServer

      protected RpcClient.ServerInfo currentRpcServer()
    • getLabels

      public Map<String,String> getLabels()
      Getter method for property labels.
      返回:
      property value of labels
    • getTenant

      public String getTenant()
    • setTenant

      public void setTenant(String tenant)
    • getConnectionAbility

      public com.alibaba.nacos.api.ability.constant.AbilityStatus getConnectionAbility(com.alibaba.nacos.api.ability.constant.AbilityKey abilityKey)
      Return ability of current connection.
      参数:
      abilityKey - ability key
      返回:
      whether support, return null if connection is not ready