Search in sources :

Example 46 with TopologyDetails

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());
}
Also used : TopologyDetails(org.apache.storm.scheduler.TopologyDetails)

Example 47 with TopologyDetails

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;
}
Also used : ExecutorDetails(org.apache.storm.scheduler.ExecutorDetails) TopologyDetails(org.apache.storm.scheduler.TopologyDetails)

Aggregations

TopologyDetails (org.apache.storm.scheduler.TopologyDetails)47 HashMap (java.util.HashMap)35 SupervisorDetails (org.apache.storm.scheduler.SupervisorDetails)27 Config (org.apache.storm.Config)26 Topologies (org.apache.storm.scheduler.Topologies)26 Test (org.junit.Test)26 Cluster (org.apache.storm.scheduler.Cluster)24 SchedulerAssignmentImpl (org.apache.storm.scheduler.SchedulerAssignmentImpl)24 INimbus (org.apache.storm.scheduler.INimbus)23 Map (java.util.Map)22 ExecutorDetails (org.apache.storm.scheduler.ExecutorDetails)18 WorkerSlot (org.apache.storm.scheduler.WorkerSlot)15 ArrayList (java.util.ArrayList)13 SchedulerAssignment (org.apache.storm.scheduler.SchedulerAssignment)12 List (java.util.List)10 StormTopology (org.apache.storm.generated.StormTopology)10 HashSet (java.util.HashSet)8 LinkedList (java.util.LinkedList)8 TopologyBuilder (org.apache.storm.topology.TopologyBuilder)8 ResourceAwareScheduler (org.apache.storm.scheduler.resource.ResourceAwareScheduler)6