Class Http1StreamManager

java.lang.Object
software.amazon.awssdk.crt.http.Http1StreamManager
All Implemented Interfaces:
AutoCloseable

public class Http1StreamManager extends Object implements AutoCloseable
Manages a Pool of HTTP/1.1 Streams. Creates and manages HTTP/1.1 connections under the hood. Will grab a connection from HttpClientConnectionManager to make request on it, and will return it back until the request finishes.
  • Method Details

    • create

      Factory function for Http1StreamManager instances
      Parameters:
      options - the connection manager options configure to connection manager under the hood
      Returns:
      a new instance of an Http1StreamManager
    • getShutdownCompleteFuture

      public CompletableFuture<Void> getShutdownCompleteFuture()
    • acquireStream

      public CompletableFuture<HttpStream> acquireStream(HttpRequest request, HttpStreamBaseResponseHandler streamHandler)
      Request an HTTP/1.1 HttpStream from StreamManager.
      Parameters:
      request - HttpRequest. The Request to make to the Server.
      streamHandler - HttpStreamBaseResponseHandler. The Stream Handler to be called from the Native EventLoop
      Returns:
      A future for a HttpStream that will be completed when the stream is acquired.
      Throws:
      CrtRuntimeException - Exception happens from acquiring stream.
    • acquireStream

      public CompletableFuture<HttpStream> acquireStream(HttpRequest request, HttpStreamBaseResponseHandler streamHandler, boolean useManualDataWrites)
      Request an HTTP/1.1 HttpStream from StreamManager.
      Parameters:
      request - HttpRequest. The Request to make to the Server.
      streamHandler - HttpStreamBaseResponseHandler. The Stream Handler to be called from the Native EventLoop
      useManualDataWrites - A boolean variable to signal that body will be streamed using async writes.
      Returns:
      A future for a HttpStream that will be completed when the stream is acquired.
      Throws:
      CrtRuntimeException - Exception happens from acquiring stream.
    • acquireStream

      public CompletableFuture<HttpStream> acquireStream(HttpRequestBase request, HttpStreamBaseResponseHandler streamHandler)
      Request an HTTP/1.1 HttpStream from StreamManager.
      Parameters:
      request - HttpRequestBase. The Request to make to the Server.
      streamHandler - HttpStreamBaseResponseHandler. The Stream Handler to be called from the Native EventLoop
      Returns:
      A future for a HttpStream that will be completed when the stream is acquired.
      Throws:
      CrtRuntimeException - Exception happens from acquiring stream.
    • acquireStream

      public CompletableFuture<HttpStream> acquireStream(HttpRequestBase request, HttpStreamBaseResponseHandler streamHandler, boolean useManualDataWrites)
      Request an HTTP/1.1 HttpStream from StreamManager.

      The returned future completes with an HttpStream that will be activated immediately after the future is completed. The stream's response callbacks (onResponseHeaders, etc.) may begin firing as soon as activate is called.

      Important: Operations on the stream (such as cancel()) must only be invoked after activate() has been called. If cancel() is called before activate, it is a no-op — the stream will still proceed normally once activate runs, which may lead to unexpected behavior. Since there is a brief window between future completion and activation, callers that need to perform operations on the stream (from a future callback such as thenAccept or whenComplete) should call stream.activate() first. activate() is idempotent — calling it multiple times is safe and has no effect after the first successful call.

      Parameters:
      request - HttpRequestBase. The Request to make to the Server.
      streamHandler - HttpStreamBaseResponseHandler. The Stream Handler to be called from the Native EventLoop
      useManualDataWrites - A boolean variable to signal that body will be streamed using async writes.
      Returns:
      A future for a HttpStream that will be completed when the stream is acquired and will be activated immediately after.
      Throws:
      CrtRuntimeException - Exception happens from acquiring stream.
    • getManagerMetrics

      public HttpManagerMetrics getManagerMetrics()
      Returns:
      concurrency metrics for the current manager
    • getMaxConnections

      public int getMaxConnections()
      Returns:
      maximum number of connections this manager will pool
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable