/** * Free everything on the given slots. * * @param workerSlots the slots to free */ public void freeSlots(Collection<WorkerSlot> workerSlots) { for (RAS_Node node : nodeMap.values()) { for (WorkerSlot ws : node.getUsedSlots()) { if (workerSlots.contains(ws)) { LOG.debug("freeing ws {} on node {}", ws, node); node.free(ws); } } } }
/** * frees a single executor. * * @param exec is the executor to free * @param topo the topology the executor is a part of */ public void freeSingleExecutor(ExecutorDetails exec, TopologyDetails topo) { Map<String, Collection<ExecutorDetails>> usedSlots = topIdToUsedSlots.get(topo.getId()); if (usedSlots == null) { throw new IllegalArgumentException("Topology " + topo + " is not assigned"); } WorkerSlot ws = null; Set<ExecutorDetails> updatedAssignment = new HashSet<>(); for (Entry<String, Collection<ExecutorDetails>> entry : usedSlots.entrySet()) { if (entry.getValue().contains(exec)) { ws = slots.get(entry.getKey()); updatedAssignment.addAll(entry.getValue()); updatedAssignment.remove(exec); break; } } if (ws == null) { throw new IllegalArgumentException( "Executor " + exec + " is not assinged on this node to " + topo); } free(ws); if (!updatedAssignment.isEmpty()) { assign(ws, topo, updatedAssignment); } }
/** * Assign a single executor to a slot, even if other things are in the slot. * @param ws the slot to assign it to. * @param exec the executor to assign. * @param td the topology for the executor. */ public void assignSingleExecutor(WorkerSlot ws, ExecutorDetails exec, TopologyDetails td) { if (!isAlive) { throw new IllegalStateException("Trying to adding to a dead node " + nodeId); } Collection<WorkerSlot> freeSlots = getFreeSlots(); Set<ExecutorDetails> toAssign = new HashSet<>(); toAssign.add(exec); if (!freeSlots.contains(ws)) { Map<String, Collection<ExecutorDetails>> usedSlots = topIdToUsedSlots.get(td.getId()); if (usedSlots == null) { throw new IllegalArgumentException( "Slot " + ws + " is not availble to schedue " + exec + " on"); } Collection<ExecutorDetails> alreadyHere = usedSlots.get(ws.getId()); if (alreadyHere == null) { throw new IllegalArgumentException( "Slot " + ws + " is not availble to schedue " + exec + " on"); } toAssign.addAll(alreadyHere); free(ws); } assign(ws, td, toAssign); }
double cpuUsedByWorker = wr.get_cpu(); assertEquals("Check if CPU used by worker is calculated correctly", 100.0, cpuUsedByWorker, 0.001); nodes.get(ws.getNodeId()).free(ws); double memoryAfter = nodes.get(ws.getNodeId()).getAvailableMemoryResources(); double cpuAfter = nodes.get(ws.getNodeId()).getAvailableCpuResources();
/** * * @param workerSlots */ public void freeSlots(Collection<WorkerSlot> workerSlots) { for (RAS_Node node : nodeMap.values()) { for (WorkerSlot ws : node.getUsedSlots()) { if (workerSlots.contains(ws)) { LOG.debug("freeing ws {} on node {}", ws, node); node.free(ws); } } } }