SnifferBuilder.sniffOnFailureListener() not honored


I am using elasticsearch-rest-client-sniffer version 5.6.3.
I am following the example code for getting sniffing nodes health: Sniffer Usage

SniffOnFailureListener sniffOnFailureListener = new SniffOnFailureListener();
RestClient restClient = RestClient.builder(new HttpHost("localhost", 9200))
Sniffer sniffer = Sniffer.builder(restClient)

The problem is that I get messages for failed nodes every 5 minutes, which is the default timeout for the sniffer instead of every 30000ms as requested in the above code.
Am I doing anything wrong?


Farther investigation, I think the bug is in method Sniffer.Task.sniff().
The first call to Sniffer.Task.sniff() is done for setSniffIntervalMillis timeout which is blocked in hostsSniffer.sniffHosts().
During that time, for each failed node, Sniffer.Task.sniff()is called with setSniffAfterFailureDelayMillis timeout. Since the first call is still blocking in Sniffer.Task.sniff() it cannot call scheduleNextRun because if (running.compareAndSet(false, true)) { condition prevents it from. When all failed nodes are sniffed, hostsSniffer.sniffHosts() returns and set the time again to setSniffIntervalMillis.

I think the in the Exception statement, you should set nextSniffDelayMillis to be equal to sniffAfterFailureDelayMillis.

I Hope I am not wrong

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.