summaryrefslogtreecommitdiffstats
path: root/src/com.gluster.storage.management.gateway
diff options
context:
space:
mode:
authorSelvasundaram <selvam@gluster.com>2011-08-19 17:29:39 +0530
committerSelvasundaram <selvam@gluster.com>2011-08-19 17:42:13 +0530
commitcb3cbfb8307158167cf5fa88b2b61322be1c59a4 (patch)
tree7c87b661796525e44991706f0d88a1f52aaa2bb2 /src/com.gluster.storage.management.gateway
parent7a84412ff29f0c0491d8f01528eedf2774bb1eeb (diff)
Create volume replica / stripe count made as optional parameter
Getting Gluster servers, optional "detail" paramter added and default value is "false"
Diffstat (limited to 'src/com.gluster.storage.management.gateway')
-rw-r--r--src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/resources/v1_0/GlusterServersResource.java6
-rw-r--r--src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/resources/v1_0/VolumesResource.java25
-rw-r--r--src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/services/VolumeService.java17
-rw-r--r--src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/utils/GlusterUtil.java13
4 files changed, 30 insertions, 31 deletions
diff --git a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/resources/v1_0/GlusterServersResource.java b/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/resources/v1_0/GlusterServersResource.java
index e95a8858..b495ec12 100644
--- a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/resources/v1_0/GlusterServersResource.java
+++ b/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/resources/v1_0/GlusterServersResource.java
@@ -62,7 +62,6 @@ import com.gluster.storage.management.core.exceptions.ConnectionException;
import com.gluster.storage.management.core.exceptions.GlusterRuntimeException;
import com.gluster.storage.management.core.exceptions.GlusterValidationException;
import com.gluster.storage.management.core.model.GlusterServer;
-import com.gluster.storage.management.core.model.Server;
import com.gluster.storage.management.core.model.ServerStats;
import com.gluster.storage.management.core.model.TaskStatus;
import com.gluster.storage.management.core.response.GlusterServerListResponse;
@@ -71,7 +70,6 @@ import com.gluster.storage.management.gateway.data.ClusterInfo;
import com.gluster.storage.management.gateway.data.ServerInfo;
import com.gluster.storage.management.gateway.services.ClusterService;
import com.gluster.storage.management.gateway.services.GlusterServerService;
-import com.gluster.storage.management.gateway.services.VolumeService;
import com.gluster.storage.management.gateway.tasks.InitializeDiskTask;
import com.gluster.storage.management.gateway.utils.CpuStatsFactory;
import com.gluster.storage.management.gateway.utils.GlusterUtil;
@@ -127,8 +125,8 @@ public class GlusterServersResource extends AbstractResource {
private Response getGlusterServers(String clusterName, String mediaType, Boolean fetchDetails, Integer maxCount,
String previousServerName) {
if(fetchDetails == null) {
- // by default, fetch the server details
- fetchDetails = true;
+ // by default, fetch the server list
+ fetchDetails = false;
}
List<GlusterServer> glusterServers = new ArrayList<GlusterServer>();
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 cfcf3f96..e028cadc 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
@@ -81,6 +81,7 @@ import com.gluster.storage.management.core.exceptions.GlusterValidationException
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;
+import com.gluster.storage.management.core.model.Volume.VOLUME_TYPE;
import com.gluster.storage.management.core.model.VolumeLogMessage;
import com.gluster.storage.management.core.response.LogMessageListResponse;
import com.gluster.storage.management.core.response.VolumeListResponse;
@@ -133,18 +134,28 @@ public class VolumesResource extends AbstractResource {
@FormParam(FORM_PARAM_STRIPE_COUNT) Integer stripeCount, @FormParam(FORM_PARAM_BRICKS) String bricks,
@FormParam(FORM_PARAM_ACCESS_PROTOCOLS) String accessProtocols,
@FormParam(FORM_PARAM_VOLUME_OPTIONS) String options, @FormParam(FORM_PARAM_CIFS_USERS) String cifsUsers) {
+ int count = 0;
if (clusterName == null || clusterName.isEmpty()) {
return badRequestResponse("Cluster name must not be empty!");
}
-
- String missingParam = checkMissingParamsForCreateVolume(volumeName, volumeType, transportType, replicaCount,
- stripeCount, bricks, accessProtocols, options);
+
+ String missingParam = checkMissingParamsForCreateVolume(volumeName, volumeType, transportType, bricks,
+ accessProtocols, options);
if (missingParam != null) {
throw new GlusterValidationException("Parameter [" + missingParam + "] is missing in request!");
}
- volumeService.createVolume(clusterName, volumeName, volumeType, transportType, replicaCount,
- stripeCount, bricks, accessProtocols, options, cifsUsers);
+ // For missing parameter, let default value
+ if (volumeType.equals(VOLUME_TYPE.REPLICATE.toString())
+ || volumeType.equals(VOLUME_TYPE.DISTRIBUTED_REPLICATE.toString())) {
+ count = (replicaCount == null) ? Volume.DEFAULT_REPLICA_COUNT : replicaCount;
+ } else if (volumeType.equals(VOLUME_TYPE.STRIPE.toString())
+ || volumeType.equals(VOLUME_TYPE.DISTRIBUTED_STRIPE.toString())) {
+ count = (stripeCount == null) ? Volume.DEFAULT_STRIPE_COUNT : stripeCount;
+ }
+
+ volumeService.createVolume(clusterName, volumeName, volumeType, transportType, count, bricks, accessProtocols,
+ options, cifsUsers);
return createdResponse(volumeName);
}
@@ -152,14 +163,12 @@ public class VolumesResource extends AbstractResource {
* Returns name of the missing parameter if any. If all parameters are present,
*/
private String checkMissingParamsForCreateVolume(String volumeName, String volumeType,
- String transportType, Integer replicaCount, Integer stripeCount, String bricks, String accessProtocols,
+ String transportType, String bricks, String accessProtocols,
String options) {
return (volumeName == null || volumeName.isEmpty()) ? FORM_PARAM_VOLUME_NAME :
(volumeType == null || volumeType.isEmpty()) ? FORM_PARAM_VOLUME_TYPE :
(transportType == null || transportType.isEmpty()) ? FORM_PARAM_TRANSPORT_TYPE :
- (replicaCount == null) ? FORM_PARAM_REPLICA_COUNT :
- (stripeCount == null) ? FORM_PARAM_STRIPE_COUNT :
(bricks == null || bricks.isEmpty()) ? FORM_PARAM_BRICKS :
(accessProtocols == null || accessProtocols.isEmpty()) ? FORM_PARAM_ACCESS_PROTOCOLS :
(options == null || options.isEmpty()) ? FORM_PARAM_VOLUME_OPTIONS :
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 48a12435..7056f321 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
@@ -403,17 +403,19 @@ public class VolumeService {
}
public void createVolume(String clusterName, String volumeName, String volumeType, String transportType,
- Integer replicaCount, Integer stripeCount, String bricks, String accessProtocols, String options,
+ Integer count, String bricks, String accessProtocols, String options,
String cifsUsers) {
if (clusterService.getCluster(clusterName) == null) {
throw new GlusterValidationException("Cluster [" + clusterName + "] not found!");
}
- if (volumeType.equals(VOLUME_TYPE.DISTRIBUTED_REPLICATE) && replicaCount <= 0) {
+ if ((volumeType.equals(VOLUME_TYPE.REPLICATE.toString()) || volumeType.equals(VOLUME_TYPE.DISTRIBUTED_REPLICATE
+ .toString())) && count <= 0) {
throw new GlusterValidationException("Replica count must be a positive integer");
}
- if (volumeType.equals(VOLUME_TYPE.DISTRIBUTED_STRIPE) && stripeCount <= 0) {
+ if ((volumeType.equals(VOLUME_TYPE.STRIPE.toString()) || volumeType.equals(VOLUME_TYPE.DISTRIBUTED_STRIPE
+ .toString())) && count <= 0) {
throw new GlusterValidationException("Stripe count must be a positive integer");
}
@@ -423,8 +425,9 @@ public class VolumeService {
}
try {
- glusterUtil.createVolume(onlineServer.getName(), volumeName, volumeType, transportType, replicaCount,
- stripeCount, bricks, accessProtocols, options);
+ glusterUtil.createVolume(onlineServer.getName(), volumeName, volumeType, transportType, count,
+ bricks, accessProtocols, options);
+
} 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) {
@@ -433,8 +436,8 @@ public class VolumeService {
if (onlineServer == null) {
throw new GlusterRuntimeException("No online servers found in cluster [" + clusterName + "]");
}
- glusterUtil.createVolume(onlineServer.getName(), volumeName, volumeType, transportType, replicaCount,
- stripeCount, bricks, accessProtocols, options);
+ glusterUtil.createVolume(onlineServer.getName(), volumeName, volumeType, transportType, count,
+ bricks, accessProtocols, options);
} else {
throw new GlusterRuntimeException(e.getMessage());
}
diff --git a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/utils/GlusterUtil.java b/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/utils/GlusterUtil.java
index d9c1df3c..d2366899 100644
--- a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/utils/GlusterUtil.java
+++ b/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/utils/GlusterUtil.java
@@ -44,7 +44,6 @@ import com.gluster.storage.management.core.model.Volume;
import com.gluster.storage.management.core.model.Volume.TRANSPORT_TYPE;
import com.gluster.storage.management.core.model.Volume.VOLUME_STATUS;
import com.gluster.storage.management.core.model.Volume.VOLUME_TYPE;
-import com.gluster.storage.management.core.utils.GlusterCoreUtil;
import com.gluster.storage.management.core.utils.ProcessResult;
import com.gluster.storage.management.core.utils.StringUtil;
import com.gluster.storage.management.gateway.resources.v1_0.TasksResource;
@@ -65,7 +64,6 @@ public class GlusterUtil {
private static final String VOLUME_TRANSPORT_TYPE_PFX = "Transport-type:";
private static final String VOLUME_BRICKS_GROUP_PFX = "Bricks";
private static final String VOLUME_OPTIONS_RECONFIG_PFX = "Options Reconfigured";
- private static final String VOLUME_OPTION_AUTH_ALLOW_PFX = "auth.allow:";
private static final String VOLUME_LOG_LOCATION_PFX = "log file location:";
private static final String VOLUME_TYPE_DISTRIBUTE = "Distribute";
private static final String VOLUME_TYPE_REPLICATE = "Replicate";
@@ -75,8 +73,6 @@ public class GlusterUtil {
private static final String GLUSTERD_INFO_FILE = "/etc/glusterd/glusterd.info";
- private static final GlusterCoreUtil glusterCoreUtil = new GlusterCoreUtil();
-
private static final String INITIALIZE_DISK_STATUS_SCRIPT = "get_format_device_status.py";
private static final String BRICK_STATUS_SCRIPT = "get_brick_status.py";
@@ -85,9 +81,6 @@ public class GlusterUtil {
@Autowired
private ServerUtil serverUtil;
-
- @Autowired
- private TasksResource taskResource;
public void setSshUtil(SshUtil sshUtil) {
this.sshUtil = sshUtil;
@@ -250,18 +243,14 @@ public class GlusterUtil {
}
public void createVolume(String knownServer, String volumeName, String volumeTypeStr, String transportTypeStr,
- Integer replicaCount, Integer stripeCount, String bricks, String accessProtocols, String options) {
-
- int count = 1; // replica or stripe count
+ Integer count, String bricks, String accessProtocols, String options) {
VOLUME_TYPE volType = Volume.getVolumeTypeByStr(volumeTypeStr);
String volTypeArg = null;
if (volType == VOLUME_TYPE.REPLICATE || volType == VOLUME_TYPE.DISTRIBUTED_REPLICATE) {
volTypeArg = "replica";
- count = replicaCount;
} else if (volType == VOLUME_TYPE.STRIPE || volType == VOLUME_TYPE.DISTRIBUTED_STRIPE) {
volTypeArg = "stripe";
- count = stripeCount;
}
String transportTypeArg = null;