public void setStatusIfAbsent(String topologyId, String statusMessage) { assertValidTopologyForModification(topologyId); status.putIfAbsent(topologyId, statusMessage); }
/** * set scheduler status for a topology. */ public void setStatus(String topologyId, String statusMessage) { assertValidTopologyForModification(topologyId); LOG.info("STATUS - {} {}", topologyId, statusMessage); status.put(topologyId, statusMessage); }
/** * set scheduler status map. */ public void setStatusMap(Map<String, String> statusMap) { if (statusMap == this.status) { return; //This is a NOOP } for (String topologyId : statusMap.keySet()) { assertValidTopologyForModification(topologyId); } for (String topologyId : status.keySet()) { assertValidTopologyForModification(topologyId); } this.status.clear(); this.status.putAll(statusMap); }
/** * Set assignments for cluster. */ public void setAssignments( Map<String, ? extends SchedulerAssignment> newAssignments, boolean ignoreSingleExceptions) { if (newAssignments == assignments) { //NOOP return; } for (SchedulerAssignment assignment : newAssignments.values()) { assertValidTopologyForModification(assignment.getTopologyId()); } for (SchedulerAssignment assignment : assignments.values()) { assertValidTopologyForModification(assignment.getTopologyId()); } assignments.clear(); totalResourcesPerNodeCache.clear(); nodeToScheduledResourcesCache.values().forEach(Map::clear); nodeToUsedSlotsCache.values().forEach(Set::clear); for (SchedulerAssignment assignment : newAssignments.values()) { assign(assignment, ignoreSingleExceptions); } }
/** * Unassign everything for the given topology id. * * @param topoId the is of the topology to unassign */ public void unassign(String topoId) { assertValidTopologyForModification(topoId); freeSlots(getUsedSlotsByTopologyId(topoId)); }
/** * Assign everything for the given topology. * * @param assignment the new assignment to make */ public void assign(SchedulerAssignment assignment, boolean ignoreSingleExceptions) { String id = assignment.getTopologyId(); assertValidTopologyForModification(id); Map<WorkerSlot, Collection<ExecutorDetails>> slotToExecs = assignment.getSlotToExecutors(); for (Entry<WorkerSlot, Collection<ExecutorDetails>> entry : slotToExecs.entrySet()) { try { assign(entry.getKey(), id, entry.getValue()); } catch (RuntimeException e) { if (!ignoreSingleExceptions) { throw e; } } } }
/** * Free the specified slot. * * @param slot the slot to free */ public void freeSlot(WorkerSlot slot) { // remove the slot from the existing assignments for (SchedulerAssignmentImpl assignment : assignments.values()) { if (assignment.isSlotOccupied(slot)) { assertValidTopologyForModification(assignment.getTopologyId()); assignment.unassignBySlot(slot); String nodeId = slot.getNodeId(); assignment.setTotalSharedOffHeapMemory( nodeId, calculateSharedOffHeapMemory(nodeId, assignment)); nodeToScheduledResourcesCache.computeIfAbsent(nodeId, MAKE_MAP).put(slot, new NormalizedResourceRequest()); nodeToUsedSlotsCache.computeIfAbsent(nodeId, MAKE_SET).remove(slot); } } //Invalidate the cache as something on the node changed totalResourcesPerNodeCache.remove(slot.getNodeId()); }
/** * Update the assignments and status from the other cluster. * * @param other the cluster to get the assignments and status from */ public void updateFrom(Cluster other) { for (SchedulerAssignment assignment : other.getAssignments().values()) { assertValidTopologyForModification(assignment.getTopologyId()); } setAssignments(other.getAssignments(), false); setStatusMap(other.getStatusMap()); } }
assertValidTopologyForModification(topologyId); if (isSlotOccupied(slot)) { throw new RuntimeException(