summaryrefslogtreecommitdiffstats
path: root/src/com.gluster.storage.management.gui
diff options
context:
space:
mode:
authorSelvasundaram <selvam@gluster.com>2011-07-27 19:17:25 +0530
committerSelvasundaram <selvam@gluster.com>2011-07-27 19:24:34 +0530
commita05f9e63f8b68fd82a38499f3aa67dc5338376f1 (patch)
tree02037284b69676fa852cc3b555b73b3cc285e046 /src/com.gluster.storage.management.gui
parentc0dd21e7d4d1ae1a0f0c120193a350a675534f86 (diff)
Alerts, Running tasks and Chart refresh on all views
Password icons removed [Bug 3265] Adding an already added server throws error message - hostname validation fix
Diffstat (limited to 'src/com.gluster.storage.management.gui')
-rw-r--r--src/com.gluster.storage.management.gui/icons/tango/32x32/change-password.pngbin2119 -> 0 bytes
-rw-r--r--src/com.gluster.storage.management.gui/plugin.xml3
-rw-r--r--src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/GlusterDataModelManager.java46
-rw-r--r--src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/actions/AddServerAction.java27
-rw-r--r--src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/actions/ServerAdditionAction.java6
-rw-r--r--src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/dialogs/ServerAdditionDialog.java2
-rw-r--r--src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/utils/GUIHelper.java12
-rw-r--r--src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/ClusterSummaryView.java55
-rw-r--r--src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/GlusterServersSummaryView.java114
-rw-r--r--src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/VolumeSummaryView.java27
-rw-r--r--src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/VolumesSummaryView.java115
11 files changed, 307 insertions, 100 deletions
diff --git a/src/com.gluster.storage.management.gui/icons/tango/32x32/change-password.png b/src/com.gluster.storage.management.gui/icons/tango/32x32/change-password.png
deleted file mode 100644
index ea8f97ae..00000000
--- a/src/com.gluster.storage.management.gui/icons/tango/32x32/change-password.png
+++ /dev/null
Binary files differ
diff --git a/src/com.gluster.storage.management.gui/plugin.xml b/src/com.gluster.storage.management.gui/plugin.xml
index 3955ed91..35ef6537 100644
--- a/src/com.gluster.storage.management.gui/plugin.xml
+++ b/src/com.gluster.storage.management.gui/plugin.xml
@@ -1084,7 +1084,6 @@
allowLabelUpdate="false"
class="com.gluster.storage.management.gui.actions.ChangePasswordAction"
definitionId="com.gluster.storage.management.gui.commands.ChangePassword"
- icon="icons/tango/32x32/change-password.png"
id="com.gluster.storage.management.gui.actions.ChangePasswordAction"
label="&amp;Change Password"
menubarPath="com.gluster.storage.management.gui.menu.edit/edit"
@@ -1099,7 +1098,6 @@
allowLabelUpdate="false"
class="com.gluster.storage.management.gui.actions.ExportSshKeysAction"
definitionId="com.gluster.storage.management.gui.commands.ExportSshKeys"
- icon="icons/tango/32x32/export-keys.png"
id="com.gluster.storage.management.gui.actions.ExportSshKeysAction"
label="&amp;Export Keys"
menubarPath="com.gluster.storage.management.gui.menu.edit/edit"
@@ -1114,7 +1112,6 @@
allowLabelUpdate="false"
class="com.gluster.storage.management.gui.actions.ImportSshKeysAction"
definitionId="com.gluster.storage.management.gui.commands.ImportSshKeys"
- icon="icons/tango/32x32/import-keys.png"
id="com.gluster.storage.management.gui.actions.ImportSshKeysAction"
label="&amp;Import Keys"
menubarPath="com.gluster.storage.management.gui.menu.edit/edit"
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 afc0e7aa..cacd987e 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
@@ -213,25 +213,16 @@ public class GlusterDataModelManager {
}
private void updateAlerts(GlusterDataModel newModel) {
- List<Alert> oldAlerts = model.getCluster().getAlerts();
- List<Alert> newAlerts = newModel.getCluster().getAlerts();
+ model.getCluster().getAlerts().clear();
- Set<Alert> addedAlerts = GlusterCoreUtil.getAddedEntities(oldAlerts, newAlerts, true);
- for(Alert alert : addedAlerts) {
- addAlert(alert);
- }
+ // generate alerts for "newModel"
+ initializeAlerts(newModel.getCluster());
- Set<Alert> removedAlerts = GlusterCoreUtil.getAddedEntities(newAlerts, oldAlerts, true);
- for(Alert alert : removedAlerts) {
- removeAlert(alert);
- }
+ // set the new alerts on "model"
+ model.getCluster().setAlerts(newModel.getCluster().getAlerts());
- Map<Alert, Alert> modifiedAlerts = GlusterCoreUtil.getModifiedEntities(oldAlerts, newAlerts);
- for(Entry<Alert, Alert> entry : modifiedAlerts.entrySet()) {
- Alert modifiedAlert = entry.getKey();
- modifiedAlert.copyFrom(entry.getValue());
- updateAlert(modifiedAlert);
- }
+ // fire event "alertsGenerated"
+ alertsGenerated();
}
private void updateTasks(GlusterDataModel newModel) {
@@ -535,8 +526,7 @@ public class GlusterDataModelManager {
cluster.setAlerts( alertsManager.getAlerts() );
//cluster.setAlerts( getDummyAlerts(cluster) );
}
-
-
+
public Volume addVolume(List<Volume> volumes, String name, Cluster cluster, VOLUME_TYPE volumeType,
TRANSPORT_TYPE transportType, VOLUME_STATUS status) {
Volume volume = new Volume(name, cluster, volumeType, transportType, status);
@@ -785,24 +775,10 @@ public class GlusterDataModelManager {
listener.taskRemoved(taskInfo);
}
}
-
- public void addAlert(Alert alert) {
- model.getCluster().addAlert(alert);
- for (ClusterListener listener : listeners) {
- listener.alertAdded(alert);
- }
- }
-
- public void removeAlert(Alert alert) {
- model.getCluster().removeAlert(alert);
- for (ClusterListener listener : listeners) {
- listener.alertRemoved(alert);
- }
- }
-
- public void updateAlert(Alert alert) {
+
+ public void alertsGenerated() {
for (ClusterListener listener : listeners) {
- listener.alertUpdated(alert);
+ listener.alertsGenerated();
}
}
diff --git a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/actions/AddServerAction.java b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/actions/AddServerAction.java
index a97e537a..37dc3b6e 100644
--- a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/actions/AddServerAction.java
+++ b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/actions/AddServerAction.java
@@ -22,7 +22,6 @@ import java.util.HashSet;
import java.util.Set;
import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.viewers.ISelection;
import org.eclipse.swt.custom.BusyIndicator;
import org.eclipse.swt.widgets.Display;
@@ -30,6 +29,7 @@ import com.gluster.storage.management.client.GlusterServersClient;
import com.gluster.storage.management.core.constants.CoreConstants;
import com.gluster.storage.management.core.model.Server;
import com.gluster.storage.management.gui.GlusterDataModelManager;
+import com.gluster.storage.management.gui.dialogs.ServerAdditionDialog;
import com.gluster.storage.management.gui.utils.GUIHelper;
public class AddServerAction extends AbstractActionDelegate {
@@ -48,6 +48,10 @@ public class AddServerAction extends AbstractActionDelegate {
Set<Server> partSuccessServers = new HashSet<Server>();
String errMsg = "";
String partErrMsg = "";
+
+ if(selectedServers.isEmpty()) {
+ addServerManually();
+ }
for (Server server : selectedServers) {
guiHelper.setStatusMessage("Adding server [" + server.getName() + "]...");
@@ -64,6 +68,17 @@ public class AddServerAction extends AbstractActionDelegate {
showStatusMessage(action.getDescription(), selectedServers, successServers, partSuccessServers, errMsg,
partErrMsg);
}
+
+ private void addServerManually() {
+ try {
+ // To open a dialog for server addition
+ ServerAdditionDialog dialog = new ServerAdditionDialog(getShell());
+ dialog.open();
+ } catch (Exception e) {
+ logger.error("Error in Manual server addition", e);
+ e.printStackTrace();
+ }
+ }
};
BusyIndicator.showWhile(Display.getDefault(), new Runnable() {
@@ -104,14 +119,4 @@ public class AddServerAction extends AbstractActionDelegate {
public void dispose() {
System.out.println("Disposing [" + this.getClass().getSimpleName() + "]");
}
-
- @Override
- public void selectionChanged(IAction action, ISelection selection) {
- Set<Server> selectedServers = GUIHelper.getInstance().getSelectedEntities(getWindow(), Server.class);
- if (selectedServers == null || selectedServers.isEmpty()) {
- action.setEnabled(false);
- } else {
- action.setEnabled(true);
- }
- }
}
diff --git a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/actions/ServerAdditionAction.java b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/actions/ServerAdditionAction.java
index 410b7bea..cb6137d2 100644
--- a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/actions/ServerAdditionAction.java
+++ b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/actions/ServerAdditionAction.java
@@ -2,13 +2,8 @@ package com.gluster.storage.management.gui.actions;
import org.apache.log4j.Logger;
import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.IWorkbenchWindowActionDelegate;
-import com.gluster.storage.management.gui.dialogs.ChangePasswordDialog;
import com.gluster.storage.management.gui.dialogs.ServerAdditionDialog;
-import com.gluster.storage.management.gui.views.pages.AbstractDisksPage;
public class ServerAdditionAction extends AbstractActionDelegate {
private static final Logger logger = Logger.getLogger(ServerAdditionAction.class);
@@ -20,7 +15,6 @@ public class ServerAdditionAction extends AbstractActionDelegate {
@Override
protected void performAction(IAction action) {
-
try {
// To open a dialog for server addition
ServerAdditionDialog dialog = new ServerAdditionDialog(getShell());
diff --git a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/dialogs/ServerAdditionDialog.java b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/dialogs/ServerAdditionDialog.java
index 671b983c..01341a5a 100644
--- a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/dialogs/ServerAdditionDialog.java
+++ b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/dialogs/ServerAdditionDialog.java
@@ -168,7 +168,7 @@ public class ServerAdditionDialog extends Dialog {
public Boolean serverExists(String serverName) {
List<GlusterServer> servers = GlusterDataModelManager.getInstance().getModel().getCluster().getServers();
for (GlusterServer server : servers) {
- if (server.getName().equals(serverName)) {
+ if (server.getName().equalsIgnoreCase(serverName)) {
return false;
}
}
diff --git a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/utils/GUIHelper.java b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/utils/GUIHelper.java
index d4c78761..af8eba65 100644
--- a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/utils/GUIHelper.java
+++ b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/utils/GUIHelper.java
@@ -477,4 +477,16 @@ public class GUIHelper {
public String getDiskToolTip(Disk disk) {
return disk.getQualifiedName() + " - " + disk.getDescription();
}
+
+ public void clearSection(Composite section) {
+ if (section.isDisposed()) {
+ return;
+ }
+ for(Control control : section.getChildren()) {
+ if(! control.isDisposed()) {
+ control.dispose();
+ }
+ }
+ section.layout(true);
+ }
}
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 b67cca30..e84957ec 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
@@ -82,6 +82,8 @@ public class ClusterSummaryView extends ViewPart {
private ClusterListener clusterListener;
private static final IPreferenceStore preferenceStore = Activator.getDefault().getPreferenceStore();
private static final int CHART_WIDTH = 350;
+ private Composite alertsSection;
+ private Composite tasksSection;
/*
* (non-Javadoc)
@@ -102,6 +104,41 @@ public class ClusterSummaryView extends ViewPart {
super.aggregatedStatsChanged();
refreshCharts();
}
+
+ @Override
+ public void alertsGenerated() {
+ super.alertsGenerated();
+ guiHelper.clearSection(alertsSection);
+ populateAlerts();
+ alertsSection.layout();
+ }
+
+ @Override
+ public void taskAdded(TaskInfo taskInfo) {
+ super.taskAdded(taskInfo);
+ super.alertsGenerated();
+ guiHelper.clearSection(tasksSection);
+ populateTasksSection();
+ tasksSection.layout();
+ }
+
+ @Override
+ public void taskRemoved(TaskInfo taskInfo) {
+ super.taskRemoved(taskInfo);
+ super.alertsGenerated();
+ guiHelper.clearSection(tasksSection);
+ populateTasksSection();
+ tasksSection.layout();
+ }
+
+ @Override
+ public void taskUpdated(TaskInfo taskInfo) {
+ super.taskUpdated(taskInfo);
+ super.alertsGenerated();
+ guiHelper.clearSection(tasksSection);
+ populateTasksSection();
+ tasksSection.layout();
+ }
};
GlusterDataModelManager.getInstance().addClusterListener(clusterListener);
}
@@ -290,14 +327,17 @@ public class ClusterSummaryView extends ViewPart {
}
private void createAlertsSection() {
- Composite section = guiHelper.createSection(form, toolkit, "Alerts", null, 1, false);
+ alertsSection = guiHelper.createSection(form, toolkit, "Alerts", null, 1, false);
+ populateAlerts();
+ }
+
+ private void populateAlerts() {
List<Alert> alerts = cluster.getAlerts();
-
for (Alert alert : alerts) {
- addAlertLabel(section, alert);
+ addAlertLabel(alertsSection, alert);
}
}
-
+
private void addAlertLabel(Composite section, Alert alert) {
CLabel lblAlert = new CLabel(section, SWT.FLAT);
Image alertImage = null;
@@ -446,10 +486,13 @@ public class ClusterSummaryView extends ViewPart {
}
private void createRunningTasksSection() {
- Composite section = guiHelper.createSection(form, toolkit, "Running Tasks", null, 1, false);
+ tasksSection = guiHelper.createSection(form, toolkit, "Running Tasks", null, 1, false);
+ populateTasksSection();
+ }
+ private void populateTasksSection() {
for (TaskInfo taskInfo : cluster.getTaskInfoList()) {
- addTaskLabel(section, taskInfo);
+ addTaskLabel(tasksSection, taskInfo);
}
}
diff --git a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/GlusterServersSummaryView.java b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/GlusterServersSummaryView.java
index dab2f178..f2cdaab3 100644
--- a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/GlusterServersSummaryView.java
+++ b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/GlusterServersSummaryView.java
@@ -34,7 +34,10 @@ import org.eclipse.ui.part.ViewPart;
import com.gluster.storage.management.core.model.Alert;
import com.gluster.storage.management.core.model.Alert.ALERT_TYPES;
+import com.gluster.storage.management.core.model.ClusterListener;
+import com.gluster.storage.management.core.model.DefaultClusterListener;
import com.gluster.storage.management.core.model.EntityGroup;
+import com.gluster.storage.management.core.model.Event;
import com.gluster.storage.management.core.model.GlusterServer;
import com.gluster.storage.management.core.model.Server.SERVER_STATUS;
import com.gluster.storage.management.core.model.TaskInfo;
@@ -52,11 +55,16 @@ public class GlusterServersSummaryView extends ViewPart {
private static final GUIHelper guiHelper = GUIHelper.getInstance();
private final FormToolkit toolkit = new FormToolkit(Display.getCurrent());
private ScrolledForm form;
+ private ClusterListener clusterListener;
private EntityGroup<GlusterServer> servers;
+ private Composite alertsSection;
+ private Composite serversAvailabilitySection;
+ private Composite tasksSection;
/* (non-Javadoc)
* @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
*/
+ @SuppressWarnings("unchecked")
@Override
public void createPartControl(Composite parent) {
if (servers == null) {
@@ -64,6 +72,74 @@ public class GlusterServersSummaryView extends ViewPart {
}
setPartName("Summary");
createSections(parent);
+
+ clusterListener = new DefaultClusterListener() {
+ @Override
+ public void serverAdded(GlusterServer server) {
+ super.serverAdded(server);
+ guiHelper.clearSection(serversAvailabilitySection);
+ populateAvailabilitySection();
+ serversAvailabilitySection.layout();
+ }
+
+ @Override
+ public void serverRemoved(GlusterServer server) {
+ super.serverRemoved(server);
+ guiHelper.clearSection(serversAvailabilitySection);
+ populateAvailabilitySection();
+ serversAvailabilitySection.layout();
+ }
+
+ @Override
+ public void serverChanged(GlusterServer server, Event event) {
+ super.serverChanged(server, event);
+ guiHelper.clearSection(serversAvailabilitySection);
+ populateAvailabilitySection();
+ serversAvailabilitySection.layout();
+ }
+
+ @Override
+ public void alertsGenerated() {
+ super.alertsGenerated();
+ guiHelper.clearSection(alertsSection);
+ populateAlertSection();
+ alertsSection.layout();
+ }
+
+ @Override
+ public void taskAdded(TaskInfo taskInfo) {
+ super.taskAdded(taskInfo);
+ super.alertsGenerated();
+ guiHelper.clearSection(tasksSection);
+ populateTasksSection();
+ tasksSection.layout();
+ }
+
+ @Override
+ public void taskRemoved(TaskInfo taskInfo) {
+ super.taskRemoved(taskInfo);
+ super.alertsGenerated();
+ guiHelper.clearSection(tasksSection);
+ populateTasksSection();
+ tasksSection.layout();
+ }
+
+ @Override
+ public void taskUpdated(TaskInfo taskInfo) {
+ super.taskUpdated(taskInfo);
+ super.alertsGenerated();
+ guiHelper.clearSection(tasksSection);
+ populateTasksSection();
+ tasksSection.layout();
+ }
+ };
+ GlusterDataModelManager.getInstance().addClusterListener(clusterListener);
+ }
+
+ @Override
+ public void dispose() {
+ super.dispose();
+ GlusterDataModelManager.getInstance().removeClusterListener(clusterListener);
}
/**
@@ -80,16 +156,21 @@ public class GlusterServersSummaryView extends ViewPart {
}
private void createSummarySection() {
- Composite section = guiHelper.createSection(form, toolkit, "Availability", null, 2, false);
- if(servers.getEntities().size() == 0) {
- toolkit.createLabel(section, "This section will be populated after at least\none server is added to the storage cloud.");
+ serversAvailabilitySection = guiHelper.createSection(form, toolkit, "Availability", null, 2, false);
+ populateAvailabilitySection();
+ }
+
+ private void populateAvailabilitySection() {
+ if (servers.getEntities().size() == 0) {
+ toolkit.createLabel(serversAvailabilitySection,
+ "This section will be populated after at least\none server is added to the storage cloud.");
return;
}
Double[] values = new Double[] { Double.valueOf(getServerCountByStatus(servers, SERVER_STATUS.ONLINE)),
Double.valueOf(getServerCountByStatus(servers, SERVER_STATUS.OFFLINE)) };
- createStatusChart(section, values);
- }
+ createStatusChart(serversAvailabilitySection, values);
+ }
private int getServerCountByStatus(EntityGroup<GlusterServer> servers, SERVER_STATUS status) {
int count = 0;
@@ -112,12 +193,16 @@ public class GlusterServersSummaryView extends ViewPart {
}
private void createAlertsSection() {
- Composite section = guiHelper.createSection(form, toolkit, "Alerts", null, 1, false);
+ alertsSection = guiHelper.createSection(form, toolkit, "Alerts", null, 1, false);
+ populateAlertSection();
+ }
+
+ private void populateAlertSection() {
List<Alert> alerts = GlusterDataModelManager.getInstance().getModel().getCluster().getAlerts();
for (Alert alert : alerts) {
if (alert.getType() != ALERT_TYPES.OFFLINE_VOLUME_BRICKS_ALERT) {
- addAlertLabel(section, alert);
+ addAlertLabel(alertsSection, alert);
}
}
}
@@ -147,18 +232,21 @@ public class GlusterServersSummaryView extends ViewPart {
lblAlert.redraw();
}
-
-
private void createRunningTasksSection() {
- Composite section = guiHelper.createSection(form, toolkit, "Running Tasks", null, 1, false);
+ tasksSection = guiHelper.createSection(form, toolkit, "Running Tasks", null, 1, false);
+ populateTasksSection();
+
+ }
+ private void populateTasksSection() {
for (TaskInfo taskInfo : GlusterDataModelManager.getInstance().getModel().getCluster().getTaskInfoList()) {
- if (taskInfo.getType() != TASK_TYPE.VOLUME_REBALANCE && taskInfo.getType() != TASK_TYPE.BRICK_MIGRATE) { // Exclude volume related tasks
- addTaskLabel(section, taskInfo);
+ // Exclude volume related tasks
+ if (taskInfo.getType() != TASK_TYPE.VOLUME_REBALANCE && taskInfo.getType() != TASK_TYPE.BRICK_MIGRATE) {
+ addTaskLabel(tasksSection, taskInfo);
}
}
}
-
+
private void addTaskLabel(Composite section, TaskInfo taskInfo) {
CLabel lblAlert = new CLabel(section, SWT.NONE);
lblAlert.setText(taskInfo.getDescription());
diff --git a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/VolumeSummaryView.java b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/VolumeSummaryView.java
index 91a4e9b2..a3d8aca7 100644
--- a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/VolumeSummaryView.java
+++ b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/VolumeSummaryView.java
@@ -14,9 +14,6 @@ import org.eclipse.swt.events.KeyAdapter;
import org.eclipse.swt.events.KeyEvent;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
-
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.layout.FillLayout;
@@ -47,9 +44,9 @@ import com.gluster.storage.management.core.model.Event;
import com.gluster.storage.management.core.model.GlusterServer;
import com.gluster.storage.management.core.model.Partition;
import com.gluster.storage.management.core.model.Server.SERVER_STATUS;
+import com.gluster.storage.management.core.model.TaskInfo;
import com.gluster.storage.management.core.model.Volume;
import com.gluster.storage.management.core.model.Volume.VOLUME_TYPE;
-import com.gluster.storage.management.core.model.VolumeOption;
import com.gluster.storage.management.core.utils.NumberUtil;
import com.gluster.storage.management.core.utils.StringUtil;
import com.gluster.storage.management.core.utils.ValidationUtil;
@@ -81,6 +78,7 @@ public class VolumeSummaryView extends ViewPart {
private Label numberOfBricks;
private Label totalDiskSpace;
+ private Composite alertsSection;
@Override
public void createPartControl(Composite parent) {
@@ -103,6 +101,14 @@ public class VolumeSummaryView extends ViewPart {
updateBrickChanges(volume);
toolbarManager.updateToolbar(volume);
}
+
+ @Override
+ public void alertsGenerated() {
+ super.alertsGenerated();
+ guiHelper.clearSection(alertsSection);
+ populateAlertSection();
+ alertsSection.layout();
+ }
};
GlusterDataModelManager.getInstance().addClusterListener(volumeChangedListener);
}
@@ -124,13 +130,17 @@ public class VolumeSummaryView extends ViewPart {
}
private void createVolumeAlertsSection() {
- Composite section = guiHelper.createSection(form, toolkit, "Alerts", null, 1, false);
+ alertsSection = guiHelper.createSection(form, toolkit, "Alerts", null, 1, false);
+ populateAlertSection();
+ }
+
+ private void populateAlertSection() {
List<Alert> alerts = GlusterDataModelManager.getInstance().getModel().getCluster().getAlerts();
for (int i = 0; i < alerts.size(); i++) {
if (alerts.get(i).getType() == Alert.ALERT_TYPES.OFFLINE_VOLUME_BRICKS_ALERT
&& alerts.get(i).getReference().split(":")[0].trim().equals(volume.getName())) {
- addAlertLabel(section, alerts.get(i));
+ addAlertLabel(alertsSection, alerts.get(i));
}
}
}
@@ -156,9 +166,8 @@ public class VolumeSummaryView extends ViewPart {
String glusterFsMountInfo = "mount -t glusterfs " + firstOnlineServer + ":/" + volume.getName()
+ " <mount-point>";
nfsMountInfo = "mount -t nfs " + firstOnlineServer + ":/" + volume.getName() + " <mount-point>";
- String info = "Server can be any server name in the storage cloud eg. <" + onlineServers + ">"; // TODO: if more
- // than 10
- // servers...
+ // TODO: if more than 10 servers...
+ String info = "Server can be any server name in the storage cloud eg. <" + onlineServers + ">";
Composite section = guiHelper.createSection(form, toolkit, "Mounting Information", null, 3, false);
diff --git a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/VolumesSummaryView.java b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/VolumesSummaryView.java
index 3b5647d2..4a0a9d8c 100644
--- a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/VolumesSummaryView.java
+++ b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/VolumesSummaryView.java
@@ -33,16 +33,18 @@ import org.eclipse.ui.part.ViewPart;
import com.gluster.storage.management.core.model.Alert;
import com.gluster.storage.management.core.model.Cluster;
+import com.gluster.storage.management.core.model.ClusterListener;
+import com.gluster.storage.management.core.model.DefaultClusterListener;
import com.gluster.storage.management.core.model.EntityGroup;
+import com.gluster.storage.management.core.model.Event;
import com.gluster.storage.management.core.model.TaskInfo;
import com.gluster.storage.management.core.model.TaskInfo.TASK_TYPE;
import com.gluster.storage.management.core.model.Volume;
import com.gluster.storage.management.core.model.Volume.VOLUME_STATUS;
import com.gluster.storage.management.gui.GlusterDataModelManager;
import com.gluster.storage.management.gui.IImageKeys;
-import com.gluster.storage.management.gui.utils.ChartViewerComposite.CHART_TYPE;
-import com.gluster.storage.management.gui.utils.GUIHelper;
import com.gluster.storage.management.gui.utils.ChartViewerComposite;
+import com.gluster.storage.management.gui.utils.GUIHelper;
/**
*
@@ -54,11 +56,15 @@ public class VolumesSummaryView extends ViewPart {
private ScrolledForm form;
private EntityGroup<Volume> volumes;
private Cluster cluster = GlusterDataModelManager.getInstance().getModel().getCluster();
+ private ClusterListener clusterListener;
private static final String ALERTS = "Alerts";
private static final String RUNNING_TASKS = "Running Tasks";
private static final String VOLUMES_SUMMARY = "Volumes - Summary";
private static final String AVAILABILITY = "Availability";
+ private Composite alertsSection;
+ private Composite tasksSection;
+ private Composite summarySection;
/*
* (non-Javadoc)
@@ -79,6 +85,74 @@ public class VolumesSummaryView extends ViewPart {
setPartName("Summary");
createSections(parent);
+
+ clusterListener = new DefaultClusterListener() {
+ @Override
+ public void volumeCreated(Volume volume) {
+ super.volumeCreated(volume);
+ guiHelper.clearSection(summarySection);
+ populateSummarySection();
+ summarySection.layout();
+ }
+
+ @Override
+ public void volumeDeleted(Volume volume) {
+ super.volumeDeleted(volume);
+ guiHelper.clearSection(summarySection);
+ populateSummarySection();
+ summarySection.layout();
+ }
+
+ @Override
+ public void volumeChanged(Volume volume, Event event) {
+ super.volumeChanged(volume, event);
+ guiHelper.clearSection(summarySection);
+ populateSummarySection();
+ summarySection.layout();
+ }
+
+ @Override
+ public void alertsGenerated() {
+ super.alertsGenerated();
+ guiHelper.clearSection(alertsSection);
+ populateAlertSection();
+ alertsSection.layout();
+ }
+
+ @Override
+ public void taskAdded(TaskInfo taskInfo) {
+ super.taskAdded(taskInfo);
+ super.alertsGenerated();
+ guiHelper.clearSection(tasksSection);
+ populateTasks();
+ tasksSection.layout();
+ }
+
+ @Override
+ public void taskRemoved(TaskInfo taskInfo) {
+ super.taskRemoved(taskInfo);
+ super.alertsGenerated();
+ guiHelper.clearSection(tasksSection);
+ populateTasks();
+ tasksSection.layout();
+ }
+
+ @Override
+ public void taskUpdated(TaskInfo taskInfo) {
+ super.taskUpdated(taskInfo);
+ super.alertsGenerated();
+ guiHelper.clearSection(tasksSection);
+ populateTasks();
+ tasksSection.layout();
+ }
+ };
+ GlusterDataModelManager.getInstance().addClusterListener(clusterListener);
+ }
+
+ @Override
+ public void dispose() {
+ super.dispose();
+ GlusterDataModelManager.getInstance().removeClusterListener(clusterListener);
}
private void createSections(Composite parent) {
@@ -91,29 +165,35 @@ public class VolumesSummaryView extends ViewPart {
}
private void createAlertsSection() {
- Composite section = guiHelper.createSection(form, toolkit, ALERTS, null, 1, false);
+ alertsSection = guiHelper.createSection(form, toolkit, ALERTS, null, 1, false);
+ populateAlertSection();
+ }
+ private void populateAlertSection() {
for (Alert alert : cluster.getAlerts()) {
- addAlertLabel(section, alert);
+ if (alert.getType() == Alert.ALERT_TYPES.OFFLINE_VOLUME_BRICKS_ALERT) {
+ addAlertLabel(alertsSection, alert);
+ }
}
}
private void addAlertLabel(Composite section, Alert alert) {
- if (alert.getType() == Alert.ALERT_TYPES.OFFLINE_VOLUME_BRICKS_ALERT) {
- CLabel lblAlert = new CLabel(section, SWT.NONE);
- lblAlert.setImage((alert.getType() == Alert.ALERT_TYPES.DISK_USAGE_ALERT) ? guiHelper
- .getImage(IImageKeys.LOW_DISK_SPACE_22x22) : guiHelper.getImage(IImageKeys.BRICK_OFFLINE_22x22));
- lblAlert.setText(alert.getMessage());
- lblAlert.redraw();
- }
+ CLabel lblAlert = new CLabel(section, SWT.NONE);
+ lblAlert.setImage((alert.getType() == Alert.ALERT_TYPES.DISK_USAGE_ALERT) ? guiHelper
+ .getImage(IImageKeys.LOW_DISK_SPACE_22x22) : guiHelper.getImage(IImageKeys.BRICK_OFFLINE_22x22));
+ lblAlert.setText(alert.getMessage());
+ lblAlert.redraw();
}
private void createRunningTasksSection() {
- Composite section = guiHelper.createSection(form, toolkit, RUNNING_TASKS, null, 1, false);
+ tasksSection = guiHelper.createSection(form, toolkit, RUNNING_TASKS, null, 1, false);
+ populateTasks();
+ }
+ private void populateTasks() {
for (TaskInfo taskInfo : cluster.getTaskInfoList()) {
if (taskInfo.getType() == TASK_TYPE.BRICK_MIGRATE || taskInfo.getType() == TASK_TYPE.VOLUME_REBALANCE)
- addTaskLabel(section, taskInfo);
+ addTaskLabel(tasksSection, taskInfo);
}
}
@@ -133,17 +213,20 @@ public class VolumesSummaryView extends ViewPart {
}
private void createSummarySection() {
- Composite section = guiHelper.createSection(form, toolkit, AVAILABILITY, null, 2, false);
+ summarySection = guiHelper.createSection(form, toolkit, AVAILABILITY, null, 2, false);
+ populateSummarySection();
+ }
+ private void populateSummarySection() {
if(volumes.getEntities().size() == 0) {
- toolkit.createLabel(section,
+ toolkit.createLabel(summarySection,
"This section will be populated after at least\none volume is created the storage cloud.");
return;
}
Double[] values = new Double[] { Double.valueOf(getVolumeCountByStatus(volumes, VOLUME_STATUS.ONLINE)),
Double.valueOf(getVolumeCountByStatus(volumes, VOLUME_STATUS.OFFLINE)) };
- createStatusChart(toolkit, section, values);
+ createStatusChart(toolkit, summarySection, values);
}
private int getVolumeCountByStatus(EntityGroup<Volume> volumes, VOLUME_STATUS status) {