YARN-9072. Send exit command to terminate docker exec on connection close. Contributed by Eric Yang

This commit is contained in:
Billie Rinaldi 2018-12-18 08:43:09 -08:00
parent 99b5061265
commit c5c73182e5
2 changed files with 5 additions and 1 deletions

View File

@ -113,6 +113,7 @@ public class ContainerShellWebSocket {
.fromString(cId));
if (!checkAuthorization(session, container)) {
session.close(1008, "Forbidden");
return;
}
LOG.info(session.getRemoteAddress().getHostString() + " connected!");
LOG.info(
@ -135,6 +136,9 @@ public class ContainerShellWebSocket {
public void onClose(Session session, int status, String reason) {
try {
LOG.info(session.getRemoteAddress().getHostString() + " closed!");
String exit = "exit\r\n";
pair.out.write(exit.getBytes(Charset.forName("UTF-8")));
pair.out.flush();
pair.in.close();
pair.out.close();
} catch (IOException e) {

View File

@ -48,7 +48,7 @@ import com.sun.jersey.api.client.WebResource.Builder;
public class TestNMWebTerminal {
private static final File TESTROOTDIR = new File("target",
TestNMWebServer.class.getSimpleName());
private static File TESTLOGDIR = new File("target",
private static final File TESTLOGDIR = new File("target",
TestNMWebServer.class.getSimpleName() + "LogDir");
private NodeHealthCheckerService healthChecker;
private WebServer server;