Class ProductsCreatedAfterClient

java.lang.Object
gov.usgs.util.DefaultConfigurable
gov.usgs.earthquake.aws.ProductsCreatedAfterClient
All Implemented Interfaces:
Configurable

public class ProductsCreatedAfterClient extends DefaultConfigurable
Client to encapsulate REST interactions with server providing `products_created_after` information.
  • Field Details

    • LOGGER

      public static Logger LOGGER
      Logger to log across instances
    • BATCH_LIMIT_PROPERTY

      public static final String BATCH_LIMIT_PROPERTY
      static property string
      See Also:
    • URL_TEMPLATE_PROPERTY

      public static final String URL_TEMPLATE_PROPERTY
      The template for making REST requests. This URL supports the following replacement strings: - {CREATED_AFTER} - {BATCH_LIMIT}
      See Also:
    • DEFAULT_BATCH_LIMIT

      public static final String DEFAULT_BATCH_LIMIT
      static property default value
      See Also:
    • DEFAULT_URL_TEMPLATE

      public static final String DEFAULT_URL_TEMPLATE
      static property default URL
      See Also:
    • CONNECT_TIMEOUT_PROPERTY

      public static final String CONNECT_TIMEOUT_PROPERTY
      Property key for connect timeout property
      See Also:
    • READ_TIMEOUT_PROPERTY

      public static final String READ_TIMEOUT_PROPERTY
      Property key for read timeout property
      See Also:
    • MAX_RETRY_ATTEMPTS_PROPERTY

      public static final String MAX_RETRY_ATTEMPTS_PROPERTY
      Property key for max retry attempts property
      See Also:
    • batchLimit

      protected int batchLimit
      settable internal batch limit
    • httpClient

      protected HttpClient httpClient
    • connectTimeout

      protected long connectTimeout
    • readTimeout

      protected long readTimeout
    • maxRetryAttempts

      protected int maxRetryAttempts
    • receivers

      protected List<AwsProductReceiver> receivers
      list of aws product receivers
    • urlTemplate

      protected String urlTemplate
      URL template string
  • Constructor Details

    • ProductsCreatedAfterClient

      public ProductsCreatedAfterClient()
      default constructor
  • Method Details

    • addReceiver

      public void addReceiver(AwsProductReceiver receiver)
      Add the given receiver as a listener to be notified of messages.
      Parameters:
      receiver - aws product receiver
    • configure

      public void configure(Config config) throws Exception
      Description copied from class: DefaultConfigurable
      Process configuration settings. Called before startup().
      Specified by:
      configure in interface Configurable
      Overrides:
      configure in class DefaultConfigurable
      Parameters:
      config - the Config object with settings.
      Throws:
      Exception - if configuration exceptions occur.
    • getBatchLimit

      public int getBatchLimit()
      Getter
      Returns:
      my batch limit as an int
    • getUrlTemplate

      public String getUrlTemplate()
      Getter
      Returns:
      my url template as a string
    • notify

      public void notify(javax.json.JsonObject message)
      Notify current receives with the message.
      Parameters:
      message - json formatted message
    • onResponse

      public void onResponse(javax.json.JsonObject json, long durationMs, Instant createdAfter)
      Called on success within the running async task. Parses the raw response and notifies configured receivers about each message in the raw payload.
      Parameters:
      json - json formatted message
      durationMs - duration in milliseconds
      createdAfter - single point in time
    • removeReceiver

      public void removeReceiver(AwsProductReceiver receiver)
      Remove a receiver from the list of currently configured receivers
      Parameters:
      receiver - aws product receiver
    • send

      public void send(Instant createdAfter) throws URISyntaxException
      Send an async Http request
      Parameters:
      createdAfter - Instant to retrieve products after
      Throws:
      URISyntaxException - thrown if an invalid URI is created
    • setBatchLimit

      public void setBatchLimit(int batchLimit)
      Setter
      Parameters:
      batchLimit - integer indicating what my batch limit should be set to
    • setUrlTemplate

      public void setUrlTemplate(String urlTemplate)
      Setter
      Parameters:
      urlTemplate - a string representing what my url template should be set to
    • setHttpClient

      public void setHttpClient(HttpClient httpClient)
      Setter
      Parameters:
      httpClient - an HttpClient used to send requests and receive responses
    • getHttpClient

      public HttpClient getHttpClient()
      Getter