Class HttpPostSink

java.lang.Object
com.arpnetworking.tsdcore.sinks.BaseSink
com.arpnetworking.tsdcore.sinks.HttpPostSink
All Implemented Interfaces:
Sink
Direct Known Subclasses:
AggregationServerHttpSink

public abstract class HttpPostSink extends BaseSink
Publishes to an HTTP endpoint. This class is thread safe.
Author:
Brandon Arp (brandon dot arp at inscopemetrics dot io)
  • Constructor Details

  • Method Details

    • recordAggregateData

      public void recordAggregateData(PeriodicData data)
      Description copied from interface: Sink
      Called when an additional PeriodicData instance is available for publication.
      Parameters:
      data - The PeriodicData to be published.
    • close

      public void close()
      Description copied from interface: Sink
      Called to allow the publisher to clean-up. No further calls to recordAggregation will be made after a call to close.
    • toLogValue

      public Object toLogValue()
      Description copied from class: BaseSink
      Generate a Steno log compatible representation.
      Overrides:
      toLogValue in class BaseSink
      Returns:
      Steno log compatible representation.
    • createRequest

      protected org.asynchttpclient.Request createRequest(org.asynchttpclient.AsyncHttpClient client, byte[] serializedData)
      Creates an HTTP request from a serialized data entry. Default is an POST containing serializedData as the body with content type of application/json
      Parameters:
      client - The http client to build the request with.
      serializedData - The serialized data.
      Returns:
      Request to execute
    • getContentType

      protected String getContentType()
      Return the media type for this sink's http post payload.
      Returns:
      the media type for this sink's http post payload
    • createRequests

      protected Collection<RequestEntry.Builder> createRequests(org.asynchttpclient.AsyncHttpClient client, PeriodicData periodicData)
      Create HTTP requests for each serialized data entry. The list is guaranteed to be non-empty.
      Parameters:
      client - The http client to build the request with.
      periodicData - The PeriodicData to be serialized.
      Returns:
      The Request instance to execute.
    • getUri

      protected URI getUri()
      Accessor for the URI.
      Returns:
      The URI.
    • getAysncHttpClientUri

      protected org.asynchttpclient.uri.Uri getAysncHttpClientUri()
      Accessor for the AysncHttpClient Uri.
      Returns:
      The AysncHttpClient Uri.
    • serialize

      protected abstract Collection<com.arpnetworking.tsdcore.sinks.HttpPostSink.SerializedDatum> serialize(PeriodicData periodicData)
      Serialize the PeriodicData instances for posting.
      Parameters:
      periodicData - The PeriodicData to be serialized.
      Returns:
      The serialized representation of PeriodicData.