Added moquette.processor.benchmark sys property to enable/disable processor performance recording
This commit is contained in:
@@ -66,6 +66,7 @@ public class SimpleMessaging implements IMessaging, EventHandler<ValueEvent> {
|
|||||||
|
|
||||||
private final ProtocolProcessor m_processor = new ProtocolProcessor();
|
private final ProtocolProcessor m_processor = new ProtocolProcessor();
|
||||||
private final AnnotationSupport annotationSupport = new AnnotationSupport();
|
private final AnnotationSupport annotationSupport = new AnnotationSupport();
|
||||||
|
private boolean benchmarkEnabled = false;
|
||||||
|
|
||||||
CountDownLatch m_stopLatch;
|
CountDownLatch m_stopLatch;
|
||||||
|
|
||||||
@@ -158,8 +159,10 @@ public class SimpleMessaging implements IMessaging, EventHandler<ValueEvent> {
|
|||||||
try {
|
try {
|
||||||
long startTime = System.nanoTime();
|
long startTime = System.nanoTime();
|
||||||
annotationSupport.dispatch(session, message);
|
annotationSupport.dispatch(session, message);
|
||||||
long delay = System.nanoTime() - startTime;
|
if (benchmarkEnabled) {
|
||||||
histogram.recordValue(delay);
|
long delay = System.nanoTime() - startTime;
|
||||||
|
histogram.recordValue(delay);
|
||||||
|
}
|
||||||
} catch (Throwable th) {
|
} catch (Throwable th) {
|
||||||
LOG.error("Grave error processing the message {} for {}", message, session, th);
|
LOG.error("Grave error processing the message {} for {}", message, session, th);
|
||||||
}
|
}
|
||||||
@@ -167,6 +170,8 @@ public class SimpleMessaging implements IMessaging, EventHandler<ValueEvent> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void processInit(Properties props) {
|
private void processInit(Properties props) {
|
||||||
|
benchmarkEnabled = Boolean.parseBoolean(System.getProperty("moquette.processor.benchmark", "false"));
|
||||||
|
|
||||||
//TODO use a property to select the storage path
|
//TODO use a property to select the storage path
|
||||||
MapDBPersistentStore mapStorage = new MapDBPersistentStore();
|
MapDBPersistentStore mapStorage = new MapDBPersistentStore();
|
||||||
m_storageService = mapStorage;
|
m_storageService = mapStorage;
|
||||||
@@ -201,7 +206,9 @@ public class SimpleMessaging implements IMessaging, EventHandler<ValueEvent> {
|
|||||||
subscriptions = null;
|
subscriptions = null;
|
||||||
m_stopLatch.countDown();
|
m_stopLatch.countDown();
|
||||||
|
|
||||||
//log metrics
|
if (benchmarkEnabled) {
|
||||||
histogram.outputPercentileDistribution(System.out, 1000.0);
|
//log metrics
|
||||||
|
histogram.outputPercentileDistribution(System.out, 1000.0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user