Forcibly reloading the resolver config in Java.

354 views
Skip to first unread message

Kevin Burton

unread,
Jun 5, 2015, 6:46:03 PM6/5/15
to mechanica...@googlegroups.com
glibc doesn't do graceful reloading of resolv.conf in Java.

Which means this can yield to a pretty serious outage if you have to migrate DNS servers.  Basically ALL your Java daemons will need to be restarted.

Java just uses gethostbyname by default.

Fortunately, you can call res_init() in glibc and use JNA/JNI to reload.


I think the main issue is, how do you do this in daemons you don't control.  I've seen hacks like implementing a profiler, or using a classpath preload... but what's the most elegant way to require some code to run on startup, in a daemon you don't control.

The only Java daemons in our stack , that we don't control, are Cassandra and ElasticSearch... would be nice if I could inject resolver reloading there as well.

Richard Warburton

unread,
Jun 5, 2015, 6:59:49 PM6/5/15
to mechanica...@googlegroups.com
Hi,

The only Java daemons in our stack , that we don't control, are Cassandra and ElasticSearch... would be nice if I could inject resolver reloading there as well.

You could probably do this pretty easily with a java agent.

regards,
Reply all
Reply to author
Forward
0 new messages