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:
DataDogSink
,InfluxDbSink
,KairosDbSink
,KMonDSink
,MonitordSink
,SignalFxSink
Publishes to an HTTP endpoint. This class is thread safe.
- Author:
- Brandon Arp (brandon dot arp at inscopemetrics dot com)
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
HttpPostSink.Builder<B extends BaseSink.Builder<B,
S>, S extends HttpPostSink> Implementation of abstract builder pattern forHttpPostSink
. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
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 int
Accessor for the MaximumAttempts.protected Duration
Accessor for the BaseBackoff of retriesDuration
.protected Duration
Accessor for the MaximumDelay of retriesDuration
.protected URI
getUri()
Accessor for theURI
.void
Called when additionalPeriodicData
instances are available for publication.protected abstract Collection<com.arpnetworking.tsdcore.sinks.HttpPostSink.SerializedDatum>
serialize
(PeriodicData periodicData) Serialize thePeriodicData
instance 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 additionalPeriodicData
instances are 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
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
-
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
.
-
getMaximumAttempts
protected int getMaximumAttempts()Accessor for the MaximumAttempts.- Returns:
- The MaximumAttempts.
-
getRetryBaseBackoff
Accessor for the BaseBackoff of retriesDuration
.- Returns:
- The BaseBackoff
Duration
.
-
getRetryMaximumDelay
Accessor for the MaximumDelay of retriesDuration
.- Returns:
- The MaximumDelay
Duration
.
-
serialize
protected abstract Collection<com.arpnetworking.tsdcore.sinks.HttpPostSink.SerializedDatum> serialize(PeriodicData periodicData) Serialize thePeriodicData
instance for posting.- Parameters:
periodicData
- ThePeriodicData
to be serialized.- Returns:
- The serialized representation of
PeriodicData
.
-