This commit is contained in:
Richard Hightower 2015-07-01 17:26:04 -07:00
Родитель 552ccb7795
Коммит 77ca6ccd3e
1 изменённых файлов: 5 добавлений и 0 удалений

Просмотреть файл

@ -67,6 +67,10 @@ public class StatsdClient extends TimerTask {
public StatsdClient(InetAddress host, int port) throws IOException {
_address = new InetSocketAddress(host, port);
_channel = DatagramChannel.open();
/* Put this in non-blocking mode so send does not block forever. */
_channel.configureBlocking(false);
/* Increase the size of the output buffer so that the size is larger than our buffer size. */
_channel.setOption(StandardSocketOptions.SO_SNDBUF, 4096);
setBufferSize((short) 1500);
}
@ -250,6 +254,7 @@ public class StatsdClient extends TimerTask {
}
} catch (IOException e) {
/* This would be a good place to close the channel down and recreate it. */
log.error(
String.format("Could not send stat %s to host %s:%d", sendBuffer.toString(), _address.getHostName(),
_address.getPort()), e);