VisitedResourceRequestTracker { boolean visit(ResourceRequest rr) { Priority priority = rr.getPriority(); Resource capability = rr.getCapability(); Map<Resource, TrackerPerPriorityResource> subMap = map.get(priority); if (subMap == null) { subMap = new HashMap<>(); map.put(priority, subMap); } TrackerPerPriorityResource tracker = subMap.get(capability); if (tracker == null) { tracker = new TrackerPerPriorityResource(); subMap.put(capability, tracker); } return tracker.visit(rr.getResourceName()); } VisitedResourceRequestTracker(
      ClusterNodeTracker<FSSchedulerNode> nodeTracker);   }
@Test public void testVisitAnyRequestFirst() { VisitedResourceRequestTracker tracker = new VisitedResourceRequestTracker(nodeTracker); assertTrue(FIRST_CALL_FAILURE, tracker.visit(anyRequest)); assertFalse(ANY_VISITED + RACK_FAILURE, tracker.visit(rackRequest)); assertFalse(ANY_VISITED + NODE_FAILURE, tracker.visit(node1Request)); assertFalse(ANY_VISITED + NODE_FAILURE, tracker.visit(node2Request)); }
@Test public void testVisitRackRequestFirst() { VisitedResourceRequestTracker tracker = new VisitedResourceRequestTracker(nodeTracker); assertTrue(FIRST_CALL_FAILURE, tracker.visit(rackRequest)); assertFalse(RACK_VISITED + ANY_FAILURE, tracker.visit(anyRequest)); assertFalse(RACK_VISITED + NODE_FAILURE, tracker.visit(node1Request)); assertFalse(RACK_VISITED + NODE_FAILURE, tracker.visit(node2Request)); }
@Test public void testVisitNodeRequestFirst() { VisitedResourceRequestTracker tracker = new VisitedResourceRequestTracker(nodeTracker); assertTrue(FIRST_CALL_FAILURE, tracker.visit(node1Request)); assertFalse(NODE_VISITED + ANY_FAILURE, tracker.visit(anyRequest)); assertFalse(NODE_VISITED + RACK_FAILURE, tracker.visit(rackRequest)); assertTrue(NODE_VISITED + "Different node visit failed", tracker.visit(node2Request)); }