.setMaxInboundMessageSize(MAX_MESSAGE_SIZE) .setMaxInboundMetadataSize(MAX_METADATA_SIZE) .setPoolSize(options.getNumChannels())
public Builder setChannelsPerCpu(double multiplier, int maxChannels) { Preconditions.checkArgument(multiplier > 0, "multiplier must be positive"); Preconditions.checkArgument(maxChannels > 0, "maxChannels must be positive"); int channelCount = (int) Math.ceil(processorCount * multiplier); if (channelCount > maxChannels) { channelCount = maxChannels; } return setPoolSize(channelCount); }
public Builder setChannelsPerCpu(double multiplier, int maxChannels) { Preconditions.checkArgument(multiplier > 0, "multiplier must be positive"); Preconditions.checkArgument(maxChannels > 0, "maxChannels must be positive"); int channelCount = (int) Math.ceil(processorCount * multiplier); if (channelCount > maxChannels) { channelCount = maxChannels; } return setPoolSize(channelCount); }
.setMaxInboundMessageSize(MAX_MESSAGE_SIZE) .setMaxInboundMetadataSize(MAX_METADATA_SIZE) .setPoolSize(options.getNumChannels())
.setExecutorProvider(Mockito.mock(ExecutorProvider.class)) .setChannelConfigurator(channelConfigurator) .setPoolSize(numChannels) .build() .getTransportChannel();
private void testWithInterceptors(int numChannels) throws Exception { final GrpcInterceptorProvider interceptorProvider = Mockito.mock(GrpcInterceptorProvider.class); InstantiatingGrpcChannelProvider channelProvider = InstantiatingGrpcChannelProvider.newBuilder() .setEndpoint("localhost:8080") .setPoolSize(numChannels) .setHeaderProvider(Mockito.mock(HeaderProvider.class)) .setExecutorProvider(Mockito.mock(ExecutorProvider.class)) .setInterceptorProvider(interceptorProvider) .build(); Mockito.verify(interceptorProvider, Mockito.never()).getInterceptors(); channelProvider.getTransportChannel().shutdownNow(); Mockito.verify(interceptorProvider, Mockito.times(numChannels)).getInterceptors(); }
@Override @BetaApi("The surface for customizing pool size is not stable yet and may change in the future.") public TransportChannelProvider withPoolSize(int size) { Preconditions.checkState(acceptsPoolSize(), "pool size already set to %s", poolSize); return toBuilder().setPoolSize(size).build(); }
@Override @BetaApi("The surface for customizing pool size is not stable yet and may change in the future.") public TransportChannelProvider withPoolSize(int size) { Preconditions.checkState(acceptsPoolSize(), "pool size already set to %s", poolSize); return toBuilder().setPoolSize(size).build(); }