summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorShireesh Anjal <shireesh@gluster.com>2011-07-25 12:48:03 +0530
committerShireesh Anjal <shireesh@gluster.com>2011-07-25 23:10:27 +0530
commit0f1f4befeeca22071851f064a57b235fe21993ab (patch)
treea98e051188ca8d9b801367edd9db4e5bc6fd63d1 /src
parent6026b15816e8156dd6ef9c04f28eff7106e16097 (diff)
Story #38 - CPU Usage graph
Diffstat (limited to 'src')
-rw-r--r--src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/constants/GlusterConstants.java4
-rw-r--r--src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/GlusterDataModelManager.java2
-rw-r--r--src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/preferences/ChartsPreferencePage.java3
-rw-r--r--src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/utils/ChartViewerComposite.java156
-rw-r--r--src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/ClusterSummaryView.java141
-rw-r--r--src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/GlusterServerSummaryView.java10
6 files changed, 236 insertions, 80 deletions
diff --git a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/constants/GlusterConstants.java b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/constants/GlusterConstants.java
index b6384a18..51b53241 100644
--- a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/constants/GlusterConstants.java
+++ b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/constants/GlusterConstants.java
@@ -38,4 +38,8 @@ public class GlusterConstants {
public static final String ON = "on";
public static final String OFF = "off";
+ public static final String STATS_PERIOD_1DAY = "1d";
+ public static final String STATS_PERIOD_1WEEK = "1w";
+ public static final String STATS_PERIOD_1MONTH = "1m";
+ public static final String STATS_PERIOD_1YEAR = "1y";
}
diff --git a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/GlusterDataModelManager.java b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/GlusterDataModelManager.java
index f9c27cf6..28f36078 100644
--- a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/GlusterDataModelManager.java
+++ b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/GlusterDataModelManager.java
@@ -433,7 +433,7 @@ public class GlusterDataModelManager {
cluster.setTaskInfoList(taskInfoList);
}
- private void initializeAggregatedCpuStats(Cluster cluster) {
+ public void initializeAggregatedCpuStats(Cluster cluster) {
IPreferenceStore preferenceStore = Activator.getDefault().getPreferenceStore();
String cpuStatsPeriod = preferenceStore.getString(PreferenceConstants.P_CPU_CHART_PERIOD);
diff --git a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/preferences/ChartsPreferencePage.java b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/preferences/ChartsPreferencePage.java
index 3dd636f1..2d16fcd2 100644
--- a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/preferences/ChartsPreferencePage.java
+++ b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/preferences/ChartsPreferencePage.java
@@ -57,7 +57,8 @@ public class ChartsPreferencePage extends FieldEditorPreferencePage implements I
@Override
protected void createFieldEditors() {
String[][] entryNamesAndValues = new String[][] {
- { "1d", "1 day" }, { "1w", "1 week" }, { "1m", "1 month" }, { "1y", "1 year" } };
+ { "1d", "1d" }, { "1w", "1w" }, { "1m", "1m" }, { "1y", "1y" } };
+ //{ "1 day", "1d" }, { "1 week", "1w" }, { "1 month", "1m" }, { "1 year", "1y" } };
addField(new ComboFieldEditor(PreferenceConstants.P_CPU_CHART_PERIOD, "CPU Usage chart period", entryNamesAndValues,
getFieldEditorParent()));
addField(new ComboFieldEditor(PreferenceConstants.P_MEM_CHART_PERIOD, "Memory Usage chart period", entryNamesAndValues,
diff --git a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/utils/ChartViewerComposite.java b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/utils/ChartViewerComposite.java
index f2735380..30982096 100644
--- a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/utils/ChartViewerComposite.java
+++ b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/utils/ChartViewerComposite.java
@@ -140,11 +140,11 @@ public final class ChartViewerComposite extends Composite implements PaintListen
* Values of each category in the pie chart Constructs a pie
* chart viewer composite for given categories and values
*/
- public ChartViewerComposite(Composite parent, int style, Calendar[] categories, Double[] values, String unit) {
+ public ChartViewerComposite(Composite parent, int style, Calendar[] categories, Double[] values, String unit, String timestampFormat) {
super(parent, style);
init();
- chart = createLineChart(categories, values, unit);
+ createSingleAreaChart(categories, values, unit, timestampFormat);
addPaintListener(this);
}
@@ -170,8 +170,8 @@ public final class ChartViewerComposite extends Composite implements PaintListen
});
}
- private Chart createLineChart(Calendar[] timestamps, Double[] values, String unit) {
- return createAreaChart(timestamps, new Double[][] {values}, unit);
+ private void createSingleAreaChart(Calendar[] timestamps, Double[] values, String unit, String timestampFormat) {
+ createAreaChart(timestamps, new Double[][] {values}, unit, timestampFormat);
}
/**
@@ -180,23 +180,23 @@ public final class ChartViewerComposite extends Composite implements PaintListen
* @return An instance of the simulated runtime chart model (containing
* filled datasets)
*/
- public static final Chart createAreaChart(Calendar[] timestamps, Double[][] values, final String unit) {
- ChartWithAxes cwaLine = ChartWithAxesImpl.create();
+ private final void createAreaChart(Calendar[] timestamps, Double[][] values, final String unit, final String timestampFormat) {
+ chart = ChartWithAxesImpl.create();
// Plot
- cwaLine.getBlock().setBackground(ColorDefinitionImpl.WHITE());
- Plot p = cwaLine.getPlot();
+ chart.getBlock().setBackground(ColorDefinitionImpl.WHITE());
+ Plot p = chart.getPlot();
p.getClientArea().setBackground(ColorDefinitionImpl.WHITE());
p.setBackground(ColorDefinitionImpl.WHITE());
// Title
- cwaLine.getTitle().getLabel().getCaption().setValue("Line Chart");//$NON-NLS-1$
- cwaLine.getTitle().setVisible(false);
- cwaLine.getTitle().getLabel().setVisible(true);
- cwaLine.getTitle().getInsets().set(0, 10, 0, 0);
- cwaLine.getTitle().setAnchor(Anchor.SOUTH_LITERAL);
+ chart.getTitle().getLabel().getCaption().setValue("Line Chart");//$NON-NLS-1$
+ chart.getTitle().setVisible(false);
+ chart.getTitle().getLabel().setVisible(true);
+ chart.getTitle().getInsets().set(0, 10, 0, 0);
+ chart.getTitle().setAnchor(Anchor.SOUTH_LITERAL);
// Legend
- Legend lg = cwaLine.getLegend();
+ Legend lg = chart.getLegend();
lg.setVisible(false);
LineAttributes lia = lg.getOutline( );
lia.setStyle( LineStyle.SOLID_LITERAL );
@@ -206,52 +206,17 @@ public final class ChartViewerComposite extends Composite implements PaintListen
lg.getOutline( ).setVisible( false );
lg.setAnchor( Anchor.NORTH_LITERAL );
- // X-Axis
- Axis xAxisPrimary = cwaLine.getPrimaryBaseAxes()[0];
- xAxisPrimary.setType(AxisType.TEXT_LITERAL);
- DateTimeDataElement dtde = DateTimeDataElementImpl.create(timestamps[timestamps.length-1]);
- DateTimeDataElement dtde1 = DateTimeDataElementImpl.create(timestamps[0]);
- xAxisPrimary.getScale().setMax(dtde);
- xAxisPrimary.getScale().setStep((dtde.getValue() - dtde1.getValue())/ 10);
- xAxisPrimary.getScale().setMajorGridsStepNumber(timestamps.length > 10 ? timestamps.length / 10 : 1);
- //xAxisPrimary.getMajorGrid().setTickStyle(TickStyle.ABOVE_LITERAL);
- xAxisPrimary.getMajorGrid().getTickAttributes().setVisible(false);
- xAxisPrimary.getMajorGrid().setLineAttributes(LineAttributesImpl.create(ColorDefinitionImpl.GREY(), LineStyle.SOLID_LITERAL, 1));
- xAxisPrimary.getTitle().setVisible(false);
- xAxisPrimary.getTitle().getInsets().set(1, 1, 1, 1);
- xAxisPrimary.getLabel().getInsets().set(1, 1, 1, 1);
- xAxisPrimary.getLabel().getCaption().setFont(createChartFont());
- xAxisPrimary.setFormatSpecifier( JavaDateFormatSpecifierImpl.create( "HH:mm" ) );
-
- // Y-Axis
- Axis yAxisPrimary = cwaLine.getPrimaryOrthogonalAxis(xAxisPrimary);
- yAxisPrimary.getScale().setMax(NumberDataElementImpl.create(100));
- yAxisPrimary.getScale().setMin(NumberDataElementImpl.create(0));
- yAxisPrimary.setGapWidth(0);
- yAxisPrimary.getScale().setStep(20);
- yAxisPrimary.getScale().setMajorGridsStepNumber(1);
- yAxisPrimary.getMajorGrid().setTickStyle(TickStyle.LEFT_LITERAL);
- yAxisPrimary.getMajorGrid().setLineAttributes(LineAttributesImpl.create(ColorDefinitionImpl.GREY(), LineStyle.SOLID_LITERAL, 1));
- yAxisPrimary.getLabel().setVisible(true);
- yAxisPrimary.getLabel().getCaption().setFont(createChartFont());
- yAxisPrimary.setFormatSpecifier(new NumberFormatSpecifierImpl() {
- @Override
- public String getSuffix() {
- return " " + unit;
- }
- });
-
- // Data Set
- DateTimeDataSet categoryValues = DateTimeDataSetImpl.create(timestamps);
-
- // X-Series
- Series seCategory = SeriesImpl.create();
- seCategory.setDataSet(categoryValues);
- SeriesDefinition sdX = SeriesDefinitionImpl.create();
+ updateDataSet(timestamps, values, unit, timestampFormat);
+ }
- xAxisPrimary.getSeriesDefinitions().add(sdX);
- sdX.getSeries().add(seCategory);
+ private void updateDataSet(Calendar[] timestamps, Double[][] values, final String unit, final String timestampFormat) {
+ Axis xAxisPrimary = setupXAxis(timestamps, timestampFormat);
+ Axis yAxisPrimary = setupYAxis(unit, xAxisPrimary);
+ configureXSeries(timestamps, xAxisPrimary);
+ configureYSeries(values, yAxisPrimary);
+ }
+ private void configureYSeries(Double[][] values, Axis yAxisPrimary) {
SeriesDefinition sdY = SeriesDefinitionImpl.create();
sdY.getSeriesPalette().shift(-3);
yAxisPrimary.getSeriesDefinitions().add(sdY);
@@ -273,7 +238,59 @@ public final class ChartViewerComposite extends Composite implements PaintListen
ls.getLabel().setVisible(false);
sdY.getSeries().add(ls);
}
- return cwaLine;
+ }
+
+ private void configureXSeries(Calendar[] timestamps, Axis xAxisPrimary) {
+ // Data Set
+ DateTimeDataSet categoryValues = DateTimeDataSetImpl.create(timestamps);
+
+ // X-Series
+ Series seCategory = SeriesImpl.create();
+ seCategory.setDataSet(categoryValues);
+ SeriesDefinition sdX = SeriesDefinitionImpl.create();
+
+ xAxisPrimary.getSeriesDefinitions().add(sdX);
+ sdX.getSeries().add(seCategory);
+ }
+
+ private Axis setupYAxis(final String unit, Axis xAxisPrimary) {
+ Axis yAxisPrimary = ((ChartWithAxesImpl)chart).getPrimaryOrthogonalAxis(xAxisPrimary);
+ yAxisPrimary.getScale().setMax(NumberDataElementImpl.create(100));
+ yAxisPrimary.getScale().setMin(NumberDataElementImpl.create(0));
+ yAxisPrimary.setGapWidth(0);
+ yAxisPrimary.getScale().setStep(20);
+ yAxisPrimary.getScale().setMajorGridsStepNumber(1);
+ yAxisPrimary.getMajorGrid().setTickStyle(TickStyle.LEFT_LITERAL);
+ yAxisPrimary.getMajorGrid().setLineAttributes(LineAttributesImpl.create(ColorDefinitionImpl.GREY(), LineStyle.SOLID_LITERAL, 1));
+ yAxisPrimary.getLabel().setVisible(true);
+ yAxisPrimary.getLabel().getCaption().setFont(createChartFont());
+ yAxisPrimary.setFormatSpecifier(new NumberFormatSpecifierImpl() {
+ @Override
+ public String getSuffix() {
+ return " " + unit;
+ }
+ });
+ return yAxisPrimary;
+ }
+
+ private Axis setupXAxis(Calendar[] timestamps, final String timestampFormat) {
+ Axis xAxisPrimary = ((ChartWithAxesImpl)chart).getPrimaryBaseAxes()[0];
+ xAxisPrimary.setType(AxisType.TEXT_LITERAL);
+ DateTimeDataElement dtde = DateTimeDataElementImpl.create(timestamps[timestamps.length-1]);
+ DateTimeDataElement dtde1 = DateTimeDataElementImpl.create(timestamps[0]);
+ xAxisPrimary.getScale().setMax(dtde);
+ xAxisPrimary.getScale().setStep((dtde.getValue() - dtde1.getValue())/ 10);
+ xAxisPrimary.getScale().setMajorGridsStepNumber(timestamps.length > 10 ? timestamps.length / 10 : 1);
+ //xAxisPrimary.getMajorGrid().setTickStyle(TickStyle.ABOVE_LITERAL);
+ xAxisPrimary.getMajorGrid().getTickAttributes().setVisible(false);
+ xAxisPrimary.getMajorGrid().setLineAttributes(LineAttributesImpl.create(ColorDefinitionImpl.GREY(), LineStyle.SOLID_LITERAL, 1));
+ xAxisPrimary.getTitle().setVisible(false);
+ xAxisPrimary.getTitle().getInsets().set(1, 1, 1, 1);
+ xAxisPrimary.getLabel().getInsets().set(1, 1, 1, 1);
+ xAxisPrimary.getLabel().getCaption().setFont(createChartFont());
+ xAxisPrimary.getLabel( ).getCaption( ).getFont( ).setRotation( 75 );
+ xAxisPrimary.setFormatSpecifier( JavaDateFormatSpecifierImpl.create( timestampFormat ) );
+ return xAxisPrimary;
}
public static FontDefinition createChartFont() {
@@ -378,6 +395,27 @@ public final class ChartViewerComposite extends Composite implements PaintListen
logger.log(Level.SEVERE, "Exception while rendering pie chart [" + gex.getMessage() + "]", gex);
}
}
+
+ public void chartRefresh(Calendar[] timestamps, Double[][] values, String unit, String timestampFormat)
+ {
+ if ( !isDisposed( ) )
+ {
+ final Generator gr = Generator.instance( );
+ updateDataSet( timestamps, values, unit, timestampFormat);
+
+ // Refresh
+ try
+ {
+ gr.refresh( generatedChartState );
+ }
+ catch ( ChartException ex )
+ {
+ // TODO: log the exception
+ ex.printStackTrace( );
+ }
+ redraw( );
+ }
+ }
/*
* (non-Javadoc)
diff --git a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/ClusterSummaryView.java b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/ClusterSummaryView.java
index 51b8f4da..7f5526a8 100644
--- a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/ClusterSummaryView.java
+++ b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/ClusterSummaryView.java
@@ -31,6 +31,7 @@ import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.ui.forms.events.HyperlinkAdapter;
@@ -43,6 +44,7 @@ import org.eclipse.ui.handlers.IHandlerService;
import org.eclipse.ui.part.ViewPart;
import com.gluster.storage.management.client.GlusterServersClient;
+import com.gluster.storage.management.core.constants.GlusterConstants;
import com.gluster.storage.management.core.model.Alert;
import com.gluster.storage.management.core.model.Cluster;
import com.gluster.storage.management.core.model.EntityGroup;
@@ -139,7 +141,92 @@ public class ClusterSummaryView extends ViewPart {
chartViewerComposite.setLayoutData(data);
}
- private Composite createChartLinks(Composite section, int columnCount) {
+ public abstract class ChartPeriodLinkListener extends HyperlinkAdapter {
+ protected String statsPeriod;
+ protected String unit;
+ protected int columnCount;
+
+ public String getStatsPeriod() {
+ return this.statsPeriod;
+ }
+
+ public ChartPeriodLinkListener(String statsPeriod) {
+ this.statsPeriod = statsPeriod;
+ }
+
+ public ChartPeriodLinkListener(String statsPeriod, String unit, int columnCount) {
+ this.statsPeriod = statsPeriod;
+ this.unit = unit;
+ this.columnCount = columnCount;
+ }
+
+ @Override
+ public void linkActivated(HyperlinkEvent e) {
+ super.linkActivated(e);
+ //GlusterDataModelManager.getInstance().initializeAlerts(cluster);
+ Composite section = ((Hyperlink)e.getSource()).getParent().getParent();
+ for(Control control : section.getChildren()) {
+ control.dispose();
+ }
+ List<Calendar> timestamps = new ArrayList<Calendar>();
+ List<Double> data = new ArrayList<Double>();
+ ServerStats stats = fetchStats();
+ extractChartData(stats, timestamps, data, 2);
+ createAreaChart(section, timestamps.toArray(new Calendar[0]), data.toArray(new Double[0]), unit, getTimestampFormatForPeriod(statsPeriod));
+ createChartLinks(section, columnCount, this);
+ section.layout();
+ }
+
+ public abstract ChartPeriodLinkListener getInstance(String statsPeriod);
+
+ protected abstract ServerStats fetchStats();
+ }
+
+ public class CpuChartPeriodLinkListener extends ChartPeriodLinkListener {
+ public CpuChartPeriodLinkListener(String statsPeriod) {
+ super(statsPeriod);
+ }
+
+ private CpuChartPeriodLinkListener(String statsPeriod, String unit, int columnCount) {
+ super(statsPeriod, unit, columnCount);
+ }
+
+ @Override
+ protected ServerStats fetchStats() {
+ IPreferenceStore preferenceStore = Activator.getDefault().getPreferenceStore();
+ preferenceStore.setValue(PreferenceConstants.P_CPU_CHART_PERIOD, statsPeriod);
+ return new GlusterServersClient().getAggregatedCpuStats(statsPeriod);
+ }
+
+ @Override
+ public ChartPeriodLinkListener getInstance(String statsPeriod) {
+ return new CpuChartPeriodLinkListener(statsPeriod, "%", 4);
+ }
+ }
+
+ public class NetworkChartPeriodLinkListener extends ChartPeriodLinkListener {
+ public NetworkChartPeriodLinkListener(String statsPeriod) {
+ super(statsPeriod);
+ }
+
+ private NetworkChartPeriodLinkListener(String statsPeriod, String unit, int columnCount) {
+ super(statsPeriod, unit, columnCount);
+ }
+
+ @Override
+ protected ServerStats fetchStats() {
+ IPreferenceStore preferenceStore = Activator.getDefault().getPreferenceStore();
+ preferenceStore.setValue(PreferenceConstants.P_NETWORK_CHART_PERIOD, statsPeriod);
+ return new GlusterServersClient().getAggregatedNetworkStats(statsPeriod);
+ }
+
+ @Override
+ public ChartPeriodLinkListener getInstance(String statsPeriod) {
+ return new NetworkChartPeriodLinkListener(statsPeriod, "KiB/s", 4);
+ }
+ }
+
+ private Composite createChartLinks(Composite section, int columnCount, ChartPeriodLinkListener listener) {
GridLayout layout = new org.eclipse.swt.layout.GridLayout(columnCount, false);
layout.marginBottom = 0;
layout.marginTop = 0;
@@ -150,21 +237,30 @@ public class ClusterSummaryView extends ViewPart {
data.widthHint = CHART_WIDTH;
graphComposite.setLayoutData(data);
- Label label1 = toolkit.createLabel(graphComposite, "1 day");
- Hyperlink link1 = toolkit.createHyperlink(graphComposite, "1 week", SWT.NONE);
- Hyperlink link2 = toolkit.createHyperlink(graphComposite, "1 month", SWT.NONE);
- Hyperlink link3 = toolkit.createHyperlink(graphComposite, "1 year", SWT.NONE);
+ createStatsLink(listener, graphComposite, "1 day", GlusterConstants.STATS_PERIOD_1DAY);
+ createStatsLink(listener, graphComposite, "1 week", GlusterConstants.STATS_PERIOD_1WEEK);
+ createStatsLink(listener, graphComposite, "1 month", GlusterConstants.STATS_PERIOD_1MONTH);
+ createStatsLink(listener, graphComposite, "1 year", GlusterConstants.STATS_PERIOD_1YEAR);
return graphComposite;
}
- private void createLineChart(Composite section, Calendar timestamps[], Double values[], String unit) {
- ChartViewerComposite chartViewerComposite = new ChartViewerComposite(section, SWT.NONE, timestamps, values, unit);
+ private void createStatsLink(ChartPeriodLinkListener listener, Composite parent, String label, String statsPeriod) {
+ Hyperlink link1 = toolkit.createHyperlink(parent, label, SWT.NONE);
+ link1.addHyperlinkListener(listener.getInstance(statsPeriod));
+ if(listener.getStatsPeriod().equals(statsPeriod)) {
+ link1.setEnabled(false);
+ }
+ }
+
+ private ChartViewerComposite createAreaChart(Composite section, Calendar timestamps[], Double values[], String unit, String timestampFormat) {
+ ChartViewerComposite chartViewerComposite = new ChartViewerComposite(section, SWT.NONE, timestamps, values, unit, timestampFormat);
GridData data = new GridData(SWT.FILL, SWT.FILL, false, false);
data.widthHint = CHART_WIDTH;
data.heightHint = 250;
data.verticalAlignment = SWT.CENTER;
chartViewerComposite.setLayoutData(data);
+ return chartViewerComposite;
}
private void createAlertsSection() {
@@ -249,7 +345,7 @@ public class ClusterSummaryView extends ViewPart {
parent.layout(); // IMP: lays out the form properly
}
- private void createAreaChartSection(ServerStats stats, String sectionTitle, int dataColumnIndex, String unit) {
+ private ChartViewerComposite createAreaChartSection(ServerStats stats, String sectionTitle, int dataColumnIndex, String unit, String timestampFormat, ChartPeriodLinkListener listener) {
Composite section = guiHelper.createSection(form, toolkit, sectionTitle, null, 1, false);
List<Calendar> timestamps = new ArrayList<Calendar>();
@@ -258,15 +354,15 @@ public class ClusterSummaryView extends ViewPart {
if(timestamps.size() == 0) {
toolkit.createLabel(section, "Server statistics not available!\n Please check if all services are running properly on the cluster servers.");
- return;
+ return null;
}
if (cluster.getServers().size() == 0) {
toolkit.createLabel(section, "This section will be populated after at least\none server is added to the storage cloud.");
- return;
+ return null;
}
- createLineChart(section, timestamps.toArray(new Calendar[0]), data.toArray(new Double[0]), unit);
+ ChartViewerComposite chart = createAreaChart(section, timestamps.toArray(new Calendar[0]), data.toArray(new Double[0]), unit, timestampFormat);
// Calendar[] timestamps = new Calendar[] { new CDateTime(1000l*1310468100), new CDateTime(1000l*1310468400), new CDateTime(1000l*1310468700),
// new CDateTime(1000l*1310469000), new CDateTime(1000l*1310469300), new CDateTime(1000l*1310469600), new CDateTime(1000l*1310469900),
@@ -277,12 +373,26 @@ public class ClusterSummaryView extends ViewPart {
//
// Double[] values = new Double[] { 10d, 11.23d, 17.92d, 18.69d, 78.62d, 89.11d, 92.43d, 89.31d, 57.39d, 18.46d, 10.44d, 16.28d, 13.51d, 17.53d, 12.21, 20d, 21.43d, 16.45d, 14.86d, 15.27d };
// createLineChart(section, timestamps, values, "%");
- createChartLinks(section, 4);
+ createChartLinks(section, 4, listener);
+ return chart;
}
private void createCPUUsageSection() {
+ IPreferenceStore preferenceStore = Activator.getDefault().getPreferenceStore();
+ String cpuStatsPeriod = preferenceStore.getString(PreferenceConstants.P_CPU_CHART_PERIOD);
+
// in case of CPU usage, there are three elements in usage data: user, system and total. we use total.
- createAreaChartSection(cluster.getAggregatedCpuStats(), "CPU Usage (Aggregated)", 2, "%");
+ createAreaChartSection(cluster.getAggregatedCpuStats(), "CPU Usage (Aggregated)", 2, "%", getTimestampFormatForPeriod(cpuStatsPeriod), new CpuChartPeriodLinkListener(cpuStatsPeriod));
+ }
+
+ private String getTimestampFormatForPeriod(String statsPeriod) {
+ if(statsPeriod.equals(GlusterConstants.STATS_PERIOD_1DAY)) {
+ return "HH:mm";
+ } else if (statsPeriod.equals(GlusterConstants.STATS_PERIOD_1WEEK)) {
+ return "dd-MMM HH:mm";
+ } else {
+ return "dd-MMM";
+ }
}
private void extractChartData(ServerStats stats, List<Calendar> timestamps, List<Double> data, int dataColumnIndex) {
@@ -296,8 +406,11 @@ public class ClusterSummaryView extends ViewPart {
}
private void createNetworkUsageSection() {
+ IPreferenceStore preferenceStore = Activator.getDefault().getPreferenceStore();
+ String networkStatsPeriod = preferenceStore.getString(PreferenceConstants.P_NETWORK_CHART_PERIOD);
+
// in case of network usage, there are three elements in usage data: received, transmitted and total. we use total.
- createAreaChartSection(cluster.getAggregatedNetworkStats(), "Network Usage (Aggregated)", 2, "KiB/s");
+ createAreaChartSection(cluster.getAggregatedNetworkStats(), "Network Usage (Aggregated)", 2, "KiB/s", getTimestampFormatForPeriod(networkStatsPeriod), new NetworkChartPeriodLinkListener(networkStatsPeriod));
}
private void createRunningTasksSection() {
diff --git a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/GlusterServerSummaryView.java b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/GlusterServerSummaryView.java
index dfbafa70..e7ef1648 100644
--- a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/GlusterServerSummaryView.java
+++ b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/GlusterServerSummaryView.java
@@ -115,8 +115,8 @@ public class GlusterServerSummaryView extends ViewPart {
GlusterDataModelManager.getInstance().removeClusterListener(serverChangedListener);
}
- private void createLineChart(Composite section, Calendar timestamps[], Double values[], String unit) {
- ChartViewerComposite chartViewerComposite = new ChartViewerComposite(section, SWT.NONE, timestamps, values, unit);
+ private void createAreaChart(Composite section, Calendar timestamps[], Double values[], String unit) {
+ ChartViewerComposite chartViewerComposite = new ChartViewerComposite(section, SWT.NONE, timestamps, values, unit, "HH:mm");
GridData data = new GridData(SWT.FILL, SWT.FILL, false, false);
data.widthHint = CHART_WIDTH;
data.heightHint = 250;
@@ -138,7 +138,7 @@ public class GlusterServerSummaryView extends ViewPart {
new CDateTime(1000l*1310473800) };
//Double[] values = new Double[] { 10d, 11.23d, 17.92d, 18.69d, 78.62d, 89.11d, 92.43d, 20.31d, 19.63d, 18.46d, 10.44d, 16.28d, 13.51d, 17.53d, 12.21, 20d, 40d, 10d, 90d, 40d };
Double[] values = new Double[] { 35d, 34.23d, 37.92d, 28.69d, 38.62d, 39.11d, 38.46d, 30.44d, 36.28d, 72.43d, 79.31d, 77.39d, 33.51d, 37.53d, 32.21, 30d, 31.43d, 36.45d, 34.86d, 35.27d };
- createLineChart(section, timestamps, values, "%");
+ createAreaChart(section, timestamps, values, "%");
createChartLinks(section, 4);
}
@@ -153,7 +153,7 @@ public class GlusterServerSummaryView extends ViewPart {
new CDateTime(1000l*1310473800) };
Double[] values = new Double[] { 32d, 31.23d, 27.92d, 48.69d, 58.62d, 49.11d, 72.43d, 69.31d, 87.39d, 78.46d, 60.44d, 56.28d, 33.51d, 27.53d, 12.21, 10d, 21.43d, 36.45d, 34.86d, 35.27d };
- createLineChart(section, timestamps, values, "Kib/s");
+ createAreaChart(section, timestamps, values, "Kib/s");
Composite graphComposite = createChartLinks(section, 5);
@@ -183,7 +183,7 @@ public class GlusterServerSummaryView extends ViewPart {
}
Composite section = guiHelper.createSection(form, toolkit, sectionTitle, null, 1, false);
- createLineChart(section, timestamps.toArray(new Calendar[0]), data.toArray(new Double[0]), unit);
+ createAreaChart(section, timestamps.toArray(new Calendar[0]), data.toArray(new Double[0]), unit);
// Calendar[] timestamps = new Calendar[] { new CDateTime(1000l*1310468100), new CDateTime(1000l*1310468400), new CDateTime(1000l*1310468700),
// new CDateTime(1000l*1310469000), new CDateTime(1000l*1310469300), new CDateTime(1000l*1310469600), new CDateTime(1000l*1310469900),