Skip to content

Commit

Permalink
Fix another regression: a crash introduced in #78 (feb892f)
Browse files Browse the repository at this point in the history
That commit introduced a NullPointerException crash:

After the first pass through the `computeResourcesForSlot()` main loop, the
`executorCpuResources` and `executorMemResources` variables are not populated,
and thus incorreclty null, because `subtractedExecutorResources ` was set to
true on the 1st pass.

The fix is to unconditionally set them to the requested resource amounts
unconditionally, and only subtract the resources out of the offer on the
1st pass.

Also an unrelated change:  clarify that the reservations that are being skipped
in a couple functions are *dynamic* reservations.
  • Loading branch information
erikdw committed Dec 10, 2015
1 parent 8079582 commit 2ff0eb3
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/main/storm/mesos/MesosNimbus.java
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ protected OfferResources getResources(Offer offer, double executorCpu, double ex

for (Resource r : offer.getResourcesList()) {
if (r.hasReservation()) {
// skip resources with reservations
// skip resources with dynamic reservations
continue;
}
if (r.getType() == Type.SCALAR) {
Expand Down Expand Up @@ -495,7 +495,7 @@ protected List<Resource> getResourcesScalar(final List<Resource> offerResources,
double valueNeeded = value;
for (Resource r : offerResources) {
if (r.hasReservation()) {
// skip resources with reservations
// skip resources with dynamic reservations
continue;
}
if (r.getType() == Type.SCALAR &&
Expand Down Expand Up @@ -739,13 +739,11 @@ protected void computeResourcesForSlot(final RotatingMap<OfferID, Offer> offers,
Collections.sort(offerResources, new ResourceRoleComparator());
}

List<Resource> executorCpuResources = null;
List<Resource> executorMemResources = null;
List<Resource> executorCpuResources = getResourcesScalar(offerResources, executorCpu, "cpus");
List<Resource> executorMemResources = getResourcesScalar(offerResources, executorMem, "mem");
List<Resource> executorPortsResources = null;
if (!subtractedExecutorResources) {
executorCpuResources = getResourcesScalar(offerResources, executorCpu, "cpus");
offerResources = subtractResourcesScalar(offerResources, executorCpu, "cpus");
executorMemResources = getResourcesScalar(offerResources, executorMem, "mem");
offerResources = subtractResourcesScalar(offerResources, executorMem, "mem");
subtractedExecutorResources = true;
}
Expand Down

0 comments on commit 2ff0eb3

Please sign in to comment.