org.jppf.ui.monitoring.data
Class StatsHandler

java.lang.Object
  extended by org.jppf.ui.monitoring.data.StatsHandler
All Implemented Interfaces:
EventListener, ClientListener, StatsConstants

public final class StatsHandler
extends Object
implements StatsConstants, ClientListener

This class provides a convenient access to the statistics obtained from the JPPF server.

Author:
Laurent Cohen

Field Summary
 
Fields inherited from interface org.jppf.ui.monitoring.data.StatsConstants
ALL_FIELDS, CONNECTION_PROPS, EXECUTION_PROPS, NODE_EXECUTION_PROPS, QUEUE_PROPS, TRANSPORT_PROPS
 
Method Summary
 void addStatsHandlerListener(StatsHandlerListener listener)
          Register a StatsHandlerListener with this stats formatter.
 String changeSettings(String algorithm, Map params)
          Request the server settings.
 void connectionFailed(ClientEvent event)
          Notifiy this listener that a driver connection has failed.
 JMXDriverConnectionWrapper currentJmxConnection()
          Get the JMX connection for the current driver connection.
 void fireStatsHandlerEvent(StatsHandlerEvent.Type type)
          Notify all listeners of a change in this stats formatter.
 JPPFClientConnection getCurrentConnection()
          Get the current client connection for which statistics and charts are displayed.
 Map<Fields,Double> getDoubleValues(int position)
          Get the mapping of a data snapshot's fields, at a specified position, to their corresponding double values.
static StatsHandler getInstance()
          Get the singleton instance of this class.
 JPPFClient getJppfClient(ClientListener clientListener)
          JPPF client used to submit data udpate and administration requests.
 Map<Fields,Double> getLatestDoubleValues()
          Get the mapping of the most recent data snapshot's fields to their corresponding double values.
 JPPFStats getLatestStats()
          Get the latest data snapshot.
 Map<Fields,String> getLatestStringValues()
          Get the mapping of the most recent data snapshot's fields to their corresponding string values.
 long getRefreshInterval()
          Get the interval between refreshes from the server.
 int getRolloverPosition()
          Get the number of data snapshots kept in memory.
 OptionElement getServerListOption()
          Get the option containing the combobox with the list of driver connections.
 JPPFStats getStats(int position)
          Get the data snapshot at a specified position.
 int getStatsCount()
          Get the current number of data snapshots.
 Map<Fields,String> getStringValues(int position)
          Get the mapping of a data snapshot's fields, at a specified position, to their corresponding string values.
 int getTickCount()
          Get the number of data updates so far.
 void newConnection(ClientEvent event)
          Notifiy this listener that a new driver connection was created.
 void removeStatsHandlerListener(StatsHandlerListener listener)
          Unregister a StatsHandlerListener from this stats formatter.
 String requestShutdownRestart(Number shutdownDelay, Number restartDelay)
          Shutdown, and eventually restart, the server.
 void requestUpdate()
          Request an update from the current server conenction.
 void requestUpdate(JPPFClientConnectionImpl c)
          Request an update from the server.
 void setCurrentConnection(JPPFClientConnectionImpl connection)
          Set the current client connection for which statistics and charts are displayed.
 void setRefreshInterval(long refreshInterval)
          Set the interval between refreshes from the server.
 void setRolloverPosition(int rolloverPosition)
          Set the number of data snapshots kept in memory.
 void setServerListOption(OptionElement serverListOption)
          Set the option containing the combobox with the list of driver connections.
 void stopRefreshTimer()
          Stop the automatic refresh of the stats through a timer.
 void update(JPPFClientConnection connection, JPPFStats stats)
          Update the current statistics with new values obtained from the server.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static StatsHandler getInstance()
Get the singleton instance of this class.

Returns:
a StatsHandler instance.

stopRefreshTimer

public void stopRefreshTimer()
Stop the automatic refresh of the stats through a timer.


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 void requestUpdate()
Request an update from the current server conenction.


requestUpdate

public void requestUpdate(JPPFClientConnectionImpl c)
Request an update from the server.

Parameters:
c - the client connection to request the data from.

changeSettings

public String changeSettings(String algorithm,
                             Map params)
Request the server settings.

Parameters:
algorithm - - the name of the load-balancing algorithm to set on the server.
params - - the algorithm's parameters.
Returns:
the response message from the server.

