public double updateAllocationPercentages() { switch (schedulingPolicy) { case FAIR: int totalSessions = sessions.size() + initializingSessions.size(); if (totalSessions == 0) return 0; double allocation = finalFractionRemaining / totalSessions; for (WmTezSession session : sessions) { updateSessionAllocationWithEvent(session, allocation); } // Do not give out the capacity of the initializing sessions to the running ones; // we expect init to be fast. return finalFractionRemaining - allocation * initializingSessions.size(); case FIFO: if (sessions.isEmpty()) return 0; boolean isFirst = true; for (WmTezSession session : sessions) { updateSessionAllocationWithEvent(session, isFirst ? finalFractionRemaining : 0); isFirst = false; } return finalFractionRemaining; default: throw new AssertionError("Unexpected enum value " + schedulingPolicy); } }