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

    https://github.com/apache/storm/pull/1016#discussion_r49821063
  
    --- 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 --
    
    will fix


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to