SnifferBuilder.sniffOnFailureListener() not honored

Hi,

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))
    .setFailureListener(sniffOnFailureListener) 
    .build();
Sniffer sniffer = Sniffer.builder(restClient)
    .setSniffAfterFailureDelayMillis(30000) 
    .build();
sniffOnFailureListener.setSniffer(sniffer); 

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?

Thanks

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.