Skip to main content

How to check if DNS name lookups has been cached?

  • December 21, 2021
  • 0 replies
  • 1645 views

AkshayJadhav
StreamSets Employee
Forum|alt.badge.img

In the sdc.properties file, we have a property called java.security.networkaddress.cache.TTL. It gives the JVM a value to set the time to live (TTL) in order to cache the DNS name lookups.

This is an important property because most of the users have pipelines with name addresses in the string URL - E.g.: JDBC, sftp... -  It has to be resolved by the DNS server and if the IP changes the pipeline has to resolve it accordingly. 

 The Java Security Manager is the object in charge to set up this value, once it is called the JVM by default sets the TTL value to -1, so it means that Java will cache this DNS name lookups forever  -"cache forever" -, in other words,  it will never refresh DNS entries until the JVM is restarted.

If we don't want to restart the JVM - it may be working on production - the best option is to set a number of seconds to cache the DNS lookups. This number has to be specified as an integer. A zero value (0) means that it will "never cache" so it always refreshes the DNS entries as often as it changes. 

To check this behavior in the SDC  we can try the following steps:

1. Set up an SFTP

E.g.: Server IP: 192.168.86.168

 

2. Edit etc/hosts 

This file is a simple text file that associates IP addresses with hostnames. Whenever you type an address, your system will check the hosts file for its presence; if it is present there, you will be directed to the corresponding IP. If the hostname is not defined in the hosts file, your system will check the DNS server of your internet to look up for the corresponding IP and redirect you accordingly.

You can  edit this file by adding the following line:

192.168.86.168 sftpserver

192.168.86.168 is the IP address of the SFTP server. Then you can ping sftpserver and check if it works correctly.

 

3. Change the string URL in the pipeline to your domain name server

Let's say we have the following string URL: sftp://192.168.86.168/directory, now it can be changed to sftp://sftpserver/directory and start the pipeline.

 

4. Modify the server IP

Edit again /etc/hosts file and change the IP address that has been added before. Ideally, we could have another SFTP Server running and set it with the new IP, but we can also try by adding a nonexistent IP. If the pipeline is still running with no issue either java.security.networkaddress.cache.TTL has a high value  - in this case, we should wait until TTL expires -  or it has been set with the value by default (-1). 

Did this topic help you find an answer to your question?
This topic has been closed for comments