diff --git a/hadoop-common-project/hadoop-common/CHANGES.txt b/hadoop-common-project/hadoop-common/CHANGES.txt index 451ce61709c..7a57ef03d6b 100644 --- a/hadoop-common-project/hadoop-common/CHANGES.txt +++ b/hadoop-common-project/hadoop-common/CHANGES.txt @@ -100,6 +100,9 @@ Release 2.7.0 - UNRELEASED HADOOP-11455. KMS and Credential CLI should request confirmation for deletion by default. (Charles Lamb via yliu) + HADOOP-11390 Metrics 2 ganglia provider to include hostname in + unresolved address problems. (Varun Saxena via stevel) + OPTIMIZATIONS HADOOP-11323. WritableComparator#compare keeps reference to byte array. diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/sink/ganglia/AbstractGangliaSink.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/sink/ganglia/AbstractGangliaSink.java index 15eea61e125..6757068b391 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/sink/ganglia/AbstractGangliaSink.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/sink/ganglia/AbstractGangliaSink.java @@ -21,6 +21,7 @@ package org.apache.hadoop.metrics2.sink.ganglia; import java.io.IOException; import java.net.DatagramPacket; import java.net.DatagramSocket; +import java.net.InetSocketAddress; import java.net.SocketAddress; import java.net.SocketException; import java.net.UnknownHostException; @@ -255,6 +256,12 @@ public abstract class AbstractGangliaSink implements MetricsSink { protected void emitToGangliaHosts() throws IOException { try { for (SocketAddress socketAddress : metricsServers) { + if (socketAddress == null || !(socketAddress instanceof InetSocketAddress)) + throw new IllegalArgumentException("Unsupported Address type"); + InetSocketAddress inetAddress = (InetSocketAddress)socketAddress; + if(inetAddress.isUnresolved()) { + throw new UnknownHostException("Unresolved host: " + inetAddress); + } DatagramPacket packet = new DatagramPacket(buffer, offset, socketAddress); datagramSocket.send(packet);