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 void onConnect(Session session) {
.fromString(cId)); .fromString(cId));
if (!checkAuthorization(session, container)) { if (!checkAuthorization(session, container)) {
session.close(1008, "Forbidden"); session.close(1008, "Forbidden");
return;
} }
LOG.info(session.getRemoteAddress().getHostString() + " connected!"); LOG.info(session.getRemoteAddress().getHostString() + " connected!");
LOG.info( LOG.info(
@ -135,6 +136,9 @@ public void onConnect(Session session) {
public void onClose(Session session, int status, String reason) { public void onClose(Session session, int status, String reason) {
try { try {
LOG.info(session.getRemoteAddress().getHostString() + " closed!"); 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.in.close();
pair.out.close(); pair.out.close();
} catch (IOException e) { } catch (IOException e) {

View File

@ -48,7 +48,7 @@
public class TestNMWebTerminal { public class TestNMWebTerminal {
private static final File TESTROOTDIR = new File("target", private static final File TESTROOTDIR = new File("target",
TestNMWebServer.class.getSimpleName()); TestNMWebServer.class.getSimpleName());
private static File TESTLOGDIR = new File("target", private static final File TESTLOGDIR = new File("target",
TestNMWebServer.class.getSimpleName() + "LogDir"); TestNMWebServer.class.getSimpleName() + "LogDir");
private NodeHealthCheckerService healthChecker; private NodeHealthCheckerService healthChecker;
private WebServer server; private WebServer server;