Package org.jppf.ui.monitoring.data
Class BaseStatsHandler
java.lang.Object
org.jppf.ui.monitoring.data.BaseStatsHandler
- Direct Known Subclasses:
StatsHandler
This class provides a convenient access to the statistics obtained from the JPPF server.
- Author:
- Laurent Cohen
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final Map<String,ConnectionDataHolder> Contains all the data and its converted values received from the server.protected longInterval, in milliseconds, between refreshes from the server.protected final intNumber of data snapshots kept in memory. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddStatsHandlerListener(StatsHandlerListener listener) Register aStatsHandlerListenerwith this stats formatter.voidNotify all listeners of a change in this stats formatter.formatLatestValue(Locale locale, org.jppf.client.monitoring.topology.TopologyDriver driver, Fields field) Format the value of the specified field according tot he specified locale.getDoubleValues(org.jppf.client.monitoring.topology.TopologyDriver driver, int position) Get the mapping of a data snapshot's fields, at a specified position, to their corresponding double values.protected StatsFormattergetFormatter(Locale locale) Get, and create if needed, the formatter for the specified locale.getLatestDoubleValues(org.jppf.client.monitoring.topology.TopologyDriver driver) Get the mapping of the most recent data snapshot's fields to their corresponding double values.getLatestStringValues(Locale locale, org.jppf.client.monitoring.topology.TopologyDriver driver) Get the mapping of the most recent data snapshot's fields to their corresponding string values.longGet the interval between refreshes from the server.intGet the number of data snapshots kept in memory.intgetStatsCount(org.jppf.client.monitoring.topology.TopologyDriver driver) Get the current number of data snapshots for the specified driver.getStringValues(Locale locale, org.jppf.client.monitoring.topology.TopologyDriver driver, int position) Get the mapping of a data snapshot's fields, at a specified position, to their corresponding string values.intGet the number of data updates so far.voidUnregister aStatsHandlerListenerfrom this stats formatter.org.jppf.utils.stats.JPPFStatisticsrequestUpdate(org.jppf.client.monitoring.topology.TopologyDriver driver) Request an update from the server.voidsetRefreshInterval(long refreshInterval) Set the interval between refreshes from the server.voidupdate(org.jppf.client.monitoring.topology.TopologyDriver driver, org.jppf.utils.stats.JPPFStatistics stats) Update the current statistics with new values obtained from the server.
-
Field Details
-
refreshInterval
protected long refreshIntervalInterval, in milliseconds, between refreshes from the server. -
rolloverPosition
protected final int rolloverPositionNumber of data snapshots kept in memory. -
dataHolderMap
Contains all the data and its converted values received from the server.
-
-
Constructor Details
-
BaseStatsHandler
public BaseStatsHandler()Initialize this statistics handler.
-
-
Method Details
-
getRefreshInterval
public long getRefreshInterval()Get the interval between refreshes from the server.- Returns:
- the interval in milliseconds.
-
setRefreshInterval
public void setRefreshInterval(long refreshInterval) Set the interval between refreshes from the server.- Parameters:
refreshInterval- the interval in milliseconds.
-
requestUpdate
public org.jppf.utils.stats.JPPFStatistics requestUpdate(org.jppf.client.monitoring.topology.TopologyDriver driver) Request an update from the server.- Parameters:
driver- represents the client connection to request the data from.- Returns:
- a
JPPFStatisticsobject.
-
update
public void update(org.jppf.client.monitoring.topology.TopologyDriver driver, org.jppf.utils.stats.JPPFStatistics stats) Update the current statistics with new values obtained from the server.- Parameters:
driver- represents the client connection from which the data is obtained.stats- the object holding the new statistics values.
-
getRolloverPosition
public int getRolloverPosition()Get the number of data snapshots kept in memory.- Returns:
- the rollover position as an int value.
-
getStatsCount
public int getStatsCount(org.jppf.client.monitoring.topology.TopologyDriver driver) Get the current number of data snapshots for the specified driver.- Parameters:
driver- the driver for which to get the information.- Returns:
- the number of snapshots as an int.
-
getStringValues
public Map<Fields,String> getStringValues(Locale locale, org.jppf.client.monitoring.topology.TopologyDriver driver, int position) Get the mapping of a data snapshot's fields, at a specified position, to their corresponding string values.- Parameters:
locale- the locale to use for values formatting.driver- the driver for which to get the information.position- the position to get the data at.- Returns:
- a map of field names to their values represented as strings.
-
getLatestStringValues
public Map<Fields,String> getLatestStringValues(Locale locale, org.jppf.client.monitoring.topology.TopologyDriver driver) Get the mapping of the most recent data snapshot's fields to their corresponding string values.- Parameters:
locale- the locale to use for values formatting.driver- the driver for which to get the information.- Returns:
- a map of field names to their values represented as strings.
-
formatLatestValue
public String formatLatestValue(Locale locale, org.jppf.client.monitoring.topology.TopologyDriver driver, Fields field) Format the value of the specified field according tot he specified locale.- Parameters:
locale- the locale in which to format.driver- the driver to add.field- the field whose value is to be formatted.- Returns:
- value formatted accoridng to the locale.
-
getDoubleValues
public Map<Fields,Double> getDoubleValues(org.jppf.client.monitoring.topology.TopologyDriver driver, int position) Get the mapping of a data snapshot's fields, at a specified position, to their corresponding double values.- Parameters:
driver- the driver for which to get the information.position- the position to get the data at.- Returns:
- a map of field names to their values represented as double values.
-
getLatestDoubleValues
public Map<Fields,Double> getLatestDoubleValues(org.jppf.client.monitoring.topology.TopologyDriver driver) Get the mapping of the most recent data snapshot's fields to their corresponding double values.- Parameters:
driver- the driver for which to get the information.- Returns:
- a map of field names to their values represented as double values.
-
addStatsHandlerListener
Register aStatsHandlerListenerwith this stats formatter.- Parameters:
listener- the listener to register.
-
removeStatsHandlerListener
Unregister aStatsHandlerListenerfrom this stats formatter.- Parameters:
listener- the listener to unregister.
-
fireStatsHandlerEvent
Notify all listeners of a change in this stats formatter.- Parameters:
type- the type of event to fire.
-
getTickCount
public int getTickCount()Get the number of data updates so far.- Returns:
- the number of updates as an int.
-
getFormatter
Get, and create if needed, the formatter for the specified locale.- Parameters:
locale- the locale to use for values formatting.- Returns:
- a
StatsFormatterinstance.
-
getShowIPHandler
- Returns:
- the object that handles the toggle for showing host names vs. IP addresses.
-