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 Details

  • Constructor Details

    • AbstractOutputWriter

      public AbstractOutputWriter()
  • Method Details

    • start

      public void start()
      No-op implementation
      Specified by:
      start in interface OutputWriter
    • stop

      public void stop() throws Exception
      No-op implementation
      Specified by:
      stop in interface OutputWriter
      Throws:
      Exception
    • getIntSetting

      protected int getIntSetting​(String name) throws IllegalArgumentException
      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

      protected int getIntSetting​(String name, int defaultValue) throws IllegalArgumentException
      Convert value of this setting to a Java int. If the property is not found, the defaultValue is returned. If the property is not an int, an exception is thrown.
      Parameters:
      name - name of the property
      defaultValue - default value if the property is not defined.
      Returns:
      int value of the property or defaultValue if the property is not defined.
      Throws:
      IllegalArgumentException - if setting is not is not an integer.
    • getLongSetting

      protected long getLongSetting​(String name, long defaultValue) throws IllegalArgumentException
      Convert value of this setting to a Java long. If the property is not found, the defaultValue is returned. If the property is not a long, an exception is thrown.
      Parameters:
      name - name of the property
      defaultValue - default value if the property is not defined.
      Returns:
      int value of the property or defaultValue if the property is not defined.
      Throws:
      IllegalArgumentException - if setting is not is not a long.
    • getBooleanSetting

      protected boolean getBooleanSetting​(String name, boolean defaultValue)
      Convert value of this setting to a Java boolean (via Boolean.parseBoolean(String)). If the property is not found, the defaultValue is returned.
      Parameters:
      name - name of the property
      defaultValue - default value if the property is not defined.
      Returns:
      int value of the property or defaultValue if the property is not defined.
    • getStringSetting

      protected String getStringSetting​(String name) throws IllegalArgumentException
      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

      protected String getStringSetting​(String name, String defaultValue)
      Return the value of the given property. If the property is not found, the defaultValue is returned.
      Parameters:
      name - name of the property
      defaultValue - default value if the property is not defined.
      Returns:
      value of the property or defaultValue if the property is not defined.
    • write

      public abstract void write​(Iterable<QueryResult> results)
      Description copied from interface: OutputWriter
      Write all the given QueryResult to the target system.
      Specified by:
      write in interface OutputWriter
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getSettings

      public Map<String,​Object> getSettings()
      Description copied from interface: OutputWriter
      Configuration settings of the OutputWriter.
      Specified by:
      getSettings in interface OutputWriter
    • setSettings

      public void setSettings​(Map<String,​Object> settings)
      Description copied from interface: OutputWriter
      Sets the configuration setting of the OutputWriter.
      Specified by:
      setSettings in interface OutputWriter
    • getStrategy

      public ResultNameStrategy getStrategy()
    • setStrategy

      public void setStrategy​(ResultNameStrategy strategy)
    • isEnabled

      public boolean isEnabled()
      Specified by:
      isEnabled in interface OutputWriter
    • setEnabled

      public void setEnabled​(boolean enabled)
      Specified by:
      setEnabled in interface OutputWriter
    • equals

      public boolean equals​(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object