diff options
Diffstat (limited to 'src')
14 files changed, 130 insertions, 34 deletions
diff --git a/src/com.gluster.storage.management.client/src/com/gluster/storage/management/client/VolumesClient.java b/src/com.gluster.storage.management.client/src/com/gluster/storage/management/client/VolumesClient.java index f85afd4d..0e24fad0 100644 --- a/src/com.gluster.storage.management.client/src/com/gluster/storage/management/client/VolumesClient.java +++ b/src/com.gluster.storage.management.client/src/com/gluster/storage/management/client/VolumesClient.java @@ -87,19 +87,20 @@ public class VolumesClient extends AbstractClient { postRequest(form); } - private void performOperation(String volumeName, String operation) { + private void performOperation(String volumeName, String operation, Boolean force) { Form form = new Form(); form.add(RESTConstants.FORM_PARAM_OPERATION, operation); + form.add(RESTConstants.FORM_PARAM_FORCE_OPTION, force); putRequest(volumeName, form); } - public void startVolume(String volumeName) { - performOperation(volumeName, RESTConstants.TASK_START); + public void startVolume(String volumeName, Boolean forceStart) { + performOperation(volumeName, RESTConstants.TASK_START, forceStart); } - public void stopVolume(String volumeName) { - performOperation(volumeName, RESTConstants.TASK_STOP); + public void stopVolume(String volumeName, Boolean forceStop) { + performOperation(volumeName, RESTConstants.TASK_STOP, forceStop); } public void setCifsConfig(String volumeName, Boolean isCifsEnabled, String cifsUsers) { diff --git a/src/com.gluster.storage.management.console/plugin.xml b/src/com.gluster.storage.management.console/plugin.xml index 95615346..5195b1f0 100644 --- a/src/com.gluster.storage.management.console/plugin.xml +++ b/src/com.gluster.storage.management.console/plugin.xml @@ -526,6 +526,17 @@ label="Volume Actions" visible="false"> <action + class="com.gluster.storage.management.console.actions.ForceStartVolumeAction" + definitionId="com.gluster.storage.management.console.commands.ForceStartVolume" + icon="icons/tango/32x32/start-volume.png" + id="com.gluster.storage.management.console.actions.ForceStartVolumeAction" + label="Force Start Volume" + menubarPath="com.gluster.storage.management.console.menu.volume/volume" + style="push" + toolbarPath="Normal" + tooltip="Start the offline brick service"> + </action> + <action class="com.gluster.storage.management.console.actions.VolumeLogRotateAction" definitionId="com.gluster.storage.management.console.commands.LogRotate" icon="icons/tango/32x32/log-rotate.png" diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/DeleteVolumeAction.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/DeleteVolumeAction.java index 3de3f945..f5f7d209 100644 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/DeleteVolumeAction.java +++ b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/DeleteVolumeAction.java @@ -87,7 +87,7 @@ public class DeleteVolumeAction extends AbstractMonitoredActionDelegate { try { monitor.setTaskName("Deleting volume [" + volume.getName() + "]"); if (volume.getStatus() == VOLUME_STATUS.ONLINE) { // stop if online volume - vc.stopVolume(volume.getName()); + vc.stopVolume(volume.getName(), false); } vc.deleteVolume(volume.getName(), confirmDeleteDir); modelManager.deleteVolume(volume); diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/ForceStartVolumeAction.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/ForceStartVolumeAction.java new file mode 100644 index 00000000..f6f0e44b --- /dev/null +++ b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/ForceStartVolumeAction.java @@ -0,0 +1,69 @@ +package com.gluster.storage.management.console.actions; + +import java.util.Set; + +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.ui.IWorkbenchPart; + +import com.gluster.storage.management.client.VolumesClient; +import com.gluster.storage.management.console.utils.GUIHelper; +import com.gluster.storage.management.console.views.VolumeBricksView; +import com.gluster.storage.management.core.model.Brick; +import com.gluster.storage.management.core.model.Brick.BRICK_STATUS; +import com.gluster.storage.management.core.model.Volume; + +public class ForceStartVolumeAction extends AbstractActionDelegate { + + private Volume volume; + private GUIHelper guiHelper = GUIHelper.getInstance(); + private Set<Brick> bricks; + + @Override + public void dispose() { + + } + + @Override + protected void performAction(IAction action) { + // volume brick service will be started, do you want to continue? + final String actionDesc = action.getDescription(); + boolean confirmed = showConfirmDialog(actionDesc, + "Volume brick service will be started, do you want to continue?"); + if (!confirmed) { + return; + } + try { + new VolumesClient().startVolume(volume.getName(), true); + showInfoDialog(actionDesc, "Volume [" + volume.getName() + "] forcefully started successfully!"); + } catch (Exception e) { + showErrorDialog(actionDesc, + "Failed to forcefully start volume [" + volume.getName() + "]! Error: [" + e.getMessage() + "]"); + } + } + + @Override + public void selectionChanged(IAction action, ISelection selection) { + super.selectionChanged(action, selection); + + volume = guiHelper.getSelectedEntity(window, Volume.class); + if (volume != null) { + // a volume is selected on navigation tree. Let's check if the currently open view is volume bricks view + IWorkbenchPart view = guiHelper.getActiveView(); + if (view instanceof VolumeBricksView) { + // volume bricks view is open. check if any offline brick is selected + bricks = GUIHelper.getInstance().getSelectedEntities(getWindow(), Brick.class); + for (Brick brick : bricks) { + if (brick.getStatus() == BRICK_STATUS.OFFLINE) { + action.setEnabled(true); + } else { + // if any one of the selected brick is online, the disable the button + action.setEnabled(false); + break; + } + } + } + } + } + +} diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/RemoveBrickAction.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/RemoveBrickAction.java index 4b747294..105ab0da 100644 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/RemoveBrickAction.java +++ b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/actions/RemoveBrickAction.java @@ -71,10 +71,10 @@ public class RemoveBrickAction extends AbstractActionDelegate { action.setEnabled(false); volume = guiHelper.getSelectedEntity(window, Volume.class); if (volume != null) { - // a volume is selected on navigation tree. Let's check if the currently open view is volume disks view + // a volume is selected on navigation tree. Let's check if the currently open view is volume bricks view IWorkbenchPart view = guiHelper.getActiveView(); if (view instanceof VolumeBricksView) { - // volume disks view is open. check if any brick is selected + // volume bricks view is open. check if any brick is selected bricks = GUIHelper.getInstance().getSelectedEntities(getWindow(), Brick.class); action.setEnabled(bricks.size() > 0); } 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 0df91ab8..6407b322 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 @@ -84,7 +84,7 @@ public class StartVolumeAction extends AbstractMonitoredActionDelegate { } try { monitor.setTaskName("Starting volume [" + volume.getName() + "]"); - vc.startVolume(volume.getName()); + vc.startVolume(volume.getName(), false); startedVolumes.add(volume.getName()); } catch (Exception e) { failedVolumes.add(volume.getName()); 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 31f8d164..dad5d4ac 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 @@ -94,7 +94,7 @@ public class StopVolumeAction extends AbstractMonitoredActionDelegate { } try { monitor.setTaskName("Stopping volume [" + volume.getName() + "]"); - vc.stopVolume(volume.getName()); + vc.stopVolume(volume.getName(), false); // modelManager.updateVolumeStatus(volume, VOLUME_STATUS.OFFLINE); stoppedVolumes.add(volume.getName()); } catch (Exception e) { diff --git a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/dialogs/CreateVolumeWizard.java b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/dialogs/CreateVolumeWizard.java index 227c60b7..1558749c 100644 --- a/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/dialogs/CreateVolumeWizard.java +++ b/src/com.gluster.storage.management.console/src/com/gluster/storage/management/console/dialogs/CreateVolumeWizard.java @@ -99,7 +99,7 @@ public class CreateVolumeWizard extends Wizard { boolean warning = false; if (page.startVolumeAfterCreation()) { try { - volumesClient.startVolume(newVolume.getName()); + volumesClient.startVolume(newVolume.getName(), false); newVolume.setStatus(VOLUME_STATUS.ONLINE); message = "Volume created and started successfully!"; } catch(Exception e) { @@ -127,7 +127,7 @@ public class CreateVolumeWizard extends Wizard { + errMsg + CoreConstants.NEWLINE + CoreConstants.NEWLINE + "Do you still want to start the volume [" + newVolume.getName() + "]?")) { try { - volumesClient.startVolume(newVolume.getName()); + volumesClient.startVolume(newVolume.getName(), false); newVolume.setStatus(VOLUME_STATUS.ONLINE); message1 = "Volume [" + newVolume.getName() + "] started successfully!"; // Only start operation } catch(Exception e1) { diff --git a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/constants/RESTConstants.java b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/constants/RESTConstants.java index 22d7e3dc..e04658d7 100644 --- a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/constants/RESTConstants.java +++ b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/constants/RESTConstants.java @@ -86,6 +86,7 @@ public class RESTConstants { public static final String FORM_PARAM_FORCED_DATA_MIGRATE = "forcedDataMigrate"; public static final String FORM_PARAM_OLD_PASSWORD = "oldPassword"; public static final String FORM_PARAM_NEW_PASSWORD = "newPassword"; + public static final String FORM_PARAM_FORCE_OPTION = "forceOperation"; public static final String PATH_PARAM_FORMAT = "format"; public static final String PATH_PARAM_VOLUME_NAME = "volumeName"; diff --git a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/resources/v1_0/VolumesResource.java b/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/resources/v1_0/VolumesResource.java index 4303aa63..bc38469e 100644 --- a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/resources/v1_0/VolumesResource.java +++ b/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/resources/v1_0/VolumesResource.java @@ -37,6 +37,7 @@ import static com.gluster.storage.management.core.constants.RESTConstants.FORM_P import static com.gluster.storage.management.core.constants.RESTConstants.FORM_PARAM_VOLUME_NAME; import static com.gluster.storage.management.core.constants.RESTConstants.FORM_PARAM_VOLUME_OPTIONS; import static com.gluster.storage.management.core.constants.RESTConstants.FORM_PARAM_VOLUME_TYPE; +import static com.gluster.storage.management.core.constants.RESTConstants.FORM_PARAM_FORCE_OPTION; import static com.gluster.storage.management.core.constants.RESTConstants.PATH_PARAM_CLUSTER_NAME; import static com.gluster.storage.management.core.constants.RESTConstants.PATH_PARAM_VOLUME_NAME; import static com.gluster.storage.management.core.constants.RESTConstants.QUERY_PARAM_BRICKS; @@ -195,7 +196,7 @@ public class VolumesResource extends AbstractResource { @FormParam(FORM_PARAM_MIGRATE_DATA) Boolean isMigrateData, @FormParam(FORM_PARAM_FORCED_DATA_MIGRATE) Boolean isForcedDataMigrate, @FormParam(FORM_PARAM_CIFS_ENABLE) Boolean enableCifs, @FormParam(FORM_PARAM_CIFS_USERS) String cifsUsers, - @FormParam(FORM_PARAM_BRICKS) String bricks) { + @FormParam(FORM_PARAM_BRICKS) String bricks, @FormParam(FORM_PARAM_FORCE_OPTION) Boolean force) { if (clusterName == null || clusterName.isEmpty()) { throw new GlusterValidationException("Cluster name must not be empty!"); } @@ -234,7 +235,10 @@ public class VolumesResource extends AbstractResource { List<String> brickList = Arrays.asList(bricks.split(",")); volumeService.logRotate(clusterName, volumeName, brickList); } else { - volumeService.performVolumeOperation(clusterName, volumeName, operation); + if (force == null) { + force = false; + } + volumeService.performVolumeOperation(clusterName, volumeName, operation, force); } return noContentResponse(); } catch(Exception e) { diff --git a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/services/Gluster323InterfaceService.java b/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/services/Gluster323InterfaceService.java index fba64352..9b093baf 100644 --- a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/services/Gluster323InterfaceService.java +++ b/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/services/Gluster323InterfaceService.java @@ -79,16 +79,17 @@ public class Gluster323InterfaceService extends AbstractGlusterInterface { * @see com.gluster.storage.management.gateway.utils.GlusterInterface#startVolume(java.lang.String, java.lang.String) */ @Override - public void startVolume(String volumeName, String knownServer) { - serverUtil.executeOnServer(knownServer, "gluster volume start " + volumeName); + public void startVolume(String volumeName, String knownServer, Boolean force) { + serverUtil.executeOnServer(knownServer, "gluster volume start " + volumeName + ((force) ? " force" : "")); } /* (non-Javadoc) * @see com.gluster.storage.management.gateway.utils.GlusterInterface#stopVolume(java.lang.String, java.lang.String) */ @Override - public void stopVolume(String volumeName, String knownServer) { - serverUtil.executeOnServer(knownServer, "gluster --mode=script volume stop " + volumeName); + public void stopVolume(String volumeName, String knownServer, Boolean force) { + serverUtil.executeOnServer(knownServer, "gluster --mode=script volume stop " + volumeName + + ((force) ? " force" : "")); } /* (non-Javadoc) diff --git a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/services/GlusterInterface.java b/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/services/GlusterInterface.java index 2df24497..c282bb45 100644 --- a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/services/GlusterInterface.java +++ b/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/services/GlusterInterface.java @@ -52,8 +52,12 @@ public interface GlusterInterface { * @param serverName * Server on which the Gluster command is to be executed. This server must be part of the cluster to * which the volume belongs. + * @param force + * Flag indicating whether the "force" option should be used for starting the Volume. This is typically + * used when Volume is already started, but at least one of its bricks is offline, and results in + * bringing up the offline bricks. */ - public abstract void startVolume(String volumeName, String serverName); + public abstract void startVolume(String volumeName, String serverName, Boolean force); /** * Stops the given volume by executing appropriate Gluster command on given server. @@ -63,8 +67,12 @@ public interface GlusterInterface { * @param serverName * Server on which the Gluster command is to be executed. This server must be part of the cluster to * which the volume belongs. + * @param force + * Flag indicating whether the Volume should be stopped forcefully. This is typically used if the regular + * stop option fails because of issues like rebalance / brick migration / geo-replication being in + * progress. This results in forcefully stopping the volume, leaving the other processes intact. */ - public abstract void stopVolume(String volumeName, String serverName); + public abstract void stopVolume(String volumeName, String serverName, Boolean force); /** * Resets volume options on the given volume by executing appropriate Gluster command on given server. diff --git a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/services/GlusterInterfaceService.java b/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/services/GlusterInterfaceService.java index 8d1760fd..4baca5d9 100644 --- a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/services/GlusterInterfaceService.java +++ b/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/services/GlusterInterfaceService.java @@ -72,16 +72,16 @@ public class GlusterInterfaceService extends AbstractGlusterInterface { * @see com.gluster.storage.management.gateway.utils.GlusterInterface#startVolume(java.lang.String, java.lang.String) */ @Override - public void startVolume(String volumeName, String knownServer) { - getGlusterInterface(knownServer).startVolume(volumeName, knownServer); + public void startVolume(String volumeName, String knownServer, Boolean force) { + getGlusterInterface(knownServer).startVolume(volumeName, knownServer, force); } /* (non-Javadoc) * @see com.gluster.storage.management.gateway.utils.GlusterInterface#stopVolume(java.lang.String, java.lang.String) */ @Override - public void stopVolume(String volumeName, String knownServer) { - getGlusterInterface(knownServer).stopVolume(volumeName, knownServer); + public void stopVolume(String volumeName, String knownServer, Boolean force) { + getGlusterInterface(knownServer).stopVolume(volumeName, knownServer, force); } public void logRotate(String volumeName, List<String> brickList, String knownServer) { diff --git a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/services/VolumeService.java b/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/services/VolumeService.java index df33d7ba..e44cebb5 100644 --- a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/services/VolumeService.java +++ b/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/services/VolumeService.java @@ -670,8 +670,8 @@ public class VolumeService { taskResource.getTask(clusterName, taskId).stop(); } - public void startVolume(String clusterName, GlusterServer onlineServer, Volume volume) { - glusterUtil.startVolume(volume.getName(), onlineServer.getName()); + public void startVolume(String clusterName, GlusterServer onlineServer, Volume volume, Boolean force) { + glusterUtil.startVolume(volume.getName(), onlineServer.getName(), force); // call the start_volume_cifs.py script only if the volume is cifs enabled if (volume.isCifsEnable()) { @@ -679,8 +679,8 @@ public class VolumeService { } } - public void stopVolume(String clusterName, GlusterServer onlineServer, Volume volume) { - glusterUtil.stopVolume(volume.getName(), onlineServer.getName()); + public void stopVolume(String clusterName, GlusterServer onlineServer, Volume volume, Boolean force) { + glusterUtil.stopVolume(volume.getName(), onlineServer.getName(), force); // call the stop_volume_cifs.py script only if the volume is cifs enabled if (volume.isCifsEnable()) { @@ -708,27 +708,28 @@ public class VolumeService { } } - public void performVolumeOperation(String clusterName, String volumeName, String operation) { + public void performVolumeOperation(String clusterName, String volumeName, String operation, Boolean forceOption) { GlusterServer onlineServer = clusterService.getOnlineServer(clusterName); try { if (onlineServer == null) { throw new GlusterRuntimeException("No online servers found in cluster [" + clusterName + "]"); } - performOperation(clusterName, volumeName, operation, onlineServer); + performOperation(clusterName, volumeName, operation, onlineServer, forceOption); } catch (Exception e) { // check if online server has gone offline. If yes, try again one more time. if (e instanceof ConnectionException || serverUtil.isServerOnline(onlineServer) == false) { // online server has gone offline! try with a different one. onlineServer = clusterService.getNewOnlineServer(clusterName); - performOperation(clusterName, volumeName, operation, onlineServer); + performOperation(clusterName, volumeName, operation, onlineServer, forceOption); } else { throw new GlusterRuntimeException(e.getMessage()); } } } - private void performOperation(String clusterName, String volumeName, String operation, GlusterServer onlineServer) { + private void performOperation(String clusterName, String volumeName, String operation, GlusterServer onlineServer, + Boolean forceOption) { Volume volume = null; try { volume = getVolume(clusterName, volumeName); @@ -738,9 +739,9 @@ public class VolumeService { } if (operation.equals(TASK_START)) { - startVolume(clusterName, onlineServer, volume); + startVolume(clusterName, onlineServer, volume, forceOption); } else if (operation.equals(TASK_STOP)) { - stopVolume(clusterName, onlineServer, volume); + stopVolume(clusterName, onlineServer, volume, forceOption); } else { throw new GlusterValidationException("Invalid operation code [" + operation + "]"); } |