Skip to content

Commit 85cd82a

Browse files
author
Aparajita Choudhary
committed
lowercasing workflowid in workflow priority mappings
1 parent 1ddc909 commit 85cd82a

File tree

2 files changed

+15
-21
lines changed

2 files changed

+15
-21
lines changed

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/WorkflowPriorityMappingsManager.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ public class WorkflowPriorityMappingsManager {
5656

5757
private boolean overrideWithPriorityMappings = false;
5858
// Map of queue to a map of workflow ID to priority
59-
private Map<String, Map<String, WorkflowPriorityMapping>> priorityMappings =
60-
new HashMap<String, Map<String, WorkflowPriorityMapping>>();
59+
private Map<String, Map<String, Priority>> priorityMappings =
60+
new HashMap<>();
6161

6262
public static class WorkflowPriorityMapping {
6363
String workflowID;
@@ -115,10 +115,9 @@ public void initialize(CapacityScheduler scheduler) throws IOException {
115115
*
116116
* @return workflowID to priority mappings for a queue
117117
*/
118-
public Map<String, Map<String, WorkflowPriorityMapping>>
118+
public Map<String, Map<String, Priority>>
119119
getWorkflowPriorityMappings() {
120-
Map<String, Map<String, WorkflowPriorityMapping>> mappings =
121-
new HashMap<String, Map<String, WorkflowPriorityMapping>>();
120+
Map<String, Map<String, Priority>> mappings = new HashMap<>();
122121

123122
Collection<String> workflowMappings = conf.getWorkflowPriorityMappings();
124123
for (String workflowMapping : workflowMappings) {
@@ -127,9 +126,9 @@ public void initialize(CapacityScheduler scheduler) throws IOException {
127126
if (mapping != null) {
128127
if (!mappings.containsKey(mapping.queue)) {
129128
mappings.put(mapping.queue,
130-
new HashMap<String, WorkflowPriorityMapping>());
129+
new HashMap<String, Priority>());
131130
}
132-
mappings.get(mapping.queue).put(mapping.workflowID, mapping);
131+
mappings.get(mapping.queue).put(mapping.workflowID, mapping.priority);
133132
}
134133
}
135134
return mappings;
@@ -150,7 +149,8 @@ private WorkflowPriorityMapping getWorkflowMappingFromString(
150149
}
151150
WorkflowPriorityMapping mapping;
152151
try {
153-
mapping = new WorkflowPriorityMapping(mappingArray[0], mappingArray[1],
152+
//Converting workflow id to lowercase as yarn converts application tags also to lowercase
153+
mapping = new WorkflowPriorityMapping(StringUtils.toLowerCase(mappingArray[0]), mappingArray[1],
154154
Priority.newInstance(Integer.parseInt(mappingArray[2])));
155155
} catch (NumberFormatException e) {
156156
throw new IllegalArgumentException(
@@ -168,7 +168,7 @@ public Priority getMappedPriority(String workflowID, CSQueue queue) {
168168
String queuePath = queue.getQueuePath();
169169
if (priorityMappings.containsKey(queuePath)
170170
&& priorityMappings.get(queuePath).containsKey(workflowID)) {
171-
return priorityMappings.get(queuePath).get(workflowID).priority;
171+
return priorityMappings.get(queuePath).get(workflowID);
172172
} else {
173173
queue = queue.getParent();
174174
return getMappedPriority(workflowID, queue);

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestCapacitySchedulerWorkflowPriorityMapping.java

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ private static void setWorkFlowPriorityMappings(
7878
List<WorkflowPriorityMapping> mappings = Arrays.asList(
7979
new WorkflowPriorityMapping("workflow1", B, Priority.newInstance(2)),
8080
new WorkflowPriorityMapping("workflow2", A1, Priority.newInstance(3)),
81-
new WorkflowPriorityMapping("workflow3", A, Priority.newInstance(4)));
81+
new WorkflowPriorityMapping("Workflow3", A, Priority.newInstance(4)));
8282
conf.setWorkflowPriorityMappings(mappings);
8383
}
8484

@@ -98,17 +98,11 @@ public void testWorkflowPriorityMappings() throws Exception {
9898
CapacityScheduler cs = (CapacityScheduler) mockRM.getResourceScheduler();
9999
mockRM.start();
100100
cs.start();
101-
102-
Map<String, Map<String, Object>> expected = ImmutableMap.of(
103-
A, ImmutableMap.of("workflow3",
104-
new WorkflowPriorityMapping(
105-
"workflow3", A, Priority.newInstance(4))),
106-
B, ImmutableMap.of("workflow1",
107-
new WorkflowPriorityMapping(
108-
"workflow1", B, Priority.newInstance(2))),
109-
A1, ImmutableMap.of("workflow2",
110-
new WorkflowPriorityMapping(
111-
"workflow2", A1, Priority.newInstance(3))));
101+
102+
Map<String, Object> expected = ImmutableMap.of(
103+
A, ImmutableMap.of("workflow3", Priority.newInstance(4)),
104+
B, ImmutableMap.of("workflow1", Priority.newInstance(2)),
105+
A1, ImmutableMap.of("workflow2", Priority.newInstance(3)));
112106
assertEquals(expected, cs.getWorkflowPriorityMappingsManager()
113107
.getWorkflowPriorityMappings());
114108

0 commit comments

Comments
 (0)