code: private static void trickleShareDownPriorityGroups(
        double share,
        TreeMap<Integer, Vector<Schedulable>> prioritizedSchedulableMap) {
  
      double surplusDemandForPriorityGroup, totalMinDemandForPriorityGroup;
      for (Map.Entry<Integer, Vector<Schedulable>> entry :
          prioritizedSchedulableMap.descendingMap().entrySet()) {
        Vector<Schedulable> schedulableVector = entry.getValue();
        if (share <= 0) {
          distributeShareMin(schedulableVector);
          continue;
        }
  
        surplusDemandForPriorityGroup = 0.0;
        totalMinDemandForPriorityGroup = 0.0;
  
        for (Schedulable schedulable : schedulableVector) {
          double d = Math.min(schedulable.getMaximum(),
                              schedulable.getRequested());
          totalMinDemandForPriorityGroup +=
              Math.min(schedulable.getMinimum(), d);
          surplusDemandForPriorityGroup +=
              Math.max(0, d - schedulable.getMinimum());
        }
  
        if (surplusDemandForPriorityGroup >= share) {
          distributeShareFair(share + totalMinDemandForPriorityGroup,
                              schedulableVector);
        } else {
          distributeShareMax(schedulableVector);
        }
        share -= surplusDemandForPriorityGroup;
      }
    }
docs: Does PRIORITY share distribution across priority groups.
  Algorithm is as follows:
  Starting from the highest priority,
  try to allocate min(max_alloc, demand) to priority group.
  If that's possible, then move to the next prty group in order.
  If that's not possible, do fair share on that prty group
  and then allocate min_alloc to all the other
  priority groups.
  
  @param share The number of resources that need to be allocated.
  @param prioritizedSchedulableMap The priority group map.