Skip to content

Small HTTP SPI cleanups. #825

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 15, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import software.amazon.awssdk.core.exception.AbortedException;
import software.amazon.awssdk.core.exception.ApiCallTimeoutException;
import software.amazon.awssdk.core.internal.http.AmazonSyncHttpClient;
import software.amazon.awssdk.http.AbortableCallable;
import software.amazon.awssdk.http.InvokeableHttpRequest;
import software.amazon.awssdk.http.SdkHttpClient;
import software.amazon.awssdk.http.SdkHttpFullResponse;
import utils.HttpTestUtils;
Expand All @@ -43,7 +43,7 @@ public class AbortedExceptionClientExecutionTimerIntegrationTest {
private SdkHttpClient sdkHttpClient;

@Mock
private AbortableCallable<SdkHttpFullResponse> abortableCallable;
private InvokeableHttpRequest abortableCallable;

@Before
public void setup() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,9 @@
import software.amazon.awssdk.core.internal.http.loader.DefaultSdkHttpClientBuilder;
import software.amazon.awssdk.core.internal.util.UserAgentUtils;
import software.amazon.awssdk.core.retry.RetryPolicy;
import software.amazon.awssdk.http.AbortableCallable;
import software.amazon.awssdk.http.ExecuteRequest;
import software.amazon.awssdk.http.InvokeableHttpRequest;
import software.amazon.awssdk.http.SdkHttpClient;
import software.amazon.awssdk.http.SdkHttpFullResponse;
import software.amazon.awssdk.http.async.AsyncExecuteRequest;
import software.amazon.awssdk.http.async.SdkAsyncHttpClient;
import software.amazon.awssdk.utils.AttributeMap;
Expand Down Expand Up @@ -366,7 +365,7 @@ private NonManagedSdkHttpClient(SdkHttpClient delegate) {
}

@Override
public AbortableCallable<SdkHttpFullResponse> prepareRequest(ExecuteRequest request) {
public InvokeableHttpRequest prepareRequest(ExecuteRequest request) {
return delegate.prepareRequest(request);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import java.util.Optional;
import java.util.TreeMap;
import java.util.function.Consumer;
import software.amazon.awssdk.annotations.SdkInternalApi;
import software.amazon.awssdk.annotations.SdkPublicApi;
import software.amazon.awssdk.core.interceptor.ExecutionInterceptor;
import software.amazon.awssdk.core.retry.RetryPolicy;
Expand Down Expand Up @@ -245,12 +244,8 @@ default Builder retryPolicy(Consumer<RetryPolicy.Builder> retryPolicy) {
* <p>
* This overrides any values currently configured in the builder.
*
* <p>
* <b><i>This is currently an INTERNAL api, which means it is subject to change and should not be used.</i></b>
*
* @see ClientOverrideConfiguration#executionInterceptors()
*/
@SdkInternalApi
Builder executionInterceptors(List<ExecutionInterceptor> executionInterceptors);

/**
Expand All @@ -262,12 +257,8 @@ default Builder retryPolicy(Consumer<RetryPolicy.Builder> retryPolicy) {
* than the ones automatically added by the SDK. See {@link ExecutionInterceptor} for a more detailed explanation of
* interceptor order.
*
* <p>
* <b><i>This is currently an INTERNAL api, which means it is subject to change and should not be used.</i></b>
*
* @see ClientOverrideConfiguration#executionInterceptors()
*/
@SdkInternalApi
Builder addExecutionInterceptor(ExecutionInterceptor executionInterceptor);

List<ExecutionInterceptor> executionInterceptors();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

package software.amazon.awssdk.core.interceptor;

import software.amazon.awssdk.annotations.SdkProtectedApi;
import software.amazon.awssdk.annotations.SdkPublicApi;
import software.amazon.awssdk.core.SdkRequest;
import software.amazon.awssdk.core.SdkResponse;
// Disable CS to avoid "Unused Import" error. If we use the FQCN in the Javadoc, we'll run into line length issues instead.
Expand All @@ -26,6 +26,8 @@
import software.amazon.awssdk.http.SdkHttpFullRequest;
import software.amazon.awssdk.http.SdkHttpFullResponse;



/**
* An interceptor that is invoked during the execution lifecycle of a request/response (execution). This can be used to publish
* metrics, modify a request in-flight, debug request processing, view exceptions, etc. This interface exposes different methods
Expand Down Expand Up @@ -111,11 +113,8 @@
* collection of attributes is created when a call to a service client is made and can be mutated throughout the course of the
* client call. These attributes are made available to every interceptor hook and is available for storing data between method
* calls. The SDK provides some attributes automatically, available via {@link SdkExecutionAttribute}.
*
* <p>
* <b><i>Note: This interface will change between SDK versions and should not be implemented by SDK users.</i></b>
*/
@SdkProtectedApi
@SdkPublicApi
public interface ExecutionInterceptor {
/**
* Read a request that has been given to a service client before it is modified by other interceptors.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
import software.amazon.awssdk.core.internal.http.InterruptMonitor;
import software.amazon.awssdk.core.internal.http.RequestExecutionContext;
import software.amazon.awssdk.core.internal.http.pipeline.RequestPipeline;
import software.amazon.awssdk.http.AbortableCallable;
import software.amazon.awssdk.http.ExecuteRequest;
import software.amazon.awssdk.http.InvokeableHttpRequest;
import software.amazon.awssdk.http.SdkHttpClient;
import software.amazon.awssdk.http.SdkHttpFullRequest;
import software.amazon.awssdk.http.SdkHttpFullResponse;
Expand Down Expand Up @@ -52,7 +52,7 @@ public Pair<SdkHttpFullRequest, SdkHttpFullResponse> execute(SdkHttpFullRequest
}

private SdkHttpFullResponse executeHttpRequest(SdkHttpFullRequest request, RequestExecutionContext context) throws Exception {
AbortableCallable<SdkHttpFullResponse> requestCallable = sdkHttpClient
InvokeableHttpRequest requestCallable = sdkHttpClient
.prepareRequest(ExecuteRequest.builder().request(request).build());

context.apiCallTimeoutTracker().abortable(requestCallable);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@
import software.amazon.awssdk.core.retry.RetryPolicy;
import software.amazon.awssdk.core.runtime.transform.Marshaller;
import software.amazon.awssdk.core.sync.ResponseTransformer;
import software.amazon.awssdk.http.AbortableCallable;
import software.amazon.awssdk.http.AbortableInputStream;
import software.amazon.awssdk.http.InvokeableHttpRequest;
import software.amazon.awssdk.http.SdkHttpClient;
import software.amazon.awssdk.http.SdkHttpFullRequest;
import software.amazon.awssdk.http.SdkHttpFullResponse;
Expand All @@ -69,7 +69,7 @@ public class SyncClientHandlerTest {
private SdkHttpClient httpClient;

@Mock
private AbortableCallable<SdkHttpFullResponse> httpClientCall;
private InvokeableHttpRequest httpClientCall;

@Mock
private HttpResponseHandler<SdkResponse> responseHandler;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
import software.amazon.awssdk.core.exception.SdkClientException;
import software.amazon.awssdk.core.internal.http.AmazonSyncHttpClient;
import software.amazon.awssdk.core.internal.http.timers.ClientExecutionAndRequestTimerTestUtils;
import software.amazon.awssdk.http.AbortableCallable;
import software.amazon.awssdk.http.ExecuteRequest;
import software.amazon.awssdk.http.InvokeableHttpRequest;
import software.amazon.awssdk.http.SdkHttpClient;
import software.amazon.awssdk.http.SdkHttpFullResponse;
import utils.HttpTestUtils;
Expand All @@ -51,7 +51,7 @@ public class AmazonHttpClientTest {
private SdkHttpClient sdkHttpClient;

@Mock
private AbortableCallable<SdkHttpFullResponse> abortableCallable;
private InvokeableHttpRequest abortableCallable;

private AmazonSyncHttpClient client;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,9 @@
public final class ExecuteRequest {

private final SdkHttpFullRequest request;
private final boolean isFullDuplex;

private ExecuteRequest(BuilderImpl builder) {
this.request = builder.request;
this.isFullDuplex = builder.isFullDuplex;
}

/**
Expand All @@ -40,10 +38,6 @@ public SdkHttpFullRequest httpRequest() {
return request;
}

public boolean fullDuplex() {
return isFullDuplex;
}

public static Builder builder() {
return new BuilderImpl();
}
Expand All @@ -57,36 +51,18 @@ public interface Builder {
*/
Builder request(SdkHttpFullRequest request);

/**
* Option to indicate if the request is for a full duplex operation ie., request and response are sent/received at
* the same time.
* <p>
* This can be used to set http configuration like ReadTimeouts as soon as request has begin sending data instead of
* waiting for the entire request to be sent.
*
* @return True if the operation this request belongs to is full duplex. Otherwise false.
*/
Builder fullDuplex(boolean fullDuplex);

ExecuteRequest build();
}

private static class BuilderImpl implements Builder {
private SdkHttpFullRequest request;
private boolean isFullDuplex;

@Override
public Builder request(SdkHttpFullRequest request) {
this.request = request;
return this;
}

@Override
public Builder fullDuplex(boolean fullDuplex) {
isFullDuplex = fullDuplex;
return this;
}

@Override
public ExecuteRequest build() {
return new ExecuteRequest(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,16 @@

package software.amazon.awssdk.http;

import java.io.IOException;
import java.util.concurrent.Callable;
import software.amazon.awssdk.annotations.SdkProtectedApi;
import software.amazon.awssdk.annotations.SdkPublicApi;

/**
* Callable task that can be aborted.
*
* @param <T> Return type of task. May be {@link Void}.
* An HTTP request that can be invoked by {@link #call()}. Once invoked, the HTTP call can be cancelled via {@link #abort()},
* which should release the thread that has invoked {@link #call()} as soon as possible.
*/
@SdkProtectedApi
public interface AbortableCallable<T> extends Callable<T>, Abortable {

@SdkPublicApi
public interface InvokeableHttpRequest extends Callable<SdkHttpFullResponse>, Abortable {
@Override
SdkHttpFullResponse call() throws IOException;
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
package software.amazon.awssdk.http;

import software.amazon.awssdk.annotations.Immutable;
import software.amazon.awssdk.annotations.SdkProtectedApi;
import software.amazon.awssdk.annotations.SdkPublicApi;
import software.amazon.awssdk.annotations.ThreadSafe;
import software.amazon.awssdk.utils.AttributeMap;
import software.amazon.awssdk.utils.SdkAutoCloseable;
Expand All @@ -26,20 +26,18 @@
* Interface to take a representation of an HTTP request, make an HTTP call, and return a representation of an HTTP response.
*
* <p>Implementations MUST be thread safe.</p>
*
* <p><b><i>Note: This interface will change between SDK versions and should not be implemented by SDK users.</i></b></p>
*/
@Immutable
@ThreadSafe
@SdkProtectedApi
@SdkPublicApi
public interface SdkHttpClient extends SdkAutoCloseable {
/**
* Create a {@link AbortableCallable} that can be used to execute the HTTP request.
* Create a {@link InvokeableHttpRequest} that can be used to execute the HTTP request.
*
* @param request Representation of an HTTP request.
* @return Task that can execute an HTTP request and can be aborted.
*/
AbortableCallable<SdkHttpFullResponse> prepareRequest(ExecuteRequest request);
InvokeableHttpRequest prepareRequest(ExecuteRequest request);

/**
* Interface for creating an {@link SdkHttpClient} with service specific defaults applied.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

package software.amazon.awssdk.http;

import software.amazon.awssdk.annotations.SdkProtectedApi;
import software.amazon.awssdk.annotations.SdkPublicApi;
import software.amazon.awssdk.annotations.ThreadSafe;

/**
Expand All @@ -31,7 +31,7 @@
* </p>
*/
@ThreadSafe
@SdkProtectedApi
@SdkPublicApi
public interface SdkHttpService {

/**
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@

package software.amazon.awssdk.http.async;

import software.amazon.awssdk.annotations.SdkProtectedApi;
import software.amazon.awssdk.annotations.SdkPublicApi;
import software.amazon.awssdk.http.SdkHttpRequest;

/**
* Request object containing the parameters necessary to make an asynchronous HTTP request.
*
* @see SdkAsyncHttpClient
*/
@SdkProtectedApi
@SdkPublicApi
public final class AsyncExecuteRequest {
private final SdkHttpRequest request;
private final SdkHttpContentPublisher requestContentPublisher;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@
package software.amazon.awssdk.http.async;

import java.util.concurrent.CompletableFuture;

import software.amazon.awssdk.annotations.Immutable;
import software.amazon.awssdk.annotations.SdkProtectedApi;
import software.amazon.awssdk.annotations.SdkPublicApi;
import software.amazon.awssdk.annotations.ThreadSafe;
import software.amazon.awssdk.utils.AttributeMap;
import software.amazon.awssdk.utils.SdkAutoCloseable;
Expand All @@ -29,12 +28,10 @@
* HTTP response.
*
* <p>Implementations MUST be thread safe.</p>
*
* <p><b><i>Note: This interface will change between SDK versions and should not be implemented by SDK users.</i></b></p>
*/
@Immutable
@ThreadSafe
@SdkProtectedApi
@SdkPublicApi
public interface SdkAsyncHttpClient extends SdkAutoCloseable {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

package software.amazon.awssdk.http.async;

import software.amazon.awssdk.annotations.SdkProtectedApi;
import software.amazon.awssdk.annotations.SdkPublicApi;
import software.amazon.awssdk.annotations.ThreadSafe;

/**
Expand All @@ -31,7 +31,7 @@
* </p>
*/
@ThreadSafe
@SdkProtectedApi
@SdkPublicApi
public interface SdkAsyncHttpService {

/**
Expand Down
Loading