Mercurial > stress-tester
changeset 1284:8527e4c0f984
DpdkUnidirectionalRawPacketWorker - bugfixes
author | Devel 1 |
---|---|
date | Thu, 09 Jul 2020 15:11:35 +0200 |
parents | da1afebf57ef |
children | 1c53cc761dcd |
files | stress-tester/src/main/java/com/passus/st/emitter/raw/DpdkUnidirectionalRawPacketEmitter.java stress-tester/src/main/java/com/passus/st/emitter/raw/DpdkUnidirectionalRawPacketWorker.java |
diffstat | 2 files changed, 25 insertions(+), 18 deletions(-) [+] |
line wrap: on
line diff
--- a/stress-tester/src/main/java/com/passus/st/emitter/raw/DpdkUnidirectionalRawPacketEmitter.java Thu Jul 09 14:15:53 2020 +0200 +++ b/stress-tester/src/main/java/com/passus/st/emitter/raw/DpdkUnidirectionalRawPacketEmitter.java Thu Jul 09 15:11:35 2020 +0200 @@ -53,7 +53,7 @@ MapNodeDefinition def = super.create(); def.add( tupleDef("bufferSize", INT_GREATER_EQUAL_ZERO_DEF).setRequired(false), - tupleDef("bufferFlushPeriod", LONG_GREATER_THAN_ZERO_DEF).setRequired(false), + tupleDef("bufferFlushPeriod", LONG_GREATER_EQUAL_ZERO_DEF).setRequired(false), tupleDef("verbosity", INT_GREATER_EQUAL_ZERO_DEF).setRequired(false) ); return def;
--- a/stress-tester/src/main/java/com/passus/st/emitter/raw/DpdkUnidirectionalRawPacketWorker.java Thu Jul 09 14:15:53 2020 +0200 +++ b/stress-tester/src/main/java/com/passus/st/emitter/raw/DpdkUnidirectionalRawPacketWorker.java Thu Jul 09 15:11:35 2020 +0200 @@ -19,7 +19,7 @@ public static final int MAX_BUFFER_SIZE = DpdkAO.sendBuffSize(); public static final int DEFAULT_BUFFER_SIZE = 0; - public static final long DEFAULT_FLUSH_PERIOD = 50; + public static final long DEFAULT_FLUSH_PERIOD = 0; public static final int DEFAULT_VERBOSITY = 1; private DpdkAO dpdkAO; @@ -132,24 +132,39 @@ bufferLengths = new int[bufferSize]; bufferPkts = 0; -// scheduler = new DefaultScheduledTimerService(getClass().getSimpleName() + "-Scheduler", bufferFlushPeriod, this::flushBuffer); -// scheduler.start(); + if (bufferFlushPeriod > 0) { + scheduler = new DefaultScheduledTimerService(getClass().getSimpleName() + "-Scheduler", bufferFlushPeriod, this::flushBuffer); + scheduler.start(); + } } } } @Override protected void onFinish() { - if (scheduler != null) { - scheduler.stop(); - scheduler = null; + synchronized (this) { + if (scheduler != null) { + scheduler.stop(); + scheduler = null; + } + } + + synchronized (DpdkAO.class) { + if (dpdkInitCalls > 0) { + dpdkInitCalls--; + if (dpdkInitCalls == 0) { + DpdkAO.cleanApp(); + } + } } } private void flushBuffer() { - synchronized (this) { - DpdkAO.sendPackets0(bufferBytes, bufferLengths, bufferPkts); - bufferPkts = 0; + if (bufferPkts > 0) { + synchronized (this) { + DpdkAO.sendPackets0(bufferBytes, bufferLengths, bufferPkts); + bufferPkts = 0; + } } } @@ -180,13 +195,5 @@ if (bufferSize > 0) { flushBuffer(); } - synchronized (DpdkAO.class) { - if (dpdkInitCalls > 0) { - dpdkInitCalls--; - if (dpdkInitCalls == 0) { - DpdkAO.cleanApp(); - } - } - } } }