diff options
4 files changed, 22 insertions, 12 deletions
diff --git a/vespa_feed_perf/src/main/java/com/yahoo/vespa/feed/perf/FeederParams.java b/vespa_feed_perf/src/main/java/com/yahoo/vespa/feed/perf/FeederParams.java index fde3e13ada3..cad8bb7b312 100644 --- a/vespa_feed_perf/src/main/java/com/yahoo/vespa/feed/perf/FeederParams.java +++ b/vespa_feed_perf/src/main/java/com/yahoo/vespa/feed/perf/FeederParams.java @@ -34,6 +34,7 @@ class FeederParams { private boolean benchmarkMode = false; private int numDispatchThreads = 1; private int maxPending = 0; + private double timeout = 180.0; private double windowSizeBackOff = 0.95; private double windowDecrementFactor = 1.2; @@ -100,6 +101,9 @@ class FeederParams { public double getWindowResizeRate() { return windowResizeRate; } + public double getTimeout() { + return timeout; + } public int getWindowIncrementSize() { return windowIncrementSize; @@ -137,6 +141,7 @@ class FeederParams { opts.addOption("b", "mode", true, "Mode for benchmarking."); opts.addOption("o", "output", true, "File to write to. Extensions gives format (.xml, .json, .vespa) json will be produced if no extension."); opts.addOption("c", "numconnections", true, "Number of connections per host."); + opts.addOption("t", "timeout", true, "Timeout for a message in seconds. default = " + timeout); opts.addOption("l", "nummessages", true, "Number of messages to send (all is default)."); opts.addOption("wi", "window_incrementsize", true, "Dynamic window increment step size. default = " + windowIncrementSize); opts.addOption("wd", "window_decrementfactor", true, "Dynamic window decrement step size factor. default = " + windowDecrementFactor); @@ -169,6 +174,9 @@ class FeederParams { if (cmd.hasOption('r')) { route = Route.parse(cmd.getOptionValue('r').trim()); } + if (cmd.hasOption("t")) { + timeout = Double.valueOf(cmd.getOptionValue("t").trim()); + } benchmarkMode = cmd.hasOption('b'); if (cmd.hasOption('o')) { String fileName = cmd.getOptionValue('o').trim(); diff --git a/vespa_feed_perf/src/main/java/com/yahoo/vespa/feed/perf/SimpleFeeder.java b/vespa_feed_perf/src/main/java/com/yahoo/vespa/feed/perf/SimpleFeeder.java index 18c0de339e6..14123c7a73c 100644 --- a/vespa_feed_perf/src/main/java/com/yahoo/vespa/feed/perf/SimpleFeeder.java +++ b/vespa_feed_perf/src/main/java/com/yahoo/vespa/feed/perf/SimpleFeeder.java @@ -129,11 +129,13 @@ public class SimpleFeeder implements ReplyHandler { private final PrintStream err; private final Route route; private final SourceSession session; + private final long timeoutMS; private final AtomicReference<Throwable> failure; - MbusDestination(SourceSession session, Route route, AtomicReference<Throwable> failure, PrintStream err) { + MbusDestination(SourceSession session, Route route, double timeoutS, AtomicReference<Throwable> failure, PrintStream err) { this.route = route; this.err = err; this.session = session; + this.timeoutMS = (long)(timeoutS * 1000.0); this.failure = failure; } public void send(FeedOperation op) { @@ -142,6 +144,7 @@ public class SimpleFeeder implements ReplyHandler { err.println("ignoring operation; " + op.getType()); return; } + msg.setTimeRemaining(timeoutMS); msg.setContext(System.currentTimeMillis()); msg.setRoute(route); try { @@ -352,7 +355,7 @@ public class SimpleFeeder implements ReplyHandler { benchmarkMode = params.isBenchmarkMode(); destination = (params.getDumpStream() != null) ? createDumper(params) - : new MbusDestination(session, params.getRoute(), failure, params.getStdErr()); + : new MbusDestination(session, params.getRoute(), params.getTimeout(), failure, params.getStdErr()); } SourceSession getSourceSession() { return session; } diff --git a/vespa_feed_perf/src/test/java/com/yahoo/vespa/feed/perf/FeederParamsTest.java b/vespa_feed_perf/src/test/java/com/yahoo/vespa/feed/perf/FeederParamsTest.java index d4b114112b6..6f575038f75 100644 --- a/vespa_feed_perf/src/test/java/com/yahoo/vespa/feed/perf/FeederParamsTest.java +++ b/vespa_feed_perf/src/test/java/com/yahoo/vespa/feed/perf/FeederParamsTest.java @@ -28,6 +28,8 @@ public class FeederParamsTest { private static final String TESTFILE_JSON = "test.json"; private static final String TESTFILE_VESPA = "test.vespa"; private static final String TESTFILE_UNKNOWN = "test.xyz"; + private static final double EPSILON = 0.000000000001; + @Test public void requireThatAccessorsWork() { @@ -94,6 +96,13 @@ public class FeederParamsTest { } @Test + public void requireThatTimeoutIsParsed() throws ParseException, FileNotFoundException { + assertEquals(180.0, new FeederParams().getTimeout(), EPSILON); + assertEquals(16.7, new FeederParams().parseArgs("-t 16.7").getTimeout(), EPSILON); + assertEquals(1700.9, new FeederParams().parseArgs("--timeout", "1700.9").getTimeout(), EPSILON); + } + + @Test public void requireThatNumMessagesToSendAreParsed() throws ParseException, FileNotFoundException { assertEquals(Long.MAX_VALUE, new FeederParams().getNumMessagesToSend()); assertEquals(18, new FeederParams().parseArgs("-l 18").getNumMessagesToSend()); @@ -106,8 +115,6 @@ public class FeederParamsTest { assertEquals(17, new FeederParams().parseArgs("--window_incrementsize", "17").getWindowIncrementSize()); } - static final double EPSILON = 0.000000000001; - @Test public void requireThatWindowSizeDecrementFactorIsParsed() throws ParseException, FileNotFoundException { assertEquals(1.2, new FeederParams().getWindowDecrementFactor(), EPSILON); diff --git a/vespaclient-core/src/main/java/com/yahoo/feedapi/MessagePropertyProcessor.java b/vespaclient-core/src/main/java/com/yahoo/feedapi/MessagePropertyProcessor.java index 74a4f916c07..581a51ffc02 100644 --- a/vespaclient-core/src/main/java/com/yahoo/feedapi/MessagePropertyProcessor.java +++ b/vespaclient-core/src/main/java/com/yahoo/feedapi/MessagePropertyProcessor.java @@ -208,14 +208,6 @@ public class MessagePropertyProcessor implements ConfigSubscriber.SingleSubscrib this.route = route; } - public long getTimeout() { - return timeout; - } - - public void setTimeout(long timeout) { - this.timeout = timeout; - } - public DocumentProtocol.Priority getPriority() { return priority; } |