public RemoteDataSet(final HostAndPort serverEndpoint, final int remoteHandle) { this.serverEndpoint = serverEndpoint; this.remoteHandle = remoteHandle; this.stub = HillviewServerGrpc.newStub(NettyChannelBuilder .forAddress(serverEndpoint.getHost(), serverEndpoint.getPort()) .maxInboundMessageSize(HillviewServer.MAX_MESSAGE_SIZE) .executor(executorService) .eventLoopGroup(workerElg) .usePlaintext() // channel is unencrypted. .build()); }
@Override public synchronized void init(Properties properties) { final Metadata metadata = new Metadata(); metadata.put(MetaConstants.STORE_TYPE.asMetaKey(), storeInfo.getType()); metadata.put(MetaConstants.TABLE_NAME.asMetaKey(), storeInfo.getTableName()); metadata.put(MetaConstants.NAME_SPACE.asMetaKey(), storeInfo.getNameSpace()); metadata.put(MetaConstants.FRAGMENT.asMetaKey(), storeInfo.getFragment() + ""); String host = properties.getProperty("host"); int port = -1; Object portObj = properties.get("port"); if (portObj instanceof String) { port = Integer.valueOf(portObj.toString()); } else { port = (int) properties.get("port"); } channel = NettyChannelBuilder.forAddress(host, port).usePlaintext().maxInboundMessageSize(maxMessageSize).build(); blockingStub = MetadataUtils.attachHeaders(KVServiceGrpc.newBlockingStub(channel), metadata); stub = MetadataUtils.attachHeaders(KVServiceGrpc.newStub(channel), metadata); }
private ManagedChannel createChannel(BasicMeta.Endpoint endpoint) { String target = endpoint.getIp(); if (Strings.isNullOrEmpty(target)) { target = endpoint.getHostname(); } NettyChannelBuilder builder = NettyChannelBuilder .forAddress(target, endpoint.getPort()) .executor((Executor) applicationContext.getBean("grpcClientExecutor")) .keepAliveTime(6, TimeUnit.MINUTES) .keepAliveTimeout(24, TimeUnit.HOURS) .keepAliveWithoutCalls(true) .idleTimeout(1, TimeUnit.HOURS) .perRpcBufferLimit(128 << 20) .flowControlWindow(32 << 20) .maxInboundMessageSize(32 << 20) .enableRetry() .retryBufferSize(16 << 20) .maxRetryAttempts(20); // todo: configurable LOGGER.info("[COMMON][CHANNEL][CREATE] use insecure channel to {}", toStringUtils.toOneLineString(endpoint)); builder.negotiationType(NegotiationType.PLAINTEXT) .usePlaintext(); ManagedChannel managedChannel = builder .build(); LOGGER.info("[COMMON][CHANNEL][CREATE] created channel to {}", toStringUtils.toOneLineString(endpoint)); return managedChannel; }
.perRpcBufferLimit(16 << 20) .flowControlWindow(32 << 20) .maxInboundMessageSize(32 << 20) .enableRetry() .retryBufferSize(16 << 20)