summaryrefslogtreecommitdiffstats
path: root/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management
diff options
context:
space:
mode:
Diffstat (limited to 'src/com.gluster.storage.management.gateway/src/com/gluster/storage/management')
-rw-r--r--src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/resources/v1_0/VolumesResource.java8
-rw-r--r--src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/services/Gluster323InterfaceService.java9
-rw-r--r--src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/services/GlusterInterface.java12
-rw-r--r--src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/services/GlusterInterfaceService.java8
-rw-r--r--src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/services/VolumeService.java21
5 files changed, 36 insertions, 22 deletions
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..14e7be8c 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;
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) 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..1a86b9cd 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 force) {
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, force);
} 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, force);
} 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 force) {
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, force);
} else if (operation.equals(TASK_STOP)) {
- stopVolume(clusterName, onlineServer, volume);
+ stopVolume(clusterName, onlineServer, volume, force);
} else {
throw new GlusterValidationException("Invalid operation code [" + operation + "]");
}