public class AgentServer
extends java.lang.Object
implements java.lang.Runnable
MetricAgent objects and corresponding set of metric
keys. A running agent server is a passive component of the
monitoring system and is used to serve metric value queries over a
network using Zabbix protocol (i.e. JabbixProtocol).
Each metric key is a textual string value that can be used in bijection with
a MetricAgent. However, for a projection of multiple metric keys to a
single MetricAgent component be also possible, the assumption is made that
the '.' (dot) symbol of a key is a component separator. For a given
multicomponent key the longest leftmost mapping is selected if any.
The incoming requests are processed using a thread pool (i.e.
ThreadPoolExecutor).
| Constructor and Description |
|---|
AgentServer(java.util.concurrent.ThreadPoolExecutor pool)
Creates a new agent server instance with a given thread pool set to
process incoming requests.
|
| Modifier and Type | Method and Description |
|---|---|
MetricAgent |
getMetricAgent(java.lang.String key)
Returns a metric agent registered for a given metric key.
|
java.util.Map<java.lang.String,MetricAgent> |
getMetricAgentMap()
Returns the metric key -> metric agent map.
|
java.util.concurrent.ThreadPoolExecutor |
getPool()
Returns the thread pool being used to process incoming requests.
|
int |
getPort()
Returns a port number of a server socket.
|
void |
run()
Starts a serving cycle.
|
void |
setMetricAgentMap(java.util.Map<java.lang.String,MetricAgent> map)
Sets the metric key -> metric agent map.
|
void |
setPool(java.util.concurrent.ThreadPoolExecutor pool)
Sets the thread pool to be used to process incoming requests.
|
void |
setPort(int port)
Sets a port number for a server socket.
|
public AgentServer(java.util.concurrent.ThreadPoolExecutor pool)
pool - a thread pool executor objectpublic int getPort()
public void setPort(int port)
port - port number to listen atpublic void run()
SecurityManager doesn't prevent it, then
enqueues a new JabbixRequest task to the thread pool (see
getPool()) and starts a new iteration.
If the thread pool is built upon a blocking queue the next iteration may be blocked until some previous tasks are done.
run in interface java.lang.Runnablepublic java.util.Map<java.lang.String,MetricAgent> getMetricAgentMap()
public void setMetricAgentMap(java.util.Map<java.lang.String,MetricAgent> map)
map - the map of (metric key, metric agent) pairspublic MetricAgent getMetricAgent(java.lang.String key)
MetricAgent. However, for a projection of multiple metric
keys to a single MetricAgent component be also possible, the assumption
is made that the '.' (dot) symbol of a key is a component separator. For
a given multicomponent key the longest leftmost mapping is selected if
any.key - the name of a metricpublic void setPool(java.util.concurrent.ThreadPoolExecutor pool)
pool - a thread pool executor objectpublic java.util.concurrent.ThreadPoolExecutor getPool()