Search in sources :

Example 1 with XceiverClientProtocolServiceStub

use of org.apache.hadoop.hdds.protocol.datanode.proto.XceiverClientProtocolServiceGrpc.XceiverClientProtocolServiceStub in project ozone by apache.

the class XceiverClientGrpc method connectToDatanode.

private synchronized void connectToDatanode(DatanodeDetails dn) throws IOException {
    if (isConnected(dn)) {
        return;
    }
    // read port from the data node, on failure use default configured
    // port.
    int port = dn.getPort(DatanodeDetails.Port.Name.STANDALONE).getValue();
    if (port == 0) {
        port = config.getInt(OzoneConfigKeys.DFS_CONTAINER_IPC_PORT, OzoneConfigKeys.DFS_CONTAINER_IPC_PORT_DEFAULT);
    }
    // Add credential context to the client call
    if (LOG.isDebugEnabled()) {
        LOG.debug("Nodes in pipeline : {}", pipeline.getNodes());
        LOG.debug("Connecting to server : {}", dn.getIpAddress());
    }
    NettyChannelBuilder channelBuilder = NettyChannelBuilder.forAddress(dn.getIpAddress(), port).usePlaintext().maxInboundMessageSize(OzoneConsts.OZONE_SCM_CHUNK_MAX_SIZE).intercept(new GrpcClientInterceptor());
    if (secConfig.isGrpcTlsEnabled()) {
        SslContextBuilder sslContextBuilder = GrpcSslContexts.forClient();
        if (caCerts != null) {
            sslContextBuilder.trustManager(caCerts);
        }
        if (secConfig.useTestCert()) {
            channelBuilder.overrideAuthority("localhost");
        }
        channelBuilder.useTransportSecurity().sslContext(sslContextBuilder.build());
    } else {
        channelBuilder.usePlaintext();
    }
    ManagedChannel channel = channelBuilder.build();
    XceiverClientProtocolServiceStub asyncStub = XceiverClientProtocolServiceGrpc.newStub(channel);
    asyncStubs.put(dn.getUuid(), asyncStub);
    channels.put(dn.getUuid(), channel);
}
Also used : XceiverClientProtocolServiceStub(org.apache.hadoop.hdds.protocol.datanode.proto.XceiverClientProtocolServiceGrpc.XceiverClientProtocolServiceStub) SslContextBuilder(org.apache.ratis.thirdparty.io.netty.handler.ssl.SslContextBuilder) NettyChannelBuilder(org.apache.ratis.thirdparty.io.grpc.netty.NettyChannelBuilder) GrpcClientInterceptor(org.apache.hadoop.hdds.tracing.GrpcClientInterceptor) ManagedChannel(org.apache.ratis.thirdparty.io.grpc.ManagedChannel)

Aggregations

XceiverClientProtocolServiceStub (org.apache.hadoop.hdds.protocol.datanode.proto.XceiverClientProtocolServiceGrpc.XceiverClientProtocolServiceStub)1 GrpcClientInterceptor (org.apache.hadoop.hdds.tracing.GrpcClientInterceptor)1 ManagedChannel (org.apache.ratis.thirdparty.io.grpc.ManagedChannel)1 NettyChannelBuilder (org.apache.ratis.thirdparty.io.grpc.netty.NettyChannelBuilder)1 SslContextBuilder (org.apache.ratis.thirdparty.io.netty.handler.ssl.SslContextBuilder)1