private 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)) { for (Entry<String, Set<WorkerSlot>> topologySetEntry : _topIdToUsedSlots.entrySet()) { if (topologySetEntry.getValue().contains(ws)) { if (dontThrow) { LOG.warn("Worker slot [" + ws + "] can't be assigned to " + topId + ". Its already assigned to " + topologySetEntry.getKey() + "."); return true; } throw new IllegalStateException("Worker slot [" + ws + "] can't be assigned to " + topId + ". Its already assigned to " + topologySetEntry.getKey() + "."); } } LOG.warn("Adding Worker slot [" + ws + "] that was not reported in the supervisor heartbeats," + " but the worker is already running for topology " + topId + "."); } Set<WorkerSlot> usedSlots = _topIdToUsedSlots.get(topId); if (usedSlots == null) { usedSlots = new HashSet<>(); _topIdToUsedSlots.put(topId, usedSlots); } usedSlots.add(ws); return false; }
private 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)) { for (Entry<String, Set<WorkerSlot>> topologySetEntry : _topIdToUsedSlots.entrySet()) { if (topologySetEntry.getValue().contains(ws)) { if (dontThrow) { LOG.warn("Worker slot [" + ws + "] can't be assigned to " + topId + ". Its already assigned to " + topologySetEntry.getKey() + "."); return true; } throw new IllegalStateException("Worker slot [" + ws + "] can't be assigned to " + topId + ". Its already assigned to " + topologySetEntry.getKey() + "."); } } LOG.warn("Adding Worker slot [" + ws + "] that was not reported in the supervisor heartbeats," + " but the worker is already running for topology " + topId + "."); } Set<WorkerSlot> usedSlots = _topIdToUsedSlots.get(topId); if (usedSlots == null) { usedSlots = new HashSet<>(); _topIdToUsedSlots.put(topId, usedSlots); } usedSlots.add(ws); return false; }