HADOOP-11390 Metrics 2 ganglia provider to include hostname in unresolved address problems. (Varun Saxena via stevel)

This commit is contained in:
Steve Loughran 2015-01-05 16:09:25 +00:00
parent 27d8395867
commit 2403634de0
2 changed files with 10 additions and 0 deletions

View File

@ -455,6 +455,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.

View File

@ -21,6 +21,7 @@
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;
@ -257,6 +258,12 @@ protected void xdr_int(int i) {
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);