diff options
author | Jose <jose@zeroc.com> | 2012-09-28 23:44:07 +0200 |
---|---|---|
committer | Jose <jose@zeroc.com> | 2012-09-28 23:44:07 +0200 |
commit | 9fa149f8507463a7e92a313057d5614eeb00084b (patch) | |
tree | d630a4595907f7782e773a6af6daef2ce5d1030d /java/src/IceGridGUI/LiveDeployment/GraphView.java | |
parent | Merge branch 'mx' of ssh://dev.zeroc.com/home/git/ice into mx (diff) | |
download | ice-9fa149f8507463a7e92a313057d5614eeb00084b.tar.bz2 ice-9fa149f8507463a7e92a313057d5614eeb00084b.tar.xz ice-9fa149f8507463a7e92a313057d5614eeb00084b.zip |
Added support to display IceBox metrics
Diffstat (limited to 'java/src/IceGridGUI/LiveDeployment/GraphView.java')
-rw-r--r-- | java/src/IceGridGUI/LiveDeployment/GraphView.java | 92 |
1 files changed, 67 insertions, 25 deletions
diff --git a/java/src/IceGridGUI/LiveDeployment/GraphView.java b/java/src/IceGridGUI/LiveDeployment/GraphView.java index 4b8ee00cf3a..4014c0656e8 100644 --- a/java/src/IceGridGUI/LiveDeployment/GraphView.java +++ b/java/src/IceGridGUI/LiveDeployment/GraphView.java @@ -46,6 +46,8 @@ import javax.swing.border.Border; import javax.swing.DefaultCellEditor; import javax.swing.DefaultListCellRenderer; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; import javax.swing.event.TableModelEvent; import javax.swing.event.ListSelectionListener; import javax.swing.event.ListSelectionEvent; @@ -327,14 +329,12 @@ public class GraphView extends JFrame implements MetricsFieldContext for(final MetricsViewInfo m : metrics) { - Ice.Identity adminId = new Ice.Identity(m.server, _coordinator.getServerAdminCategory()); - Ice.ObjectPrx admin = _coordinator.getAdmin().ice_identity(adminId); IceMX.Callback_MetricsAdmin_getMetricsView cb = new IceMX.Callback_MetricsAdmin_getMetricsView() { public void response(final java.util.Map<java.lang.String, IceMX.Metrics[]> data, long timestamp) { - addData(m, data, System.currentTimeMillis()); + addData(m, data, timestamp); } public void exception(final Ice.LocalException e) @@ -366,9 +366,7 @@ public class GraphView extends JFrame implements MetricsFieldContext }; try { - IceMX.MetricsAdminPrx metricsAdmin = - IceMX.MetricsAdminPrxHelper.uncheckedCast(admin.ice_facet("MetricsAdmin")); - metricsAdmin.begin_getMetricsView(m.view, cb); + m.admin.begin_getMetricsView(m.view, cb); } catch(Ice.LocalException e) { @@ -478,20 +476,46 @@ public class GraphView extends JFrame implements MetricsFieldContext // SpinnerNumberModel refreshPeriod = new SpinnerNumberModel(getRefreshPeriod(), _minRefreshPeriod, _maxRefreshPeriod, 1); + + // + // SpinnerNumberModel to set the duration of samples to keep in X axis. + // + final SpinnerNumberModel duration = new SpinnerNumberModel(getDuration(), _minDuration, + _maxDuration, 1); + + JPanel refreshPanel; { DefaultFormBuilder builder = new DefaultFormBuilder(new FormLayout("pref,2dlu,pref:grow", "pref")); - builder.append("Refresh period (s):", new JSpinner(refreshPeriod)); + final JSpinner spinner = new JSpinner(refreshPeriod); + builder.append("Refresh period (s):", spinner); + spinner.addChangeListener(new ChangeListener() + { + @Override + public void stateChanged(ChangeEvent e) + { + int refreshPeriod = ((Number)spinner.getValue()).intValue(); + _maxDuration = (_maxPoints * refreshPeriod) / 60; + _minDuration = Math.max((refreshPeriod * 2) / 60, 1); + int value = ((Number)duration.getValue()).intValue(); + if(value > _maxDuration) + { + duration.setValue(_maxDuration); + } + else if(value < _minDuration) + { + duration.setValue(_minDuration); + } + duration.setMinimum(_minDuration); + duration.setMaximum(_maxDuration); + + } + }); refreshPanel = builder.getPanel(); } // - // SpinnerNumberModel to set the duration of samples to keep in X axis. - // - SpinnerNumberModel duration = new SpinnerNumberModel(getDuration(), _minDuration, _maxDuration, 1); - - // // JComboBox to select time format used in X Axis // JComboBox<String> dateFormats = new JComboBox<String>(_dateFormats); @@ -913,18 +937,29 @@ public class GraphView extends JFrame implements MetricsFieldContext _legendTable.getColumnModel().getColumn(i).setPreferredWidth(columnWidth); } } - + int refreshPeriod = preferences.getInt("refreshPeriod", _defaultRefreshPeriod); - if(refreshPeriod < _minRefreshPeriod || refreshPeriod > _maxRefreshPeriod) + if(refreshPeriod < _minRefreshPeriod) + { + refreshPeriod = _minRefreshPeriod; + } + else if(refreshPeriod > _maxRefreshPeriod) { - refreshPeriod = _defaultRefreshPeriod; + refreshPeriod = _maxRefreshPeriod; } setRefreshPeriod(refreshPeriod); + _maxDuration = (_maxPoints * _refreshPeriod) / 60; + _minDuration = Math.max((_refreshPeriod * 2) / 60, 1); + int duration = preferences.getInt("duration", _defaultDuration); - if(duration < _minDuration || duration > _maxDuration) + if(duration < _minDuration) { - duration = _defaultDuration; + duration = _minDuration; + } + else if(duration > _maxDuration) + { + duration = _maxDuration; } setDuration(duration); @@ -1079,7 +1114,7 @@ public class GraphView extends JFrame implements MetricsFieldContext try { MetricsRow row = j.getValue(); - Number value = row.cell.getValue(metrics); + Number value = row.cell.getValue(metrics, timestamp); if(value == null) { continue; @@ -1724,16 +1759,23 @@ public class GraphView extends JFrame implements MetricsFieldContext private final Coordinator _coordinator; private RefreshThread _refreshThread; - private final static int _minDuration = 5; // 5 minutes - private final static int _maxDuration = 60; // 60 minutes = 1 hour - private final static int _defaultDuration = 5; // 5 minutes - private int _duration = _defaultDuration; + // + // The max number of points for a series, it is calculate dividing the duration, + // by the refresh period. + // + private final static int _maxPoints = 5000; + private final static int _minPoints = 2; - private final static int _minRefreshPeriod = 1; // 1 second - private final static int _maxRefreshPeriod = 120; // 120 second = 2 minutes - private final static int _defaultRefreshPeriod = 5; // 5 second + private final static int _minRefreshPeriod = 1; // 1 seconds + private final static int _maxRefreshPeriod = 60 * 60; // 3600 seconds = 1 hour. + private final static int _defaultRefreshPeriod = 5; // 5 seconds private int _refreshPeriod = _defaultRefreshPeriod; + private int _minDuration = Math.max((_refreshPeriod * 2) / 60, 1); // 1 minutes + private int _maxDuration = (_maxPoints * _refreshPeriod) / 60; // 100 points. + private int _defaultDuration = 5; // 5 minutes. + private int _duration = _defaultDuration; + private String[] _dateFormats = new String[]{"HH:mm:ss", "mm:ss"}; private String _dateFormat = _dateFormats[0]; private final TimeFormatter _timeFormater = new TimeFormatter(_dateFormat); |