summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShireesh Anjal <shireesh@gluster.com>2011-05-25 18:12:48 +0530
committerShireesh Anjal <shireesh@gluster.com>2011-05-30 14:30:45 +0530
commit8a93639b21c1f347d8b8bc3ff033cc108bb26a0c (patch)
tree573cbafee44cf81374757d875ffaaaf553643cbb
parent66eeb6a273b1a60813375a4bf55bcc38e1a3d00a (diff)
Design changes - introducing cluster-server mapping on gateway
-rw-r--r--src/com.gluster.storage.management.client/src/com/gluster/storage/management/client/GlusterDataModelManager.java2
-rw-r--r--src/com.gluster.storage.management.client/src/com/gluster/storage/management/client/VolumesClient.java6
-rw-r--r--src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/utils/ProcessResult.java5
-rw-r--r--src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/ClusterSummaryView.java6
-rw-r--r--src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/GlusterServersSummaryView.java4
-rw-r--r--src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/VolumesSummaryView.java7
-rw-r--r--src/com.gluster.storage.management.server/src/com/gluster/storage/management/server/resources/GlusterServersResource.java12
-rw-r--r--src/com.gluster.storage.management.server/src/com/gluster/storage/management/server/resources/VolumesResource.java92
-rw-r--r--src/com.gluster.storage.management.server/src/com/gluster/storage/management/server/utils/GlusterUtil.java35
9 files changed, 104 insertions, 65 deletions
diff --git a/src/com.gluster.storage.management.client/src/com/gluster/storage/management/client/GlusterDataModelManager.java b/src/com.gluster.storage.management.client/src/com/gluster/storage/management/client/GlusterDataModelManager.java
index 356e1e0d..b01a0ece 100644
--- a/src/com.gluster.storage.management.client/src/com/gluster/storage/management/client/GlusterDataModelManager.java
+++ b/src/com.gluster.storage.management.client/src/com/gluster/storage/management/client/GlusterDataModelManager.java
@@ -137,7 +137,7 @@ public class GlusterDataModelManager {
}
private void initializeVolumes(Cluster cluster) {
- VolumesClient volumeClient = new VolumesClient(securityToken);
+ VolumesClient volumeClient = new VolumesClient(clusterName);
VolumeListResponse response = volumeClient.getAllVolumes();
if (!response.getStatus().isSuccess()) {
throw new GlusterRuntimeException("Error fetching volume list: [" + response.getStatus() + "]");
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 96517766..d38a41b3 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
@@ -31,6 +31,7 @@ import com.gluster.storage.management.core.constants.RESTConstants;
import com.gluster.storage.management.core.model.Brick;
import com.gluster.storage.management.core.model.Status;
import com.gluster.storage.management.core.model.Volume;
+import com.gluster.storage.management.core.response.GenericResponse;
import com.gluster.storage.management.core.response.LogMessageListResponse;
import com.gluster.storage.management.core.response.VolumeListResponse;
import com.gluster.storage.management.core.response.VolumeOptionInfoListResponse;
@@ -88,8 +89,9 @@ public class VolumesClient extends AbstractClient {
return (VolumeListResponse) fetchResource(VolumeListResponse.class);
}
- public Volume getVolume(String volumeName) {
- return (Volume) fetchSubResource(volumeName, Volume.class);
+ @SuppressWarnings("unchecked")
+ public GenericResponse<Volume> getVolume(String volumeName) {
+ return (GenericResponse<Volume>)fetchSubResource(volumeName, GenericResponse.class);
}
public Status deleteVolume(Volume volume, boolean deleteOption) {
diff --git a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/utils/ProcessResult.java b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/utils/ProcessResult.java
index 9d6ddc93..c297a9c4 100644
--- a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/utils/ProcessResult.java
+++ b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/utils/ProcessResult.java
@@ -61,4 +61,9 @@ public class ProcessResult {
public boolean isSuccess() {
return exitValue == SUCCESS;
}
+
+ @Override
+ public String toString() {
+ return "["+ getExitValue() + "][" + getOutput() + "]";
+ }
}
diff --git a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/ClusterSummaryView.java b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/ClusterSummaryView.java
index efecbf7a..da9d6544 100644
--- a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/ClusterSummaryView.java
+++ b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/ClusterSummaryView.java
@@ -128,7 +128,7 @@ public class ClusterSummaryView extends ViewPart {
private void createDiskSpaceSection() {
Composite section = guiHelper.createSection(form, toolkit, "Disk Space", null, 3, false);
if (cluster.getServers().size() == 0) {
- toolkit.createLabel(section, "This section will be populated after at least one server is added to the storage cloud.");
+ toolkit.createLabel(section, "This section will be populated after at least\none server is added to the storage cloud.");
return;
}
@@ -262,10 +262,10 @@ public class ClusterSummaryView extends ViewPart {
private void createCPUUsageSection() {
Composite section = guiHelper.createSection(form, toolkit, "CPU Usage (aggregated)", null, 1, false);
if (cluster.getServers().size() == 0) {
- toolkit.createLabel(section, "This section will be populated after at least one server is added to the storage cloud.");
+ toolkit.createLabel(section, "This section will be populated after at least\none server is added to the storage cloud.");
return;
}
- toolkit.createLabel(section, "Historical CPU Usage graph aggregated across all servers will be displayed here.");
+ toolkit.createLabel(section, "Historical CPU Usage graph aggregated across\nall servers will be displayed here.");
}
private void createNetworkUsageSection() {
diff --git a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/GlusterServersSummaryView.java b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/GlusterServersSummaryView.java
index ba9faca4..d80e3879 100644
--- a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/GlusterServersSummaryView.java
+++ b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/GlusterServersSummaryView.java
@@ -73,6 +73,10 @@ public class GlusterServersSummaryView extends ViewPart {
private void createSummarySection() {
Composite section = guiHelper.createSection(form, toolkit, "Availability", null, 2, false);
+ if(servers.getEntities().size() == 0) {
+ toolkit.createLabel(section, "This section will be populated after at least\none server is added to the storage cloud.");
+ return;
+ }
Double[] values = new Double[] { Double.valueOf(getServerCountByStatus(servers, SERVER_STATUS.ONLINE)),
Double.valueOf(getServerCountByStatus(servers, SERVER_STATUS.OFFLINE)) };
diff --git a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/VolumesSummaryView.java b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/VolumesSummaryView.java
index 88ca96c5..db2bb71d 100644
--- a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/VolumesSummaryView.java
+++ b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/VolumesSummaryView.java
@@ -133,8 +133,11 @@ public class VolumesSummaryView extends ViewPart {
private void createSummarySection() {
Composite section = guiHelper.createSection(form, toolkit, AVAILABILITY, null, 2, false);
- // Cluster cluster = GlusterDataModelManager.getInstance().getModel()
- // .getCluster();
+ if(volumes.getEntities().size() == 0) {
+ toolkit.createLabel(section,
+ "This section will be populated after at least\none volume is created the storage cloud.");
+ return;
+ }
Double[] values = new Double[] { Double.valueOf(getVolumeCountByStatus(volumes, VOLUME_STATUS.ONLINE)),
Double.valueOf(getVolumeCountByStatus(volumes, VOLUME_STATUS.OFFLINE)) };
diff --git a/src/com.gluster.storage.management.server/src/com/gluster/storage/management/server/resources/GlusterServersResource.java b/src/com.gluster.storage.management.server/src/com/gluster/storage/management/server/resources/GlusterServersResource.java
index 58f72ffd..d020a35e 100644
--- a/src/com.gluster.storage.management.server/src/com/gluster/storage/management/server/resources/GlusterServersResource.java
+++ b/src/com.gluster.storage.management.server/src/com/gluster/storage/management/server/resources/GlusterServersResource.java
@@ -102,7 +102,10 @@ public class GlusterServersResource extends AbstractServersResource {
return null;
}
- private GlusterServerListResponse getServerDetails(String clusterName) {
+ @GET
+ @Produces(MediaType.TEXT_XML)
+ public GlusterServerListResponse getGlusterServers(
+ @PathParam(PATH_PARAM_CLUSTER_NAME) String clusterName) {
GlusterServer onlineServer = getOnlineServer(clusterName);
if(onlineServer == null) {
return new GlusterServerListResponse(Status.STATUS_SUCCESS, new ArrayList<GlusterServer>());
@@ -146,13 +149,6 @@ public class GlusterServersResource extends AbstractServersResource {
}
@GET
- @Produces(MediaType.TEXT_XML)
- public GlusterServerListResponse getGlusterServers(
- @PathParam(PATH_PARAM_CLUSTER_NAME) String clusterName) {
- return getServerDetails(clusterName);
- }
-
- @GET
@Path("{serverName}")
@Produces(MediaType.TEXT_XML)
public GlusterServerResponse getGlusterServer(
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 3857f104..9a5ee0c5 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
@@ -20,9 +20,9 @@
*/
package com.gluster.storage.management.server.resources;
+import static com.gluster.storage.management.core.constants.RESTConstants.FORM_PARAM_BRICKS;
import static com.gluster.storage.management.core.constants.RESTConstants.FORM_PARAM_OPERATION;
import static com.gluster.storage.management.core.constants.RESTConstants.FORM_PARAM_SOURCE;
-import static com.gluster.storage.management.core.constants.RESTConstants.FORM_PARAM_BRICKS;
import static com.gluster.storage.management.core.constants.RESTConstants.FORM_PARAM_TARGET;
import static com.gluster.storage.management.core.constants.RESTConstants.FORM_PARAM_VALUE_START;
import static com.gluster.storage.management.core.constants.RESTConstants.FORM_PARAM_VALUE_STOP;
@@ -71,8 +71,10 @@ import javax.ws.rs.core.StreamingOutput;
import com.gluster.storage.management.core.constants.CoreConstants;
import com.gluster.storage.management.core.constants.RESTConstants;
+import com.gluster.storage.management.core.exceptions.ConnectionException;
import com.gluster.storage.management.core.exceptions.GlusterRuntimeException;
import com.gluster.storage.management.core.model.Brick;
+import com.gluster.storage.management.core.model.GlusterServer;
import com.gluster.storage.management.core.model.LogMessage;
import com.gluster.storage.management.core.model.Status;
import com.gluster.storage.management.core.model.Volume;
@@ -98,14 +100,17 @@ public class VolumesResource {
private static final String VOLUME_BRICK_LOG_SCRIPT = "get_volume_brick_log.py";
@InjectParam
- private static ServerUtil serverUtil;
+ private GlusterServersResource glusterServersResource;
+
+ @InjectParam
+ private ServerUtil serverUtil;
@InjectParam
- private static GlusterUtil glusterUtil;
+ private GlusterUtil glusterUtil;
- private static final FileUtil fileUtil = new FileUtil();
+ private FileUtil fileUtil = new FileUtil();
- private static GlusterCoreUtil glusterCoreUtil = new GlusterCoreUtil();
+ private GlusterCoreUtil glusterCoreUtil = new GlusterCoreUtil();
@InjectParam
private VolumeOptionsDefaults volumeOptionsDefaults;
@@ -113,13 +118,21 @@ public class VolumesResource {
@GET
@Produces(MediaType.TEXT_XML)
public VolumeListResponse getAllVolumes(@PathParam(PATH_PARAM_CLUSTER_NAME) String clusterName) {
+ GlusterServer onlineServer = glusterServersResource.getOnlineServer(clusterName);
+ if(onlineServer == null) {
+ return new VolumeListResponse(Status.STATUS_SUCCESS, new ArrayList<Volume>());
+ }
+
try {
- // TODO: pass cluster name to getAllVolumes
- return new VolumeListResponse(Status.STATUS_SUCCESS, glusterUtil.getAllVolumes());
- } catch (Exception e) {
- // TODO: log the error
- e.printStackTrace();
- return new VolumeListResponse(new Status(Status.STATUS_CODE_FAILURE, e.getMessage()), null);
+ return new VolumeListResponse(Status.STATUS_SUCCESS, glusterUtil.getAllVolumes(onlineServer.getName()));
+ } catch(ConnectionException e) {
+ // online server has gone offline! try with a different one.
+ onlineServer = glusterServersResource.getNewOnlineServer(clusterName);
+ if(onlineServer == null) {
+ return new VolumeListResponse(Status.STATUS_SUCCESS, new ArrayList<Volume>());
+ }
+
+ return new VolumeListResponse(Status.STATUS_SUCCESS, glusterUtil.getAllVolumes(onlineServer.getName()));
}
}
@@ -141,13 +154,28 @@ public class VolumesResource {
return status;
}
+ @SuppressWarnings("rawtypes")
@GET
@Path("{" + PATH_PARAM_VOLUME_NAME + "}")
@Produces(MediaType.TEXT_XML)
- public Volume getVolume(@PathParam(PATH_PARAM_CLUSTER_NAME) String clusterName,
+ public GenericResponse getVolume(@PathParam(PATH_PARAM_CLUSTER_NAME) String clusterName,
@PathParam(PATH_PARAM_VOLUME_NAME) String volumeName) {
- // TODO: Pass cluster name to getVolume
- return glusterUtil.getVolume(volumeName);
+ GlusterServer onlineServer = glusterServersResource.getOnlineServer(clusterName);
+ if(onlineServer == null) {
+ return new GenericResponse<Volume>(new Status(Status.STATUS_CODE_FAILURE, "No online servers found in cluster [" + clusterName + "]"), null);
+ }
+
+ try {
+ return new GenericResponse<Volume>(Status.STATUS_SUCCESS, glusterUtil.getVolume(volumeName, onlineServer.getName()));
+ } catch(ConnectionException e) {
+ // online server has gone offline! try with a different one.
+ onlineServer = glusterServersResource.getNewOnlineServer(clusterName);
+ if(onlineServer == null) {
+ return new GenericResponse<Volume>(new Status(Status.STATUS_CODE_FAILURE, "No online servers found in cluster [" + clusterName + "]"), null);
+ }
+
+ return new GenericResponse<Volume>(Status.STATUS_SUCCESS, glusterUtil.getVolume(volumeName, onlineServer.getName()));
+ }
}
@PUT
@@ -171,22 +199,32 @@ public class VolumesResource {
public Status deleteVolume(@PathParam(PATH_PARAM_CLUSTER_NAME) String clusterName,
@QueryParam(QUERY_PARAM_VOLUME_NAME) String volumeName,
@QueryParam(QUERY_PARAM_DELETE_OPTION) boolean deleteFlag) {
- // TODO: Delete volume on given cluster
- Volume volume = glusterUtil.getVolume(volumeName);
- Status status = glusterUtil.deleteVolume(volumeName);
-
- String deleteOption = "";
- if (deleteFlag) {
- deleteOption = "-d";
+ GlusterServer onlineServer = glusterServersResource.getOnlineServer(clusterName);
+ if(onlineServer == null) {
+ return new Status(Status.STATUS_CODE_FAILURE, "No online servers found in cluster [" + clusterName + "]");
}
+
+ Volume volume = null;
+ try {
+ volume = glusterUtil.getVolume(volumeName, onlineServer.getName());
+ } catch(ConnectionException e) {
+ // online server has gone offline! try with a different one.
+ onlineServer = glusterServersResource.getNewOnlineServer(clusterName);
+ if(onlineServer == null) {
+ return new Status(Status.STATUS_CODE_FAILURE, "No online servers found in cluster [" + clusterName + "]");
+ }
+ volume = glusterUtil.getVolume(volumeName, onlineServer.getName());
+ }
+
+ Status status = glusterUtil.deleteVolume(volumeName, onlineServer.getName());
if (status.isSuccess()) {
List<String> disks = volume.getDisks();
- Status postDeleteStatus = postDelete(volumeName, disks, deleteOption);
+ Status postDeleteStatus = postDelete(volumeName, disks, deleteFlag);
if (!postDeleteStatus.isSuccess()) {
status.setCode(Status.STATUS_CODE_PART_SUCCESS);
- status.setMessage("Error while post deletion operation: " + postDeleteStatus);
+ status.setMessage("Error in post-delete operation: " + postDeleteStatus);
}
}
return status;
@@ -218,7 +256,7 @@ public class VolumesResource {
return status;
}
- private Status postDelete(String volumeName, List<String> disks, String deleteFlag) {
+ private Status postDelete(String volumeName, List<String> disks, boolean deleteFlag) {
String serverName, diskName, diskInfo[];
Status result;
for (int i = 0; i < disks.size(); i++) {
@@ -226,7 +264,7 @@ public class VolumesResource {
serverName = diskInfo[0];
diskName = diskInfo[1];
result = (Status) serverUtil.executeOnServer(true, serverName, VOLUME_DIRECTORY_CLEANUP_SCRIPT + " "
- + diskName + " " + volumeName + " " + deleteFlag, Status.class);
+ + diskName + " " + volumeName + (deleteFlag ? " -d" : ""), Status.class);
if (!result.isSuccess()) {
return result;
}
@@ -384,7 +422,7 @@ public class VolumesResource {
@Override
public void write(OutputStream output) throws IOException, WebApplicationException {
- Volume volume = getVolume(clusterName, volumeName);
+ Volume volume = (Volume)getVolume(clusterName, volumeName).getData();
try {
// TODO: pass clusterName to downloadLogs
File archiveFile = new File(downloadLogs(volume));
@@ -435,7 +473,7 @@ public class VolumesResource {
try {
// TODO: Fetch logs from brick(s) of given cluster only
- Volume volume = getVolume(clusterName, volumeName);
+ Volume volume = (Volume)getVolume(clusterName, volumeName).getData();
if (brickName == null || brickName.isEmpty() || brickName.equals(CoreConstants.ALL)) {
logMessages = getLogsForAllBricks(volume, lineCount);
} else {
diff --git a/src/com.gluster.storage.management.server/src/com/gluster/storage/management/server/utils/GlusterUtil.java b/src/com.gluster.storage.management.server/src/com/gluster/storage/management/server/utils/GlusterUtil.java
index 64595e5f..7991cfb0 100644
--- a/src/com.gluster.storage.management.server/src/com/gluster/storage/management/server/utils/GlusterUtil.java
+++ b/src/com.gluster.storage.management.server/src/com/gluster/storage/management/server/utils/GlusterUtil.java
@@ -93,14 +93,6 @@ public class GlusterUtil {
return null;
}
- private GlusterServer getKnownServer(String knownServer) {
- GlusterServer server = new GlusterServer(knownServer);
- server.setStatus(SERVER_STATUS.ONLINE); //TODO: If pingable
- //NOTE: No UUID assumed, it can be fetch while getting server details
- return server;
- }
-
-
public GlusterServer getGlusterServer(GlusterServer onlineServer, String serverName) {
List<GlusterServer> servers = getGlusterServers(onlineServer);
for(GlusterServer server : servers) {
@@ -278,24 +270,23 @@ public class GlusterUtil {
return new Status(processUtil.executeCommand(command));
}
- public Status deleteVolume(String volumeName) {
- return new Status(processUtil.executeCommand("gluster", "--mode=script", "volume", "delete", volumeName));
+ public Status deleteVolume(String volumeName, String knownServer) {
+ return new Status(sshUtil.executeRemote(knownServer, "gluster --mode=script volume delete " + volumeName));
}
- private String getVolumeInfo(String volumeName) {
- ProcessResult result = new ProcessUtil().executeCommand("gluster", "volume", "info", volumeName);
+ private String getVolumeInfo(String volumeName, String knownServer) {
+ ProcessResult result = sshUtil.executeRemote(knownServer, "gluster volume info " + volumeName);
if (!result.isSuccess()) {
- throw new GlusterRuntimeException("Command [gluster volume info] failed with error: ["
- + result.getExitValue() + "][" + result.getOutput() + "]");
+ throw new GlusterRuntimeException("Command [gluster volume info] failed on [" + knownServer
+ + "] with error: " + result);
}
return result.getOutput();
}
- private String getVolumeInfo() {
- ProcessResult result = new ProcessUtil().executeCommand("gluster", "volume", "info");
+ private String getVolumeInfo(String knownServer) {
+ ProcessResult result = sshUtil.executeRemote(knownServer, "gluster volume info ");
if (!result.isSuccess()) {
- throw new GlusterRuntimeException("Command [gluster volume info] failed with error: ["
- + result.getExitValue() + "][" + result.getOutput() + "]");
+ throw new GlusterRuntimeException("Command [gluster volume info] failed on [" + knownServer + "] with error: " + result);
}
return result.getOutput();
}
@@ -399,16 +390,16 @@ public class GlusterUtil {
return false;
}
- public Volume getVolume(String volumeName) {
- List<Volume> volumes = parseVolumeInfo(getVolumeInfo(volumeName));
+ public Volume getVolume(String volumeName, String knownServer) {
+ List<Volume> volumes = parseVolumeInfo(getVolumeInfo(volumeName, knownServer));
if (volumes.size() > 0) {
return volumes.get(0);
}
return null;
}
- public List<Volume> getAllVolumes() {
- return parseVolumeInfo(getVolumeInfo());
+ public List<Volume> getAllVolumes(String knownServer) {
+ return parseVolumeInfo(getVolumeInfo(knownServer));
}
private List<Volume> parseVolumeInfo(String volumeInfoText) {