Source:
<code>public List<WorkerSlot> allSlotsAvailableForScheduling(RotatingMap<Protos.OfferID, Protos.Offer> offers, Collection<SupervisorDetails> existingSupervisors, Topologies topologies, Set<String> topologiesMissingAssignments) { if (topologiesMissingAssignments.isEmpty()) { log.info("Declining all offers that are currently buffered because no topologies need assignments"); offers.clear(); return new ArrayList<>(); } log.info("Topologies that need assignments: {}", topologiesMissingAssignments.toString()); List<WorkerSlot> allSlots = new ArrayList<>(); Map<String, OfferResources> offerResourcesPerNode = MesosCommon.getConsolidatedOfferResourcesPerNode(offers); for (String currentTopology : topologiesMissingAssignments) { TopologyDetails topologyDetails = topologies.getById(currentTopology); int slotsNeeded = topologyDetails.getNumWorkers(); <START> <END> log.info("Trying to find slots for {}", slotsNeeded, topologyDetails.getId()); if (slotsNeeded <= 0) { continue; } Set<String> nodesWithExistingSupervisors = new HashSet<>(); for (String currentNode : offerResourcesPerNode.keySet()) { if (SchedulerUtils.supervisorExists(currentNode, existingSupervisors, currentTopology)) { nodesWithExistingSupervisors.add(currentNode); } } List<MesosWorkerSlot> mesosWorkerSlotList = getMesosWorkerSlots(offerResourcesPerNode, nodesWithExistingSupervisors, topologyDetails); for (MesosWorkerSlot mesosWorkerSlot : mesosWorkerSlotList) { String slotId = String.format("%s:%s", mesosWorkerSlot.getNodeId(), mesosWorkerSlot.getPort()); mesosWorkerSlotMap.put(slotId, mesosWorkerSlot); allSlots.add(mesosWorkerSlot); } log.info("Number of available slots for : {}", topologyDetails.getId(), allSlots.size()); } log.info("Number of available slots: {}", allSlots.size()); return allSlots; }</code><technical_language>nit: remove extraneous newline please (or dd)</technical_language>

Target:
public List<WorkerSlot> allSlotsAvailableForScheduling(RotatingMap<Protos.OfferID, Protos.Offer> offers, Collection<SupervisorDetails> existingSupervisors, Topologies topologies, Set<String> topologiesMissingAssignments) { if (topologiesMissingAssignments.isEmpty()) { log.info("Declining all offers that are currently buffered because no topologies need assignments"); offers.clear(); return new ArrayList<>(); } log.info("Topologies that need assignments: {}", topologiesMissingAssignments.toString()); List<WorkerSlot> allSlots = new ArrayList<>(); Map<String, AggregatedOffers> aggregatedOffersPerNode = MesosCommon.getAggregatedOffersPerNode(offers); for (String currentTopology : topologiesMissingAssignments) { TopologyDetails topologyDetails = topologies.getById(currentTopology); int slotsNeeded = topologyDetails.getNumWorkers(); log.info("Trying to find slots for {}", slotsNeeded, topologyDetails.getId()); if (slotsNeeded <= 0) { continue; } Set<String> nodesWithExistingSupervisors = new HashSet<>(); for (String currentNode : aggregatedOffersPerNode.keySet()) { if (SchedulerUtils.supervisorExists(currentNode, existingSupervisors, currentTopology)) { nodesWithExistingSupervisors.add(currentNode); } } List<MesosWorkerSlot> mesosWorkerSlotList = getMesosWorkerSlots(aggregatedOffersPerNode, nodesWithExistingSupervisors, topologyDetails); for (MesosWorkerSlot mesosWorkerSlot : mesosWorkerSlotList) { String slotId = String.format("%s:%s", mesosWorkerSlot.getNodeId(), mesosWorkerSlot.getPort()); mesosWorkerSlotMap.put(slotId, mesosWorkerSlot); allSlots.add(mesosWorkerSlot); } log.info("Number of available slots for : {}", topologyDetails.getId(), allSlots.size()); } log.info("Number of available slots: {}", allSlots.size()); return allSlots; }