Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamic UDP target host address #481

Closed
wants to merge 1 commit into from

Conversation

m4ce
Copy link

@m4ce m4ce commented Jul 31, 2018

This PR tries to solve #480 by refreshing the target UDP host address every 5m. I am not sure if this is the best approach but that's all I could come up with!

@codecov-io
Copy link

codecov-io commented Jul 31, 2018

Codecov Report

Merging #481 into master will decrease coverage by 0.02%.
The diff coverage is 83.33%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master     #481      +/-   ##
============================================
- Coverage     87.29%   87.27%   -0.03%     
  Complexity      357      357              
============================================
  Files            24       24              
  Lines          1496     1501       +5     
  Branches        164      165       +1     
============================================
+ Hits           1306     1310       +4     
  Misses          124      124              
- Partials         66       67       +1
Impacted Files Coverage Δ Complexity Δ
src/main/java/org/influxdb/InfluxDBFactory.java 100% <ø> (ø) 6 <0> (ø) ⬇️
src/main/java/org/influxdb/impl/InfluxDBImpl.java 89.45% <83.33%> (-0.13%) 73 <1> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update dab365a...cb46702. Read the comment docs.

@lxhoan lxhoan requested a review from fmachado August 8, 2018 06:29
@lxhoan
Copy link
Contributor

lxhoan commented Aug 8, 2018

Hi @fmachado , I think resolving and caching IP address for datagram is unnecessary (and obviously falls defective this case)
In my opinion, this snippet

datagramSocket.send(new DatagramPacket(bytes, bytes.length, hostAddress, udpPort));

hostAddress should be changed to SocketAdress, something like this

datagramSocket.send(new DatagramPacket(bytes, bytes.length, new InetSocketAddress(hostname,  udpPort)));

What do you think ?

@m4ce
Copy link
Author

m4ce commented Aug 8, 2018

@lxhoan, that works well only if one has batching enabled. If batching is disabled, it will resolve the hostname every time an UDP write is performed. It can result in denial of service to the DNS service if one sends out a lot of metrics in a short interval of time.

@lxhoan
Copy link
Contributor

lxhoan commented Aug 8, 2018

@m4ce, there some other dns caching levels down to the IP layer (at least at JVM and your OS), So I think we can be safe
(for java you can refer to this https://docs.oracle.com/javase/6/docs/technotes/guides/net/properties.html)

Otherwise we must be meticulous when introducing more configuration to influxdb (I mean this one ADDRESS_LOOKUP_INTERVAL)

@lxhoan
Copy link
Contributor

lxhoan commented Aug 15, 2018

Hi @fmachado , if you can arrange time please take a look on it
I think this is a realistic use case that influxdb-java should consider to support

@lxhoan lxhoan added this to the 2.13 milestone Aug 15, 2018
@fmachado
Copy link
Contributor

fmachado commented Aug 20, 2018

@m4ce as far as I could understand from your issue ticket and this PR, you can solve your problem by adding a parameter -Dnetworkaddress.cache.ttl=300 to the JVM (as mentioned by @lxhoan and here).

You can also apply this configuration by calling Security.setProperty (javadoc) but I don't know what happens with already resolved names.

For the reasons mentioned before, I vote for do not merge this PR.

@fmachado fmachado self-assigned this Aug 20, 2018
@fmachado
Copy link
Contributor

I'm closing this issue but feel free to reopen it if you think your issue cannot be fixed with the way we mentioned here.

@m4ce
Copy link
Author

m4ce commented Sep 14, 2018

@fmachado , sorry to comment on a close issue. I think you suggestion would only work if we changed the code to be:

datagramSocket.send(new DatagramPacket(bytes, bytes.length, new InetSocketAddress(hostname, udpPort)));

Just like @lxhoan suggested above.

@m4ce
Copy link
Author

m4ce commented Sep 14, 2018

I see this change was implemented on Sept 5th. We are good then!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants