use of org.apache.storm.scheduler.TopologyDetails in project storm by apache.
the class RAS_Node method free.
/**
* 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());
}
use of org.apache.storm.scheduler.TopologyDetails in project storm by apache.
the class RAS_Node method getCpuUsedByWorker.
/**
* 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;
}
Aggregations