Hazelcast SlowOperationDetector for determining operations with runtime less than 1 second

I have an example of using performance by which I need to identify specific calls process()in EntryProcessorthat take more than 300 milliseconds. I tried to use SlowOperationDetectorwith the following configuration.

    <!-- SlowOperation Detector Configuration -->
    <property name="hazelcast.slow.operation.detector.enabled">true</property>
    <property name="hazelcast.slow.operation.detector.stacktrace.logging.enabled">true</property>
    <property name="hazelcast.slow.operation.detector.log.purge.interval.seconds">60000</property>
    <property name="hazelcast.slow.operation.detector.log.retention.seconds">60000</property>
    <property name="hazelcast.slow.operation.detector.threshold.millis">300</property>

I gave a sample test code that sleeps for 1 second inside process().

public static void main(String args[])
{
    Config cfg = null;
    try {
        cfg = new FileSystemXmlConfig("C:\\workarea\\hazelcast\\hazelcast-perf.xml");
    } catch (FileNotFoundException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    HazelcastInstance hazelcastInstance = Hazelcast.newHazelcastInstance(cfg);
    IMap<String, Employee> employeesMap = hazelcastInstance.getMap("anyMap");
    employeesMap.put("100", new Employee(100));
    SlowEntryProcessor slowEntryProcessor = new SlowEntryProcessor();
    employeesMap.executeOnKey("100", slowEntryProcessor);

}

static public class SlowEntryProcessor implements EntryProcessor<String, Employee>
{

    private static final long serialVersionUID = 1L;

    @Override
    public EntryBackupProcessor<String, Employee> getBackupProcessor() 
    {
        return null;
    }

    @Override
    public Object process(Entry<String, Employee> arg0) 
    {
        System.out.println("About to sleep");
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("done processing");
        return null;
    }

}   

I do not see any logs when the configured threshold is less than 1000 ms. Therefore, in this example, I don’t see a trace of the slow stack or logs.

If I change the sleep time to 2 seconds and the slow working threshold to 1 second, then the slow detector will fire and logs will be displayed.

Is this a bug in SlowOperationDetectoror something I do not see here?

+4
1

; . . . ( ) . .

+2

Source: https://habr.com/ru/post/1618684/


All Articles