类 GrpcClient
- java.lang.Object
-
- com.alibaba.nacos.common.remote.client.RpcClient
-
- com.alibaba.nacos.common.remote.client.grpc.GrpcClient
-
- 所有已实现的接口:
Closeable
- 直接已知子类:
GrpcClusterClient,GrpcSdkClient
public abstract class GrpcClient extends RpcClient
gRPC Client.- 版本:
- $Id: GrpcClient.java, v 0.1 2020年07月13日 9:16 PM liuzunfei Exp $
- 作者:
- liuzunfei
-
-
嵌套类概要
-
从类继承的嵌套类/接口 com.alibaba.nacos.common.remote.client.RpcClient
RpcClient.ConnectionEvent, RpcClient.ServerInfo
-
-
字段概要
字段 修饰符和类型 字段 说明 private static longDEFAULT_KEEP_ALIVE_TIMEprivate static longDEFAULT_MAX_INBOUND_MESSAGE_SIZEprivate java.util.concurrent.ThreadPoolExecutorgrpcExecutor(专用程序包) static org.slf4j.LoggerLOGGER-
从类继承的字段 com.alibaba.nacos.common.remote.client.RpcClient
clientAbilities, clientEventExecutor, connectionEventListeners, currentConnection, eventLinkedBlockingQueue, labels, rpcClientStatus, serverRequestHandlers
-
-
构造器概要
构造器 构造器 说明 GrpcClient(java.lang.String name)Empty constructor.
-
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 private io.grpc.stub.StreamObserver<com.alibaba.nacos.api.grpc.auto.Payload>bindRequestStream(com.alibaba.nacos.api.grpc.auto.BiRequestStreamGrpc.BiRequestStreamStub streamStub, GrpcConnection grpcConn)ConnectionconnectToServer(RpcClient.ServerInfo serverInfo)connect to server.private com.alibaba.nacos.api.grpc.auto.RequestGrpc.RequestFutureStubcreateNewChannelStub(java.lang.String serverIp, int serverPort)create a new channel with specific server address.ConnectionTypegetConnectionType()get connection type of this client.private intgetInboundMessageSize()private intkeepAliveTimeMillis()private voidsendResponse(com.alibaba.nacos.api.remote.response.Response response)private voidsendResponse(java.lang.String ackId, boolean success)private com.alibaba.nacos.api.remote.response.ResponseserverCheck(java.lang.String ip, int port, com.alibaba.nacos.api.grpc.auto.RequestGrpc.RequestFutureStub requestBlockingStub)check server if success.private voidshuntDownChannel(io.grpc.ManagedChannel managedChannel)shutdown a channel.voidshutdown()Shutdown the Resources, such as Thread Pool.-
从类继承的方法 com.alibaba.nacos.common.remote.client.RpcClient
asyncRequest, clientAbilities, currentRpcServer, getCurrentServer, getLabels, getName, getServerListFactory, getTenant, handleServerRequest, isRunning, isShutdown, isWaitInitiated, keepAlive, labels, nextRpcServer, notifyConnected, notifyDisConnected, onServerListChange, reconnect, registerConnectionListener, registerServerRequestHandler, request, request, requestFuture, rpcPortOffset, serverListFactory, setName, setTenant, start, switchServerAsync, switchServerAsync, switchServerAsyncOnRequestFail
-
-
-
-
字段详细资料
-
LOGGER
static final org.slf4j.Logger LOGGER
-
grpcExecutor
private java.util.concurrent.ThreadPoolExecutor grpcExecutor
-
DEFAULT_MAX_INBOUND_MESSAGE_SIZE
private static final long DEFAULT_MAX_INBOUND_MESSAGE_SIZE
- 另请参阅:
- 常量字段值
-
DEFAULT_KEEP_ALIVE_TIME
private static final long DEFAULT_KEEP_ALIVE_TIME
- 另请参阅:
- 常量字段值
-
-
方法详细资料
-
getConnectionType
public ConnectionType getConnectionType()
从类复制的说明:RpcClientget connection type of this client.- 指定者:
getConnectionType在类中RpcClient- 返回:
- ConnectionType.
-
shutdown
public void shutdown() throws com.alibaba.nacos.api.exception.NacosException从接口复制的说明:CloseableShutdown the Resources, such as Thread Pool.
-
createNewChannelStub
private com.alibaba.nacos.api.grpc.auto.RequestGrpc.RequestFutureStub createNewChannelStub(java.lang.String serverIp, int serverPort)create a new channel with specific server address.- 参数:
serverIp- serverIp.serverPort- serverPort.- 返回:
- if server check success,return a non-null stub.
-
getInboundMessageSize
private int getInboundMessageSize()
-
keepAliveTimeMillis
private int keepAliveTimeMillis()
-
shuntDownChannel
private void shuntDownChannel(io.grpc.ManagedChannel managedChannel)
shutdown a channel.- 参数:
managedChannel- channel to be shutdown.
-
serverCheck
private com.alibaba.nacos.api.remote.response.Response serverCheck(java.lang.String ip, int port, com.alibaba.nacos.api.grpc.auto.RequestGrpc.RequestFutureStub requestBlockingStub)check server if success.- 参数:
requestBlockingStub- requestBlockingStub used to check server.- 返回:
- success or not
-
bindRequestStream
private io.grpc.stub.StreamObserver<com.alibaba.nacos.api.grpc.auto.Payload> bindRequestStream(com.alibaba.nacos.api.grpc.auto.BiRequestStreamGrpc.BiRequestStreamStub streamStub, GrpcConnection grpcConn)
-
sendResponse
private void sendResponse(java.lang.String ackId, boolean success)
-
sendResponse
private void sendResponse(com.alibaba.nacos.api.remote.response.Response response)
-
connectToServer
public Connection connectToServer(RpcClient.ServerInfo serverInfo)
从类复制的说明:RpcClientconnect to server.- 指定者:
connectToServer在类中RpcClient- 参数:
serverInfo- server address to connect.- 返回:
- return connection when successfully connect to server, or null if failed.
-
-