Skip to content

Commit b2aa3a0

Browse files
authored
Misc renaming (#3708)
1 parent e258597 commit b2aa3a0

File tree

7 files changed

+207
-201
lines changed

7 files changed

+207
-201
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"category": "AWS CRT HTTP Client",
3+
"contributor": "",
4+
"type": "feature",
5+
"description": "Renamed: `ConnectionHealthChecksConfiguration` -> `ConnectionHealthConfiguration`\nRenamed: `allowableThroughputFailureInterval` -> `minimumThroughputTimeout`\nRenamed: `minThroughputInBytesPerSecond` -> `minimumThroughputInBps`\nRenamed: `AwsCrtAsyncHttpClient.builder().connectionHealthChecksConfiguration` -> `AwsCrtAsyncHttpClient.builder().connectionHealthConfiguration`"
6+
}

http-clients/aws-crt-client/src/main/java/software/amazon/awssdk/http/crt/AwsCrtAsyncHttpClient.java

+17-17
Original file line numberDiff line numberDiff line change
@@ -111,20 +111,20 @@ private AwsCrtAsyncHttpClient(DefaultBuilder builder, AttributeMap config) {
111111
this.tlsContext = registerOwnedResource(clientTlsContext);
112112
this.readBufferSize = builder.readBufferSize == null ? DEFAULT_STREAM_WINDOW_SIZE : builder.readBufferSize;
113113
this.maxConnectionsPerEndpoint = config.get(SdkHttpConfigurationOption.MAX_CONNECTIONS);
114-
this.monitoringOptions = revolveHttpMonitoringOptions(builder.connectionHealthChecksConfiguration);
114+
this.monitoringOptions = revolveHttpMonitoringOptions(builder.connectionHealthConfiguration);
115115
this.maxConnectionIdleInMilliseconds = config.get(SdkHttpConfigurationOption.CONNECTION_MAX_IDLE_TIMEOUT).toMillis();
116116
this.proxyOptions = buildProxyOptions(builder.proxyConfiguration);
117117
}
118118
}
119119

