/** * Calculate the amount of shared off heap memory on a given nodes with the given assignment. * * @param nodeId the id of the node * @param assignment the current assignment * @return the amount of shared off heap memory for that node in MB */ private double calculateSharedOffHeapMemory(String nodeId, SchedulerAssignmentImpl assignment) { return calculateSharedOffHeapMemory(nodeId, assignment, null); }
/** * 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()); }
afterOnHeap = wrAfter.get_mem_on_heap(); currentTotal += calculateSharedOffHeapMemory(ws.getNodeId(), assignment); afterTotal += calculateSharedOffHeapMemory(ws.getNodeId(), assignment, exec);
double sharedOffHeapMemory = calculateSharedOffHeapMemory(nodeId, assignment); assignment.setTotalSharedOffHeapMemory(nodeId, sharedOffHeapMemory); updateCachesForWorkerSlot(slot, resources, sharedOffHeapMemory);