PendingTaskProcessor.java 文件源码

java
阅读 35 收藏 0 点赞 0 评论 0

项目:Mastering-Mesos 作者:
/**
 * Creates execution sequence for pending task groups by interleaving their unique occurrences.
 * For example: {G1, G1, G1, G2, G2} will be converted into {G1, G2, G1, G2, G1}.
 *
 * @param groups Multiset of task groups.
 * @return A task group execution sequence.
 */
private static List<TaskGroupKey> getPreemptionSequence(Multiset<TaskGroupKey> groups) {
  Multiset<TaskGroupKey> mutableGroups = HashMultiset.create(groups);
  List<TaskGroupKey> instructions = Lists.newLinkedList();
  Set<TaskGroupKey> keys = ImmutableSet.copyOf(groups.elementSet());
  while (!mutableGroups.isEmpty()) {
    for (TaskGroupKey key : keys) {
      if (mutableGroups.contains(key)) {
        instructions.add(key);
        mutableGroups.remove(key);
      }
    }
  }

  return instructions;
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号