Class Query

java.lang.Object
org.jmxtrans.agent.Query
All Implemented Interfaces:
Collector
Direct Known Subclasses:
DiscoveryQuery

public class Query
extends java.lang.Object
implements Collector
Author:
Cyrille Le Clerc
  • Field Summary

    Fields
    Modifier and Type Field Description
    protected java.util.List<java.lang.String> attributes
    The attribute(s) to retrieve (MBeanServer.getAttribute(javax.management.ObjectName, String)) If empty, will fetch all attributes of the MBean.
    protected java.lang.String key
    If the MBean attribute value is a CompositeData, the key to lookup.
    protected javax.management.ObjectName objectName  
    protected java.lang.Integer position
    If the returned value is a Collectionor an array, the position of the entry to lookup.
    protected java.lang.String resultAlias  
    protected ResultNameStrategy resultNameStrategy  
  • Constructor Summary

    Constructors
    Constructor Description
    Query​(java.lang.String objectName, java.lang.String attribute, int position, ResultNameStrategy resultNameStrategy)  
    Query​(java.lang.String objectName, java.lang.String attribute, java.lang.String key, java.lang.Integer position, java.lang.String type, java.lang.String resultAlias, ResultNameStrategy resultNameStrategy)
    Creates a Query with no collectInterval overide.
    Query​(java.lang.String objectName, java.lang.String attribute, java.lang.String key, java.lang.Integer position, java.lang.String type, java.lang.String resultAlias, ResultNameStrategy resultNameStrategy, java.lang.Integer collectInterval)  
    Query​(java.lang.String objectName, java.lang.String attribute, java.lang.String resultAlias, ResultNameStrategy resultNameStrategy)  
    Query​(java.lang.String objectName, java.lang.String attribute, ResultNameStrategy resultNameStrategy)  
    Query​(java.lang.String objectName, java.util.List<java.lang.String> attributes, java.lang.String key, java.lang.Integer position, java.lang.String type, java.lang.String resultAlias, ResultNameStrategy resultNameStrategy, java.lang.Integer collectInterval)
    Creates a query that accepts a list of attributes to collect.
  • Method Summary

    Modifier and Type Method Description
    void collectAndExport​(javax.management.MBeanServer mbeanServer, OutputWriter outputWriter)  
    java.util.List<java.lang.String> getAttributes()  
    java.lang.Integer getCollectIntervalOverrideOrNull()  
    java.lang.String getKey()  
    javax.management.ObjectName getObjectName()  
    java.lang.Integer getPosition()  
    java.lang.String getResultAlias()  
    java.lang.String getType()  
    java.lang.String toString()  

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • resultNameStrategy

      @Nonnull protected ResultNameStrategy resultNameStrategy
    • objectName

      @Nonnull protected final javax.management.ObjectName objectName
    • attributes

      @Nonnull protected java.util.List<java.lang.String> attributes
      The attribute(s) to retrieve (MBeanServer.getAttribute(javax.management.ObjectName, String)) If empty, will fetch all attributes of the MBean.
    • resultAlias

      @Nullable protected final java.lang.String resultAlias
    • key

      @Nullable protected final java.lang.String key
      If the MBean attribute value is a CompositeData, the key to lookup.
      See Also:
      CompositeData.get(String)
    • position

      @Nullable protected final java.lang.Integer position
      If the returned value is a Collectionor an array, the position of the entry to lookup.
  • Constructor Details

    • Query

      public Query​(@Nonnull java.lang.String objectName, @Nullable java.lang.String attribute, @Nonnull ResultNameStrategy resultNameStrategy)
      See Also:
      Query(String, String, String, Integer, String, String, ResultNameStrategy)
    • Query

      public Query​(@Nonnull java.lang.String objectName, @Nullable java.lang.String attribute, int position, @Nonnull ResultNameStrategy resultNameStrategy)
      See Also:
      Query(String, String, String, Integer, String, String, ResultNameStrategy)
    • Query

      public Query​(@Nonnull java.lang.String objectName, @Nullable java.lang.String attribute, @Nullable java.lang.String resultAlias, @Nonnull ResultNameStrategy resultNameStrategy)
      See Also:
      Query(String, String, String, Integer, String, String, ResultNameStrategy)
    • Query

      public Query​(@Nonnull java.lang.String objectName, @Nullable java.lang.String attribute, @Nullable java.lang.String key, @Nullable java.lang.Integer position, @Nullable java.lang.String type, @Nullable java.lang.String resultAlias, @Nonnull ResultNameStrategy resultNameStrategy)
      Creates a Query with no collectInterval overide.
    • Query

      public Query​(@Nonnull java.lang.String objectName, @Nullable java.lang.String attribute, @Nullable java.lang.String key, @Nullable java.lang.Integer position, @Nullable java.lang.String type, @Nullable java.lang.String resultAlias, @Nonnull ResultNameStrategy resultNameStrategy, @Nullable java.lang.Integer collectInterval)
      Parameters:
      objectName - The ObjectName to search for (MBeanServer.queryMBeans(javax.management.ObjectName, javax.management.QueryExp)), can contain wildcards and return several entries.
      attribute - The attribute to retrieve (MBeanServer.getAttribute(javax.management.ObjectName, String))
      key - if the MBean attribute value is a CompositeData, the key to lookup.
      position - if the returned value is a Collection or an array, the position of the entry to lookup.
      type - type of the metric ('counter', 'gauge', ...)
      resultAlias -
      resultNameStrategy - the ResultNameStrategy used during the collectAndExport(javax.management.MBeanServer, OutputWriter) phase.
    • Query

      public Query​(@Nonnull java.lang.String objectName, @Nonnull java.util.List<java.lang.String> attributes, @Nullable java.lang.String key, @Nullable java.lang.Integer position, @Nullable java.lang.String type, @Nullable java.lang.String resultAlias, @Nonnull ResultNameStrategy resultNameStrategy, @Nullable java.lang.Integer collectInterval)
      Creates a query that accepts a list of attributes to collect. If the list is empty, all attributes will be collected.
      Parameters:
      collectInterval -
      See Also:
      Query(String, String, String, Integer, String, String, ResultNameStrategy)
  • Method Details

    • collectAndExport

      public void collectAndExport​(@Nonnull javax.management.MBeanServer mbeanServer, @Nonnull OutputWriter outputWriter)
      Specified by:
      collectAndExport in interface Collector
    • toString

      public java.lang.String toString()
      Overrides:
      toString in class java.lang.Object
    • getObjectName

      @Nonnull public javax.management.ObjectName getObjectName()
    • getResultAlias

      @Nullable public java.lang.String getResultAlias()
    • getAttributes

      @Nullable public java.util.List<java.lang.String> getAttributes()
    • getKey

      @Nullable public java.lang.String getKey()
    • getPosition

      @Nullable public java.lang.Integer getPosition()
    • getType

      @Nullable public java.lang.String getType()
    • getCollectIntervalOverrideOrNull

      @Nullable public java.lang.Integer getCollectIntervalOverrideOrNull()