changeset 1078:844bc5ceadef

Metrics bugfixes
author Devel 2
date Wed, 29 Apr 2020 11:06:52 +0200
parents 2211bb11ab38
children b6397f2033d9
files stress-tester/src/main/java/com/passus/st/emitter/raw/UnidirectionalRawPacketWorker.java stress-tester/src/main/java/com/passus/st/emitter/socket/DatagramConnection.java
diffstat 2 files changed, 14 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/stress-tester/src/main/java/com/passus/st/emitter/raw/UnidirectionalRawPacketWorker.java	Wed Apr 29 10:23:17 2020 +0200
+++ b/stress-tester/src/main/java/com/passus/st/emitter/raw/UnidirectionalRawPacketWorker.java	Wed Apr 29 11:06:52 2020 +0200
@@ -268,6 +268,13 @@
         } catch (Exception ex) {
             doCatchException(channelContext, ex);
         }
+
+        if (collectMetrics) {
+            synchronized (metric) {
+                metric.addRemoteSocketConnection(remoteAddress);
+                metric.addBindSocket(localAddress);
+            }
+        }
     }
 
     protected abstract int doWrite0(UnidirectionalRawPacketChannelContext<E> channelContext, byte[] frame, int length) throws IOException;
--- a/stress-tester/src/main/java/com/passus/st/emitter/socket/DatagramConnection.java	Wed Apr 29 10:23:17 2020 +0200
+++ b/stress-tester/src/main/java/com/passus/st/emitter/socket/DatagramConnection.java	Wed Apr 29 11:06:52 2020 +0200
@@ -95,8 +95,10 @@
         }
 
         if (collectMetrics) {
-            metric.addRemoteSocketConnection(channelContext.getRemoteAddress());
-            metric.addBindSocket(channelContext.getLocalAddress());
+            synchronized (metric) {
+                metric.addRemoteSocketConnection(channelContext.getRemoteAddress());
+                metric.addBindSocket(channelContext.getLocalAddress());
+            }
         }
     }
 
@@ -114,7 +116,9 @@
         }
 
         if (collectMetrics) {
-            metric.incClosedConnections();
+            synchronized (metric) {
+                metric.incClosedConnections();
+            }
         }
     }