summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShireesh Anjal <shireesh@gluster.com>2011-08-17 21:44:38 +0530
committerShireesh Anjal <shireesh@gluster.com>2011-08-17 21:45:43 +0530
commitcde02c615df96364a9efdcd8b03c2eb9651429ca (patch)
tree63adee27c1ed1804f1d5738f36c86fa4b38a3f65
parent73df68498c77c5b10e920392607c0eedf84245f4 (diff)
Modified to show progress dialog on performing volume start/stop on multiple volumes, and while loading the gluster server summary view.
-rw-r--r--src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/ConsoleConstants.java1
-rw-r--r--src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/AbstractMonitoredActionDelegate.java59
-rw-r--r--src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/StartVolumeAction.java98
-rw-r--r--src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/StopVolumeAction.java108
-rw-r--r--src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/utils/GUIHelper.java2
-rw-r--r--src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/GlusterServerSummaryView.java41
6 files changed, 207 insertions, 102 deletions
diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/ConsoleConstants.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/ConsoleConstants.java
index 9dce2539..47293228 100644
--- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/ConsoleConstants.java
+++ b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/ConsoleConstants.java
@@ -22,5 +22,6 @@ package com.gluster.storage.management.console;
*
*/
public class ConsoleConstants {
+ public static final String CONSOLE_TITLE = "Gluster Management Console";
public static final String TERMINAL_VIEW_ID = "org.eclipse.tm.terminal.view.TerminalView";
}
diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/AbstractMonitoredActionDelegate.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/AbstractMonitoredActionDelegate.java
new file mode 100644
index 00000000..bcbba8c8
--- /dev/null
+++ b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/AbstractMonitoredActionDelegate.java
@@ -0,0 +1,59 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Gluster, Inc. <http://www.gluster.com>
+ * This file is part of Gluster Management Console.
+ *
+ * Gluster Management Console is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Affero General Public License as published
+ * by the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Gluster Management Console is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *******************************************************************************/
+package com.gluster.storage.management.console.actions;
+
+import java.lang.reflect.InvocationTargetException;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.dialogs.ProgressMonitorDialog;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+
+import com.gluster.storage.management.console.ConsoleConstants;
+import com.gluster.storage.management.console.utils.GlusterLogger;
+
+/**
+ * Any action that can potentially run for a long time, and supports monitoring and progress dialog should extend from
+ * this class
+ */
+public abstract class AbstractMonitoredActionDelegate extends AbstractActionDelegate {
+ private GlusterLogger logger = GlusterLogger.getInstance();
+
+ /* (non-Javadoc)
+ * @see com.gluster.storage.management.console.actions.AbstractActionDelegate#performAction(org.eclipse.jface.action.IAction)
+ */
+ @Override
+ protected void performAction(final IAction action) {
+ try {
+ new ProgressMonitorDialog(getShell()).run(false, false, new IRunnableWithProgress() {
+
+ @Override
+ public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
+ performAction(action, monitor);
+ }
+ });
+ } catch (Exception e) {
+ String errMsg = "Exception while performing action [" + action.getDescription() + "] : [" + e.getMessage() + "]";
+ logger.error(errMsg, e);
+ showErrorDialog(ConsoleConstants.CONSOLE_TITLE, errMsg);
+ }
+ }
+
+ abstract void performAction(IAction action, IProgressMonitor monitor);
+}
diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/StartVolumeAction.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/StartVolumeAction.java
index e3324a12..b0c9a72c 100644
--- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/StartVolumeAction.java
+++ b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/StartVolumeAction.java
@@ -22,6 +22,7 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Set;
+import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.swt.custom.BusyIndicator;
@@ -34,7 +35,7 @@ import com.gluster.storage.management.core.constants.CoreConstants;
import com.gluster.storage.management.core.model.Volume;
import com.gluster.storage.management.core.model.Volume.VOLUME_STATUS;
-public class StartVolumeAction extends AbstractActionDelegate {
+public class StartVolumeAction extends AbstractMonitoredActionDelegate {
//private Volume volume;
private GlusterDataModelManager modelManager = GlusterDataModelManager.getInstance();
private List<Volume> selectedVolumes = new ArrayList<Volume>();
@@ -43,7 +44,7 @@ public class StartVolumeAction extends AbstractActionDelegate {
private GUIHelper guiHelper = GUIHelper.getInstance();
@Override
- protected void performAction(IAction action) {
+ protected void performAction(IAction action, IProgressMonitor monitor) {
final String actionDesc = action.getDescription();
collectVolumeNames();
@@ -52,54 +53,59 @@ public class StartVolumeAction extends AbstractActionDelegate {
showWarningDialog(actionDesc, "Volumes " + selectedVolumeNames + " already started!");
return; // Volume already started. Don't do anything.
}
- BusyIndicator.showWhile(Display.getDefault(), new Runnable() {
- @Override
- public void run() {
- VolumesClient vc = new VolumesClient();
- Volume newVolume = new Volume();
- List<String> startedVolumes = new ArrayList<String>();
- List<String> failedVolumes = new ArrayList<String>();
- String errorMessage = "";
+
+ VolumesClient vc = new VolumesClient();
+ Volume newVolume = new Volume();
+ List<String> startedVolumes = new ArrayList<String>();
+ List<String> failedVolumes = new ArrayList<String>();
+ String errorMessage = "";
- for (Volume volume : selectedVolumes.toArray(new Volume[0])) {
- if (volume.getStatus() == VOLUME_STATUS.ONLINE) {
- continue; // skip if already started
- }
- try {
- guiHelper.setStatusMessage("Starting volume [" + volume.getName() + "]");
- vc.startVolume(volume.getName());
- startedVolumes.add(volume.getName());
- } catch (Exception e) {
- failedVolumes.add(volume.getName());
- // If any post volume start activity failed, update the volume status
- if (vc.getVolume(volume.getName()).getStatus() == VOLUME_STATUS.ONLINE) {
- modelManager.updateVolumeStatus(volume, VOLUME_STATUS.ONLINE);
- }
- errorMessage += e.getMessage();
- }
- // Update the model by fetching latest volume info (NOT JUST STATUS)
- try {
- newVolume = vc.getVolume(volume.getName());
- modelManager.volumeChanged(volume, newVolume);
- } catch (Exception e) {
- errorMessage += "Updating volume info failed on UI. [" + e.getMessage() + "]";
- }
+ monitor.beginTask("Starting Selected Volumes...", selectedVolumes.size());
+ for (Volume volume : selectedVolumes.toArray(new Volume[0])) {
+ if(monitor.isCanceled()) {
+ break;
+ }
+ if (volume.getStatus() == VOLUME_STATUS.ONLINE) {
+ monitor.worked(1);
+ continue; // skip if already started
+ }
+ try {
+ String message = "Starting volume [" + volume.getName() + "]";
+ guiHelper.setStatusMessage(message);
+ monitor.setTaskName(message);
+ vc.startVolume(volume.getName());
+ startedVolumes.add(volume.getName());
+ } catch (Exception e) {
+ failedVolumes.add(volume.getName());
+ // If any post volume start activity failed, update the volume status
+ if (vc.getVolume(volume.getName()).getStatus() == VOLUME_STATUS.ONLINE) {
+ modelManager.updateVolumeStatus(volume, VOLUME_STATUS.ONLINE);
}
+ errorMessage += e.getMessage();
+ }
+ // Update the model by fetching latest volume info (NOT JUST STATUS)
+ try {
+ newVolume = vc.getVolume(volume.getName());
+ modelManager.volumeChanged(volume, newVolume);
+ } catch (Exception e) {
+ errorMessage += "Updating volume info failed on UI. [" + e.getMessage() + "]";
+ }
+ monitor.worked(1);
+ }
+ monitor.done();
- // Display the success or failure info
- if (startedVolumes.size() == 0) { // No volume(s) started successfully
- showErrorDialog(actionDesc, "Following volumes " + failedVolumes + " could not be start!"
- + CoreConstants.NEWLINE + "Error: [" + errorMessage + "]");
- } else {
- String info = "Volumes " + startedVolumes + " started successfully!";
- if (errorMessage != "") {
- info += CoreConstants.NEWLINE + CoreConstants.NEWLINE + "Volumes " + failedVolumes
- + " failed to start! [" + errorMessage + "]";
- }
- showInfoDialog(actionDesc, info);
- }
+ // Display the success or failure info
+ if (startedVolumes.size() == 0) { // No volume(s) started successfully
+ showErrorDialog(actionDesc, "Following volumes " + failedVolumes + " could not be start!"
+ + CoreConstants.NEWLINE + "Error: [" + errorMessage + "]");
+ } else {
+ String info = "Volumes " + startedVolumes + " started successfully!";
+ if (errorMessage != "") {
+ info += CoreConstants.NEWLINE + CoreConstants.NEWLINE + "Volumes " + failedVolumes
+ + " failed to start! [" + errorMessage + "]";
}
- });
+ showInfoDialog(actionDesc, info);
+ }
guiHelper.clearStatusMessage();
}
diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/StopVolumeAction.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/StopVolumeAction.java
index 974534c5..a449b08a 100644
--- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/StopVolumeAction.java
+++ b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/StopVolumeAction.java
@@ -22,6 +22,7 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Set;
+import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.ISelection;
@@ -36,7 +37,7 @@ import com.gluster.storage.management.core.constants.CoreConstants;
import com.gluster.storage.management.core.model.Volume;
import com.gluster.storage.management.core.model.Volume.VOLUME_STATUS;
-public class StopVolumeAction extends AbstractActionDelegate {
+public class StopVolumeAction extends AbstractMonitoredActionDelegate {
private GlusterDataModelManager modelManager = GlusterDataModelManager.getInstance();
private List<Volume> selectedVolumes = new ArrayList<Volume>();
private List<String> selectedVolumeNames = new ArrayList<String>();
@@ -44,7 +45,7 @@ public class StopVolumeAction extends AbstractActionDelegate {
private GUIHelper guiHelper = GUIHelper.getInstance();
@Override
- protected void performAction(final IAction action) {
+ protected void performAction(final IAction action, IProgressMonitor monitor) {
final String actionDesc = action.getDescription();
collectVolumeNames();
@@ -63,57 +64,62 @@ public class StopVolumeAction extends AbstractActionDelegate {
return;
}
-
- BusyIndicator.showWhile(Display.getDefault(), new Runnable() {
- @Override
- public void run() {
- VolumesClient vc = new VolumesClient();
- List<String> stoppedVolumes = new ArrayList<String>();
- List<String> failedVolumes = new ArrayList<String>();
- String errorMessage = "";
-
- Volume newVolume = new Volume();
-
- for (Volume volume : selectedVolumes.toArray(new Volume[0])) {
- if (volume.getStatus() == VOLUME_STATUS.OFFLINE) {
- continue; // skip if already stopped
- }
- try {
- guiHelper.setStatusMessage("Stopping volume [" + volume.getName() + "]");
- vc.stopVolume(volume.getName());
- // modelManager.updateVolumeStatus(volume, VOLUME_STATUS.OFFLINE);
- stoppedVolumes.add(volume.getName());
- } catch (Exception e) {
- failedVolumes.add(volume.getName());
- // If any post volume stop activity failed, update the volume status
- if (vc.getVolume(volume.getName()).getStatus() == VOLUME_STATUS.OFFLINE) {
- modelManager.updateVolumeStatus(volume, VOLUME_STATUS.OFFLINE);
- }
- errorMessage += e.getMessage();
- }
-
- // Update the model by fetching latest volume info (NOT JUST STATUS)
- try {
- newVolume = vc.getVolume(volume.getName());
- modelManager.volumeChanged(volume, newVolume);
- } catch (Exception e) {
- errorMessage += "Failed to update volume info on UI. [" + e.getMessage() + "]";
- }
- }
- // Display the success or failure info
- if (stoppedVolumes.size() == 0) { // No volume(s) stopped successfully
- showErrorDialog(actionDesc, "Volumes " + failedVolumes + " could not be stopped! "
- + CoreConstants.NEWLINE + "Error: [" + errorMessage + "]");
- } else {
- String info = "Volumes " + stoppedVolumes + " stopped successfully!";
- if (errorMessage != "") {
- info += CoreConstants.NEWLINE + CoreConstants.NEWLINE + "Volumes " + failedVolumes
- + " failed to stop! [" + errorMessage + "]";
- }
- showInfoDialog(actionDesc, info);
+ VolumesClient vc = new VolumesClient();
+ List<String> stoppedVolumes = new ArrayList<String>();
+ List<String> failedVolumes = new ArrayList<String>();
+ String errorMessage = "";
+
+ Volume newVolume = new Volume();
+
+ monitor.beginTask("Stopping Selected Volumes...", selectedVolumes.size());
+ for (Volume volume : selectedVolumes.toArray(new Volume[0])) {
+ if(monitor.isCanceled()) {
+ break;
+ }
+
+ if (volume.getStatus() == VOLUME_STATUS.OFFLINE) {
+ monitor.worked(1);
+ continue; // skip if already stopped
+ }
+ try {
+ String message = "Stopping volume [" + volume.getName() + "]";
+ guiHelper.setStatusMessage(message);
+ monitor.setTaskName(message);
+ vc.stopVolume(volume.getName());
+ // modelManager.updateVolumeStatus(volume, VOLUME_STATUS.OFFLINE);
+ stoppedVolumes.add(volume.getName());
+ } catch (Exception e) {
+ failedVolumes.add(volume.getName());
+ // If any post volume stop activity failed, update the volume status
+ if (vc.getVolume(volume.getName()).getStatus() == VOLUME_STATUS.OFFLINE) {
+ modelManager.updateVolumeStatus(volume, VOLUME_STATUS.OFFLINE);
}
+ errorMessage += e.getMessage();
}
- });
+
+ // Update the model by fetching latest volume info (NOT JUST STATUS)
+ try {
+ newVolume = vc.getVolume(volume.getName());
+ modelManager.volumeChanged(volume, newVolume);
+ } catch (Exception e) {
+ errorMessage += "Failed to update volume info on UI. [" + e.getMessage() + "]";
+ }
+ monitor.worked(1);
+ }
+ monitor.done();
+
+ // Display the success or failure info
+ if (stoppedVolumes.size() == 0) { // No volume(s) stopped successfully
+ showErrorDialog(actionDesc, "Volumes " + failedVolumes + " could not be stopped! " + CoreConstants.NEWLINE
+ + "Error: [" + errorMessage + "]");
+ } else {
+ String info = "Volumes " + stoppedVolumes + " stopped successfully!";
+ if (errorMessage != "") {
+ info += CoreConstants.NEWLINE + CoreConstants.NEWLINE + "Volumes " + failedVolumes
+ + " failed to stop! [" + errorMessage + "]";
+ }
+ showInfoDialog(actionDesc, info);
+ }
guiHelper.clearStatusMessage();
}
diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/utils/GUIHelper.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/utils/GUIHelper.java
index f46f9ddf..ab846e74 100644
--- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/utils/GUIHelper.java
+++ b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/utils/GUIHelper.java
@@ -475,6 +475,8 @@ public class GUIHelper {
}
public void setStatusMessage(String message) {
+ clearStatusMessage();
+ Application.getApplication().getStatusLineManager().setMessage(message);
Application.getApplication().getStatusLineManager().setMessage(message);
}
diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/GlusterServerSummaryView.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/GlusterServerSummaryView.java
index 662ca16f..03c38df7 100644
--- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/GlusterServerSummaryView.java
+++ b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/views/GlusterServerSummaryView.java
@@ -20,11 +20,16 @@
*/
package com.gluster.storage.management.console.views;
+import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.birt.chart.util.CDateTime;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.dialogs.ProgressMonitorDialog;
import org.eclipse.jface.layout.TableColumnLayout;
+import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
@@ -50,16 +55,17 @@ import org.eclipse.ui.part.ViewPart;
import com.gluster.storage.management.client.GlusterServersClient;
import com.gluster.storage.management.console.Activator;
+import com.gluster.storage.management.console.ConsoleConstants;
import com.gluster.storage.management.console.GlusterDataModelManager;
import com.gluster.storage.management.console.IImageKeys;
import com.gluster.storage.management.console.NetworkInterfaceTableLabelProvider;
import com.gluster.storage.management.console.preferences.PreferenceConstants;
import com.gluster.storage.management.console.toolbar.GlusterToolbarManager;
import com.gluster.storage.management.console.utils.ChartUtil;
+import com.gluster.storage.management.console.utils.ChartUtil.ChartPeriodLinkListener;
import com.gluster.storage.management.console.utils.ChartViewerComposite;
import com.gluster.storage.management.console.utils.GUIHelper;
import com.gluster.storage.management.console.utils.GlusterLogger;
-import com.gluster.storage.management.console.utils.ChartUtil.ChartPeriodLinkListener;
import com.gluster.storage.management.core.model.ClusterListener;
import com.gluster.storage.management.core.model.DefaultClusterListener;
import com.gluster.storage.management.core.model.Event;
@@ -330,10 +336,35 @@ public class GlusterServerSummaryView extends ViewPart {
createServerSummarySection(server, toolkit, form);
if (server.getStatus() == SERVER_STATUS.ONLINE) {
- createMemoryUsageSection();
- createNetworkUsageSection();
- createCPUUsageSection();
- createNetworkInterfacesSection(server, toolkit, form);
+ try {
+ new ProgressMonitorDialog(getSite().getShell()).run(false, false, new IRunnableWithProgress() {
+
+ @Override
+ public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
+ monitor.beginTask("Creating Server Summary View", 4);
+ monitor.setTaskName("Creating Memory Usage Section");
+ createMemoryUsageSection();
+ monitor.worked(1);
+
+ monitor.setTaskName("Creating Network Usage Section");
+ createNetworkUsageSection();
+ monitor.worked(1);
+
+ monitor.setTaskName("Creating CPU Usage Section");
+ createCPUUsageSection();
+ monitor.worked(1);
+
+ monitor.setTaskName("Creating Network Interfaces Section");
+ createNetworkInterfacesSection(server, toolkit, form);
+ monitor.worked(1);
+ monitor.done();
+ }
+ });
+ } catch (Exception e) {
+ String errMsg = "Exception while creating the Gluster Server Summary View : [" + e.getMessage() + "]";
+ logger.error(errMsg, e);
+ MessageDialog.openError(getSite().getShell(), ConsoleConstants.CONSOLE_TITLE, errMsg);
+ }
}
parent.layout(); // IMP: lays out the form properly