120-
private HttpMonitoringOptions revolveHttpMonitoringOptions(ConnectionHealthChecksConfiguration config) {
120+
private HttpMonitoringOptions revolveHttpMonitoringOptions(ConnectionHealthConfiguration config) {
121121
if (config == null) {
122122
return null;
123123
}
124124

125125
HttpMonitoringOptions httpMonitoringOptions = new HttpMonitoringOptions();
126-
httpMonitoringOptions.setMinThroughputBytesPerSecond(config.minThroughputInBytesPerSecond());
127-
int seconds = (int) config.allowableThroughputFailureInterval().getSeconds();
126+
httpMonitoringOptions.setMinThroughputBytesPerSecond(config.minimumThroughputInBps());
127+
int seconds = (int) config.minimumThroughputTimeout().getSeconds();
128128
httpMonitoringOptions.setAllowableThroughputFailureIntervalSeconds(seconds);
129129
return httpMonitoringOptions;
130130
}
@@ -355,25 +355,25 @@ public interface Builder extends SdkAsyncHttpClient.Builder<AwsCrtAsyncHttpClien
355355
*
356356
* <p>
357357
* You can set a throughput threshold for a connection to be considered healthy.
358-
* If a connection falls below this threshold ({@link ConnectionHealthChecksConfiguration#minThroughputInBytesPerSecond()
358+
* If a connection falls below this threshold ({@link ConnectionHealthConfiguration#minimumThroughputInBps()
359359
* }) for the configurable amount
360-
* of time ({@link ConnectionHealthChecksConfiguration#allowableThroughputFailureInterval()}),
360+
* of time ({@link ConnectionHealthConfiguration#minimumThroughputTimeout()}),
361361
* then the connection is considered unhealthy and will be shut down.
362362
*
363363
* @param healthChecksConfiguration The health checks config to use
364364
* @return The builder of the method chaining.
365365
*/
366-
Builder connectionHealthChecksConfiguration(ConnectionHealthChecksConfiguration healthChecksConfiguration);
366+
Builder connectionHealthConfiguration(ConnectionHealthConfiguration healthChecksConfiguration);
367367

368368
/**
369-
* A convenience method that creates an instance of the {@link ConnectionHealthChecksConfiguration} builder, avoiding the
370-
* need to create one manually via {@link ConnectionHealthChecksConfiguration#builder()}.
369+
* A convenience method that creates an instance of the {@link ConnectionHealthConfiguration} builder, avoiding the
370+
* need to create one manually via {@link ConnectionHealthConfiguration#builder()}.
371371
*
372372
* @param healthChecksConfigurationBuilder The health checks config builder to use
373373
* @return The builder of the method chaining.
374-
* @see #connectionHealthChecksConfiguration(ConnectionHealthChecksConfiguration)
374+
* @see #connectionHealthConfiguration(ConnectionHealthConfiguration)
375375
*/
376-
Builder connectionHealthChecksConfiguration(Consumer<ConnectionHealthChecksConfiguration.Builder>
376+
Builder connectionHealthConfiguration(Consumer<ConnectionHealthConfiguration.Builder>
377377
healthChecksConfigurationBuilder);
378378

379379
/**
@@ -428,7 +428,7 @@ private static final class DefaultBuilder implements Builder {
428428
private final AttributeMap.Builder standardOptions = AttributeMap.builder();
429429
private Integer readBufferSize;
430430
private ProxyConfiguration proxyConfiguration;
431-
private ConnectionHealthChecksConfiguration connectionHealthChecksConfiguration;
431+
private ConnectionHealthConfiguration connectionHealthConfiguration;
432432
private TcpKeepAliveConfiguration tcpKeepAliveConfiguration;
433433

434434
private DefaultBuilder() {
@@ -470,17 +470,17 @@ public Builder proxyConfiguration(ProxyConfiguration proxyConfiguration) {
470470
}
471471

472472
@Override
473-
public Builder connectionHealthChecksConfiguration(ConnectionHealthChecksConfiguration monitoringOptions) {
474-
this.connectionHealthChecksConfiguration = monitoringOptions;
473+
public Builder connectionHealthConfiguration(ConnectionHealthConfiguration monitoringOptions) {
474+
this.connectionHealthConfiguration = monitoringOptions;
475475
return this;
476476
}
477477

478478
@Override
479-
public Builder connectionHealthChecksConfiguration(Consumer<ConnectionHealthChecksConfiguration.Builder>
479+
public Builder connectionHealthConfiguration(Consumer<ConnectionHealthConfiguration.Builder>
480480
configurationBuilder) {
481-
ConnectionHealthChecksConfiguration.Builder builder = ConnectionHealthChecksConfiguration.builder();
481+
ConnectionHealthConfiguration.Builder builder = ConnectionHealthConfiguration.builder();
482482
configurationBuilder.accept(builder);
483-
return connectionHealthChecksConfiguration(builder.build());
483+
return connectionHealthConfiguration(builder.build());
484484
}
485485

486486
@Override

http-clients/aws-crt-client/src/main/java/software/amazon/awssdk/http/crt/ConnectionHealthChecksConfiguration.java

-118
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
/*
2+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License").
5+
* You may not use this file except in compliance with the License.
6+
* A copy of the License is located at
7+
*
8+
* http://aws.amazon.com/apache2.0
9+
*
10+
* or in the "license" file accompanying this file. This file is distributed
11+
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12+
* express or implied. See the License for the specific language governing
13+
* permissions and limitations under the License.
14+
*/
15+
16+
package software.amazon.awssdk.http.crt;
17+
18+
import java.time.Duration;
19+
import software.amazon.awssdk.annotations.SdkPreviewApi;
20+
import software.amazon.awssdk.annotations.SdkPublicApi;
21+
import software.amazon.awssdk.utils.Validate;
22+
23+
/**
24+
* Configuration that defines health checks for all connections established by
25+
* the {@link ConnectionHealthConfiguration}.
26+
*
27+
* <b>NOTE:</b> This is a Preview API and is subject to change so it should not be used in production.
28+
*/
29+
@SdkPublicApi
30+
@SdkPreviewApi
31+
public final class ConnectionHealthConfiguration {
32+
private final long minimumThroughputInBps;
33+
private final Duration minimumThroughputTimeout;
34+
35+
private ConnectionHealthConfiguration(DefaultConnectionHealthConfigurationBuilder builder) {
36+
this.minimumThroughputInBps = Validate.paramNotNull(builder.minimumThroughputInBps,
37+
"minimumThroughputInBps");
38+
this.minimumThroughputTimeout = Validate.isPositive(builder.minimumThroughputTimeout,
39+
"minimumThroughputTimeout");
40+
}
41+
42+
/**
43+
* @return the minimum amount of throughput, in bytes per second, for a connection to be considered healthy.
44+
*/
45+
public long minimumThroughputInBps() {
46+
return minimumThroughputInBps;
47+
}
48+
49+
/**
50+
* @return How long a connection is allowed to be unhealthy before getting shut down.
51+
*/
52+
public Duration minimumThroughputTimeout() {
53+
return minimumThroughputTimeout;
54+
}
55+
56+
public static Builder builder() {
57+
return new DefaultConnectionHealthConfigurationBuilder();
58+
}
59+
60+
/**
61+
* A builder for {@link ConnectionHealthConfiguration}.
62+
*
63+
* <p>All implementations of this interface are mutable and not thread safe.</p>
64+
*/
65+
public interface Builder {
66+
67+
/**
68+
* Sets a throughput threshold for connections. Throughput below this value will be considered unhealthy.
69+
*
70+
* @param minimumThroughputInBps minimum amount of throughput, in bytes per second, for a connection to be
71+
* considered healthy.
72+
* @return Builder
73+
*/
74+
Builder minimumThroughputInBps(Long minimumThroughputInBps);
75+
76+
/**
77+
* Sets how long a connection is allowed to be unhealthy before getting shut down.
78+
*
79+
* <p>
80+
* It only supports seconds precision
81+
*
82+
* @param minimumThroughputTimeout How long a connection is allowed to be unhealthy
83+
* before getting shut down.
84+
* @return Builder
85+
*/
86+
Builder minimumThroughputTimeout(Duration minimumThroughputTimeout);
87+
88+
ConnectionHealthConfiguration build();
89+
}
90+
91+
/**
92+
* An SDK-internal implementation of {@link Builder}.
93+
*/
94+
private static final class DefaultConnectionHealthConfigurationBuilder implements Builder {
95+
private Long minimumThroughputInBps;
96+
private Duration minimumThroughputTimeout;
97+
98+
private DefaultConnectionHealthConfigurationBuilder() {
99+
}
100+
101+
@Override
102+
public Builder minimumThroughputInBps(Long minimumThroughputInBps) {
103+
this.minimumThroughputInBps = minimumThroughputInBps;
104+
return this;
105+
}
106+
107+
@Override
108+
public Builder minimumThroughputTimeout(Duration minimumThroughputTimeout) {
109+
this.minimumThroughputTimeout = minimumThroughputTimeout;
110+
return this;
111+
}
112+
113+
@Override
114+
public ConnectionHealthConfiguration build() {
115+
return new ConnectionHealthConfiguration(this);
116+
}
117+
}
118+
}

http-clients/aws-crt-client/src/test/java/software/amazon/awssdk/http/crt/AwsCrtHttpClientSpiVerificationTest.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ public class AwsCrtHttpClientSpiVerificationTest {
7676
@BeforeClass
7777
public static void setup() throws Exception {
7878
client = AwsCrtAsyncHttpClient.builder()
79-
.connectionHealthChecksConfiguration(b -> b.minThroughputInBytesPerSecond(4068L)
80-
.allowableThroughputFailureInterval(Duration.ofSeconds(3)))
79+
.connectionHealthConfiguration(b -> b.minimumThroughputInBps(4068L)
80+
.minimumThroughputTimeout(Duration.ofSeconds(3)))
8181
.build();
8282
}
8383

0 commit comments

Comments
 (0)