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.
<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) {
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?