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

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

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

    https://github.com/apache/storm/pull/1016#discussion_r49786868
  
    --- Diff: 
storm-core/src/jvm/org/apache/storm/scheduler/resource/RAS_Node.java ---
    @@ -103,92 +182,37 @@ public boolean isAlive() {
         }
     
         public boolean isTotallyFree() {
    -        return _topIdToUsedSlots.isEmpty();
    +        return getUsedSlots().isEmpty();
         }
     
         public int totalSlotsFree() {
    -        return _freeSlots.size();
    +        return getFreeSlots().size();
         }
     
         public int totalSlotsUsed() {
    -        int total = 0;
    -        for (Set<WorkerSlot> slots : _topIdToUsedSlots.values()) {
    -            total += slots.size();
    -        }
    -        return total;
    +        return getUsedSlots().size();
         }
     
         public int totalSlots() {
    -        return totalSlotsFree() + totalSlotsUsed();
    +        return _slots.size();
         }
     
         public int totalSlotsUsed(String topId) {
    -        int total = 0;
    -        Set<WorkerSlot> slots = _topIdToUsedSlots.get(topId);
    -        if (slots != null) {
    -            total = slots.size();
    -        }
    -        return total;
    -    }
    -
    -    private void validateSlot(WorkerSlot ws) {
    -        if (!_nodeId.equals(ws.getNodeId())) {
    -            throw new IllegalArgumentException(
    -                    "Trying to add a slot to the wrong node " + ws +
    -                            " is not a part of " + _nodeId);
    -        }
    -    }
    -
    -    void addOrphanedSlot(WorkerSlot ws) {
    -        if (_isAlive) {
    -            throw new IllegalArgumentException("Orphaned Slots " +
    -                    "only are allowed on dead nodes.");
    -        }
    -        validateSlot(ws);
    -        if (_freeSlots.contains(ws)) {
    -            return;
    -        }
    -        for (Set<WorkerSlot> used : _topIdToUsedSlots.values()) {
    -            if (used.contains(ws)) {
    -                return;
    -            }
    -        }
    -        _freeSlots.add(ws);
    -    }
    -
    -    boolean assignInternal(WorkerSlot ws, String topId, boolean dontThrow) 
{
    -        validateSlot(ws);
    -        if (!_freeSlots.remove(ws)) {
    -            if (dontThrow) {
    -                return true;
    -            }
    -            throw new IllegalStateException("Assigning a slot that was not 
free " + ws);
    -        }
    -        Set<WorkerSlot> usedSlots = _topIdToUsedSlots.get(topId);
    -        if (usedSlots == null) {
    -            usedSlots = new HashSet<WorkerSlot>();
    -            _topIdToUsedSlots.put(topId, usedSlots);
    -        }
    -        usedSlots.add(ws);
    -        return false;
    +        return getUsedSlots(topId).size();
         }
     
         /**
          * Free all slots on this node.  This will update the Cluster too.
          */
    -    public void freeAllSlots() {
    +     public void freeAllSlots() {
    --- End diff --
    
    revert?


> 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