diff options
| author | Shireesh Anjal <shireesh@gluster.com> | 2011-07-22 16:10:03 +0530 |
|---|---|---|
| committer | Shireesh Anjal <shireesh@gluster.com> | 2011-07-22 16:10:03 +0530 |
| commit | 660a3afa12de06e790e74a0dae55f0f1dbeaab74 (patch) | |
| tree | eb34b1b19a22d38c1a9b774e0ee671353b8453e0 /src/com.gluster.storage.management.server | |
| parent | 5aaec5b2bb350cd7414fb4077c2db982599ed9c1 (diff) | |
| parent | 500221df2e0a79a055256fc87aa6a54dec34725a (diff) | |
Merge branch 'master' of github.com:gluster/console
Diffstat (limited to 'src/com.gluster.storage.management.server')
| -rw-r--r-- | src/com.gluster.storage.management.server/src/com/gluster/storage/management/server/utils/GlusterUtil.java | 32 |
1 files changed, 26 insertions, 6 deletions
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 9878f223..f43b7ae6 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 @@ -392,20 +392,40 @@ public class GlusterUtil { return false; } - private boolean readBrick(Volume volume, String line) { - if (line.matches("Brick[0-9]+:.*")) { + private boolean readBrick(Volume volume, String brickLine) { + BRICK_STATUS brickStatus; + if (brickLine.matches("Brick[0-9]+:.*")) { // line: "Brick1: server1:/export/md0/volume-name" - String[] brickParts = line.split(":"); + String brickName = brickLine.split(": ")[1]; + String[] brickParts = brickLine.split(":"); String serverName = brickParts[1].trim(); String brickDir = brickParts[2].trim(); - addBrickToVolume(volume, serverName, brickDir); + //To get the brick status + brickStatus = getBrickStatus(serverName, volume.getName(), brickName); + + addBrickToVolume(volume, serverName, brickDir, brickStatus); return true; } return false; } - private void addBrickToVolume(Volume volume, String serverName, String brickDir) { - volume.addBrick(new Brick(serverName, BRICK_STATUS.ONLINE, brickDir.split("/")[2].trim(), brickDir)); + private void addBrickToVolume(Volume volume, String serverName, String brickDir, BRICK_STATUS status) { + volume.addBrick(new Brick(serverName, status, brickDir.split("/")[2].trim(), brickDir)); + } + + // Do not throw exception, Gracefully handle as Offline brick. + private BRICK_STATUS getBrickStatus(String serverName, String volumeName, String brick){ + try { + ProcessResult output = getSshUtil().executeRemote(serverName, "get_brick_status.py" + " " + volumeName + " " + brick); + + if (output.isSuccess() && output.getOutput().equals(CoreConstants.ONLINE)) { + return BRICK_STATUS.ONLINE; + } else { + return BRICK_STATUS.OFFLINE; + } + } catch(Exception e) { // Particularly interested on ConnectionExecption, if the server is offline + return BRICK_STATUS.OFFLINE; + } } private boolean readBrickGroup(String line) { |
