[ 
https://issues.apache.org/jira/browse/STORM-1450?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15101195#comment-15101195
 ] 

ASF GitHub Bot commented on STORM-1450:
---------------------------------------

Github user jerrypeng commented on a diff in the pull request:

    https://github.com/apache/storm/pull/1016#discussion_r49821028
  
    --- Diff: 
storm-core/src/jvm/org/apache/storm/scheduler/resource/RAS_Node.java ---
    @@ -43,32 +43,84 @@
      */
     public class RAS_Node {
         private static final Logger LOG = 
LoggerFactory.getLogger(RAS_Node.class);
    -    private Map<String, Set<WorkerSlot>> _topIdToUsedSlots = new 
HashMap<String, Set<WorkerSlot>>();
    -    private Set<WorkerSlot> _freeSlots = new HashSet<WorkerSlot>();
    +
    +    //A map consisting of all workers on the node.
    +    //The key of the map is the worker id and the value is the 
corresponding workerslot object
    +    Map<String, WorkerSlot> _slots = new HashMap<String, WorkerSlot> ();
    +
    +    // A map describing which topologies are using which slots on this 
node.  The format of the map is the following:
    +    // {TopologyId -> {WorkerId -> {Executors}}}
    +    private Map<String, Map<String, Collection<ExecutorDetails>>> 
_topIdToUsedSlots = new HashMap<String, Map<String, 
Collection<ExecutorDetails>>>();
    +
         private final String _nodeId;
         private String _hostname;
         private boolean _isAlive;
         private SupervisorDetails _sup;
    -    private Double _availMemory;
    -    private Double _availCPU;
    -    private Cluster _cluster;
    -    private Topologies _topologies;
    +    private Double _availMemory = 0.0;
    +    private Double _availCPU = 0.0;
    +    private final Cluster _cluster;
    +    private final Topologies _topologies;
     
    -    public RAS_Node(String nodeId, Set<Integer> allPorts, boolean isAlive,
    -                    SupervisorDetails sup, Cluster cluster, Topologies 
topologies) {
    +    public RAS_Node(String nodeId, SupervisorDetails sup, Cluster cluster, 
Topologies topologies, Map<String, WorkerSlot> workerIdToWorker, Map<String, 
Map<String, Collection<ExecutorDetails>>> assignmentMap) {
    +        //Node ID and supervisor ID are the same.
             _nodeId = nodeId;
    -        _isAlive = isAlive;
    -        if (_isAlive && allPorts != null) {
    -            for (int port : allPorts) {
    -                _freeSlots.add(new WorkerSlot(_nodeId, port));
    -            }
    -            _sup = sup;
    +        if (sup == null) {
    +            _isAlive = false;
    +        } else {
    +            _isAlive = !cluster.isBlackListed(_nodeId);
    +        }
    +
    +        _cluster = cluster;
    +        _topologies = topologies;
    +
    +        // initialize slots for this node
    +        if (workerIdToWorker != null) {
    +            _slots = workerIdToWorker;
    +        }
    +
    +        //initialize assignment map
    +        if (assignmentMap != null) {
    +            _topIdToUsedSlots = assignmentMap;
    +        }
    +
    +        //check if node is alive
    +        if (_isAlive && sup != null) {
                 _hostname = sup.getHost();
    +            _sup = sup;
                 _availMemory = getTotalMemoryResources();
                 _availCPU = getTotalCpuResources();
    +
    +            LOG.debug("Found a {} Node {} {}",
    +                    _isAlive ? "living" : "dead", _nodeId, 
sup.getAllPorts());
    +            LOG.debug("resources_mem: {}, resources_CPU: {}", 
sup.getTotalMemory(), sup.getTotalCPU());
    +            //intialize resource usages on node
    +            intializeResources();
    +        }
    +    }
    +
    +    /**
    +     * intializes resource usages on node
    --- End diff --
    
    will fix


> Fix bugs and refactor code in ResourceAwareScheduler
> ----------------------------------------------------
>
>                 Key: STORM-1450
>                 URL: https://issues.apache.org/jira/browse/STORM-1450
>             Project: Apache Storm
>          Issue Type: Improvement
>            Reporter: Boyang Jerry Peng
>            Assignee: Boyang Jerry Peng
>            Priority: Minor
>
> Code refactored:
> 1. Refactor RAS_Nodes. Pushed some of the functionality in to RAS_Nodes.  
> Each RAS_Node will now be initialized with a map of all its assignments.  
> Each RAS_Node will also figure out resources used and available. Removed 
> unnecessary functions.
> 2.  Made WorkerSlot immutable so that a scheduling strategy won't mistakenly 
> modify it
> 3. Added a wrapping layer for RAS_Node to feed into scheduling strategies so 
> that the semantics of what a scheduling strategy should do will be more 
> clear.  Each scheduling strategy shouldn't be actually assigning anything.  
> The strategy should only calculate a scheduling.
> Bug fixes:
> 1. Minor bug in displaying the assigned resources for a supervisor on the UI. 
> The function updateSupervisorResources was placed in the wrong place
> 2. Minor bug fix in freeing memory in RAS_Node there was some wrong math that 
> was done.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to