Package com.arpnetworking.tsdcore.sinks
Class HttpPostSink
java.lang.Object
com.arpnetworking.tsdcore.sinks.BaseSink
com.arpnetworking.tsdcore.sinks.HttpPostSink
- All Implemented Interfaces:
Sink
- Direct Known Subclasses:
AggregationServerHttpSink
Publishes to an HTTP endpoint. This class is thread safe.
- Author:
- Brandon Arp (brandon dot arp at inscopemetrics dot io)
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
HttpPostSink.Builder<B extends BaseSink.Builder<B,
S>, S extends HttpPostSink> Implementation of abstract builder pattern forHttpPostSink
. -
Constructor Summary
ModifierConstructorDescriptionprotected
HttpPostSink
(HttpPostSink.Builder<?, ?> builder) Protected constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Called to allow the publisher to clean-up.protected org.asynchttpclient.Request
createRequest
(org.asynchttpclient.AsyncHttpClient client, byte[] serializedData) Creates an HTTP request from a serialized data entry.protected Collection<RequestEntry.Builder>
createRequests
(org.asynchttpclient.AsyncHttpClient client, PeriodicData periodicData) Create HTTP requests for each serialized data entry.protected org.asynchttpclient.uri.Uri
Accessor for the AysncHttpClientUri
.protected String
Return the media type for this sink's http post payload.protected URI
getUri()
Accessor for theURI
.void
Called when an additionalPeriodicData
instance is available for publication.protected abstract Collection<com.arpnetworking.tsdcore.sinks.HttpPostSink.SerializedDatum>
serialize
(PeriodicData periodicData) Serialize thePeriodicData
instances for posting.Generate a Steno log compatible representation.Methods inherited from class com.arpnetworking.tsdcore.sinks.BaseSink
getMetricSafeName, getName, toString
-
Constructor Details
-
HttpPostSink
Protected constructor.- Parameters:
builder
- Instance ofHttpPostSink.Builder
.
-
-
Method Details
-
recordAggregateData
Description copied from interface:Sink
Called when an additionalPeriodicData
instance is available for publication.- Parameters:
data
- ThePeriodicData
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
Description copied from class:BaseSink
Generate a Steno log compatible representation.- Overrides:
toLogValue
in classBaseSink
- 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 anPOST
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
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
- ThePeriodicData
to be serialized.- Returns:
- The
Request
instance to execute.
-
getUri
Accessor for theURI
.- Returns:
- The
URI
.
-
getAysncHttpClientUri
protected org.asynchttpclient.uri.Uri getAysncHttpClientUri()Accessor for the AysncHttpClientUri
.- Returns:
- The AysncHttpClient
Uri
.
-
serialize
protected abstract Collection<com.arpnetworking.tsdcore.sinks.HttpPostSink.SerializedDatum> serialize(PeriodicData periodicData) Serialize thePeriodicData
instances for posting.- Parameters:
periodicData
- ThePeriodicData
to be serialized.- Returns:
- The serialized representation of
PeriodicData
.
-