public abstract class OpenTSDBGenericWriter extends BaseOutputWriter
| Modifier and Type | Field and Description |
|---|---|
protected boolean |
addHostnameTag |
static boolean |
DEFAULT_MERGE_TYPE_NAMES_TAGS |
protected String |
host |
protected String |
hostnameTag |
protected boolean |
mergeTypeNamesTags |
protected NamingStrategy |
metricNameStrategy |
protected Integer |
port |
protected String |
tagName |
protected com.google.common.collect.ImmutableMap<String,String> |
tags |
BINARY_PATH, BOOLEAN_AS_NUMBER, DEBUG, HOST, OUTPUT_FILE, PORT, TEMPLATE_FILE, TYPE_NAMES| Constructor and Description |
|---|
OpenTSDBGenericWriter(com.google.common.collect.ImmutableList<String> typeNames,
boolean booleanAsNumber,
Boolean debugEnabled,
String host,
Integer port,
Map<String,String> tags,
String tagName,
Boolean mergeTypeNamesTags,
String metricNamingExpression,
Boolean addHostnameTag,
Map<String,Object> settings) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
addTypeNamesTags(StringBuilder resultString,
Result result)
Add the tag(s) for typeNames.
|
protected void |
finishOutput()
Complete a batch of results output, if needed.
|
protected abstract boolean |
getAddHostnameTagDefault()
Subclass responsibility: specify the default value for the "addHostnameTag" setting.
|
void |
internalWrite(Server server,
Query query,
com.google.common.collect.ImmutableList<Result> results)
Write the results of the query.
|
protected void |
prepareSender()
Prepare for sending metrics, if needed.
|
protected void |
processOneMetric(List<String> resultStrings,
Result result,
Object value,
String addTagName,
String addTagValue)
Process a single metric from the given JMX query result with the specified value.
|
protected String |
sanitizeString(String unsanitized)
VALID CHARACTERS:
METRIC, TAGNAME, AND TAG-VALUE:
[-_./a-zA-Z0-9]+
SANITIZATION:
- Discard Quotes.
|
protected abstract void |
sendOutput(String metricLine)
Subcall responsibility: method to perform the actual output for the given metric line.
|
protected void |
shutdownSender()
Shutdown the sender, if needed.
|
void |
start()
Start the output writer.
|
protected void |
startOutput()
Prepare a batch of results output, if needed.
|
void |
stop() |
void |
validateSetup(Server server,
Query query)
Validation per query, after the writer has been start()ed
|
doWrite, firstNonNull, getConcatedTypeNameValues, getSettings, getTypeNames, isDebugEnabled, setSettingspublic static final boolean DEFAULT_MERGE_TYPE_NAMES_TAGS
protected final String host
protected final Integer port
protected final String tagName
protected final NamingStrategy metricNameStrategy
protected final boolean mergeTypeNamesTags
protected final boolean addHostnameTag
protected final String hostnameTag
public OpenTSDBGenericWriter(com.google.common.collect.ImmutableList<String> typeNames, boolean booleanAsNumber, Boolean debugEnabled, String host, Integer port, Map<String,String> tags, String tagName, Boolean mergeTypeNamesTags, String metricNamingExpression, Boolean addHostnameTag, Map<String,Object> settings) throws LifecycleException, UnknownHostException
protected void prepareSender()
throws LifecycleException
LifecycleExceptionprotected void shutdownSender()
throws LifecycleException
LifecycleExceptionprotected void startOutput()
throws IOException
IOExceptionprotected abstract boolean getAddHostnameTagDefault()
protected abstract void sendOutput(String metricLine) throws IOException
metricLine - - the line containing the metric name, value, and tags for a single metric; excludes the
"put" keyword expected by OpenTSDB and the trailing newline character.IOExceptionprotected void finishOutput()
throws IOException
IOExceptionprotected void processOneMetric(List<String> resultStrings, Result result, Object value, String addTagName, String addTagValue)
protected void addTypeNamesTags(StringBuilder resultString, Result result)
result - - the result of the JMX query.resultString - - current form of the metric string.public void internalWrite(Server server, Query query, com.google.common.collect.ImmutableList<Result> results) throws Exception
internalWrite in class BaseOutputWriterserver - query - - the query and its results.results - Exceptionpublic void validateSetup(Server server, Query query) throws ValidationException
ValidationExceptionpublic void start()
throws LifecycleException
start in interface OutputWriterstart in class BaseOutputWriterLifecycleExceptionpublic void stop()
throws LifecycleException
stop in interface OutputWriterstop in class BaseOutputWriterLifecycleExceptionCopyright © 2015. All Rights Reserved.