requestShutdownRestart

public String requestShutdownRestart(Number shutdownDelay,
                                     Number restartDelay)
Shutdown, and eventually restart, the server.

Parameters:
shutdownDelay - - the delay before shutting down.
restartDelay - - the delay, starting after shutdown, before restarting. If it is < 0, no restart occurs.
Returns:
the response message from the server.

update

public void update(JPPFClientConnection connection,
                   JPPFStats stats)
Update the current statistics with new values obtained from the server.

Parameters:
connection - - the client connection from which the data is obtained.
stats - - the object holding the new statistics values.

addStatsHandlerListener

public void addStatsHandlerListener(StatsHandlerListener listener)
Register a StatsHandlerListener with this stats formatter.

Parameters:
listener - - the listener to register.

removeStatsHandlerListener

public void removeStatsHandlerListener(StatsHandlerListener listener)
Unregister a StatsHandlerListener from this stats formatter.

Parameters:
listener - - the listener to unregister.

fireStatsHandlerEvent

public void fireStatsHandlerEvent(StatsHandlerEvent.Type type)
Notify all listeners of a change in this stats formatter.

Parameters:
type - - the type of event to fire.

getRolloverPosition

public int getRolloverPosition()
Get the number of data snapshots kept in memory.

Returns:
the rollover position as an int value.

setRolloverPosition

public void setRolloverPosition(int rolloverPosition)
Set the number of data snapshots kept in memory. If the value if less than the former values, the corresponding, older, data snapshots will be deleted.

Parameters:
rolloverPosition - - the rollover position as an int value.

getStatsCount

public int getStatsCount()
Get the current number of data snapshots.

Returns:
the number of snapshots as an int.

getStats

public JPPFStats getStats(int position)
Get the data snapshot at a specified position.

Parameters:
position - - the position to get the data at.
Returns:
a JPPFStats instance.

getLatestStats

public JPPFStats getLatestStats()
Get the latest data snapshot.

Returns:
a JPPFStats instance.

getStringValues

public Map<Fields,String> getStringValues(int position)
Get the mapping of a data snapshot's fields, at a specified position, to their corresponding string values.

Parameters:
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()
Get the mapping of the most recent data snapshot's fields to their corresponding string values.

Returns:
a map of field names to their values represented as strings.

getDoubleValues

public Map<Fields,Double> getDoubleValues(int position)
Get the mapping of a data snapshot's fields, at a specified position, to their corresponding double values.

Parameters:
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()
Get the mapping of the most recent data snapshot's fields to their corresponding double values.

Returns:
a map of field names to their values represented as double values.

getTickCount

public int getTickCount()
Get the number of data updates so far.

Returns:
the nuber of updates as an int.

getCurrentConnection

public JPPFClientConnection getCurrentConnection()
Get the current client connection for which statistics and charts are displayed.

Returns:
a JPPFClientConnection instance.

setCurrentConnection

public void setCurrentConnection(JPPFClientConnectionImpl connection)
Set the current client connection for which statistics and charts are displayed.

Parameters:
connection - a JPPFClientConnection instance.

getJppfClient

public JPPFClient getJppfClient(ClientListener clientListener)
JPPF client used to submit data udpate and administration requests.

Parameters:
clientListener - a listener to register with the JPPF client.
Returns:
a JPPFClient instance.

newConnection

public void newConnection(ClientEvent event)
Notifiy this listener that a new driver connection was created.

Specified by:
newConnection in interface ClientListener
Parameters:
event - the event to notify this listener of.
See Also:
ClientListener.newConnection(org.jppf.client.event.ClientEvent)

connectionFailed

public void connectionFailed(ClientEvent event)
Notifiy this listener that a driver connection has failed.

Specified by:
connectionFailed in interface ClientListener
Parameters:
event - the event to notify this listener of.

getServerListOption

public OptionElement getServerListOption()
Get the option containing the combobox with the list of driver connections.

Returns:
an OptionElement instance.

setServerListOption

public void setServerListOption(OptionElement serverListOption)
Set the option containing the combobox with the list of driver connections.

Parameters:
serverListOption - an OptionElement instance.

currentJmxConnection

public JMXDriverConnectionWrapper currentJmxConnection()
Get the JMX connection for the current driver connection.

Returns:
a JMXDriverConnectionWrapper instance.


Copyright © 2005-2010 JPPF Team.