类 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.LoggerLOGGERprotected static java.lang.StringNACOS_SERVER_GRPC_PORT_OFFSET_KEYprivate java.lang.IntegerthreadPoolCoreSizeprivate java.lang.IntegerthreadPoolMaxSize-
从类继承的字段 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.protected java.util.concurrent.ThreadPoolExecutorcreateGrpcExecutor(java.lang.String serverIp)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()protected java.lang.IntegergetThreadPoolCoreSize()protected java.lang.IntegergetThreadPoolMaxSize()private intkeepAliveTimeMillis()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.voidsetThreadPoolCoreSize(java.lang.Integer threadPoolCoreSize)Set core size of thread pool.voidsetThreadPoolMaxSize(java.lang.Integer threadPoolMaxSize)Set max size of thread pool.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
-
NACOS_SERVER_GRPC_PORT_OFFSET_KEY
protected static final java.lang.String NACOS_SERVER_GRPC_PORT_OFFSET_KEY
- 另请参阅:
- 常量字段值
-
grpcExecutor
private java.util.concurrent.ThreadPoolExecutor grpcExecutor
-
threadPoolCoreSize
private java.lang.Integer threadPoolCoreSize
-
threadPoolMaxSize
private java.lang.Integer threadPoolMaxSize
-
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.
-
setThreadPoolCoreSize
public void setThreadPoolCoreSize(java.lang.Integer threadPoolCoreSize)
Set core size of thread pool.- 参数:
threadPoolCoreSize- core size of thread pool for grpc.
-
setThreadPoolMaxSize
public void setThreadPoolMaxSize(java.lang.Integer threadPoolMaxSize)
Set max size of thread pool.- 参数:
threadPoolMaxSize- max size of thread pool for grpc.
-
getThreadPoolCoreSize
protected java.lang.Integer getThreadPoolCoreSize()
-
getThreadPoolMaxSize
protected java.lang.Integer getThreadPoolMaxSize()
-
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(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(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.
-
-