[Refactor]Remove unnecessary judgment (#11019)
* remove unnecessary judgment * remove unnecessary judgment
This commit is contained in:
parent
27216603c2
commit
279e488e03
@ -330,40 +330,36 @@ public abstract class GrpcClient extends RpcClient {
|
||||
int port = serverInfo.getServerPort() + rpcPortOffset();
|
||||
ManagedChannel managedChannel = createNewManagedChannel(serverInfo.getServerIp(), port);
|
||||
RequestGrpc.RequestFutureStub newChannelStubTemp = createNewChannelStub(managedChannel);
|
||||
if (newChannelStubTemp != null) {
|
||||
|
||||
Response response = serverCheck(serverInfo.getServerIp(), port, newChannelStubTemp);
|
||||
if (response == null || !(response instanceof ServerCheckResponse)) {
|
||||
shuntDownChannel(managedChannel);
|
||||
return null;
|
||||
}
|
||||
|
||||
BiRequestStreamGrpc.BiRequestStreamStub biRequestStreamStub = BiRequestStreamGrpc.newStub(
|
||||
newChannelStubTemp.getChannel());
|
||||
GrpcConnection grpcConn = new GrpcConnection(serverInfo, grpcExecutor);
|
||||
grpcConn.setConnectionId(((ServerCheckResponse) response).getConnectionId());
|
||||
|
||||
//create stream request and bind connection event to this connection.
|
||||
StreamObserver<Payload> payloadStreamObserver = bindRequestStream(biRequestStreamStub, grpcConn);
|
||||
|
||||
// stream observer to send response to server
|
||||
grpcConn.setPayloadStreamObserver(payloadStreamObserver);
|
||||
grpcConn.setGrpcFutureServiceStub(newChannelStubTemp);
|
||||
grpcConn.setChannel(managedChannel);
|
||||
//send a setup request.
|
||||
ConnectionSetupRequest conSetupRequest = new ConnectionSetupRequest();
|
||||
conSetupRequest.setClientVersion(VersionUtils.getFullClientVersion());
|
||||
conSetupRequest.setLabels(super.getLabels());
|
||||
conSetupRequest.setAbilities(super.clientAbilities);
|
||||
conSetupRequest.setTenant(super.getTenant());
|
||||
grpcConn.sendRequest(conSetupRequest);
|
||||
//wait to register connection setup
|
||||
Thread.sleep(100L);
|
||||
return grpcConn;
|
||||
Response response = serverCheck(serverInfo.getServerIp(), port, newChannelStubTemp);
|
||||
if (!(response instanceof ServerCheckResponse)) {
|
||||
shuntDownChannel(managedChannel);
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
|
||||
BiRequestStreamGrpc.BiRequestStreamStub biRequestStreamStub = BiRequestStreamGrpc.newStub(
|
||||
newChannelStubTemp.getChannel());
|
||||
GrpcConnection grpcConn = new GrpcConnection(serverInfo, grpcExecutor);
|
||||
grpcConn.setConnectionId(((ServerCheckResponse) response).getConnectionId());
|
||||
|
||||
//create stream request and bind connection event to this connection.
|
||||
StreamObserver<Payload> payloadStreamObserver = bindRequestStream(biRequestStreamStub, grpcConn);
|
||||
|
||||
// stream observer to send response to server
|
||||
grpcConn.setPayloadStreamObserver(payloadStreamObserver);
|
||||
grpcConn.setGrpcFutureServiceStub(newChannelStubTemp);
|
||||
grpcConn.setChannel(managedChannel);
|
||||
//send a setup request.
|
||||
ConnectionSetupRequest conSetupRequest = new ConnectionSetupRequest();
|
||||
conSetupRequest.setClientVersion(VersionUtils.getFullClientVersion());
|
||||
conSetupRequest.setLabels(super.getLabels());
|
||||
conSetupRequest.setAbilities(super.clientAbilities);
|
||||
conSetupRequest.setTenant(super.getTenant());
|
||||
grpcConn.sendRequest(conSetupRequest);
|
||||
//wait to register connection setup
|
||||
Thread.sleep(100L);
|
||||
return grpcConn;
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("[{}]Fail to connect to server!,error={}", GrpcClient.this.getName(), e);
|
||||
LOGGER.error("[{}]Fail to connect to server!", GrpcClient.this.getName(), e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user