Added measuer of latency to server side
This commit is contained in:
+9
-2
@@ -113,7 +113,14 @@
|
|||||||
<!--version>1.1.0-SNAPSHOT</version-->
|
<!--version>1.1.0-SNAPSHOT</version-->
|
||||||
<version>2.0.0-SNAPSHOT</version>
|
<version>2.0.0-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.hdrhistogram</groupId>
|
||||||
|
<artifactId>HdrHistogram</artifactId>
|
||||||
|
<version>2.1.4</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Test dependencies -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>junit</groupId>
|
<groupId>junit</groupId>
|
||||||
<artifactId>junit</artifactId>
|
<artifactId>junit</artifactId>
|
||||||
@@ -126,7 +133,7 @@
|
|||||||
<artifactId>robot.junit</artifactId>
|
<artifactId>robot.junit</artifactId>
|
||||||
<version>0.0.0.12</version>
|
<version>0.0.0.12</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- needs extra dependencies: objenesis & hamcrest -->
|
<!-- needs extra dependencies: objenesis & hamcrest -->
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ import org.eclipse.moquette.server.IAuthenticator;
|
|||||||
import org.eclipse.moquette.server.ServerChannel;
|
import org.eclipse.moquette.server.ServerChannel;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.HdrHistogram.Histogram;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -67,6 +68,8 @@ public class SimpleMessaging implements IMessaging, EventHandler<ValueEvent> {
|
|||||||
private final AnnotationSupport annotationSupport = new AnnotationSupport();
|
private final AnnotationSupport annotationSupport = new AnnotationSupport();
|
||||||
|
|
||||||
CountDownLatch m_stopLatch;
|
CountDownLatch m_stopLatch;
|
||||||
|
|
||||||
|
Histogram histogram = new Histogram(5);
|
||||||
|
|
||||||
private SimpleMessaging() {
|
private SimpleMessaging() {
|
||||||
}
|
}
|
||||||
@@ -153,7 +156,10 @@ public class SimpleMessaging implements IMessaging, EventHandler<ValueEvent> {
|
|||||||
ServerChannel session = ((ProtocolEvent) evt).getSession();
|
ServerChannel session = ((ProtocolEvent) evt).getSession();
|
||||||
AbstractMessage message = ((ProtocolEvent) evt).getMessage();
|
AbstractMessage message = ((ProtocolEvent) evt).getMessage();
|
||||||
try {
|
try {
|
||||||
|
long startTime = System.nanoTime();
|
||||||
annotationSupport.dispatch(session, message);
|
annotationSupport.dispatch(session, message);
|
||||||
|
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);
|
||||||
}
|
}
|
||||||
@@ -194,5 +200,8 @@ public class SimpleMessaging implements IMessaging, EventHandler<ValueEvent> {
|
|||||||
|
|
||||||
subscriptions = null;
|
subscriptions = null;
|
||||||
m_stopLatch.countDown();
|
m_stopLatch.countDown();
|
||||||
|
|
||||||
|
//log metrics
|
||||||
|
histogram.outputPercentileDistribution(System.out, 1000.0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user