YARN-7351. Fix high CPU usage issue in RegistryDNS. Contributed by Jian He

This commit is contained in:
Billie Rinaldi 2017-10-25 13:01:01 -07:00 committed by Jian He
parent 501be9b4be
commit d2775fbcca

View File

@ -189,7 +189,8 @@ public void initializeChannels(Configuration conf) throws Exception {
LOG.info("Opening TCP and UDP channels on {} port {}", addr, port); LOG.info("Opening TCP and UDP channels on {} port {}", addr, port);
addNIOUDP(addr, port); addNIOUDP(addr, port);
addNIOTCP(addr, port); //TODO Fix dns lookup over TCP
// addNIOTCP(addr, port);
} }
/** /**
@ -770,6 +771,7 @@ public void nioTCPClient(SocketChannel ch) throws IOException {
byte[] response = null; byte[] response = null;
try { try {
query = new Message(in); query = new Message(in);
LOG.info("received TCP query {}", query.getQuestion());
response = generateReply(query, ch.socket()); response = generateReply(query, ch.socket());
if (response == null) { if (response == null) {
return; return;
@ -947,7 +949,7 @@ private void serveNIOUDP(DatagramChannel channel,
input.flip(); input.flip();
input.get(in); input.get(in);
query = new Message(in); query = new Message(in);
LOG.info("{}: received query {}", remoteAddress, LOG.info("{}: received UDP query {}", remoteAddress,
query.getQuestion()); query.getQuestion());
response = generateReply(query, null); response = generateReply(query, null);
if (response == null) { if (response == null) {
@ -960,7 +962,7 @@ private void serveNIOUDP(DatagramChannel channel,
output.put(response); output.put(response);
output.flip(); output.flip();
LOG.info("{}: sending response", remoteAddress); LOG.debug("{}: sending response", remoteAddress);
channel.send(output, remoteAddress); channel.send(output, remoteAddress);
} }
} catch (Exception e) { } catch (Exception e) {