diff options
| author | Shireesh Anjal <shireesh@gluster.com> | 2011-04-05 19:47:23 +0530 |
|---|---|---|
| committer | Selvam <selvam@gluster.com> | 2011-04-06 18:02:46 +0530 |
| commit | 4c69fc2e2a653d39216505ba583c428fb659d377 (patch) | |
| tree | cb605ead9b50c3b94e33591d8ca6165435a38dd6 /src/com.gluster.storage.management.core | |
| parent | c3c30b10360ac6c994ad72d9b857231b033a29f9 (diff) | |
Alerts and running task UI stories review updates
Diffstat (limited to 'src/com.gluster.storage.management.core')
4 files changed, 39 insertions, 28 deletions
diff --git a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Alert.java b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Alert.java index cfc710df..58e49efe 100644 --- a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Alert.java +++ b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/Alert.java @@ -6,7 +6,7 @@ import javax.xml.bind.annotation.XmlRootElement; public class Alert { public enum ALERT_TYPES { CPU_USAGE_ALERT, MEMORY_USAGE_ALERT, DISK_USAGE_ALERT, OFFLINE_VOLUME_DISKS_ALERT, OFFLINE_SERVERS_ALERT }; - public static final String[] ALERT_TYPE_STR = {"High CPU Usage", "High Memory Usage", "Low Disk Space", "Offline Disks", "Offline Servers" }; + public static final String[] ALERT_TYPE_STR = {"High CPU Usage", "High Memory Usage", "Low Disk Space", "Offline Disk", "Offline Server" }; protected String id; protected ALERT_TYPES type; diff --git a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/RunningTask.java b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/RunningTask.java index 9787f1ee..3860e6dc 100644 --- a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/RunningTask.java +++ b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/RunningTask.java @@ -22,12 +22,12 @@ import javax.xml.bind.annotation.XmlRootElement; @XmlRootElement public class RunningTask { - public enum TASK_TYPES { FORMAT_DISK, MIGRATE_DISK, VOLUME_REBALANCE }; - public String[] TASK_TYPE_STR = {"Formating Disk", "Migrating Disk", "Volume Rebalance"}; + public enum TASK_TYPES { DISK_FORMAT, DISK_MIGRATE, VOLUME_REBALANCE }; + public String[] TASK_TYPE_STR = {"Formatting Disk", "Disk Migration", "Volume Rebalance"}; protected String id; - protected TASK_TYPES type; // FormatDisk, MigrateDisk, VolumeRebalance - protected String reference; // Server: Server name, Volume: Volume name, Disk: disk name referred as "VolumeName:ServerName:DiskName" + protected TASK_TYPES type; + protected String reference; // Server: Server name, Volume: Volume name, Disk: disk name referred as "VolumeName:ServerName:DiskName" protected String taskInfo; protected RunningTaskStatus status; // TODO redefine @@ -35,7 +35,7 @@ public class RunningTask { } - public String getTaskType(TASK_TYPES type) { + public String getTaskType(TASK_TYPES task) { return TASK_TYPE_STR[type.ordinal()]; } 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 2322fa84..2386bcee 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 @@ -29,7 +29,6 @@ import java.util.Set; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlTransient; -import com.gluster.storage.management.core.model.Disk.DISK_STATUS; import com.gluster.storage.management.core.utils.StringUtil; @XmlRootElement @@ -49,6 +48,7 @@ public class Volume extends Entity { public enum NAS_PROTOCOL { GLUSTERFS, NFS }; + private static final String OPTION_AUTH_ALLOW = "auth.allow:"; private static final String[] VOLUME_TYPE_STR = new String[] { "Plain Distribute", "Distributed Mirror", "Distributed Stripe" }; @@ -174,7 +174,7 @@ public class Volume extends Entity { } public String getAccessControlList() { - return accessControlList; + return options.get(OPTION_AUTH_ALLOW); } public void setAccessControlList(String accessControlList) { diff --git a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/utils/GlusterUtil.java b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/utils/GlusterUtil.java index 0e2b0b8d..a5e6728f 100644 --- a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/utils/GlusterUtil.java +++ b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/utils/GlusterUtil.java @@ -25,6 +25,7 @@ import java.util.ArrayList; import java.util.List; import com.gluster.storage.management.core.constants.CoreConstants; +import com.gluster.storage.management.core.exceptions.GlusterRuntimeException; import com.gluster.storage.management.core.model.Disk; import com.gluster.storage.management.core.model.GlusterServer; import com.gluster.storage.management.core.model.GlusterServer.SERVER_STATUS; @@ -48,7 +49,6 @@ public class GlusterUtil { private static final String VOLUME_TRANSPORT_TYPE_PFX = "Transport-type:"; private static final String VOLUME_BRICKS_GROUP_PFX = "Bricks"; // Colon not used private static final String VOLUME_OPTIONS_RECONFIG_PFX = "Options Reconfigured"; - private static final String VOLUME_OPTIONS_AUTH_ALLOW = "auth.allow:"; private static final ProcessUtil processUtil = new ProcessUtil(); @@ -230,45 +230,54 @@ public class GlusterUtil { return disk.getServerName() + ":" + dirName; } - public ProcessResult getVolumeInfo() { - return new ProcessUtil().executeCommand("gluster", "volume", "info"); + private String getVolumeInfo() { + ProcessResult result = new ProcessUtil().executeCommand("gluster", "volume", "info"); + if (!result.isSuccess()) { + throw new GlusterRuntimeException("Command [gluster volume info] failed with error: [" + + result.getExitValue() + "][" + result.getOutput() + "]"); + } + return result.getOutput(); } - public List<Volume> getAllVolumes(String volumeInfoText) { + public List<Volume> getAllVolumes() { + String volumeInfoText = getVolumeInfo(); + List<Volume> volumes = new ArrayList<Volume>(); boolean isBricksGroupFound = false; boolean isOptionReconfigFound = false; - List<String> bricks = new ArrayList<String>(); Volume volume = null; for (String line : volumeInfoText.split(CoreConstants.NEWLINE)) { - if (extractToken(line, VOLUME_NAME_PFX) != null) { + String volumeName = extractToken(line, VOLUME_NAME_PFX); + if (volumeName != null) { if (volume != null) { - volume.setDisks(bricks); - bricks.clear(); + // add the previously read volume to volume list volumes.add(volume); } + + // prepare next volume to be read volume = new Volume(); - volume.setName(extractToken(line, VOLUME_NAME_PFX)); + volume.setName(volumeName); isBricksGroupFound = isOptionReconfigFound = false; continue; } - if (extractToken(line, VOLUME_TYPE_PFX) != null) { - String volumeType = extractToken(line, VOLUME_TYPE_PFX); + String volumeType = extractToken(line, VOLUME_TYPE_PFX); + if (volumeType != null) { volume.setVolumeType((volumeType == "Distribute") ? VOLUME_TYPE.PLAIN_DISTRIBUTE : VOLUME_TYPE.DISTRIBUTED_MIRROR); // TODO: for Stripe continue; } - if (extractToken(line, VOLUME_STATUS_PFX) != null) { - volume.setStatus(extractToken(line, VOLUME_STATUS_PFX).equals("Started") ? VOLUME_STATUS.ONLINE : VOLUME_STATUS.OFFLINE); + String volumeStatus = extractToken(line, VOLUME_STATUS_PFX); + if (volumeStatus != null) { + volume.setStatus(volumeStatus.equals("Started") ? VOLUME_STATUS.ONLINE : VOLUME_STATUS.OFFLINE); continue; } - if (extractToken(line, VOLUME_TRANSPORT_TYPE_PFX) != null) { - volume.setTransportType((extractToken(line, - VOLUME_TRANSPORT_TYPE_PFX) == "tcp") ? TRANSPORT_TYPE.ETHERNET + String transportType = extractToken(line, VOLUME_TRANSPORT_TYPE_PFX); + if (transportType != null) { + volume.setTransportType(transportType.equals("tcp") ? TRANSPORT_TYPE.ETHERNET : TRANSPORT_TYPE.INFINIBAND); continue; } @@ -280,7 +289,7 @@ public class GlusterUtil { if (isBricksGroupFound) { if (line.matches("Brick[0-9]+:.*")) { - bricks.add( line.split(":")[2].trim().split("/")[2].trim() ); // line: "Brick1: server1:/export/md0/volume-name" + volume.addDisk(line.split(":")[2].trim().split("/")[2].trim()); // line: "Brick1: server1:/export/md0/volume-name" continue; } else { isBricksGroupFound = false; @@ -293,14 +302,16 @@ public class GlusterUtil { } if (isOptionReconfigFound) { - if (extractToken(line, VOLUME_OPTIONS_AUTH_ALLOW) != null) { - volume.setAccessControlList( extractToken(line, VOLUME_OPTIONS_AUTH_ALLOW) ); + if(line.matches("^[^:]*:[^:]*$")) { + String[] parts = line.split(":"); + volume.setOption(parts[0].trim(), parts[1].trim()); + } else { isOptionReconfigFound = false; } } } + if (volume != null) {// Adding the last volume parsed - volume.setDisks(bricks); volumes.add(volume); } return volumes; |
