summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorShireesh Anjal <shireesh@gluster.com>2011-06-14 19:09:45 +0530
committerShireesh Anjal <shireesh@gluster.com>2011-06-15 14:43:17 +0530
commita160883ce44b7469d2bd54a86d3fc661319b0158 (patch)
treef9c56e6b27838be48246f05dec64efccd36ccf6b /src
parent2119437352c96f4eb74d648f84952e92cef9fa35 (diff)
Code cleanup / refactoring
Diffstat (limited to 'src')
-rw-r--r--src/com.gluster.storage.management.client/src/com/gluster/storage/management/client/VolumesClient.java17
-rw-r--r--src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/constants/RESTConstants.java1
-rw-r--r--src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Volume.java7
-rw-r--r--src/com.gluster.storage.management.server/src/com/gluster/storage/management/server/resources/VolumesResource.java12
4 files changed, 22 insertions, 15 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 424fbca7..3b1a4dc0 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
@@ -99,7 +99,7 @@ public class VolumesClient extends AbstractClient {
}
public Status deleteVolume(Volume volume, boolean deleteOption) {
- MultivaluedMap<String, String> queryParams = prepareDeleteVolumeQueryParams(volume.getName(), deleteOption);
+ MultivaluedMap<String, String> queryParams = prepareDeleteVolumeQueryParams(deleteOption);
return (Status) deleteSubResource(volume.getName(), Status.class, queryParams);
}
@@ -112,7 +112,7 @@ public class VolumesClient extends AbstractClient {
String bricks = StringUtil.ListToString(brickList, ",");
Form form = new Form();
form.add(RESTConstants.FORM_PARAM_BRICKS, bricks);
- return (Status) postRequest(volumeName + "/" + RESTConstants.RESOURCE_DISKS, Status.class, form);
+ return (Status) postRequest(volumeName + "/" + RESTConstants.RESOURCE_BRICKS, Status.class, form);
}
/**
@@ -150,7 +150,7 @@ public class VolumesClient extends AbstractClient {
public Status removeBricks(String volumeName, List<Brick> BrickList, boolean deleteOption) {
String bricks = StringUtil.ListToString(GlusterCoreUtil.getQualifiedBrickList(BrickList), ",");
MultivaluedMap<String, String> queryParams = prepareRemoveBrickQueryParams(volumeName, bricks, deleteOption);
- return (Status) deleteSubResource(volumeName + "/" + RESTConstants.RESOURCE_DISKS, Status.class, queryParams);
+ return (Status) deleteSubResource(volumeName + "/" + RESTConstants.RESOURCE_BRICKS, Status.class, queryParams);
}
private MultivaluedMap<String, String> prepareRemoveBrickQueryParams(String volumeName, String bricks,
@@ -162,9 +162,8 @@ public class VolumesClient extends AbstractClient {
return queryParams;
}
- private MultivaluedMap<String, String> prepareDeleteVolumeQueryParams(String volumeName, boolean deleteOption) {
+ private MultivaluedMap<String, String> prepareDeleteVolumeQueryParams(boolean deleteOption) {
MultivaluedMap<String, String> queryParams = new MultivaluedMapImpl();
- queryParams.add(RESTConstants.QUERY_PARAM_VOLUME_NAME, volumeName);
queryParams.add(RESTConstants.QUERY_PARAM_DELETE_OPTION, "" + deleteOption);
return queryParams;
}
@@ -199,7 +198,7 @@ public class VolumesClient extends AbstractClient {
form.add(RESTConstants.FORM_PARAM_TARGET, brickTo);
form.add(RESTConstants.FORM_PARAM_OPERATION, RESTConstants.FORM_PARAM_VALUE_START);
- return (Status) putRequest( volumeName + "/" + RESTConstants.RESOURCE_DISKS, Status.class, form);
+ return (Status) putRequest( volumeName + "/" + RESTConstants.RESOURCE_BRICKS, Status.class, form);
}
public Status stopMigration(String volumeName, String brickFrom, String brickkTo) {
@@ -208,7 +207,7 @@ public class VolumesClient extends AbstractClient {
form.add(RESTConstants.FORM_PARAM_TARGET, brickkTo);
form.add(RESTConstants.FORM_PARAM_OPERATION, RESTConstants.FORM_PARAM_VALUE_STOP);
- return (Status) putRequest( volumeName + "/" + RESTConstants.RESOURCE_DISKS, Status.class, form);
+ return (Status) putRequest( volumeName + "/" + RESTConstants.RESOURCE_BRICKS, Status.class, form);
}
public Status pauseMigration(String volumeName, String brickFrom, String brickTo) {
@@ -217,7 +216,7 @@ public class VolumesClient extends AbstractClient {
form.add(RESTConstants.FORM_PARAM_TARGET, brickTo);
form.add(RESTConstants.FORM_PARAM_OPERATION, RESTConstants.FORM_PARAM_VALUE_PAUSE);
- return (Status) putRequest( volumeName + "/" + RESTConstants.RESOURCE_DISKS, Status.class, form);
+ return (Status) putRequest( volumeName + "/" + RESTConstants.RESOURCE_BRICKS, Status.class, form);
}
public Status statusMigration(String volumeName, String brickFrom, String brickTo) {
@@ -226,7 +225,7 @@ public class VolumesClient extends AbstractClient {
form.add(RESTConstants.FORM_PARAM_TARGET, brickTo);
form.add(RESTConstants.FORM_PARAM_OPERATION, RESTConstants.FORM_PARAM_VALUE_STATUS);
- return (Status) putRequest( volumeName + "/" + RESTConstants.RESOURCE_DISKS, Status.class, form);
+ return (Status) putRequest( volumeName + "/" + RESTConstants.RESOURCE_BRICKS, Status.class, form);
}
public static void main(String[] args) {
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 4e8e8f33..745e460b 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
@@ -34,6 +34,7 @@ public class RESTConstants {
public static final String RESOURCE_OPTIONS = "options";
public static final String RESOURCE_LOGS = "logs";
public static final String RESOURCE_DOWNLOAD = "download";
+ public static final String RESOURCE_BRICKS = "bricks";
public static final String RESOURCE_DISKS = "disks";
public static final String RESOURCE_RUNNING_TASKS = "runningtasks";
public static final String RESOURCE_ALERTS = "alerts";
diff --git a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Volume.java b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Volume.java
index 013ca5b7..7c9dfe42 100644
--- a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Volume.java
+++ b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Volume.java
@@ -24,8 +24,11 @@ import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
+import java.util.Map.Entry;
import java.util.Set;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;
@@ -160,6 +163,8 @@ public class Volume extends Entity {
this.cluster = cluster;
}
+ @XmlElementWrapper(name = "nasProtocols")
+ @XmlElement(name = "nasProtocol", type=NAS_PROTOCOL.class)
public Set<NAS_PROTOCOL> getNASProtocols() {
return nasProtocols;
}
@@ -242,6 +247,8 @@ public class Volume extends Entity {
bricks.remove(brick);
}
+ @XmlElementWrapper(name = "bricks")
+ @XmlElement(name = "brick", type=Brick.class)
public List<Brick> getBricks() {
return bricks;
}
diff --git a/src/com.gluster.storage.management.server/src/com/gluster/storage/management/server/resources/VolumesResource.java b/src/com.gluster.storage.management.server/src/com/gluster/storage/management/server/resources/VolumesResource.java
index 1cbab5b0..aa23fe3c 100644
--- a/src/com.gluster.storage.management.server/src/com/gluster/storage/management/server/resources/VolumesResource.java
+++ b/src/com.gluster.storage.management.server/src/com/gluster/storage/management/server/resources/VolumesResource.java
@@ -38,7 +38,7 @@ import static com.gluster.storage.management.core.constants.RESTConstants.QUERY_
import static com.gluster.storage.management.core.constants.RESTConstants.QUERY_PARAM_TO_TIMESTAMP;
import static com.gluster.storage.management.core.constants.RESTConstants.QUERY_PARAM_VOLUME_NAME;
import static com.gluster.storage.management.core.constants.RESTConstants.RESOURCE_DEFAULT_OPTIONS;
-import static com.gluster.storage.management.core.constants.RESTConstants.RESOURCE_DISKS;
+import static com.gluster.storage.management.core.constants.RESTConstants.RESOURCE_BRICKS;
import static com.gluster.storage.management.core.constants.RESTConstants.RESOURCE_DOWNLOAD;
import static com.gluster.storage.management.core.constants.RESTConstants.RESOURCE_LOGS;
import static com.gluster.storage.management.core.constants.RESTConstants.RESOURCE_OPTIONS;
@@ -228,7 +228,7 @@ public class VolumesResource {
@Path("{" + PATH_PARAM_VOLUME_NAME + "}")
@Produces(MediaType.TEXT_XML)
public Status deleteVolume(@PathParam(PATH_PARAM_CLUSTER_NAME) String clusterName,
- @QueryParam(QUERY_PARAM_VOLUME_NAME) String volumeName,
+ @PathParam(PATH_PARAM_VOLUME_NAME) String volumeName,
@QueryParam(QUERY_PARAM_DELETE_OPTION) boolean deleteFlag) {
GlusterServer onlineServer = glusterServersResource.getOnlineServer(clusterName);
if (onlineServer == null) {
@@ -262,7 +262,7 @@ public class VolumesResource {
}
@DELETE
- @Path("{" + QUERY_PARAM_VOLUME_NAME + "}/" + RESOURCE_DISKS)
+ @Path("{" + QUERY_PARAM_VOLUME_NAME + "}/" + RESOURCE_BRICKS)
@Produces(MediaType.TEXT_XML)
public Status removeBricks(@PathParam(PATH_PARAM_CLUSTER_NAME) String clusterName,
@PathParam(QUERY_PARAM_VOLUME_NAME) String volumeName, @QueryParam(QUERY_PARAM_BRICKS) String bricks,
@@ -594,7 +594,7 @@ public class VolumesResource {
}
@POST
- @Path("{" + QUERY_PARAM_VOLUME_NAME + "}/" + RESOURCE_DISKS)
+ @Path("{" + QUERY_PARAM_VOLUME_NAME + "}/" + RESOURCE_BRICKS)
public Status addBricks(@PathParam(PATH_PARAM_CLUSTER_NAME) String clusterName,
@PathParam(QUERY_PARAM_VOLUME_NAME) String volumeName, @FormParam(FORM_PARAM_BRICKS) String bricks) {
GlusterServer onlineServer = glusterServersResource.getOnlineServer(clusterName);
@@ -616,8 +616,8 @@ public class VolumesResource {
}
@PUT
- @Path("{" + QUERY_PARAM_VOLUME_NAME + "}/" + RESOURCE_DISKS)
- public Status replaceDisk(@PathParam(PATH_PARAM_CLUSTER_NAME) String clusterName,
+ @Path("{" + QUERY_PARAM_VOLUME_NAME + "}/" + RESOURCE_BRICKS)
+ public Status replaceBrick(@PathParam(PATH_PARAM_CLUSTER_NAME) String clusterName,
@PathParam(QUERY_PARAM_VOLUME_NAME) String volumeName, @FormParam(FORM_PARAM_SOURCE) String diskFrom,
@FormParam(FORM_PARAM_TARGET) String diskTo, @FormParam(FORM_PARAM_OPERATION) String operation) {
GlusterServer onlineServer = glusterServersResource.getOnlineServer(clusterName);