int reservationsCount = 0;
for (Entry<InetSocketAddress, TEnqueueTaskReservationsRequest> entry : requests.entrySet()) {
// The node monitor the request is being sent to should be among the list of backend nodes.
assertTrue("Expect " + entry.getKey() + " to be among the set of backend nodes",
backendNodes.contains(entry.getKey()));
TEnqueueTaskReservationsRequest request = entry.getValue();
assertEquals(request.getAppId(), APP_ID);
assertEquals(request.getUser(), user);
assertEquals(request.getRequestId(), REQUEST_ID);
assertEquals(request.getSchedulerAddress(), SCHEDULER_ADDRESS);
// Expect the reservations to be evenly balanced over the machines.
assertTrue(request.getNumTasks() == 4 || request.getNumTasks() == 5);
reservationsCount += request.getNumTasks();
}
assertEquals(reservationsCount, EXPECTED_RESERVATIONS);
}
}