diff --git hcatalog/webhcat/svr/src/main/java/org/apache/hive/hcatalog/templeton/AppConfig.java hcatalog/webhcat/svr/src/main/java/org/apache/hive/hcatalog/templeton/AppConfig.java index 062d5a0..f3f0337 100644 --- hcatalog/webhcat/svr/src/main/java/org/apache/hive/hcatalog/templeton/AppConfig.java +++ hcatalog/webhcat/svr/src/main/java/org/apache/hive/hcatalog/templeton/AppConfig.java @@ -88,6 +88,12 @@ "webhcat-default.xml", "webhcat-site.xml" }; + + public enum JobsListOrder + { + lexicographicalasc, + lexicographicaldesc, + } public static final String PORT = "templeton.port"; public static final String EXEC_ENCODING_NAME = "templeton.exec.encoding"; @@ -105,6 +111,7 @@ public static final String HIVE_PATH_NAME = "templeton.hive.path"; public static final String MAPPER_MEMORY_MB = "templeton.mapper.memory.mb"; public static final String MR_AM_MEMORY_MB = "templeton.mr.am.memory.mb"; + public static final String TEMPLETON_JOBSLIST_ORDER = "templeton.jobs.listorder"; /** * see webhcat-default.xml @@ -280,6 +287,21 @@ public int compare(Map.Entry ent, Map.Entry ent2 } } } + + public JobsListOrder getListJobsOrder() { + String requestedOrder = get(TEMPLETON_JOBSLIST_ORDER); + if (requestedOrder != null) { + try { + return JobsListOrder.valueOf(requestedOrder.toLowerCase()); + } + catch(IllegalArgumentException ex) { + LOG.warn("Ignoring setting " + TEMPLETON_JOBSLIST_ORDER + " configured with in-correct value " + requestedOrder); + } + } + + // Default to lexicographicalasc + return JobsListOrder.lexicographicalasc; + } public void startCleanup() { JobState.getStorageInstance(this).startCleanup(this); diff --git hcatalog/webhcat/svr/src/main/java/org/apache/hive/hcatalog/templeton/Server.java hcatalog/webhcat/svr/src/main/java/org/apache/hive/hcatalog/templeton/Server.java index 27b8e38..bba16c5 100644 --- hcatalog/webhcat/svr/src/main/java/org/apache/hive/hcatalog/templeton/Server.java +++ hcatalog/webhcat/svr/src/main/java/org/apache/hive/hcatalog/templeton/Server.java @@ -1002,8 +1002,16 @@ public QueueStatusBean deleteJobId(@PathParam("jobid") String jobid) throw new BadParam("Invalid numrecords format: numrecords should be an integer > 0"); } - // Sort the list lexicographically - Collections.sort(list); + // Sort the list as requested + switch (appConf.getListJobsOrder()) { + case lexicographicaldesc: + Collections.sort(list, Collections.reverseOrder()); + break; + case lexicographicalasc: + default: + Collections.sort(list); + break; + } for (String job : list) { // If numRecords = -1, fetch all records.