From 5edcd8bcc9f29281ee227ca11153a2e918d90bfd Mon Sep 17 00:00:00 2001 From: Selvasundaram Date: Thu, 4 Aug 2011 20:38:02 +0530 Subject: Volume options integration --- .../management/core/model/VolumeOptionInfo.java | 2 +- .../gateway/constants/VolumeOptionsDefaults.java | 63 +++++++++++++++------- 2 files changed, 46 insertions(+), 19 deletions(-) diff --git a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/VolumeOptionInfo.java b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/VolumeOptionInfo.java index 44e45df5..2cafc4b5 100644 --- a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/VolumeOptionInfo.java +++ b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/VolumeOptionInfo.java @@ -25,7 +25,7 @@ import javax.xml.bind.annotation.XmlRootElement; /** * Class to hold information about a volume option */ -@XmlRootElement(name = "volumeOption") +@XmlRootElement(name = "option") public class VolumeOptionInfo { private String name; private String description; diff --git a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/constants/VolumeOptionsDefaults.java b/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/constants/VolumeOptionsDefaults.java index bdc9ce58..967b670d 100644 --- a/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/constants/VolumeOptionsDefaults.java +++ b/src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/constants/VolumeOptionsDefaults.java @@ -30,6 +30,7 @@ import com.gluster.storage.management.core.constants.CoreConstants; import com.gluster.storage.management.core.exceptions.ConnectionException; import com.gluster.storage.management.core.exceptions.GlusterRuntimeException; import com.gluster.storage.management.core.model.GlusterServer; +import com.gluster.storage.management.core.model.Status; import com.gluster.storage.management.core.model.VolumeOptionInfo; import com.gluster.storage.management.core.response.VolumeOptionInfoListResponse; import com.gluster.storage.management.gateway.services.ClusterService; @@ -54,8 +55,8 @@ public class VolumeOptionsDefaults { * @return list of volume option information objects */ public List getDefaults(String clusterName) { - // return getVolumeOptionsInfo(clusterName); - return getVolumeOptionsInfo(); + return getVolumeOptionsInfo(clusterName); + // return getVolumeOptionsInfo(); } @@ -136,44 +137,70 @@ public class VolumeOptionsDefaults { public List getVolumeOptionsInfo(String clusterName) { String command = "gluster volume set help-xml"; + String output = ""; VolumeOptionInfoListResponse options = new VolumeOptionInfoListResponse(); GlusterServer onlineServer = clusterService.getOnlineServer(clusterName); try { - options = getVolumeOptionsInfo(onlineServer.getName(), command); + output = getVolumeOptionsInfo(onlineServer.getName(), command); + options = parseXML(output); return options.getOptions(); } catch (ConnectionException e) { onlineServer = clusterService.getNewOnlineServer(clusterName); - options = getVolumeOptionsInfo(onlineServer.getName(), command); + output = getVolumeOptionsInfo(onlineServer.getName(), command); + options = parseXML(output); return options.getOptions(); } catch (Exception e) { throw new GlusterRuntimeException("Fetching volume options default failed! [" + e.getMessage() + "]"); } } - private VolumeOptionInfoListResponse getVolumeOptionsInfo(String serverName, String command) { - return (VolumeOptionInfoListResponse) serverUtil.executeOnServer(true, serverName, command, - VolumeOptionInfoListResponse.class); + private String getVolumeOptionsInfo(String serverName, String command) { + return serverUtil.executeOnServer(true, serverName, command, + String.class); + } + + public VolumeOptionInfoListResponse parseXML(String xml) { + xml = xml.replaceAll("", "") + .replaceAll("", "").replaceAll("", "", ""); + Object response = serverUtil.unmarshal(VolumeOptionInfoListResponse.class, xml); + if (response instanceof Status) { + throw new GlusterRuntimeException(((Status) response).getMessage()); + } + return (VolumeOptionInfoListResponse) response; } - public static void main(String[] args) { +// public String getHelpxml() { +// return "16Maximum number blocks per file for which self-heal process would be applied simultaneously.cluster.self-heal-window-sizeSelect between "full", "diff". The "full" algorithm copies the entire file from source to sink. The "diff" algorithm copies to sink only those blocks whose checksums don't match with those of source.cluster.data-self-heal-algorithm128KBSize of the stripe unit that would be read from or written to the striped servers.cluster.stripe-block-size0Maximum file size which would be cached by the io-cache translator.performance.cache-max-file-size0Minimum file size which would be cached by the io-cache translator.performance.cache-min-file-size1The cached data for a file will be retained till 'cache-refresh-timeout' seconds, after which data re-validation is performed.performance.cache-refresh-timeoutAssigns priority to filenames with specific patterns so that when a page needs to be ejected out of the cache, the page of a file whose priority is the lowest will be ejected earlierperformance.cache-priorityonIf this option is set ON, instructs write-behind translator to perform flush in background, by returning success (or any errors, if any of previous writes were failed) to application even before flush is sent to backend filesystem. performance.flush-behind16Number of threads in IO threads translator which perform concurrent IO operationsperformance.io-thread-count1MBSize of the per-file write-behind buffer. performance.write-behind-window-sizeoffFor nfs clients or apps that do not support 64-bit inode numbers, use this option to make NFS return 32-bit inode numbers instead. Disabled by default so NFS returns 64-bit inode numbers by default.nfs.enable-ino3215Use this option to make NFS be faster on systems by using more memory. This option specifies a multiple that determines the total amount of memory used. Default value is 15. Increase to use more memory in order to improve performance for certain use cases.Please consult gluster-users list before using this option.nfs.mem-factoronBy default, all subvolumes of nfs are exported as individual exports. There are cases where a subdirectory or subdirectories in the volume need to be exported separately. Enabling this option allows any directory on a volumes to be exported separately. Directory exports are enabled by default.nfs.export-dirsonEnable or disable exporting whole volumes, instead if used in conjunction with nfs3.export-dir, can allow setting up only subdirectories as exports. On by default.nfs.export-volumesonUsers have the option of turning off name lookup for incoming client connections using this option. In some setups, the name server can take too long to reply to DNS queries resulting in timeouts of mount requests. Use this option to turn off name lookups during address authentication. Note, turning this off will prevent you from using hostnames in rpc-auth.addr.* filters. By default, name lookup is on.nfs.addr-namelookuponFor systems that need to run multiple nfs servers, weneed to prevent more than one from registering with portmap service. Use this option to turn off portmap registration for Gluster NFS. On by defaultnfs.register-with-portmapUse this option on systems that need Gluster NFS to be associated with a non-default port number.nfs.portonDisable or enable the AUTH_UNIX authentication type for a particular exported volume over-riding defaults and general setting for AUTH_UNIX scheme. Must always be enabled for better interoperability.However, can be disabled if needed. Enabled bydefault.nfs.rpc-auth-unixAllow a comma separated list of addresses and/or hostnames to connect to the server. By default, all connections are disallowed. This allows users to define a rule for a specific exported volume.nfs.rpc-auth-allowReject a comma separated list of addresses and/or hostnames from connecting to the server. By default, all connections are disallowed. This allows users todefine a rule for a specific exported volume.nfs.rpc-auth-rejectAllow client connections from unprivileged ports. By default only privileged ports are allowed. Use this option to set enable or disable insecure ports for a specific subvolume and to over-ride global setting set by the previous option.nfs.ports-insecureoffAll writes and COMMIT requests are treated as async. This implies that no write requests are guaranteed to be on server disks when the write reply is received at the NFS client. Trusted sync includes trusted-write behaviour. Off by default.nfs.trusted-syncoffOn an UNSTABLE write from client, return STABLE flag to force client to not send a COMMIT request. In some environments, combined with a replicated GlusterFS setup, this option can improve write performance. This flag allows user to trust Gluster replication logic to sync data to the disks and recover when required. COMMIT requests if received will be handled in a default manner by fsyncing. STABLE writes are still handled in a sync manner. Off by default.nfs.trusted-writeread-writeType of access desired for this subvolume: read-only, read-write(default)nfs.volume-accessBy default, all subvolumes of nfs are exported as individual exports. There are cases where a subdirectory or subdirectories in the volume need to be exported separately. This option can also be used in conjunction with nfs3.export-volumes option to restrict exports only to the subdirectories specified through this option. Must be an absolute path.nfs.export-diroffThis option is used to enable/disable NFS serverfor individual volume.nfs.disable"; +// } +// +// +// +// public static void main(String[] args) { +// VolumeOptionsDefaults vod = new VolumeOptionsDefaults(); // String command = "gluster volume set help-xml"; // String output = ""; // ServerUtil serverUtil = new ServerUtil(); // try { -// Process p = Runtime.getRuntime().exec(command); -// p.waitFor(); -// BufferedReader reader = new BufferedReader(new InputStreamReader(p.getInputStream())); -// String line = reader.readLine(); -// while (line != null) { -// output += line; -// line = reader.readLine(); -// } +//// Process p = Runtime.getRuntime().exec(command); +//// p.waitFor(); +//// BufferedReader reader = new BufferedReader(new InputStreamReader(p.getInputStream())); +//// String line = reader.readLine(); +//// while (line != null) { +//// output += line; +//// line = reader.readLine(); +//// } +// output = vod.getHelpxml(); +// output = output.replaceAll("", "") +// .replaceAll("", "").replaceAll("", "", ""); // } catch (Exception e) { // System.out.println("Error in executing command ...." + e.getMessage()); +// return; // } -// Object response = serverUtil.unmarshal(VolumeOptionInfoListResponse.class, output, false); +// Object response = serverUtil.unmarshal(VolumeOptionInfoListResponse.class, output); // if (response instanceof Status) { // System.out.println("Error: " + response.toString()); // return; @@ -181,5 +208,5 @@ public class VolumeOptionsDefaults { // for (VolumeOptionInfo option : ((VolumeOptionInfoListResponse) response).getOptions()) { // System.out.println(option.getName() + " : " + option.getDefaultValue() ); // } - } +// } } \ No newline at end of file -- cgit