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 2800e73c27
commit 4446512e9e
2 changed files with 10 additions and 0 deletions

View File

@ -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.

View File

@ -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);