diff options
author | Shireesh Anjal <shireesh@gluster.com> | 2011-09-22 18:13:35 +0530 |
---|---|---|
committer | Shireesh Anjal <shireesh@gluster.com> | 2011-09-22 18:13:35 +0530 |
commit | c126957e7d0932763a55ae074f03ee875911d503 (patch) | |
tree | 797ee31b540c1a5277d06df45bc4c8edef45f55d /src | |
parent | 8127168d2ca5e2a98d9061659e0e1308a48bb005 (diff) |
Introduced method GlusterUtil#getVolumeOptionsInfo and modified VolumeService#getVolumeOptionsInfo to call it
Diffstat (limited to 'src')
2 files changed, 5 insertions, 26 deletions
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 885957de..eb585b98 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 @@ -946,14 +946,13 @@ public class VolumeService { throw new GlusterRuntimeException("No online servers found in cluster [" + clusterName + "]"); } - String command = "gluster volume set help-xml"; try { - return serverUtil.executeOnServer(onlineServer.getName(), command, VolumeOptionInfoListResponse.class); + return glusterUtil.getVolumeOptionsInfo(onlineServer.getName()); } 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) { onlineServer = clusterService.getNewOnlineServer(clusterName); - return serverUtil.executeOnServer(onlineServer.getName(), command, VolumeOptionInfoListResponse.class); + return glusterUtil.getVolumeOptionsInfo(onlineServer.getName()); } else { throw new GlusterRuntimeException("Fetching volume options info failed! [" + 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 50a79f6e..3bcd5826 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,6 +44,7 @@ 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.response.VolumeOptionInfoListResponse; import com.gluster.storage.management.core.utils.StringUtil; @Component @@ -157,22 +158,6 @@ public class GlusterUtil { return glusterServers; } - public List<String> getGlusterServerNames(String knownServer) { - String output = getPeerStatus(knownServer); - if (output == null) { - return null; - } - - List<String> glusterServerNames = new ArrayList<String>(); - for (String line : output.split(CoreConstants.NEWLINE)) { - String hostName = extractToken(line, HOSTNAME_PFX); - if (hostName != null) { - glusterServerNames.add(hostName); - } - } - return glusterServerNames; - } - /** * @param knownServer * A known server on which the gluster command will be executed to fetch peer status @@ -571,12 +556,7 @@ public class GlusterUtil { return serverUtil.executeOnServer(onlineServerName, command, String.class).trim(); } - public static void main(String args[]) { - // List<String> names = new GlusterUtil().getGlusterServerNames(); - // System.out.println(names); - List<String> disks = new ArrayList<String>(); - disks.add("server1:sda"); - disks.add("server1:sdb"); - new GlusterUtil().addBricks("Volume3", disks, "localhost"); + public VolumeOptionInfoListResponse getVolumeOptionsInfo(String serverName) { + return serverUtil.executeOnServer(serverName, "gluster volume set help-xml", VolumeOptionInfoListResponse.class); } } |