/** * Frees a single slot in this node. * * @param ws the slot to free */ public void free(WorkerSlot ws) { LOG.debug("freeing WorkerSlot {} on node {}", ws, hostname); if (!slots.containsKey(ws.getId())) { throw new IllegalArgumentException( "Tried to free a slot " + ws + " that was not" + " part of this node " + nodeId); } TopologyDetails topo = findTopologyUsingWorker(ws); if (topo == null) { throw new IllegalArgumentException("Tried to free a slot " + ws + " that was already free!"); } //free slot cluster.freeSlot(ws); //cleanup internal assignments topIdToUsedSlots.get(topo.getId()).remove(ws.getId()); }
/** * get the amount of memory used by a worker */ public double getMemoryUsedByWorker(WorkerSlot ws) { TopologyDetails topo = findTopologyUsingWorker(ws); if (topo == null) { return 0.0; } Collection<ExecutorDetails> execs = getExecutors(ws, _cluster); double totalMemoryUsed = 0.0; for (ExecutorDetails exec : execs) { totalMemoryUsed += topo.getTotalMemReqTask(exec); } return totalMemoryUsed; }
/** * get the amount of cpu used by a worker */ public double getCpuUsedByWorker(WorkerSlot ws) { TopologyDetails topo = findTopologyUsingWorker(ws); if (topo == null) { return 0.0; } Collection<ExecutorDetails> execs = getExecutors(ws, _cluster); double totalCpuUsed = 0.0; for (ExecutorDetails exec : execs) { totalCpuUsed += topo.getTotalCpuReqTask(exec); } return totalCpuUsed; }
/** * Frees a single slot in this node * @param ws the slot to free */ public void free(WorkerSlot ws) { LOG.info("freeing WorkerSlot {} on node {}", ws, _hostname); if (!_slots.containsKey(ws.getId())) { throw new IllegalArgumentException("Tried to free a slot " + ws + " that was not" + " part of this node " + _nodeId); } TopologyDetails topo = findTopologyUsingWorker(ws); if (topo == null) { throw new IllegalArgumentException("Tried to free a slot " + ws + " that was already free!"); } double memUsed = getMemoryUsedByWorker(ws); double cpuUsed = getCpuUsedByWorker(ws); freeMemory(memUsed); freeCPU(cpuUsed); //free slot _cluster.freeSlot(ws); //cleanup internal assignments _topIdToUsedSlots.get(topo.getId()).remove(ws.getId()); }