i think in var maxCorePerExecutor = maxCores the two variables are different. maxCores is total core's value of a application. but maxCorePerExecutor  is cores of per executor. in schedule() app's leftCoreToAssign come from  maxCores value.so two variables cannot be equal.