summaryrefslogtreecommitdiffstats
path: root/src/com.gluster.storage.management.gui
diff options
context:
space:
mode:
authorShireesh Anjal <shireesh@gluster.com>2011-06-22 21:29:26 +0530
committerShireesh Anjal <shireesh@gluster.com>2011-06-22 21:42:42 +0530
commit18d81acc64bc166073f8772c748e2cb31fdd2b65 (patch)
treed12924252a1ec30c10de9315f335d6d54b6c2be2 /src/com.gluster.storage.management.gui
parenta0c4177e29c2c3157f610c9143427662e8cd337f (diff)
REST API Enhancements
Diffstat (limited to 'src/com.gluster.storage.management.gui')
-rw-r--r--src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/actions/RemoveDiskAction.java2
-rw-r--r--src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/dialogs/AddDiskWizard.java2
-rw-r--r--src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/dialogs/CreateVolumeWizard.java122
-rw-r--r--src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/VolumeSummaryView.java2
-rw-r--r--src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/pages/VolumeLogsPage.java6
5 files changed, 70 insertions, 64 deletions
diff --git a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/actions/RemoveDiskAction.java b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/actions/RemoveDiskAction.java
index 0cad5945..9df40457 100644
--- a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/actions/RemoveDiskAction.java
+++ b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/actions/RemoveDiskAction.java
@@ -40,7 +40,7 @@ public class RemoveDiskAction extends AbstractActionDelegate {
List<String> brickList = getBrickList(bricks);
Integer deleteOption = new MessageDialog(getShell(), "Remove Bricks(s)", GUIHelper.getInstance()
.getImage(IImageKeys.VOLUME), "Are you sure you want to remove following bricks from volume ["
- + volume.getName() + "] ? \n" + StringUtil.ListToString(brickList, ", "),
+ + volume.getName() + "] ? \n" + StringUtil.collectionToString(brickList, ", "),
MessageDialog.QUESTION, new String[] { "Cancel", "Remove bricks, delete data",
"Remove bricks, keep data" }, -1).open();
if (deleteOption <= 0) { // By Cancel button(0) or Escape key(-1)
diff --git a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/dialogs/AddDiskWizard.java b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/dialogs/AddDiskWizard.java
index f41a113e..bb55ece1 100644
--- a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/dialogs/AddDiskWizard.java
+++ b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/dialogs/AddDiskWizard.java
@@ -74,7 +74,7 @@ public class AddDiskWizard extends Wizard {
GlusterDataModelManager.getInstance().addBricks(volume, bricks);
MessageDialog.openInformation(getShell(), "Add brick(s) to Volume", "Volume [" + volume.getName()
- + "] is expanded with bricks [" + StringUtil.ListToString(brickList, ", ") + "]");
+ + "] is expanded with bricks [" + StringUtil.collectionToString(brickList, ", ") + "]");
return true;
} catch (Exception e) {
MessageDialog.openError(getShell(), "Add brick(s) to Volume", e.getMessage());
diff --git a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/dialogs/CreateVolumeWizard.java b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/dialogs/CreateVolumeWizard.java
index 4575edff..ff4bdd98 100644
--- a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/dialogs/CreateVolumeWizard.java
+++ b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/dialogs/CreateVolumeWizard.java
@@ -23,87 +23,97 @@ import org.eclipse.jface.wizard.Wizard;
import com.gluster.storage.management.client.GlusterDataModelManager;
import com.gluster.storage.management.client.VolumesClient;
-import com.gluster.storage.management.core.model.Status;
import com.gluster.storage.management.core.model.Volume;
import com.gluster.storage.management.core.model.Volume.VOLUME_STATUS;
public class CreateVolumeWizard extends Wizard {
-
+ private static final String title = "Gluster Management Console - Create Volume";
+ private CreateVolumePage1 page;
+
public CreateVolumeWizard() {
- setWindowTitle("Gluster Management Console - Create Volume");
+ setWindowTitle(title);
setHelpAvailable(false); // TODO: Introduce wizard help
}
@Override
public void addPages() {
- addPage(new CreateVolumePage1());
+ page = new CreateVolumePage1();
+ addPage(page);
}
@Override
public boolean performFinish() {
- String dialogTitle = "Create Volume";
- CreateVolumePage1 page = (CreateVolumePage1) getPage(CreateVolumePage1.PAGE_NAME);
-
Volume newVolume = page.getVolume();
VolumesClient volumesClient = new VolumesClient();
- Status status = volumesClient.createVolume(newVolume);
- String message = "";
+
+ try {
+ volumesClient.createVolume(newVolume);
+ handleSuccess(newVolume, volumesClient);
+ } catch(Exception e) {
+ String errMsg = e.getMessage();
+ // the error could be in to post-volume-create processing. check if this is the case.
+ if (volumesClient.volumeExists(newVolume.getName())) {
+ handlePartSuccess(newVolume, volumesClient, errMsg);
+ } else {
+ MessageDialog.openError(getShell(), title, "Volume creation failed! Error: " + errMsg);
+ }
+ }
+
+ return true;
+ }
+
+ public void handleSuccess(Volume newVolume, VolumesClient volumesClient) {
+ String message = "Volume created successfully!";
+ newVolume.setStatus(VOLUME_STATUS.OFFLINE);
boolean warning = false;
- if (status.isSuccess()) {
- message = "Volume created successfully!";
- newVolume.setStatus(VOLUME_STATUS.OFFLINE);
- if (page.startVolumeAfterCreation()) {
+ if (page.startVolumeAfterCreation()) {
+ try {
+ volumesClient.startVolume(newVolume.getName());
+ newVolume.setStatus(VOLUME_STATUS.ONLINE);
+ message = "Volume created and started successfully!";
+ } catch(Exception e) {
+ message = "Volume created successfuly, but couldn't be started. Error: " + e.getMessage();
+ warning = true;
+ }
+ }
+
+ // update the model
+ GlusterDataModelManager.getInstance().addVolume(newVolume);
+ if (warning) {
+ MessageDialog.openWarning(getShell(), title, message);
+ } else {
+ MessageDialog.openInformation(getShell(), title, message);
+ }
+ }
+
+ public void handlePartSuccess(Volume newVolume, VolumesClient volumesClient, String errMsg) {
+ // volume exists. error was in post-volume-create
+ newVolume.setStatus(VOLUME_STATUS.OFFLINE);
+ boolean error = false;
+ String message1 = null;
+ if (page.startVolumeAfterCreation()) {
+ if (MessageDialog.openConfirm(getShell(), title,
+ "Volume created, but following error(s) occured: " + errMsg
+ + "\n\nDo you still want to start the volume [" + newVolume.getName() + "]?")) {
try {
volumesClient.startVolume(newVolume.getName());
newVolume.setStatus(VOLUME_STATUS.ONLINE);
- message = "Volume created and started successfully!";
- } catch(Exception e) {
- message = "Volume created successfuly, but couldn't be started. Error: " + e.getMessage();
- warning = true;
+ message1 = "Volume [" + newVolume.getName() + "] started successfully!"; // Only start operation
+ } catch(Exception e1) {
+ message1 = "Volume couldn't be started. Error: " + e1.getMessage();
+ error = true;
}
}
- // update the model
- GlusterDataModelManager.getInstance().addVolume(newVolume);
- if (warning) {
- MessageDialog.openWarning(getShell(), dialogTitle, message);
- } else {
- MessageDialog.openInformation(getShell(), dialogTitle, message);
- }
- } else {
- if (status.isPartSuccess()) {
- newVolume.setStatus(VOLUME_STATUS.OFFLINE);
- boolean error = false;
- if (page.startVolumeAfterCreation()) {
- if (MessageDialog.openConfirm(getShell(), dialogTitle,
- "Volume created, but following error(s) occured: " + status
- + "\n\nDo you still want to start the volume [" + newVolume.getName() + "]?")) {
- try {
- volumesClient.startVolume(newVolume.getName());
- newVolume.setStatus(VOLUME_STATUS.ONLINE);
- message = "Volume [" + newVolume.getName() + "] started successfully!"; // Only start operation
- } catch(Exception e) {
- message = "Volume couldn't be started. Error: " + e.getMessage();
- error = true;
- }
- }
- if (error) {
- MessageDialog.openWarning(getShell(), dialogTitle, message);
- } else {
- MessageDialog.openInformation(getShell(), dialogTitle, message);
- }
-
- } else { // Start volume is not checked
- MessageDialog.openWarning(getShell(), dialogTitle, "Volume created, but following error(s) occured: "
- + status);
- }
- GlusterDataModelManager.getInstance().addVolume(newVolume);
-
+ if (error) {
+ MessageDialog.openWarning(getShell(), title, message1);
} else {
- MessageDialog.openError(getShell(), dialogTitle, "Volume creation failed! " + status);
+ MessageDialog.openInformation(getShell(), title, message1);
}
+ } else { // Start volume is not checked
+ MessageDialog.openWarning(getShell(), title,
+ "Volume created, but following error(s) occured: " + errMsg);
}
-
- return true;
+ GlusterDataModelManager.getInstance().addVolume(newVolume);
}
}
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 c708100d..17bb28f4 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
@@ -215,7 +215,7 @@ public class VolumeSummaryView extends ViewPart {
}
}
}
- return StringUtil.ListToString(OnlineServers, ", ") + ((OnlineServers.size() > maxServers) ? "..." : "");
+ return StringUtil.collectionToString(OnlineServers, ", ") + ((OnlineServers.size() > maxServers) ? "..." : "");
}
/**
diff --git a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/pages/VolumeLogsPage.java b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/pages/VolumeLogsPage.java
index 9bff0213..6ba9c0d1 100644
--- a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/pages/VolumeLogsPage.java
+++ b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/pages/VolumeLogsPage.java
@@ -46,16 +46,12 @@ import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.forms.widgets.FormToolkit;
-import com.gluster.storage.management.client.GlusterDataModelManager;
import com.gluster.storage.management.client.VolumesClient;
import com.gluster.storage.management.core.constants.CoreConstants;
import com.gluster.storage.management.core.constants.GlusterConstants;
import com.gluster.storage.management.core.constants.GlusterConstants.VOLUME_LOG_LEVELS;
-import com.gluster.storage.management.core.model.VolumeLogMessage;
-import com.gluster.storage.management.core.model.Status;
import com.gluster.storage.management.core.model.Volume;
-import com.gluster.storage.management.core.response.LogMessageListResponse;
-import com.gluster.storage.management.core.utils.GlusterCoreUtil;
+import com.gluster.storage.management.core.model.VolumeLogMessage;
import com.gluster.storage.management.gui.VolumeLogTableLabelProvider;
import com.gluster.storage.management.gui.utils.GUIHelper;