类 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 GrpcClientConfigclientConfigprivate java.util.concurrent.ThreadPoolExecutorgrpcExecutorprivate static org.slf4j.LoggerLOGGER-
从类继承的字段 com.alibaba.nacos.common.remote.client.RpcClient
clientAbilities, clientEventExecutor, connectionEventListeners, currentConnection, eventLinkedBlockingQueue, rpcClientConfig, rpcClientStatus, serverRequestHandlers
-
-
构造器概要
构造器 构造器 说明 GrpcClient(GrpcClientConfig clientConfig)constructor.GrpcClient(GrpcClientConfig clientConfig, ServerListFactory serverListFactory)constructor.GrpcClient(java.lang.String name)constructor.GrpcClient(java.lang.String name, java.lang.Integer threadPoolCoreSize, java.lang.Integer threadPoolMaxSize, java.util.Map<java.lang.String,java.lang.String> labels)constructor.GrpcClient(java.util.Properties properties)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.protected java.util.concurrent.ThreadPoolExecutorcreateGrpcExecutor(java.lang.String serverIp)private com.alibaba.nacos.api.grpc.auto.RequestGrpc.RequestFutureStubcreateNewChannelStub(io.grpc.ManagedChannel managedChannelTemp)Create a stub using a channel.private io.grpc.ManagedChannelcreateNewManagedChannel(java.lang.String serverIp, int serverPort)create a new channel with specific server address.ConnectionTypegetConnectionType()get connection type of this client.private voidsendResponse(com.alibaba.nacos.api.remote.response.Response response)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, init, isRunning, isShutdown, isWaitInitiated, labels, nextRpcServer, notifyConnected, notifyDisConnected, onServerListChange, reconnect, registerConnectionListener, registerServerRequestHandler, request, request, requestFuture, rpcPortOffset, serverListFactory, setTenant, start, switchServerAsync, switchServerAsync, switchServerAsyncOnRequestFail
-
-
-
-
字段详细资料
-
LOGGER
private static final org.slf4j.Logger LOGGER
-
clientConfig
private final GrpcClientConfig clientConfig
-
grpcExecutor
private java.util.concurrent.ThreadPoolExecutor grpcExecutor
-
-
构造器详细资料
-
GrpcClient
public GrpcClient(java.lang.String name)
constructor.- 参数:
name- .
-
GrpcClient
public GrpcClient(java.util.Properties properties)
constructor.- 参数:
properties- .
-
GrpcClient
public GrpcClient(GrpcClientConfig clientConfig)
constructor.- 参数:
clientConfig- .
-
GrpcClient
public GrpcClient(GrpcClientConfig clientConfig, ServerListFactory serverListFactory)
constructor.- 参数:
clientConfig- .serverListFactory- .
-
GrpcClient
public GrpcClient(java.lang.String name, java.lang.Integer threadPoolCoreSize, java.lang.Integer threadPoolMaxSize, java.util.Map<java.lang.String,java.lang.String> labels)constructor.- 参数:
name- .threadPoolCoreSize- .threadPoolMaxSize- .labels- .
-
-
方法详细资料
-
getConnectionType
public ConnectionType getConnectionType()
从类复制的说明:RpcClientget connection type of this client.- 指定者:
getConnectionType在类中RpcClient- 返回:
- ConnectionType.
-
createGrpcExecutor
protected java.util.concurrent.ThreadPoolExecutor createGrpcExecutor(java.lang.String serverIp)
-
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(io.grpc.ManagedChannel managedChannelTemp)
Create a stub using a channel.- 参数:
managedChannelTemp- channel.- 返回:
- if server check success,return a non-null stub.
-
createNewManagedChannel
private io.grpc.ManagedChannel createNewManagedChannel(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 channel.
-
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(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.
-
-