public int totalSlotsFree() { return getFreeSlots().size(); }
/** * 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); }
throw new IllegalStateException("Trying to adding to a dead node " + nodeId); Collection<WorkerSlot> freeSlots = getFreeSlots(); if (freeSlots.isEmpty()) { throw new IllegalStateException("Trying to assign to a full node " + nodeId); target = getFreeSlots().iterator().next();
@Override public String toString() { return "{Node: " + ((sup == null) ? "null (possibly down)" : sup.getHost()) + ", Avail [ Mem: " + getAvailableMemoryResources() + ", CPU: " + getAvailableCpuResources() + ", Slots: " + this.getFreeSlots() + "] Total [ Mem: " + ((sup == null) ? "N/A" : this.getTotalMemoryResources()) + ", CPU: " + ((sup == null) ? "N/A" : this.getTotalCpuResources()) + ", Slots: " + this.slots.values() + " ]}"; }
String nodeHostname = nodeHostnames.get(i % nodeHostnames.size()); RAS_Node node = rs.hostnameToNodes(nodeHostname).get(0); WorkerSlot targetSlot = node.getFreeSlots().iterator().next(); ExecutorDetails targetExec = executorIterator.next();
String nodeHostname = nodeHostnames.get(i % nodeHostnames.size()); RAS_Node node = rs.hostnameToNodes(nodeHostname).get(0); WorkerSlot targetSlot = node.getFreeSlots().iterator().next(); ExecutorDetails targetExec = executorIterator.next();
node.assign(node.getFreeSlots().iterator().next(), topology1, executors11); assertEquals(1, node.getRunningTopologies().size()); assertFalse(node.isTotallyFree()); node.assign(node.getFreeSlots().iterator().next(), topology1, executors12); assertEquals(1, node.getRunningTopologies().size()); assertFalse(node.isTotallyFree()); node.assign(node.getFreeSlots().iterator().next(), topology2, executors21); assertEquals(2, node.getRunningTopologies().size()); assertFalse(node.isTotallyFree()); node.assign(node.getFreeSlots().iterator().next(), topology2, executors22); assertEquals(2, node.getRunningTopologies().size()); assertFalse(node.isTotallyFree());
public int totalSlotsFree() { return getFreeSlots().size(); }
@Override public String toString() { return "{Node: " + ((_sup == null) ? "null (possibly down)" : _sup.getHost()) + ", Avail [ Mem: " + ((_availMemory == null) ? "N/A" : _availMemory.toString()) + ", CPU: " + ((_availCPU == null) ? "N/A" : _availCPU.toString()) + ", Slots: " + this.getFreeSlots() + "] Total [ Mem: " + ((_sup == null) ? "N/A" : this.getTotalMemoryResources()) + ", CPU: " + ((_sup == null) ? "N/A" : this.getTotalCpuResources()) + ", Slots: " + this._slots.values() + " ]}"; }
throw new IllegalStateException("Trying to adding to a dead node " + _nodeId); Collection<WorkerSlot> freeSlots = getFreeSlots(); if (freeSlots.isEmpty()) { throw new IllegalStateException("Trying to assign to a full node " + _nodeId); target = getFreeSlots().iterator().next();
/** * Get the best worker to assign executor exec on a rack * * @param exec the executor to schedule * @param td the topology that the executor is a part of * @param rackId the rack id of the rack to find a worker on * @param scheduleAssignmentMap already calculated assignments * @return a worker to assign executor exec to. Returns null if a worker cannot be successfully found on rack with rackId */ private WorkerSlot getBestWorker(ExecutorDetails exec, TopologyDetails td, String rackId, Map<WorkerSlot, Collection<ExecutorDetails>> scheduleAssignmentMap) { if (!_rackIdToSortedNodes.containsKey(rackId)) { _rackIdToSortedNodes.put(rackId, sortNodes(this.getAvailableNodesFromRack(rackId), rackId, td.getId(), scheduleAssignmentMap)); } TreeSet<ObjectResources> sortedNodes = _rackIdToSortedNodes.get(rackId); double taskMem = td.getTotalMemReqTask(exec); double taskCPU = td.getTotalCpuReqTask(exec); for (ObjectResources nodeResources : sortedNodes) { RAS_Node n = _nodes.getNodeById(nodeResources.id); if (n.getAvailableCpuResources() >= taskCPU && n.getAvailableMemoryResources() >= taskMem && n.getFreeSlots().size() > 0) { for (WorkerSlot ws : n.getFreeSlots()) { if (checkWorkerConstraints(exec, ws, td, scheduleAssignmentMap)) { return ws; } } } } return null; }