/** * Would scheduling exec in ws fit with the current resource constraints. * * @param ws the slot to possibly put exec in * @param exec the executor to possibly place in ws * @param td the topology exec is a part of * @return true if it would fit else false */ public boolean wouldFit(WorkerSlot ws, ExecutorDetails exec, TopologyDetails td) { assert nodeId.equals(ws.getNodeId()) : "Slot " + ws + " is not a part of this node " + nodeId; return isAlive && cluster.wouldFit( ws, exec, td, getTotalAvailableResources(), td.getTopologyWorkerMaxHeapSize() ); }
/** * Get the remaining amount memory that can be assigned to a worker given the set worker max heap size * * @param ws the worker to get the remaining amount of memory that can be assigned to it * @param td the topology that has executors running on the worker * @param scheduleAssignmentMap the schedulings calculated so far * @return The remaining amount of memory */ private Double getWorkerScheduledMemoryAvailable(WorkerSlot ws, TopologyDetails td, Map<WorkerSlot, Collection<ExecutorDetails>> scheduleAssignmentMap) { Double memScheduleUsed = this.getWorkerScheduledMemoryUse(ws, td, scheduleAssignmentMap); return td.getTopologyWorkerMaxHeapSize() - memScheduleUsed; }