summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSelvasundaram <selvam@gluster.com>2011-08-04 20:38:02 +0530
committerSelvasundaram <selvam@gluster.com>2011-08-08 12:05:10 +0530
commit5edcd8bcc9f29281ee227ca11153a2e918d90bfd (patch)
treec83bc7a74fbcdd5d51bf0f179300e96e680cab58 /src
parent9cd9cb2f6da78c01fb3282307af783fb20213de0 (diff)
Volume options integration
Diffstat (limited to 'src')
-rw-r--r--src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/model/VolumeOptionInfo.java2
-rw-r--r--src/com.gluster.storage.management.gateway/src/com/gluster/storage/management/gateway/constants/VolumeOptionsDefaults.java63
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<VolumeOptionInfo> getDefaults(String clusterName) {
- // return getVolumeOptionsInfo(clusterName);
- return getVolumeOptionsInfo();
+ return getVolumeOptionsInfo(clusterName);
+ // return getVolumeOptionsInfo();
}
@@ -136,44 +137,70 @@ public class VolumeOptionsDefaults {
public List<VolumeOptionInfo> 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("<volumeOptionsDefaults>", "<options>")
+ .replaceAll("</volumeOptionsDefaults>", "</options>").replaceAll("<volumeOption>", "<option>")
+ .replaceAll("</volumeOption>", "</option>");
+ 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 "<volumeOptionsDefaults><volumeOption><defaultValue>16</defaultValue><Description>Maximum number blocks per file for which self-heal process would be applied simultaneously.</Description><name>cluster.self-heal-window-size</name></volumeOption><volumeOption><defaultValue></defaultValue><Description>Select between &quot;full&quot;, &quot;diff&quot;. The &quot;full&quot; algorithm copies the entire file from source to sink. The &quot;diff&quot; algorithm copies to sink only those blocks whose checksums don't match with those of source.</Description><name>cluster.data-self-heal-algorithm</name></volumeOption><volumeOption><defaultValue>128KB</defaultValue><Description>Size of the stripe unit that would be read from or written to the striped servers.</Description><name>cluster.stripe-block-size</name></volumeOption><volumeOption><defaultValue>0</defaultValue><Description>Maximum file size which would be cached by the io-cache translator.</Description><name>performance.cache-max-file-size</name></volumeOption><volumeOption><defaultValue>0</defaultValue><Description>Minimum file size which would be cached by the io-cache translator.</Description><name>performance.cache-min-file-size</name></volumeOption><volumeOption><defaultValue>1</defaultValue><Description>The cached data for a file will be retained till 'cache-refresh-timeout' seconds, after which data re-validation is performed.</Description><name>performance.cache-refresh-timeout</name></volumeOption><volumeOption><defaultValue></defaultValue><Description>Assigns 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 earlier</Description><name>performance.cache-priority</name></volumeOption><volumeOption><defaultValue>on</defaultValue><Description>If 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. </Description><name>performance.flush-behind</name></volumeOption><volumeOption><defaultValue>16</defaultValue><Description>Number of threads in IO threads translator which perform concurrent IO operations</Description><name>performance.io-thread-count</name></volumeOption><volumeOption><defaultValue>1MB</defaultValue><Description>Size of the per-file write-behind buffer. </Description><name>performance.write-behind-window-size</name></volumeOption><volumeOption><defaultValue>off</defaultValue><Description>For 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.</Description><name>nfs.enable-ino32</name></volumeOption><volumeOption><defaultValue>15</defaultValue><Description>Use 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.</Description><name>nfs.mem-factor</name></volumeOption><volumeOption><defaultValue>on</defaultValue><Description>By 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.</Description><name>nfs.export-dirs</name></volumeOption><volumeOption><defaultValue>on</defaultValue><Description>Enable 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.</Description><name>nfs.export-volumes</name></volumeOption><volumeOption><defaultValue>on</defaultValue><Description>Users 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.</Description><name>nfs.addr-namelookup</name></volumeOption><volumeOption><defaultValue>on</defaultValue><Description>For 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 default</Description><name>nfs.register-with-portmap</name></volumeOption><volumeOption><defaultValue></defaultValue><Description>Use this option on systems that need Gluster NFS to be associated with a non-default port number.</Description><name>nfs.port</name></volumeOption><volumeOption><defaultValue>on</defaultValue><Description>Disable 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.</Description><name>nfs.rpc-auth-unix</name></volumeOption><volumeOption><defaultValue></defaultValue><Description>Allow 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.</Description><name>nfs.rpc-auth-allow</name></volumeOption><volumeOption><defaultValue></defaultValue><Description>Reject 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.</Description><name>nfs.rpc-auth-reject</name></volumeOption><volumeOption><defaultValue></defaultValue><Description>Allow 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.</Description><name>nfs.ports-insecure</name></volumeOption><volumeOption><defaultValue>off</defaultValue><Description>All 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.</Description><name>nfs.trusted-sync</name></volumeOption><volumeOption><defaultValue>off</defaultValue><Description>On 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.</Description><name>nfs.trusted-write</name></volumeOption><volumeOption><defaultValue>read-write</defaultValue><Description>Type of access desired for this subvolume: read-only, read-write(default)</Description><name>nfs.volume-access</name></volumeOption><volumeOption><defaultValue></defaultValue><Description>By 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.</Description><name>nfs.export-dir</name></volumeOption><volumeOption><defaultValue>off</defaultValue><Description>This option is used to enable/disable NFS serverfor individual volume.</Description><name>nfs.disable</name></volumeOption></volumeOptionsDefaults>";
+// }
+//
+//
+//
+// 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("<volumeOptionsDefaults>", "<options>")
+// .replaceAll("</volumeOptionsDefaults>", "</options>").replaceAll("<volumeOption>", "<option>")
+// .replaceAll("</volumeOption>", "</option>");
// } 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