Mercurial > stress-tester
changeset 1074:a5236d71d2ca
PcapUnidirectionalRawPacketEmitter.dumpFile
author | Devel 2 |
---|---|
date | Tue, 28 Apr 2020 15:14:00 +0200 |
parents | 2d7ad6c35a8b |
children | c3bcec472408 |
files | stress-tester/src/main/java/com/passus/st/emitter/raw/PcapUnidirectionalRawPacketEmitter.java |
diffstat | 1 files changed, 38 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/stress-tester/src/main/java/com/passus/st/emitter/raw/PcapUnidirectionalRawPacketEmitter.java Tue Apr 28 15:07:06 2020 +0200 +++ b/stress-tester/src/main/java/com/passus/st/emitter/raw/PcapUnidirectionalRawPacketEmitter.java Tue Apr 28 15:14:00 2020 +0200 @@ -1,15 +1,37 @@ package com.passus.st.emitter.raw; import com.passus.commons.annotations.Plugin; +import com.passus.config.Configuration; +import com.passus.config.ConfigurationContext; import com.passus.config.annotations.NodeDefinitionCreate; +import com.passus.config.schema.MapNodeDefinition; import com.passus.st.plugin.PluginConstants; -@NodeDefinitionCreate(UnidirectionalRawPacketEmitter.UnidirectionalRawPacketEmitterNodeDefCreator.class) +import static com.passus.config.schema.ConfigurationSchemaBuilder.tupleDef; +import static com.passus.config.schema.ConfigurationSchemaBuilder.valueDef; + +@NodeDefinitionCreate(PcapUnidirectionalRawPacketEmitter.PcapUnidirectionalRawPacketEmitterNodeDefCreator.class) @Plugin(name = PcapUnidirectionalRawPacketEmitter.TYPE, category = PluginConstants.CATEGORY_EMITTER) public class PcapUnidirectionalRawPacketEmitter extends UnidirectionalRawPacketEmitter<PcapOutput> { public static final String TYPE = "pcap"; + private String dumpFile; + + public String getDumpFile() { + return dumpFile; + } + + public void setDumpFile(String dumpFile) { + this.dumpFile = dumpFile; + } + + @Override + public void configure(Configuration config, ConfigurationContext context) { + super.configure(config, context); + setDumpFile(config.getString("dumpFile", null)); + } + @Override protected UnidirectionalRawPacketWorker<PcapOutput>[] createWorkersArray(int workersNum) { return new PcapUnidirectionalRawPacketWorker[workersNum]; @@ -17,6 +39,20 @@ @Override protected UnidirectionalRawPacketWorker<PcapOutput> createWorker() { - return new PcapUnidirectionalRawPacketWorker(); + PcapUnidirectionalRawPacketWorker worker = new PcapUnidirectionalRawPacketWorker(); + worker.setDumpFile(dumpFile); + return worker; + } + + public static class PcapUnidirectionalRawPacketEmitterNodeDefCreator extends UnidirectionalRawPacketEmitterNodeDefCreator { + + @Override + public MapNodeDefinition create() { + MapNodeDefinition def = super.create(); + def.add( + tupleDef("dumpFile", valueDef()).setRequired(false) + ); + return def; + } } }