Package org.jmxtrans.embedded
Class Query
java.lang.Object
org.jmxtrans.embedded.Query
- All Implemented Interfaces:
QueryMBean
public class Query extends Object implements QueryMBean
Describe a JMX query on which metrics are collected and hold the query and export business logic
(
collectMetrics() and exportCollectedMetrics()).- Author:
- Cyrille Le Clerc, Jon Stevens
-
Constructor Summary
-
Method Summary
Modifier and Type Method Description QueryaddAttribute(String attributeName)Create a basicQueryAttribute, add it to the list attributes of this query and maintains the reverse relation (seeQueryAttribute.getQuery()).QueryaddAttribute(QueryAttribute attribute)Add the given attribute to the list attributes of this query and maintains the reverse relation (seeQueryAttribute.getQuery()).voidcollectMetrics()Collect the values for this query and store them asQueryResultin the queryResults queueintexportCollectedMetrics()Export the collected metrics to the OutputWriters associated with this Query (seegetEffectiveOutputWriters()).intgetCollectedMetricsCount()intgetCollectionCount()longgetCollectionDurationInNanos()intgetDiscardedResultsCount()Returns the number of discarded elements in thequeryResultsqueue or-1if the queue is not aDiscardingBlockingQueue.List<OutputWriter>getEffectiveOutputWriters()Return theoutputWritersto which the collected metrics of this Query are exported, theoutputWritersdeclared at query level or a the parent level.EmbeddedJmxTransgetEmbeddedJmxTrans()intgetExportCount()longgetExportDurationInNanos()intgetExportedMetricsCount()StringgetId()ObjectNamegetObjectName()List<OutputWriter>getOutputWriters()Collection<QueryAttribute>getQueryAttributes()StringgetResultAlias()BlockingQueue<QueryResult>getResults()voidsetEmbeddedJmxTrans(EmbeddedJmxTrans embeddedJmxTrans)voidsetId(String id)voidsetResultAlias(String resultAlias)voidsetResultsQueue(BlockingQueue<QueryResult> queryResultQueue)WARNING: queryResults queue should not be changed at runtime as the operation is not thread safe.voidstart()Start all the OutputWriters attached to this Queryvoidstop()Stop all the OutputWriters attached to this QueryStringtoString()
-
Constructor Details
-
Query
Creates a Query on the givenobjectName.- Parameters:
objectName-ObjectNameto query, can contain wildcards ('*' or '?')
-
Query
Creates a Query on the givenobjectName.- Parameters:
objectName-ObjectNameto query, can contain wildcards ('*' or '?')
-
-
Method Details
-
collectMetrics
public void collectMetrics()Collect the values for this query and store them asQueryResultin the queryResults queue- Specified by:
collectMetricsin interfaceQueryMBean
-
exportCollectedMetrics
public int exportCollectedMetrics()Export the collected metrics to the OutputWriters associated with this Query (seegetEffectiveOutputWriters()). Metrics are batched according toEmbeddedJmxTrans.getExportBatchSize()- Specified by:
exportCollectedMetricsin interfaceQueryMBean- Returns:
- the number of exported QueryResult
-
start
Start all the OutputWriters attached to this Query- Throws:
Exception
-
stop
Stop all the OutputWriters attached to this Query- Throws:
Exception
-
getObjectName
- Specified by:
getObjectNamein interfaceQueryMBean
-
getQueryAttributes
-
addAttribute
Add the given attribute to the list attributes of this query and maintains the reverse relation (seeQueryAttribute.getQuery()).- Parameters:
attribute- attribute to add- Returns:
- this
-
addAttribute
Create a basicQueryAttribute, add it to the list attributes of this query and maintains the reverse relation (seeQueryAttribute.getQuery()).- Parameters:
attributeName- attribute to add- Returns:
- this
-
getResults
-
setResultsQueue
WARNING: queryResults queue should not be changed at runtime as the operation is not thread safe. -
setResultAlias
-
getEmbeddedJmxTrans
-
setEmbeddedJmxTrans
-
getEffectiveOutputWriters
Return theoutputWritersto which the collected metrics of this Query are exported, theoutputWritersdeclared at query level or a the parent level. -
getOutputWriters
-
getResultAlias
- Specified by:
getResultAliasin interfaceQueryMBean
-
toString
-
getCollectedMetricsCount
public int getCollectedMetricsCount()- Specified by:
getCollectedMetricsCountin interfaceQueryMBean
-
getCollectionDurationInNanos
public long getCollectionDurationInNanos()- Specified by:
getCollectionDurationInNanosin interfaceQueryMBean
-
getCollectionCount
public int getCollectionCount()- Specified by:
getCollectionCountin interfaceQueryMBean
-
getExportedMetricsCount
public int getExportedMetricsCount()- Specified by:
getExportedMetricsCountin interfaceQueryMBean
-
getExportDurationInNanos
public long getExportDurationInNanos()- Specified by:
getExportDurationInNanosin interfaceQueryMBean
-
getExportCount
public int getExportCount()- Specified by:
getExportCountin interfaceQueryMBean
-
getId
- Specified by:
getIdin interfaceQueryMBean
-
setId
-
getDiscardedResultsCount
public int getDiscardedResultsCount()Returns the number of discarded elements in thequeryResultsqueue or-1if the queue is not aDiscardingBlockingQueue.- Specified by:
getDiscardedResultsCountin interfaceQueryMBean
-