Skip to content

Commit

Permalink
YARN-7511. NPE in ContainerLocalizer when localization failed for run…
Browse files Browse the repository at this point in the history
…ning container. Contributed by Tao Yang

(cherry picked from commit 83798f1)
  • Loading branch information
jlowe committed Mar 2, 2018
1 parent 2599b97 commit 2d313c8
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,10 @@ public Set<String> resourceLocalized(LocalResourceRequest request,
}

public void resourceLocalizationFailed(LocalResourceRequest request) {
// Skip null request when localization failed for running container
if (request == null) {
return;
}
pendingResources.remove(request);
resourcesFailedToBeLocalized.add(request);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,27 @@ public void testLocalizationFailureAtDone() throws Exception {
}
}

@Test
@SuppressWarnings("unchecked")
public void testLocalizationFailureWhileRunning()
throws Exception {
WrappedContainer wc = null;
try {
wc = new WrappedContainer(6, 314159265358979L, 4344, "yak");
wc.initContainer();
wc.localizeResources();
wc.launchContainer();
reset(wc.localizerBus);
assertEquals(ContainerState.RUNNING, wc.c.getContainerState());
// Now in RUNNING, handle ContainerResourceFailedEvent, cause NPE before
wc.handleContainerResourceFailedEvent();
} finally {
if (wc != null) {
wc.finished();
}
}
}

@Test
@SuppressWarnings("unchecked") // mocked generic
public void testCleanupOnKillRequest() throws Exception {
Expand Down Expand Up @@ -1132,6 +1153,11 @@ public void resourceFailedContainer() {
drainDispatcherEvents();
}

public void handleContainerResourceFailedEvent() {
c.handle(new ContainerResourceFailedEvent(cId, null, null));
drainDispatcherEvents();
}

// Localize resources
// Skip some resources so as to consider them failed
public Map<Path, List<String>> doLocalizeResources(
Expand Down

0 comments on commit 2d313c8

Please sign in to comment.