org.apache.ratis.proto.grpc.RaftServerProtocolServiceGrpc Java Examples
The following examples show how to use
org.apache.ratis.proto.grpc.RaftServerProtocolServiceGrpc.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GrpcServerProtocolClient.java From incubator-ratis with Apache License 2.0 | 5 votes |
public GrpcServerProtocolClient(RaftPeer target, int flowControlWindow, TimeDuration requestTimeoutDuration, GrpcTlsConfig tlsConfig) { raftPeerId = target.getId(); NettyChannelBuilder channelBuilder = NettyChannelBuilder.forTarget(target.getAddress()); if (tlsConfig!= null) { SslContextBuilder sslContextBuilder = GrpcSslContexts.forClient(); if (tlsConfig.isFileBasedConfig()) { sslContextBuilder.trustManager(tlsConfig.getTrustStoreFile()); } else { sslContextBuilder.trustManager(tlsConfig.getTrustStore()); } if (tlsConfig.getMtlsEnabled()) { if (tlsConfig.isFileBasedConfig()) { sslContextBuilder.keyManager(tlsConfig.getCertChainFile(), tlsConfig.getPrivateKeyFile()); } else { sslContextBuilder.keyManager(tlsConfig.getPrivateKey(), tlsConfig.getCertChain()); } } try { channelBuilder.useTransportSecurity().sslContext(sslContextBuilder.build()); } catch (Exception ex) { throw new IllegalArgumentException("Failed to build SslContext, peerId=" + raftPeerId + ", tlsConfig=" + tlsConfig, ex); } } else { channelBuilder.negotiationType(NegotiationType.PLAINTEXT); } channel = channelBuilder.flowControlWindow(flowControlWindow).build(); blockingStub = RaftServerProtocolServiceGrpc.newBlockingStub(channel); asyncStub = RaftServerProtocolServiceGrpc.newStub(channel); this.requestTimeoutDuration = requestTimeoutDuration; }
Example #2
Source File: GrpcServerProtocolClient.java From ratis with Apache License 2.0 | 5 votes |
public GrpcServerProtocolClient(RaftPeer target, int flowControlWindow, TimeDuration requestTimeoutDuration, GrpcTlsConfig tlsConfig) { NettyChannelBuilder channelBuilder = NettyChannelBuilder.forTarget(target.getAddress()); if (tlsConfig!= null) { SslContextBuilder sslContextBuilder = GrpcSslContexts.forClient(); if (tlsConfig.getTrustStore() != null) { sslContextBuilder.trustManager(tlsConfig.getTrustStore()); } if (tlsConfig.getMtlsEnabled()) { sslContextBuilder.keyManager(tlsConfig.getCertChain(), tlsConfig.getPrivateKey()); } try { channelBuilder.useTransportSecurity().sslContext(sslContextBuilder.build()); } catch (Exception ex) { throw new IllegalArgumentException("Failed to build SslContext, tlsConfig=" + tlsConfig, ex); } } else { channelBuilder.negotiationType(NegotiationType.PLAINTEXT); } channel = channelBuilder.flowControlWindow(flowControlWindow).build(); blockingStub = RaftServerProtocolServiceGrpc.newBlockingStub(channel); asyncStub = RaftServerProtocolServiceGrpc.newStub(channel); this.requestTimeoutDuration = requestTimeoutDuration; }