askhatri commented on code in PR #384:
URL: https://github.com/apache/incubator-livy/pull/384#discussion_r1094130842


##########
client-common/src/main/java/org/apache/livy/client/common/ClientConf.java:
##########
@@ -265,6 +265,51 @@ private Map<String, ConfPair> allAlternativeKeys() {
     return altToNewKeyMap;
   }
 
+  public static boolean validateTtl(String ttl) {
+    if (ttl == null || ttl.trim().isEmpty()) {
+      return true;
+    }
+    Matcher m = 
Pattern.compile("(-?[0-9]+)([a-z]+)?").matcher(ttl.trim().toLowerCase());
+    if (!m.matches()) {
+      LOG.error("Invalid ttl string: " + ttl);
+      return false;
+    }
+    long val = Long.parseLong(m.group(1));
+    if (val <= 0L) {
+      LOG.error("Invalid ttl value: " + val);
+      return false;
+    }
+    String suffix = m.group(2);
+    if (suffix != null && !TIME_SUFFIXES.containsKey(suffix)) {
+      LOG.error("Invalid ttl suffix: " + suffix);
+      return false;
+    }
+    return true;
+  }
+
+  public static long getTimeAsNanos(String time, int sessionId, long 
defaultVale) {

Review Comment:
   `getTimeAsMs()` is defined at class level as non-static method whereas 
`getTimeAsNanos()` is a static method. It not easy to reuse I believe.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to