Package org.jmxtrans.embedded.output
Class AbstractOutputWriter
java.lang.Object
org.jmxtrans.embedded.output.AbstractOutputWriter
- All Implemented Interfaces:
OutputWriter
- Direct Known Subclasses:
ConsoleWriter,CopperEggWriter,CsvWriter,GraphiteHttpWriter,GraphitePickleWriter,GraphiteWriter,LibratoWriter,NoOpWriter,Slf4jWriter,StackdriverWriter,StatsDWriter
public abstract class AbstractOutputWriter extends Object implements OutputWriter
Convenience abstract class to implement an
OutputWriter.- Author:
- Cyrille Le Clerc, Patrick Brühlmann
-
Field Summary
Fields Modifier and Type Field Description protected org.slf4j.Loggerloggerstatic StringSETTING_HOSTstatic StringSETTING_NAME_PREFIXstatic StringSETTING_PORTstatic StringSETTING_PROTOCOLstatic StringSETTING_PROXY_HOSTstatic StringSETTING_PROXY_PORTstatic StringSETTING_SOCKET_FACTORYstatic StringSETTING_TLS_INSECUREstatic StringSETTING_TLS_KEY_STOREstatic StringSETTING_TLS_KEY_STORE_PASSWORDstatic StringSETTING_TLS_TRUST_STOREstatic StringSETTING_TLS_TRUST_STORE_PASSWORDstatic StringSETTING_TOKENstatic StringSETTING_URLstatic StringSETTING_USE_TLSstatic StringSETTING_USERNAME -
Constructor Summary
Constructors Constructor Description AbstractOutputWriter() -
Method Summary
Modifier and Type Method Description booleanequals(Object o)protected booleangetBooleanSetting(String name, boolean defaultValue)Convert value of this setting to a Java boolean (viaBoolean.parseBoolean(String)).protected intgetIntSetting(String name)Convert value of this setting to a Java int.protected intgetIntSetting(String name, int defaultValue)Convert value of this setting to a Java int.protected longgetLongSetting(String name, long defaultValue)Convert value of this setting to a Java long.Map<String,Object>getSettings()Configuration settings of the OutputWriter.ResultNameStrategygetStrategy()protected StringgetStringSetting(String name)Convert value of this setting to a Java int.protected StringgetStringSetting(String name, String defaultValue)Return the value of the given property.inthashCode()booleanisEnabled()voidsetEnabled(boolean enabled)voidsetSettings(Map<String,Object> settings)Sets the configuration setting of the OutputWriter.voidsetStrategy(ResultNameStrategy strategy)voidstart()No-op implementationvoidstop()No-op implementationStringtoString()abstract voidwrite(Iterable<QueryResult> results)Write all the given QueryResult to the target system.
-
Field Details
-
SETTING_URL
- See Also:
- Constant Field Values
-
SETTING_USERNAME
- See Also:
- Constant Field Values
-
SETTING_TOKEN
- See Also:
- Constant Field Values
-
SETTING_PORT
- See Also:
- Constant Field Values
-
SETTING_HOST
- See Also:
- Constant Field Values
-
SETTING_SOCKET_FACTORY
- See Also:
- Constant Field Values
-
SETTING_USE_TLS
- See Also:
- Constant Field Values
-
SETTING_TLS_INSECURE
- See Also:
- Constant Field Values
-
SETTING_TLS_TRUST_STORE
- See Also:
- Constant Field Values
-
SETTING_TLS_TRUST_STORE_PASSWORD
- See Also:
- Constant Field Values
-
SETTING_TLS_KEY_STORE
- See Also:
- Constant Field Values
-
SETTING_TLS_KEY_STORE_PASSWORD
- See Also:
- Constant Field Values
-
SETTING_PROXY_PORT
- See Also:
- Constant Field Values
-
SETTING_PROXY_HOST
- See Also:
- Constant Field Values
-
SETTING_NAME_PREFIX
- See Also:
- Constant Field Values
-
SETTING_PROTOCOL
- See Also:
- Constant Field Values
-
logger
protected final org.slf4j.Logger logger
-
-
Constructor Details
-
AbstractOutputWriter
public AbstractOutputWriter()
-
-
Method Details
-
start
public void start()No-op implementation- Specified by:
startin interfaceOutputWriter
-
stop
No-op implementation- Specified by:
stopin interfaceOutputWriter- Throws:
Exception
-
getIntSetting
Convert value of this setting to a Java int. If the setting is not found or is not an int, an exception is thrown.- Parameters:
name- name of the setting / property- Returns:
- int value of the setting / property
- Throws:
IllegalArgumentException- if setting is not found or is not an integer.
-
getIntSetting
Convert value of this setting to a Java int. If the property is not found, thedefaultValueis returned. If the property is not an int, an exception is thrown.- Parameters:
name- name of the propertydefaultValue- default value if the property is not defined.- Returns:
- int value of the property or
defaultValueif the property is not defined. - Throws:
IllegalArgumentException- if setting is not is not an integer.
-
getLongSetting
Convert value of this setting to a Java long. If the property is not found, thedefaultValueis returned. If the property is not a long, an exception is thrown.- Parameters:
name- name of the propertydefaultValue- default value if the property is not defined.- Returns:
- int value of the property or
defaultValueif the property is not defined. - Throws:
IllegalArgumentException- if setting is not is not a long.
-
getBooleanSetting
Convert value of this setting to a Java boolean (viaBoolean.parseBoolean(String)). If the property is not found, thedefaultValueis returned.- Parameters:
name- name of the propertydefaultValue- default value if the property is not defined.- Returns:
- int value of the property or
defaultValueif the property is not defined.
-
getStringSetting
Convert value of this setting to a Java int. If the setting is not found, an exception is thrown.- Parameters:
name- name of the property- Returns:
- value of the property
- Throws:
IllegalArgumentException- if setting is not found.
-
getStringSetting
Return the value of the given property. If the property is not found, thedefaultValueis returned.- Parameters:
name- name of the propertydefaultValue- default value if the property is not defined.- Returns:
- value of the property or
defaultValueif the property is not defined.
-
write
Description copied from interface:OutputWriterWrite all the given QueryResult to the target system.- Specified by:
writein interfaceOutputWriter
-
toString
-
getSettings
Description copied from interface:OutputWriterConfiguration settings of the OutputWriter.- Specified by:
getSettingsin interfaceOutputWriter
-
setSettings
Description copied from interface:OutputWriterSets the configuration setting of the OutputWriter.- Specified by:
setSettingsin interfaceOutputWriter
-
getStrategy
-
setStrategy
-
isEnabled
public boolean isEnabled()- Specified by:
isEnabledin interfaceOutputWriter
-
setEnabled
public void setEnabled(boolean enabled)- Specified by:
setEnabledin interfaceOutputWriter
-
equals
-
hashCode
public int hashCode()
-