javadoc, imports

(shendaras)
This commit is contained in:
shendaras
2004-04-12 08:14:07 +00:00
committed by zzz
parent ceb9a935de
commit e3354a805e
15 changed files with 529 additions and 120 deletions

View File

@@ -89,7 +89,7 @@ public class ClientConfig {
/** /**
* Create a dummy client config to be fetched from the specified location * Create a dummy client config to be fetched from the specified location
* * @param location the location to fetch from
*/ */
public ClientConfig(String location) { public ClientConfig(String location) {
this(null, null, location, -1, -1, -1, -1, 0, null, null); this(null, null, location, -1, -1, -1, -1, 0, null, null);

View File

@@ -103,7 +103,14 @@ public class PeerData {
public long getSessionStart() { public long getSessionStart() {
return _sessionStart; return _sessionStart;
} }
public void setSessionStart(long when) { _sessionStart = when; }
/**
* Sets when the test began
* @param when the time the session began
*/
public void setSessionStart(long when) {
_sessionStart = when;
}
/** /**
* how many pings have we sent for this test? * how many pings have we sent for this test?

View File

@@ -2,8 +2,8 @@ package net.i2p.heartbeat;
import java.io.File; import java.io.File;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.OutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols; import java.text.DecimalFormatSymbols;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
@@ -48,6 +48,13 @@ public class PeerDataWriter {
return true; return true;
} }
/**
* persists the peer state to the output stream
* @param data the peer data to persist
* @param out where to persist the data
* @return true if it was persisted correctly [always (as implemented)], false on error
* @throws IOException
*/
public boolean persist(PeerData data, OutputStream out) throws IOException { public boolean persist(PeerData data, OutputStream out) throws IOException {
String header = getHeader(data); String header = getHeader(data);

View File

@@ -1,15 +1,13 @@
package net.i2p.heartbeat.gui; package net.i2p.heartbeat.gui;
import javax.swing.JPanel;
import javax.swing.JLabel;
import javax.swing.JTabbedPane;
import javax.swing.JScrollPane;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Color; import java.awt.Color;
import java.awt.Dimension;
import java.util.List;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTabbedPane;
import net.i2p.util.Log; import net.i2p.util.Log;
@@ -28,16 +26,29 @@ class HeartbeatControlPane extends JPanel {
private Color _background = WHITE; private Color _background = WHITE;
private Color _foreground = BLACK; private Color _foreground = BLACK;
/**
* Constructs a control panel onto the gui
* @param gui the gui the panel is associated with
*/
public HeartbeatControlPane(HeartbeatMonitorGUI gui) { public HeartbeatControlPane(HeartbeatMonitorGUI gui) {
_gui = gui; _gui = gui;
initializeComponents(); initializeComponents();
} }
/**
* Adds a test to the panel
* @param config the configuration for the test
*/
public void addTest(PeerPlotConfig config) { public void addTest(PeerPlotConfig config) {
_configPane.addTab(config.getTitle(), null, new JScrollPane(new PeerPlotConfigPane(config, this)), config.getSummary()); _configPane.addTab(config.getTitle(), null, new JScrollPane(new PeerPlotConfigPane(config, this)), config.getSummary());
_configPane.setBackgroundAt(_configPane.getTabCount()-1, _background); _configPane.setBackgroundAt(_configPane.getTabCount()-1, _background);
_configPane.setForegroundAt(_configPane.getTabCount()-1, _foreground); _configPane.setForegroundAt(_configPane.getTabCount()-1, _foreground);
} }
/**
* Removes a test from the panel
* @param config the configuration for the test
*/
public void removeTest(PeerPlotConfig config) { public void removeTest(PeerPlotConfig config) {
_gui.getMonitor().getState().removeTest(config); _gui.getMonitor().getState().removeTest(config);
int index = _configPane.indexOfTab(config.getTitle()); int index = _configPane.indexOfTab(config.getTitle());
@@ -45,6 +56,9 @@ class HeartbeatControlPane extends JPanel {
_configPane.removeTabAt(index); _configPane.removeTabAt(index);
} }
/**
* Callback: when tests have changed
*/
public void testsUpdated() { public void testsUpdated() {
List knownNames = new ArrayList(8); List knownNames = new ArrayList(8);
for (int i = 0; i < _gui.getMonitor().getState().getTestCount(); i++) { for (int i = 0; i < _gui.getMonitor().getState().getTestCount(); i++) {

View File

@@ -3,17 +3,39 @@ package net.i2p.heartbeat.gui;
import net.i2p.util.I2PThread; import net.i2p.util.I2PThread;
import net.i2p.util.Log; import net.i2p.util.Log;
/**
* The HeartbeatMonitor, complete with main()! Act now, and it's only 5 easy
* payments of $19.95 (plus shipping and handling)! You heard me, only _5_
* easy payments of $19.95 (plus shipping and handling)!
*
* (fine print: something about some states in the US requiring the addition
* of sales tax... or something)
*
* (finer print: Satan owns you. Deal with it.)
*/
public class HeartbeatMonitor implements PeerPlotStateFetcher.FetchStateReceptor { public class HeartbeatMonitor implements PeerPlotStateFetcher.FetchStateReceptor {
private final static Log _log = new Log(HeartbeatMonitor.class); private final static Log _log = new Log(HeartbeatMonitor.class);
private HeartbeatMonitorState _state; private HeartbeatMonitorState _state;
private HeartbeatMonitorGUI _gui; private HeartbeatMonitorGUI _gui;
/**
* Delegating constructor.
* @see HeartbeatMonitor#HeartbeatMonitor(String)
*/
public HeartbeatMonitor() { this(null); } public HeartbeatMonitor() { this(null); }
/**
* Creates a HeartbeatMonitor . . .
* @param configFilename the configuration file to read from
*/
public HeartbeatMonitor(String configFilename) { public HeartbeatMonitor(String configFilename) {
_state = new HeartbeatMonitorState(configFilename); _state = new HeartbeatMonitorState(configFilename);
_gui = new HeartbeatMonitorGUI(this); _gui = new HeartbeatMonitorGUI(this);
} }
/**
* Starts the game rollin'
*/
public void runMonitor() { public void runMonitor() {
loadConfig(); loadConfig();
I2PThread t = new I2PThread(new HeartbeatMonitorRunner(this)); I2PThread t = new I2PThread(new HeartbeatMonitorRunner(this));
@@ -23,8 +45,13 @@ public class HeartbeatMonitor implements PeerPlotStateFetcher.FetchStateReceptor
_log.debug("Monitor started"); _log.debug("Monitor started");
} }
/** give us all the data/config available */ /**
HeartbeatMonitorState getState() { return _state; } * give us all the data/config available
* @return the current state (data/config)
*/
HeartbeatMonitorState getState() {
return _state;
}
/** for all of the peer tests being monitored, refetch the data and rerender */ /** for all of the peer tests being monitored, refetch the data and rerender */
void refetchData() { void refetchData() {
@@ -40,12 +67,19 @@ public class HeartbeatMonitor implements PeerPlotStateFetcher.FetchStateReceptor
//} //}
} }
/**
* Loads config data
* @param location the name of the location to load data from
*/
public void load(String location) { public void load(String location) {
PeerPlotConfig cfg = new PeerPlotConfig(location); PeerPlotConfig cfg = new PeerPlotConfig(location);
PeerPlotState state = new PeerPlotState(cfg); PeerPlotState state = new PeerPlotState(cfg);
PeerPlotStateFetcher.fetchPeerPlotState(this, state); PeerPlotStateFetcher.fetchPeerPlotState(this, state);
} }
/* (non-Javadoc)
* @see PeerPlotStateFetcher.FetchStateReceptor#peerPlotStateFetched
*/
public synchronized void peerPlotStateFetched(PeerPlotState state) { public synchronized void peerPlotStateFetched(PeerPlotState state) {
_state.addTest(state); _state.addTest(state);
_gui.stateUpdated(); _gui.stateUpdated();
@@ -54,6 +88,10 @@ public class HeartbeatMonitor implements PeerPlotStateFetcher.FetchStateReceptor
/** store the config defining what peer tests we are monitoring (and how to render) */ /** store the config defining what peer tests we are monitoring (and how to render) */
void storeConfig() {} void storeConfig() {}
/**
* And now, the main function, the one you've all been waiting for! . . .
* @param args da args. Should take 1, which is the location to load config data from
*/
public static void main(String args[]) { public static void main(String args[]) {
Thread.currentThread().setName("HeartbeatMonitor.main"); Thread.currentThread().setName("HeartbeatMonitor.main");
if (args.length == 1) if (args.length == 1)

View File

@@ -1,22 +1,27 @@
package net.i2p.heartbeat.gui; package net.i2p.heartbeat.gui;
import javax.swing.JPanel;
import javax.swing.JLabel;
import javax.swing.JComboBox;
import javax.swing.JTextField;
import javax.swing.JButton;
import javax.swing.JFileChooser;
import javax.swing.DefaultComboBoxModel;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent; import java.awt.event.ItemEvent;
import java.awt.event.ItemListener; import java.awt.event.ItemListener;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFileChooser;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
class HeartbeatMonitorCommandBar extends JPanel { class HeartbeatMonitorCommandBar extends JPanel {
private HeartbeatMonitorGUI _gui; private HeartbeatMonitorGUI _gui;
private JComboBox _refreshRate; private JComboBox _refreshRate;
private JTextField _location; private JTextField _location;
/**
* Constructs a command bar onto the gui
* @param gui the gui the command bar is associated with
*/
public HeartbeatMonitorCommandBar(HeartbeatMonitorGUI gui) { public HeartbeatMonitorCommandBar(HeartbeatMonitorGUI gui) {
_gui = gui; _gui = gui;
initializeComponents(); initializeComponents();

View File

@@ -1,15 +1,15 @@
package net.i2p.heartbeat.gui; package net.i2p.heartbeat.gui;
import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.JMenuBar;
import javax.swing.JScrollPane;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Color; import java.awt.Color;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JScrollPane;
class HeartbeatMonitorGUI extends JFrame { class HeartbeatMonitorGUI extends JFrame {
private HeartbeatMonitor _monitor; private HeartbeatMonitor _monitor;
@@ -18,6 +18,10 @@ class HeartbeatMonitorGUI extends JFrame {
private final static Color WHITE = new Color(255, 255, 255); private final static Color WHITE = new Color(255, 255, 255);
private Color _background = WHITE; private Color _background = WHITE;
/**
* Creates the GUI for all youz who be too shoopid for text based shitz
* @param monitor the monitor the gui operates over
*/
public HeartbeatMonitorGUI(HeartbeatMonitor monitor) { public HeartbeatMonitorGUI(HeartbeatMonitor monitor) {
super("Heartbeat Monitor"); super("Heartbeat Monitor");
_monitor = monitor; _monitor = monitor;
@@ -49,6 +53,9 @@ class HeartbeatMonitorGUI extends JFrame {
initializeMenus(); initializeMenus();
} }
/**
* Callback: when the state of the world changes . . .
*/
public void stateUpdated() { public void stateUpdated() {
_controlPane.testsUpdated(); _controlPane.testsUpdated();
_plotPane.stateUpdated(); _plotPane.stateUpdated();

View File

@@ -6,16 +6,22 @@ import net.i2p.util.Log;
* Periodically fire off necessary events (instructing the heartbeat monitor when * Periodically fire off necessary events (instructing the heartbeat monitor when
* to refetch the data, etc). This is the only active thread in the heartbeat * to refetch the data, etc). This is the only active thread in the heartbeat
* monitor (outside the swing/jvm threads) * monitor (outside the swing/jvm threads)
*
*/ */
class HeartbeatMonitorRunner implements Runnable { class HeartbeatMonitorRunner implements Runnable {
private final static Log _log = new Log(HeartbeatMonitorRunner.class); private final static Log _log = new Log(HeartbeatMonitorRunner.class);
private HeartbeatMonitor _monitor; private HeartbeatMonitor _monitor;
/**
* Creates the thread . . .
* @param monitor the monitor the thread runs over
*/
public HeartbeatMonitorRunner(HeartbeatMonitor monitor) { public HeartbeatMonitorRunner(HeartbeatMonitor monitor) {
_monitor = monitor; _monitor = monitor;
} }
/* (non-Javadoc)
* @see java.lang.Runnable#run()
*/
public void run() { public void run() {
while (!_monitor.getState().getWasKilled()) { while (!_monitor.getState().getWasKilled()) {
_monitor.refetchData(); _monitor.refetchData();

View File

@@ -1,13 +1,12 @@
package net.i2p.heartbeat.gui; package net.i2p.heartbeat.gui;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List;
import java.util.Collections; import java.util.Collections;
import java.util.List;
/** /**
* manage the current state of the GUI - all data points, as well as any * manage the current state of the GUI - all data points, as well as any
* rendering or configuration options. * rendering or configuration options.
*
*/ */
class HeartbeatMonitorState { class HeartbeatMonitorState {
private String _configFile; private String _configFile;
@@ -21,7 +20,16 @@ class HeartbeatMonitorState {
/** where do we load/store config info from? */ /** where do we load/store config info from? */
private final static String DEFAULT_CONFIG_FILE = "heartbeatMonitor.config"; private final static String DEFAULT_CONFIG_FILE = "heartbeatMonitor.config";
/**
* A delegating constructor.
* @see HeartbeatMonitorState#HeartbeatMonitorState(String)
*/
public HeartbeatMonitorState() { this(DEFAULT_CONFIG_FILE); } public HeartbeatMonitorState() { this(DEFAULT_CONFIG_FILE); }
/**
* Constructs the state, loading from the specified location
* @param configFile the name of the file to load info from
*/
public HeartbeatMonitorState(String configFile) { public HeartbeatMonitorState(String configFile) {
_peerPlotState = Collections.synchronizedList(new ArrayList()); _peerPlotState = Collections.synchronizedList(new ArrayList());
_refreshRateMs = DEFAULT_REFRESH_RATE; _refreshRateMs = DEFAULT_REFRESH_RATE;
@@ -30,15 +38,37 @@ class HeartbeatMonitorState {
_currentPeerPlotConfig = 0; _currentPeerPlotConfig = 0;
} }
/** how many tests are we monitoring? */ /**
* how many tests are we monitoring?
* @return the number of tests
*/
public int getTestCount() { return _peerPlotState.size(); } public int getTestCount() { return _peerPlotState.size(); }
/**
* Retrieves the current info of a test for a certain peer . . .
* @param peer a number associated with a certain peer
* @return the test data
*/
public PeerPlotState getTest(int peer) { return (PeerPlotState)_peerPlotState.get(peer); } public PeerPlotState getTest(int peer) { return (PeerPlotState)_peerPlotState.get(peer); }
/**
* Adds a test . . .
* @param peerState the test (by state) to add . . .
*/
public void addTest(PeerPlotState peerState) { public void addTest(PeerPlotState peerState) {
if (!_peerPlotState.contains(peerState)) if (!_peerPlotState.contains(peerState))
_peerPlotState.add(peerState); _peerPlotState.add(peerState);
} }
/**
* Removes a test . . .
* @param peerState the test (by state) to remove . . .
*/
public void removeTest(PeerPlotState peerState) { _peerPlotState.remove(peerState); } public void removeTest(PeerPlotState peerState) { _peerPlotState.remove(peerState); }
/**
* Removes a test . . .
* @param peerConfig the test (by config) to remove . . .
*/
public void removeTest(PeerPlotConfig peerConfig) { public void removeTest(PeerPlotConfig peerConfig) {
for (int i = 0; i < getTestCount(); i++) { for (int i = 0; i < getTestCount(); i++) {
PeerPlotState state = getTest(i); PeerPlotState state = getTest(i);
@@ -49,19 +79,51 @@ class HeartbeatMonitorState {
} }
} }
/** which of the tests are we currently editing/viewing? */ /**
* which of the tests are we currently editing/viewing?
* @return the number associated with the test
*/
public int getPeerPlotConfig() { return _currentPeerPlotConfig; } public int getPeerPlotConfig() { return _currentPeerPlotConfig; }
/**
* Sets the test we are currently editting/viewing
* @param whichTest the number associated with the test
*/
public void setPeerPlotConfig(int whichTest) { _currentPeerPlotConfig = whichTest; } public void setPeerPlotConfig(int whichTest) { _currentPeerPlotConfig = whichTest; }
/** how frequently should we update the data? */ /**
* how frequently should we update the data?
* @return the current frequency (in milliseconds)
*/
public int getRefreshRateMs() { return _refreshRateMs; } public int getRefreshRateMs() { return _refreshRateMs; }
/**
* Sets how frequently we should update data
* @param ms the frequency (in milliseconds)
*/
public void setRefreshRateMs(int ms) { _refreshRateMs = ms; } public void setRefreshRateMs(int ms) { _refreshRateMs = ms; }
/** where is our config stored? */ /**
* where is our config stored?
* @return the name of the config file
*/
public String getConfigFile() { return _configFile; } public String getConfigFile() { return _configFile; }
/**
* Sets where our config is stored
* @param filename the name of the config file
*/
public void setConfigFile(String filename) { _configFile = filename; } public void setConfigFile(String filename) { _configFile = filename; }
/** have we been shut down? */ /**
* have we been shut down?
* @return true if we have, false otherwise
*/
public boolean getWasKilled() { return _killed; } public boolean getWasKilled() { return _killed; }
/**
* Sets if we have been shutdown or not
* @param killed true if we've been shutdown, false otherwise
*/
public void setWasKilled(boolean killed) { _killed = killed; } public void setWasKilled(boolean killed) { _killed = killed; }
} }

View File

@@ -1,31 +1,35 @@
package net.i2p.heartbeat.gui; package net.i2p.heartbeat.gui;
import java.awt.Color;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.JTextArea; import javax.swing.JTextArea;
import javax.swing.JScrollPane;
import java.awt.Color;
import java.awt.Dimension;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import net.i2p.heartbeat.PeerDataWriter; import net.i2p.heartbeat.PeerDataWriter;
import net.i2p.util.Log; import net.i2p.util.Log;
/** /**
* Render the graph and legend * Render the graph and legend
*
*/ */
class HeartbeatPlotPane extends JPanel { class HeartbeatPlotPane extends JPanel {
private final static Log _log = new Log(HeartbeatPlotPane.class); private final static Log _log = new Log(HeartbeatPlotPane.class);
private HeartbeatMonitorGUI _gui; private HeartbeatMonitorGUI _gui;
private JTextArea _text; private JTextArea _text;
/**
* Constructs the plot pane
* @param gui the gui the pane is attached to
*/
public HeartbeatPlotPane(HeartbeatMonitorGUI gui) { public HeartbeatPlotPane(HeartbeatMonitorGUI gui) {
_gui = gui; _gui = gui;
initializeComponents(); initializeComponents();
} }
/**
* Callback: when things change . . .
*/
public void stateUpdated() { public void stateUpdated() {
StringBuffer buf = new StringBuffer(32*1024); StringBuffer buf = new StringBuffer(32*1024);
PeerDataWriter writer = new PeerDataWriter(); PeerDataWriter writer = new PeerDataWriter();
@@ -46,14 +50,14 @@ class HeartbeatPlotPane extends JPanel {
private void initializeComponents() { private void initializeComponents() {
setBackground(new Color(255, 255, 255)); setBackground(new Color(255, 255, 255));
//Dimension size = new Dimension(800, 600); // Dimension size = new Dimension(800, 600);
_text = new JTextArea("",30,80); // 16, 60); _text = new JTextArea("",30,80); // 16, 60);
_text.setAutoscrolls(true); _text.setAutoscrolls(true);
_text.setEditable(false); _text.setEditable(false);
// _text.setLineWrap(true); // _text.setLineWrap(true);
// add(new JScrollPane(_text)); // add(new JScrollPane(_text));
add(_text); add(_text);
//add(new JScrollPane(_text, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS)); // add(new JScrollPane(_text, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS));
//setPreferredSize(size); // setPreferredSize(size);
} }
} }

View File

@@ -1,22 +1,20 @@
package net.i2p.heartbeat.gui; package net.i2p.heartbeat.gui;
import java.util.List; import java.awt.Color;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Set;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import java.util.TreeMap; import java.util.TreeMap;
import java.awt.Color;
import net.i2p.data.Destination; import net.i2p.data.Destination;
import net.i2p.heartbeat.ClientConfig; import net.i2p.heartbeat.ClientConfig;
/** /**
* Configure how we want to render a particular clientConfig in the GUI * Configure how we want to render a particular clientConfig in the GUI
*
*/ */
class PeerPlotConfig { class PeerPlotConfig {
/** where can we find the current state/data (either as a filename or a URL)? */ /** where can we find the current state/data (either as a filename or a URL)? */
@@ -30,10 +28,21 @@ class PeerPlotConfig {
private Set _listeners; private Set _listeners;
private boolean _disabled; private boolean _disabled;
/**
* Delegating constructor . . .
* @param location the name of the file/URL to get the data from
*/
public PeerPlotConfig(String location) { public PeerPlotConfig(String location) {
this(location, null, null, null); this(location, null, null, null);
} }
/**
* Constructs a config =)
* @param location the location of the file/URL to get the data from
* @param config the client's configuration
* @param currentSeriesConfig the series config
* @param averageSeriesConfigs the average
*/
public PeerPlotConfig(String location, ClientConfig config, PlotSeriesConfig currentSeriesConfig, List averageSeriesConfigs) { public PeerPlotConfig(String location, ClientConfig config, PlotSeriesConfig currentSeriesConfig, List averageSeriesConfigs) {
_location = location; _location = location;
if (config == null) if (config == null)
@@ -53,6 +62,9 @@ class PeerPlotConfig {
_disabled = false; _disabled = false;
} }
/**
* 'Rebuilds' the average series stuff from the client configuration
*/
public void rebuildAverageSeriesConfigs() { public void rebuildAverageSeriesConfigs() {
int periods[] = _config.getAveragePeriods(); int periods[] = _config.getAveragePeriods();
if (periods == null) { if (periods == null) {
@@ -66,6 +78,10 @@ class PeerPlotConfig {
} }
} }
/**
* Adds an average period
* @param minutes the number of minutes averaged over
*/
public void addAverage(int minutes) { public void addAverage(int minutes) {
_config.addAveragePeriod(minutes); _config.addAveragePeriod(minutes);
@@ -86,33 +102,66 @@ class PeerPlotConfig {
/** /**
* Where is the current state data supposed to be found? This must either be a * Where is the current state data supposed to be found? This must either be a
* local file path or a URL * local file path or a URL
* * @return the current location
*/ */
public String getLocation() { return _location; } public String getLocation() { return _location; }
/**
* The location the current state data is supposed to be found. This must either be
* a local file path or a URL
* @param location the location
*/
public void setLocation(String location) { public void setLocation(String location) {
_location = location; _location = location;
fireUpdate(); fireUpdate();
} }
/** What are we configuring? */ /**
* What are we configuring?
* @return the client configuration
*/
public ClientConfig getClientConfig() { return _config; } public ClientConfig getClientConfig() { return _config; }
/**
* Sets what we are currently configuring
* @param config the new config
*/
public void setClientConfig(ClientConfig config) { public void setClientConfig(ClientConfig config) {
_config = config; _config = config;
fireUpdate(); fireUpdate();
} }
/** How do we want to render the current data set? */ /**
* How do we want to render the current data set?
* @return the way we currently render the data
*/
public PlotSeriesConfig getCurrentSeriesConfig() { return _currentSeriesConfig; } public PlotSeriesConfig getCurrentSeriesConfig() { return _currentSeriesConfig; }
/**
* Sets how we want to render the current data set.
* @param config the new config
*/
public void setCurrentSeriesConfig(PlotSeriesConfig config) { public void setCurrentSeriesConfig(PlotSeriesConfig config) {
_currentSeriesConfig = config; _currentSeriesConfig = config;
fireUpdate(); fireUpdate();
} }
/** How do we want to render the averages? */ /**
* How do we want to render the averages?
* @return the way we currently render the averages
*/
public List getAverageSeriesConfigs() { return _averageSeriesConfigs; } public List getAverageSeriesConfigs() { return _averageSeriesConfigs; }
/**
* Sets how we want to render the averages
* @param configs the new configs
*/
public void setAverageSeriesConfigs(List configs) { _averageSeriesConfigs = configs; } public void setAverageSeriesConfigs(List configs) { _averageSeriesConfigs = configs; }
/** four char description of the peer */ /**
* four char description of the peer
* @return the name
*/
public String getPeerName() { public String getPeerName() {
Destination peer = getClientConfig().getPeer(); Destination peer = getClientConfig().getPeer();
if (peer == null) if (peer == null)
@@ -121,7 +170,18 @@ class PeerPlotConfig {
return peer.calculateHash().toBase64().substring(0, 4); return peer.calculateHash().toBase64().substring(0, 4);
} }
public String getTitle() { return getPeerName() + '.' + getSize() + '.' + getClientConfig().getSendFrequency(); } /**
* title: name.packetsize.sendfrequency
* @return the title
*/
public String getTitle() {
return getPeerName() + '.' + getSize() + '.' + getClientConfig().getSendFrequency();
}
/**
* summary. includes:name, size, sendfrequency, and # of hops
* @return the summary
*/
public String getSummary() { public String getSummary() {
return "Send peer " + getPeerName() + ' ' + getSize() + " every " + return "Send peer " + getPeerName() + ' ' + getSize() + " every " +
getClientConfig().getSendFrequency() + " seconds through " + getClientConfig().getSendFrequency() + " seconds through " +
@@ -136,8 +196,16 @@ class PeerPlotConfig {
return bytes/1024 + "kb"; return bytes/1024 + "kb";
} }
/** we've got someone who wants to be notified of changes to the plot config */ /**
* we've got someone who wants to be notified of changes to the plot config
* @param lsnr the listener to be added
*/
public void addListener(UpdateListener lsnr) { _listeners.add(lsnr); } public void addListener(UpdateListener lsnr) { _listeners.add(lsnr); }
/**
* remove a listener
* @param lsnr the listener to remove
*/
public void removeListener(UpdateListener lsnr) { _listeners.remove(lsnr); } public void removeListener(UpdateListener lsnr) { _listeners.remove(lsnr); }
void fireUpdate() { void fireUpdate() {
@@ -147,7 +215,16 @@ class PeerPlotConfig {
} }
} }
/**
* Disables notification of events listeners
* @see PeerPlotConfig#fireUpdate()
*/
public void disableEvents() { _disabled = true; } public void disableEvents() { _disabled = true; }
/**
* Enables notification of events listeners
* @see PeerPlotConfig#fireUpdate()
*/
public void enableEvents() { _disabled = false; } public void enableEvents() { _disabled = false; }
/** /**
@@ -160,9 +237,25 @@ class PeerPlotConfig {
private boolean _plotLostMessages; private boolean _plotLostMessages;
private Color _plotLineColor; private Color _plotLineColor;
/**
* Delegating constructor . . .
* @param period the period for the config
* (0 for current, otherwise # of milliseconds being averaged over)
*/
public PlotSeriesConfig(long period) { public PlotSeriesConfig(long period) {
this(period, false, false, false, null); this(period, false, false, false, null);
} }
/**
* Creates a config for the rendering of a particular dataset)
* @param period the period for the config
* (0 for current, otherwise # of milliseconds being averaged over)
* @param plotSend do we plot send times?
* @param plotReceive do we plot receive times?
* @param plotLost do we plot lost packets?
* @param plotColor in what color?
*/
public PlotSeriesConfig(long period, boolean plotSend, boolean plotReceive, boolean plotLost, Color plotColor) { public PlotSeriesConfig(long period, boolean plotSend, boolean plotReceive, boolean plotLost, Color plotColor) {
_period = period; _period = period;
_plotSendTime = plotSend; _plotSendTime = plotSend;
@@ -171,45 +264,95 @@ class PeerPlotConfig {
_plotLineColor = plotColor; _plotLineColor = plotColor;
} }
/**
* Retrieves the plot config this plot series config is a part of
* @return the plot config
*/
public PeerPlotConfig getPlotConfig() { return PeerPlotConfig.this; } public PeerPlotConfig getPlotConfig() { return PeerPlotConfig.this; }
/** /**
* What period is this series config describing? * What period is this series config describing?
*
* @return 0 for current, otherwise # milliseconds that are being averaged over * @return 0 for current, otherwise # milliseconds that are being averaged over
*/ */
public long getPeriod() { return _period; } public long getPeriod() { return _period; }
/**
* Sets the period this series config is describing
* @param period the period
* (0 for current, otherwise # milliseconds that are being averaged over)
*/
public void setPeriod(long period) { public void setPeriod(long period) {
_period = period; _period = period;
fireUpdate(); fireUpdate();
} }
/** Should we render the time to send (ping to peer)? */
/**
* Should we render the time to send (ping to peer)?
* @return true or false . . .
*/
public boolean getPlotSendTime() { return _plotSendTime; } public boolean getPlotSendTime() { return _plotSendTime; }
/**
* Sets whether we render the time to send (ping to peer) or not
* @param shouldPlot true or false
*/
public void setPlotSendTime(boolean shouldPlot) { public void setPlotSendTime(boolean shouldPlot) {
_plotSendTime = shouldPlot; _plotSendTime = shouldPlot;
fireUpdate(); fireUpdate();
} }
/** Should we render the time to receive (peer pong to us)? */
/**
* Should we render the time to receive (peer pong to us)?
* @return true or false . . .
*/
public boolean getPlotReceiveTime() { return _plotReceiveTime; } public boolean getPlotReceiveTime() { return _plotReceiveTime; }
/**
* Sets whether we render the time to receive (peer pong to us)
* @param shouldPlot true or false
*/
public void setPlotReceiveTime(boolean shouldPlot) { public void setPlotReceiveTime(boolean shouldPlot) {
_plotReceiveTime = shouldPlot; _plotReceiveTime = shouldPlot;
fireUpdate(); fireUpdate();
} }
/** Should we render the number of messages lost (ping sent, no pong received in time)? */ /**
* Should we render the number of messages lost (ping sent, no pong received in time)?
* @return true or false . . .
*/
public boolean getPlotLostMessages() { return _plotLostMessages; } public boolean getPlotLostMessages() { return _plotLostMessages; }
/**
* Sets whether we render the number of messages lost (ping sent, no pong received in time) or not
* @param shouldPlot true or false
*/
public void setPlotLostMessages(boolean shouldPlot) { public void setPlotLostMessages(boolean shouldPlot) {
_plotLostMessages = shouldPlot; _plotLostMessages = shouldPlot;
fireUpdate(); fireUpdate();
} }
/** What color should we plot the data with? */ /**
* What color should we plot the data with?
* @return the color
*/
public Color getPlotLineColor() { return _plotLineColor; } public Color getPlotLineColor() { return _plotLineColor; }
/**
* Sets the color we should plot the data with
* @param color the color to use
*/
public void setPlotLineColor(Color color) { public void setPlotLineColor(Color color) {
_plotLineColor = color; _plotLineColor = color;
fireUpdate(); fireUpdate();
} }
} }
/**
* An interface for listening to updates . . .
*/
public interface UpdateListener { public interface UpdateListener {
/**
* @param config the peer plot config that changes
* @see PeerPlotConfig#fireUpdate()
*/
void configUpdated(PeerPlotConfig config); void configUpdated(PeerPlotConfig config);
} }
} }

View File

@@ -1,31 +1,24 @@
package net.i2p.heartbeat.gui; package net.i2p.heartbeat.gui;
import net.i2p.util.Log;
import javax.swing.JPanel;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JButton;
import javax.swing.JTextField;
import javax.swing.JTextArea;
import javax.swing.JScrollPane;
import javax.swing.DefaultComboBoxModel;
import javax.swing.ComboBoxModel;
import javax.swing.JColorChooser;
import javax.swing.border.LineBorder;
import javax.swing.border.BevelBorder;
import java.awt.BorderLayout;
import java.awt.Color; import java.awt.Color;
import java.awt.Dimension;
import java.awt.GridBagLayout;
import java.awt.GridBagConstraints; import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.util.List; import java.util.List;
import java.util.Random; import java.util.Random;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JColorChooser;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import net.i2p.util.Log;
class PeerPlotConfigPane extends JPanel implements PeerPlotConfig.UpdateListener { class PeerPlotConfigPane extends JPanel implements PeerPlotConfig.UpdateListener {
private final static Log _log = new Log(PeerPlotConfigPane.class); private final static Log _log = new Log(PeerPlotConfigPane.class);
private PeerPlotConfig _config; private PeerPlotConfig _config;
@@ -44,6 +37,11 @@ class PeerPlotConfigPane extends JPanel implements PeerPlotConfig.UpdateListener
private final static Color WHITE = new Color(255, 255, 255); private final static Color WHITE = new Color(255, 255, 255);
private Color _background = WHITE; private Color _background = WHITE;
/**
* Constructs a pane
* @param config the plot config it represents
* @param pane the pane this one is attached to
*/
public PeerPlotConfigPane(PeerPlotConfig config, HeartbeatControlPane pane) { public PeerPlotConfigPane(PeerPlotConfig config, HeartbeatControlPane pane) {
_config = config; _config = config;
_parent = pane; _parent = pane;
@@ -66,7 +64,10 @@ class PeerPlotConfigPane extends JPanel implements PeerPlotConfig.UpdateListener
setBackground(_background); setBackground(_background);
} }
/** place all the gui components onto the given panel */ /**
* place all the gui components onto the given panel
* @param body the panel to place the components on
*/
private void placeComponents(JPanel body) { private void placeComponents(JPanel body) {
body.setLayout(new GridBagLayout()); body.setLayout(new GridBagLayout());
GridBagConstraints cts = new GridBagConstraints(); GridBagConstraints cts = new GridBagConstraints();
@@ -206,7 +207,11 @@ class PeerPlotConfigPane extends JPanel implements PeerPlotConfig.UpdateListener
} }
} }
/** find the right config for the given period, or null if none exist */ /**
* find the right config for the given period
* @param minutes the minutes to locate the config by
* @return the config for the given period, or null
*/
private PeerPlotConfig.PlotSeriesConfig getConfig(int minutes) { private PeerPlotConfig.PlotSeriesConfig getConfig(int minutes) {
if (minutes <= 0) if (minutes <= 0)
return _config.getCurrentSeriesConfig(); return _config.getCurrentSeriesConfig();
@@ -220,17 +225,27 @@ class PeerPlotConfigPane extends JPanel implements PeerPlotConfig.UpdateListener
return null; return null;
} }
/** notified that the config has been updated */ /**
* notified that the config has been updated
* @param config the config that was been updated
*/
public void configUpdated(PeerPlotConfig config) { refreshView(); } public void configUpdated(PeerPlotConfig config) { refreshView(); }
private class ChooseColor implements ActionListener { private class ChooseColor implements ActionListener {
private int _minutes; private int _minutes;
private JButton _button; private JButton _button;
/**
* @param minutes the minutes (line) to change the color of...
* @param button the associated button
*/
public ChooseColor(int minutes, JButton button) { public ChooseColor(int minutes, JButton button) {
_minutes = minutes; _minutes = minutes;
_button = button; _button = button;
} }
/* (non-Javadoc)
* @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
*/
public void actionPerformed(ActionEvent evt) { public void actionPerformed(ActionEvent evt) {
PeerPlotConfig.PlotSeriesConfig cfg = getConfig(_minutes); PeerPlotConfig.PlotSeriesConfig cfg = getConfig(_minutes);
Color origColor = null; Color origColor = null;
@@ -253,6 +268,10 @@ class PeerPlotConfigPane extends JPanel implements PeerPlotConfig.UpdateListener
JCheckBox _all; JCheckBox _all;
JButton _color; JButton _color;
/**
* Creates an OptionLine.
* @param durationMinutes the minutes =)
*/
public OptionLine(int durationMinutes) { public OptionLine(int durationMinutes) {
_durationMinutes = durationMinutes; _durationMinutes = durationMinutes;
_send = new JCheckBox("send time"); _send = new JCheckBox("send time");
@@ -283,10 +302,20 @@ class PeerPlotConfigPane extends JPanel implements PeerPlotConfig.UpdateListener
private class UpdateListener implements ActionListener { private class UpdateListener implements ActionListener {
private OptionLine _line; private OptionLine _line;
private int _minutes; private int _minutes;
/**
* Update Listener constructor . . .
* @param line the line
* @param minutes the minutes
*/
public UpdateListener(OptionLine line, int minutes) { public UpdateListener(OptionLine line, int minutes) {
_line = line; _line = line;
_minutes = minutes; _minutes = minutes;
} }
/* (non-Javadoc)
* @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
*/
public void actionPerformed(ActionEvent evt) { public void actionPerformed(ActionEvent evt) {
PeerPlotConfig.PlotSeriesConfig cfg = getConfig(_minutes); PeerPlotConfig.PlotSeriesConfig cfg = getConfig(_minutes);
if (cfg == null) { if (cfg == null) {
@@ -315,12 +344,19 @@ class PeerPlotConfigPane extends JPanel implements PeerPlotConfig.UpdateListener
} }
} }
/**
* Unit test stuff
* @param args da arsg
*/
public final static void main(String args[]) { public final static void main(String args[]) {
Test t = new Test(); Test t = new Test();
t.runTest(); t.runTest();
} }
private final static class Test implements PeerPlotStateFetcher.FetchStateReceptor { private final static class Test implements PeerPlotStateFetcher.FetchStateReceptor {
/**
* Runs da test
*/
public void runTest() { public void runTest() {
PeerPlotConfig cfg = new PeerPlotConfig("C:\\testnet\\r2\\heartbeatStat_10s_30kb.txt"); PeerPlotConfig cfg = new PeerPlotConfig("C:\\testnet\\r2\\heartbeatStat_10s_30kb.txt");
PeerPlotState state = new PeerPlotState(cfg); PeerPlotState state = new PeerPlotState(cfg);
@@ -329,6 +365,9 @@ class PeerPlotConfigPane extends JPanel implements PeerPlotConfig.UpdateListener
System.exit(-1); System.exit(-1);
} }
/* (non-Javadoc)
* @see net.i2p.heartbeat.gui.PeerPlotStateFetcher.FetchStateReceptor#peerPlotStateFetched(net.i2p.heartbeat.gui.PeerPlotState)
*/
public void peerPlotStateFetched(PeerPlotState state) { public void peerPlotStateFetched(PeerPlotState state) {
javax.swing.JFrame f = new javax.swing.JFrame("Test"); javax.swing.JFrame f = new javax.swing.JFrame("Test");
f.getContentPane().add(new JScrollPane(new PeerPlotConfigPane(state.getPlotConfig(), null))); f.getContentPane().add(new JScrollPane(new PeerPlotConfigPane(state.getPlotConfig(), null)));

View File

@@ -1,6 +1,5 @@
package net.i2p.heartbeat.gui; package net.i2p.heartbeat.gui;
import net.i2p.heartbeat.PeerData;
/** /**
* Current data + plot config for a particular test * Current data + plot config for a particular test
@@ -10,17 +9,39 @@ class PeerPlotState {
private StaticPeerData _currentData; private StaticPeerData _currentData;
private PeerPlotConfig _plotConfig; private PeerPlotConfig _plotConfig;
/**
* Delegating constructor . . .
* @see PeerPlotState#PeerPlotState(PeerPlotConfig, StaticPeerData)
*/
public PeerPlotState() { public PeerPlotState() {
this(null, null); this(null, null);
} }
/**
* Delegating constructor . . .
* @param config plot config
* @see PeerPlotState#PeerPlotState(PeerPlotConfig, StaticPeerData)
*/
public PeerPlotState(PeerPlotConfig config) { public PeerPlotState(PeerPlotConfig config) {
this(config, new StaticPeerData(config.getClientConfig())); this(config, new StaticPeerData(config.getClientConfig()));
} }
/**
* Creates a PeerPlotState
* @param config plot config
* @param data peer data
*/
public PeerPlotState(PeerPlotConfig config, StaticPeerData data) { public PeerPlotState(PeerPlotConfig config, StaticPeerData data) {
_plotConfig = config; _plotConfig = config;
_currentData = data; _currentData = data;
} }
/**
* Add an average
* @param minutes mins averaged over
* @param sendMs how much later did the peer receieve
* @param recvMs how much later did we receieve
* @param lost how many were lost
*/
public void addAverage(int minutes, int sendMs, int recvMs, int lost) { public void addAverage(int minutes, int sendMs, int recvMs, int lost) {
// make sure we've got the config entry for the average // make sure we've got the config entry for the average
_plotConfig.addAverage(minutes); _plotConfig.addAverage(minutes);
@@ -48,11 +69,27 @@ class PeerPlotState {
_currentData.addData(sendTime); _currentData.addData(sendTime);
} }
/** data set to render */ /**
* data set to render
* @return the data set
*/
public StaticPeerData getCurrentData() { return _currentData; } public StaticPeerData getCurrentData() { return _currentData; }
/**
* Sets the data set to render
* @param data the data set
*/
public void setCurrentData(StaticPeerData data) { _currentData = data; } public void setCurrentData(StaticPeerData data) { _currentData = data; }
/** configuration options on how to render the data set */ /**
* configuration options on how to render the data set
* @return the config options
*/
public PeerPlotConfig getPlotConfig() { return _plotConfig; } public PeerPlotConfig getPlotConfig() { return _plotConfig; }
/**
* Sets the configuration options on how to render the data
* @param config the config options
*/
public void setPlotConfig(PeerPlotConfig config) { _plotConfig = config; } public void setPlotConfig(PeerPlotConfig config) { _plotConfig = config; }
} }

View File

@@ -1,35 +1,29 @@
package net.i2p.heartbeat.gui; package net.i2p.heartbeat.gui;
import net.i2p.util.Log;
import net.i2p.util.I2PThread;
import net.i2p.data.Destination;
import net.i2p.data.DataFormatException;
import net.i2p.heartbeat.ClientConfig;
import net.i2p.heartbeat.PeerData;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.io.IOException;
import java.io.FileInputStream;
import java.net.URL;
import java.net.MalformedURLException; import java.net.MalformedURLException;
import java.net.URL;
import java.text.SimpleDateFormat;
import java.text.ParseException; import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Locale; import java.util.Locale;
import java.util.List;
import java.util.ArrayList;
import java.util.StringTokenizer; import java.util.StringTokenizer;
import net.i2p.data.DataFormatException;
import net.i2p.data.Destination;
import net.i2p.util.I2PThread;
import net.i2p.util.Log;
class PeerPlotStateFetcher { class PeerPlotStateFetcher {
private final static Log _log = new Log(PeerPlotStateFetcher.class); private final static Log _log = new Log(PeerPlotStateFetcher.class);
/** /**
* Fetch and fill the specified state structure * Fetch and fill the specified state structure
* * @param receptor the 'receptor' (callbacks)
* @param state the state
*/ */
public static void fetchPeerPlotState(FetchStateReceptor receptor, PeerPlotState state) { public static void fetchPeerPlotState(FetchStateReceptor receptor, PeerPlotState state) {
I2PThread t = new I2PThread(new Fetcher(receptor, state)); I2PThread t = new I2PThread(new Fetcher(receptor, state));
@@ -38,17 +32,34 @@ class PeerPlotStateFetcher {
t.start(); t.start();
} }
/**
* Callback stuff . . .
*/
public interface FetchStateReceptor { public interface FetchStateReceptor {
/**
* Called when a peer plot state is fetched
* @param state state that was fetched
*/
void peerPlotStateFetched(PeerPlotState state); void peerPlotStateFetched(PeerPlotState state);
} }
private static class Fetcher implements Runnable { private static class Fetcher implements Runnable {
private PeerPlotState _state; private PeerPlotState _state;
private FetchStateReceptor _receptor; private FetchStateReceptor _receptor;
/**
* Creates a Fetcher thread
* @param receptor the 'receptor' (callbacks)
* @param state the state
*/
public Fetcher(FetchStateReceptor receptor, PeerPlotState state) { public Fetcher(FetchStateReceptor receptor, PeerPlotState state) {
_state = state; _state = state;
_receptor = receptor; _receptor = receptor;
} }
/* (non-Javadoc)
* @see java.lang.Runnable#run()
*/
public void run() { public void run() {
String loc = _state.getPlotConfig().getLocation(); String loc = _state.getPlotConfig().getLocation();
_log.debug("Load called [" + loc + "]"); _log.debug("Load called [" + loc + "]");
@@ -82,7 +93,7 @@ class PeerPlotStateFetcher {
/** /**
* check to make sure we've got everything we need * check to make sure we've got everything we need
* * @return true [always]
*/ */
boolean valid() { boolean valid() {
return true; return true;
@@ -139,6 +150,8 @@ class PeerPlotStateFetcher {
* EVENT LOST 20040409.23:30:22.656 * EVENT LOST 20040409.23:30:22.656
* EVENT OK 20040409.23:31:24.305 1843 771 * EVENT OK 20040409.23:31:24.305 1843 771
* </pre> * </pre>
*
* @param line (see above)
*/ */
private void handleLine(String line) { private void handleLine(String line) {
if (line.startsWith("peerDest")) if (line.startsWith("peerDest"))

View File

@@ -1,14 +1,13 @@
package net.i2p.heartbeat.gui; package net.i2p.heartbeat.gui;
import net.i2p.heartbeat.PeerData;
import net.i2p.heartbeat.ClientConfig;
import java.util.Map;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map;
import net.i2p.heartbeat.ClientConfig;
import net.i2p.heartbeat.PeerData;
/** /**
* Raw data points for a test * Raw data points for a test
*
*/ */
class StaticPeerData extends PeerData { class StaticPeerData extends PeerData {
private int _pending; private int _pending;
@@ -19,6 +18,10 @@ class StaticPeerData extends PeerData {
/** Integer (period, in minutes) to Integer (num messages) of how many messages were lost on average */ /** Integer (period, in minutes) to Integer (num messages) of how many messages were lost on average */
private Map _lostMessages; private Map _lostMessages;
/**
* Creates a static peer data with a specified client config ... duh
* @param config the client config
*/
public StaticPeerData(ClientConfig config) { public StaticPeerData(ClientConfig config) {
super(config); super(config);
_averageSendTimes = new HashMap(4); _averageSendTimes = new HashMap(4);
@@ -26,16 +29,36 @@ class StaticPeerData extends PeerData {
_lostMessages = new HashMap(4); _lostMessages = new HashMap(4);
} }
/**
* Adds averaged data
* @param minutes the minutes (averaged over)
* @param sendMs the send time (ping) in milliseconds
* @param recvMs the receive time (pong) in milliseconds
* @param lost the number lost
*/
public void addAverage(int minutes, int sendMs, int recvMs, int lost) { public void addAverage(int minutes, int sendMs, int recvMs, int lost) {
_averageSendTimes.put(new Integer(minutes), new Integer(sendMs)); _averageSendTimes.put(new Integer(minutes), new Integer(sendMs));
_averageReceiveTimes.put(new Integer(minutes), new Integer(recvMs)); _averageReceiveTimes.put(new Integer(minutes), new Integer(recvMs));
_lostMessages.put(new Integer(minutes), new Integer(lost)); _lostMessages.put(new Integer(minutes), new Integer(lost));
} }
/**
* Sets the number pending
* @param numPending the number pending
*/
public void setPendingCount(int numPending) { _pending = numPending; } public void setPendingCount(int numPending) { _pending = numPending; }
/* (non-Javadoc)
* @see net.i2p.heartbeat.PeerData#setSessionStart(long)
*/
public void setSessionStart(long when) { super.setSessionStart(when); } public void setSessionStart(long when) { super.setSessionStart(when); }
/**
* Adds data
* @param sendTime the time it was sent
* @param sendMs the send time (ping) in milliseconds
* @param recvMs the receive time (pong) in milliseconds
*/
public void addData(long sendTime, int sendMs, int recvMs) { public void addData(long sendTime, int sendMs, int recvMs) {
PeerData.EventDataPoint dataPoint = new PeerData.EventDataPoint(sendTime); PeerData.EventDataPoint dataPoint = new PeerData.EventDataPoint(sendTime);
dataPoint.setPongSent(sendTime + sendMs); dataPoint.setPongSent(sendTime + sendMs);
@@ -44,14 +67,16 @@ class StaticPeerData extends PeerData {
addDataPoint(dataPoint); addDataPoint(dataPoint);
} }
/**
* Adds data
* @param sendTime the time it was sent
*/
public void addData(long sendTime) { public void addData(long sendTime) {
PeerData.EventDataPoint dataPoint = new PeerData.EventDataPoint(sendTime); PeerData.EventDataPoint dataPoint = new PeerData.EventDataPoint(sendTime);
dataPoint.setWasPonged(false); dataPoint.setWasPonged(false);
addDataPoint(dataPoint); addDataPoint(dataPoint);
} }
/** /**
* how many pings are still outstanding? * how many pings are still outstanding?
* @return the number of pings outstanding * @return the number of pings outstanding
@@ -80,7 +105,6 @@ class StaticPeerData extends PeerData {
return ((Integer)_averageReceiveTimes.get(new Integer(period))).doubleValue(); return ((Integer)_averageReceiveTimes.get(new Integer(period))).doubleValue();
} }
/** /**
* number of lost messages over the given period. * number of lost messages over the given period.
* *
@@ -91,5 +115,8 @@ class StaticPeerData extends PeerData {
return ((Integer)_lostMessages.get(new Integer(period))).doubleValue(); return ((Integer)_lostMessages.get(new Integer(period))).doubleValue();
} }
/* (non-Javadoc)
* @see net.i2p.heartbeat.PeerData#cleanup()
*/
public void cleanup() {} public void cleanup() {}
} }