diff --git a/dfsclient/src/main/java/org/hpccsystems/dfs/client/FileUtility.java b/dfsclient/src/main/java/org/hpccsystems/dfs/client/FileUtility.java index 483065663..40c766323 100644 --- a/dfsclient/src/main/java/org/hpccsystems/dfs/client/FileUtility.java +++ b/dfsclient/src/main/java/org/hpccsystems/dfs/client/FileUtility.java @@ -426,7 +426,7 @@ private static Options getReadTestOptions() options.addOption("user", true, "Specifies the username used to connect. Defaults to null."); options.addOption("pass", true, "Specifies the password used to connect. Defaults to null."); options.addOption("num_threads", true, "Specifies the number of parallel to use to perform operations."); - options.addOption("expiry_seconds", true, "Access token expiration seconds."); + options.addOption("access_expiry_seconds", true, "Access token expiration seconds."); options.addOption(Option.builder("file_parts") .argName("_file_parts") @@ -1247,14 +1247,14 @@ private static void performReadTest(String[] args, TaskContext context) } int expirySeconds = DEFAULT_ACCESS_EXPIRY_SECONDS; - String expirySecondsStr = cmd.getOptionValue("expiry_seconds", "" + expirySeconds); + String expirySecondsStr = cmd.getOptionValue("access_expiry_seconds", "" + expirySeconds); try { expirySeconds = Integer.parseInt(expirySecondsStr); } catch(Exception e) { - System.out.println("Invalid option value for expiry_seconds: " + System.out.println("Invalid option value for access_expiry_seconds: " + numThreadsStr + ", must be an integer. Defaulting to: " + DEFAULT_ACCESS_EXPIRY_SECONDS + "s."); } diff --git a/dfsclient/src/main/java/org/hpccsystems/dfs/client/HpccRemoteFileReader.java b/dfsclient/src/main/java/org/hpccsystems/dfs/client/HpccRemoteFileReader.java index c3bb5da84..b77792dba 100644 --- a/dfsclient/src/main/java/org/hpccsystems/dfs/client/HpccRemoteFileReader.java +++ b/dfsclient/src/main/java/org/hpccsystems/dfs/client/HpccRemoteFileReader.java @@ -43,6 +43,7 @@ public class HpccRemoteFileReader implements Iterator private int connectTimeout = 0; private int readSizeKB = 0; private int limit = -1; + private int maxReadRetries = DEFAULT_READ_RETRIES; private int socketOpTimeoutMs = 0; private long openTimeMs = 0; private long recordsRead = 0; @@ -50,6 +51,7 @@ public class HpccRemoteFileReader implements Iterator public static final int NO_RECORD_LIMIT = -1; public static final int DEFAULT_READ_SIZE_OPTION = -1; public static final int DEFAULT_CONNECT_TIMEOUT_OPTION = -1; + public static final int DEFAULT_READ_RETRIES = 3; public static class FileReadResumeInfo { @@ -210,7 +212,7 @@ public HpccRemoteFileReader(DataPartition dp, FieldDef originalRD, IRecordBuilde if (this.originalRecordDef == null) { - throw new Exception("HpccRemoteFileReader: Original record definition is null."); + throw new Exception("HpccRemoteFileReader: Provided original record definition is null, original record definition is required."); } FieldDef projectedRecordDefinition = recBuilder.getRecordDefinition(); @@ -259,7 +261,7 @@ public HpccRemoteFileReader(DataPartition dp, FieldDef originalRD, IRecordBuilde private boolean retryRead() { - if (retryCount < 3) + if (retryCount < maxReadRetries) { log.info("Retrying read for " + this.dataPartition.toString() + " retry count: " + retryCount); retryCount++; @@ -302,6 +304,16 @@ private boolean retryRead() return false; } + /** + * Sets the maximum number of times to retry a read operation before failing. + * + * @param maxReadRetries + */ + public void setMaxReadRetries(int maxReadRetries) + { + this.maxReadRetries = maxReadRetries; + } + /** * Returns the stream position within the file. *