private Map<String, Set<WorkerSlot>> hostToUsedSlots(Cluster cluster) { Collection<WorkerSlot> usedSlots = cluster.getUsedSlots(); Map<String, Set<WorkerSlot>> hostUsedSlots = new HashMap<String, Set<WorkerSlot>>(); for (WorkerSlot slot : usedSlots) { String host = cluster.getHost(slot.getNodeId()); Set<WorkerSlot> slots = hostUsedSlots.get(host); if (slots == null) { slots = new HashSet<WorkerSlot>(); hostUsedSlots.put(host, slots); } slots.add(slot); } return hostUsedSlots; }
@Override public void schedule(Topologies topologies, Cluster cluster) { LOG.debug("running Black List scheduler"); LOG.debug("AssignableSlots: {}", cluster.getAssignableSlots()); LOG.debug("AvailableSlots: {}", cluster.getAvailableSlots()); LOG.debug("UsedSlots: {}", cluster.getUsedSlots()); Map<String, SupervisorDetails> supervisors = cluster.getSupervisors(); blacklistStrategy.resumeFromBlacklist(); badSupervisors(supervisors); Set<String> blacklistHosts = getBlacklistHosts(cluster, topologies); this.blacklistHost = blacklistHosts; cluster.setBlacklistedHosts(blacklistHosts); removeLongTimeDisappearFromCache(); underlyingScheduler.schedule(topologies, cluster); }
long schedulingDuration = Time.currentTimeMillis() - startTime; LOG.info("Scheduling took " + schedulingDuration + " ms"); LOG.info("HAS {} SLOTS USED", cluster.getUsedSlots().size());