@Test public void idleTimeout() { Builder builder = new Builder("target"); assertEquals(AbstractManagedChannelImplBuilder.IDLE_MODE_DEFAULT_TIMEOUT_MILLIS, builder.getIdleTimeoutMillis()); builder.idleTimeout(Long.MAX_VALUE, TimeUnit.DAYS); assertEquals(ManagedChannelImpl.IDLE_TIMEOUT_MILLIS_DISABLE, builder.getIdleTimeoutMillis()); builder.idleTimeout(AbstractManagedChannelImplBuilder.IDLE_MODE_MAX_TIMEOUT_DAYS, TimeUnit.DAYS); assertEquals(ManagedChannelImpl.IDLE_TIMEOUT_MILLIS_DISABLE, builder.getIdleTimeoutMillis()); try { builder.idleTimeout(0, TimeUnit.SECONDS); fail("Should throw"); } catch (IllegalArgumentException e) { } builder.idleTimeout(1, TimeUnit.NANOSECONDS); assertEquals(AbstractManagedChannelImplBuilder.IDLE_MODE_MIN_TIMEOUT_MILLIS, builder.getIdleTimeoutMillis()); builder.idleTimeout(30, TimeUnit.SECONDS); assertEquals(TimeUnit.SECONDS.toMillis(30), builder.getIdleTimeoutMillis()); }
@Override public final T idleTimeout(long value, TimeUnit unit) { checkArgument(value > 0, "idle timeout is %s, but must be positive", value); if (unit.toDays(value) >= IDLE_MODE_MAX_TIMEOUT_DAYS) { this.idleTimeoutMillis = ManagedChannelImpl.IDLE_TIMEOUT_MILLIS_DISABLE; } else { this.idleTimeoutMillis = Math.max(unit.toMillis(value), IDLE_MODE_MIN_TIMEOUT_MILLIS); } return thisT(); }
AbstractManagedChannelImplBuilder extends ManagedChannelBuilder<T> { @Override public final T idleTimeout(long value, TimeUnit unit) { checkArgument(value > 0, "idle timeout is %s, but must be positive", value); if (unit.toDays(value) >= IDLE_MODE_MAX_TIMEOUT_DAYS) { this.idleTimeoutMillis = ManagedChannelImpl.IDLE_TIMEOUT_MILLIS_DISABLE; } else { this.idleTimeoutMillis = Math.max(unit.toMillis(value), IDLE_MODE_MIN_TIMEOUT_MILLIS); } return thisT(); } }
AbstractManagedChannelImplBuilder extends ManagedChannelBuilder<T> { @Override public final T idleTimeout(long value, TimeUnit unit) { checkArgument(value > 0, "idle timeout is %s, but must be positive", value); if (unit.toDays(value) >= IDLE_MODE_MAX_TIMEOUT_DAYS) { this.idleTimeoutMillis = ManagedChannelImpl.IDLE_TIMEOUT_MILLIS_DISABLE; } else { this.idleTimeoutMillis = Math.max(unit.toMillis(value), IDLE_MODE_MIN_TIMEOUT_MILLIS); } return thisT(); } protected  AbstractManagedChannelImplBuilder(String target); protected  AbstractManagedChannelImplBuilder(SocketAddress directServerAddress, String authority); }
AbstractManagedChannelImplBuilder extends ManagedChannelBuilder<T> { @Override public final T idleTimeout(long value, TimeUnit unit) { checkArgument(value > 0, "idle timeout is %s, but must be positive", value); if (unit.toDays(value) >= IDLE_MODE_MAX_TIMEOUT_DAYS) { this.idleTimeoutMillis = ManagedChannelImpl.IDLE_TIMEOUT_MILLIS_DISABLE; } else { this.idleTimeoutMillis = Math.max(unit.toMillis(value), IDLE_MODE_MIN_TIMEOUT_MILLIS); } return thisT(); } protected  AbstractManagedChannelImplBuilder(String target); protected  AbstractManagedChannelImplBuilder(SocketAddress directServerAddress, String authority); static ManagedChannelBuilder<?> forAddress(String name, int port); static ManagedChannelBuilder<?> forTarget(String target); @Override T maxInboundMessageSize(int max); @Override final T directExecutor(); @Override final T executor(Executor executor); @Override final T intercept(List<ClientInterceptor> interceptors); @Override final T intercept(ClientInterceptor... interceptors); @Override final T nameResolverFactory(NameResolver.Factory resolverFactory); @Override final T loadBalancerFactory(LoadBalancer.Factory loadBalancerFactory); @Override final T enableFullStreamDecompression(); @Override final T decompressorRegistry(DecompressorRegistry registry); @Override final T compressorRegistry(CompressorRegistry registry); @Override final T userAgent(@Nullable String userAgent); @Override final T overrideAuthority(String authority); @Override final T idleTimeout(long value, TimeUnit unit); @Override final T maxRetryAttempts(int maxRetryAttempts); @Override final T maxHedgedAttempts(int maxHedgedAttempts); @Override final T retryBufferSize(long bytes); @Override final T perRpcBufferLimit(long bytes); @Override final T disableRetry(); @Override final T enableRetry(); @Override final T setBinaryLog(BinaryLog binlog); @Override T maxTraceEvents(int maxTraceEvents); @Override ManagedChannel build(); }
AbstractManagedChannelImplBuilder extends ManagedChannelBuilder<T> { @Override public final T idleTimeout(long value, TimeUnit unit) { checkArgument(value > 0, "idle timeout is %s, but must be positive", value); if (unit.toDays(value) >= IDLE_MODE_MAX_TIMEOUT_DAYS) { this.idleTimeoutMillis = ManagedChannelImpl.IDLE_TIMEOUT_MILLIS_DISABLE; } else { this.idleTimeoutMillis = Math.max(unit.toMillis(value), IDLE_MODE_MIN_TIMEOUT_MILLIS); } return thisT(); } protected  AbstractManagedChannelImplBuilder(String target); protected  AbstractManagedChannelImplBuilder(SocketAddress directServerAddress, String authority); static ManagedChannelBuilder<?> forAddress(String name, int port); static ManagedChannelBuilder<?> forTarget(String target); @Override T maxInboundMessageSize(int max); @Override final T directExecutor(); @Override final T executor(Executor executor); @Override final T intercept(List<ClientInterceptor> interceptors); @Override final T intercept(ClientInterceptor... interceptors); @Override final T nameResolverFactory(NameResolver.Factory resolverFactory); @Override final T loadBalancerFactory(LoadBalancer.Factory loadBalancerFactory); @Override final T enableFullStreamDecompression(); @Override final T decompressorRegistry(DecompressorRegistry registry); @Override final T compressorRegistry(CompressorRegistry registry); @Override final T userAgent(@Nullable String userAgent); @Override final T overrideAuthority(String authority); @Override final T idleTimeout(long value, TimeUnit unit); @Override final T maxRetryAttempts(int maxRetryAttempts); @Override final T maxHedgedAttempts(int maxHedgedAttempts); @Override final T retryBufferSize(long bytes); @Override final T perRpcBufferLimit(long bytes); @Override final T disableRetry(); @Override final T enableRetry(); @Override final T setBinaryLog(BinaryLog binlog); @Override T maxTraceEvents(int maxTraceEvents); @Override ManagedChannel build();  }