summaryrefslogtreecommitdiffstats
path: root/vespaclient-core
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2018-01-25 10:45:11 +0100
committerHenning Baldersheim <balder@yahoo-inc.com>2018-01-25 10:45:11 +0100
commit9c868d0c4c25488facd7843f12e07dfc6f2353b8 (patch)
tree7103cae94073350723fcca24a71bcea9e86ca4e7 /vespaclient-core
parentcfb78037fdc4eb22410b5ed13bf59225ac476ec4 (diff)
The http parameter &totaltimeout can be used to control the overall timeout.
If both timeouts are given the lower of the computed and the given &timeout is used per message. Setting &totaltimeout to a negative value enables a fixed timeout given to each message. This mimics todays broken behavior.
Diffstat (limited to 'vespaclient-core')
-rw-r--r--vespaclient-core/src/main/java/com/yahoo/feedapi/MessagePropertyProcessor.java21
1 files changed, 13 insertions, 8 deletions
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 017525ef1c2..3897f1d7d2a 100644
--- a/vespaclient-core/src/main/java/com/yahoo/feedapi/MessagePropertyProcessor.java
+++ b/vespaclient-core/src/main/java/com/yahoo/feedapi/MessagePropertyProcessor.java
@@ -107,7 +107,7 @@ public class MessagePropertyProcessor implements ConfigSubscriber.SingleSubscrib
String loadTypeStr = null;
String traceStr = null;
String createIfNonExistentParam = null;
- boolean useConstantTimeout = false;
+ Double totalTimeoutParam = null;
if (request != null) {
routeParam = request.getProperty("route");
@@ -116,7 +116,10 @@ public class MessagePropertyProcessor implements ConfigSubscriber.SingleSubscrib
if (timeoutStr != null) {
timeoutParam = Double.parseDouble(timeoutStr);
}
- useConstantTimeout = request.getBooleanProperty("useconstanttimeout");
+ timeoutStr = request.getProperty("totaltimeout");
+ if (timeoutStr != null) {
+ totalTimeoutParam = Double.parseDouble(timeoutStr);
+ }
priorityParam = request.getProperty("priority");
traceStr = request.getProperty("tracelevel");
@@ -143,6 +146,8 @@ public class MessagePropertyProcessor implements ConfigSubscriber.SingleSubscrib
abortOnFeedError = (abortOnFeedErrorParam == null ? defaultAbortOnSendError : (!"false".equals(abortOnFeedErrorParam)));
createIfNonExistent = (createIfNonExistentParam == null ? defaultCreateIfNonExistent : ("true".equals(createIfNonExistentParam)));
}
+ long totalTimeout = (totalTimeoutParam == null) ? timeout : (long)(totalTimeoutParam*1000);
+
DocumentProtocol.Priority priority = null;
if (priorityParam != null) {
priority = DocumentProtocol.getPriorityByName(priorityParam);
@@ -157,7 +162,7 @@ public class MessagePropertyProcessor implements ConfigSubscriber.SingleSubscrib
loadType = LoadType.DEFAULT;
}
- return new PropertySetter(useConstantTimeout, route, timeout, priority, loadType, retry, abortOnDocumentError, abortOnFeedError, createIfNonExistent, traceStr != null ? Integer.parseInt(traceStr) : 0);
+ return new PropertySetter(route, timeout, totalTimeout, priority, loadType, retry, abortOnDocumentError, abortOnFeedError, createIfNonExistent, traceStr != null ? Integer.parseInt(traceStr) : 0);
}
public long getDefaultTimeoutMillis() { return defaultTimeoutMillis; }
@@ -220,8 +225,8 @@ public class MessagePropertyProcessor implements ConfigSubscriber.SingleSubscrib
private Route route;
/** Timeout (in milliseconds) */
private long timeout;
+ private long totalTimeout;
private long startTime;
- boolean useConstantTimeout;
/** Explicit priority set. May be null */
private DocumentProtocol.Priority priority;
private boolean retryEnabled;
@@ -231,12 +236,12 @@ public class MessagePropertyProcessor implements ConfigSubscriber.SingleSubscrib
private LoadType loadType;
private int traceLevel;
- public PropertySetter(boolean useConstantTimeout, Route route, long timeout, DocumentProtocol.Priority priority, LoadType loadType,
+ public PropertySetter(Route route, long timeout, long totalTimeout, DocumentProtocol.Priority priority, LoadType loadType,
boolean retryEnabled, boolean abortOnDocumentError, boolean abortOnFeedError,
boolean createIfNonExistent, int traceLevel) {
- this.useConstantTimeout = useConstantTimeout;
this.route = route;
this.timeout = timeout;
+ this.totalTimeout = totalTimeout;
this.priority = priority;
this.loadType = loadType;
this.retryEnabled = retryEnabled;
@@ -248,9 +253,9 @@ public class MessagePropertyProcessor implements ConfigSubscriber.SingleSubscrib
}
private long getTimeRemaining() {
- return useConstantTimeout
+ return (totalTimeout < 0L)
? timeout
- : timeout - (SystemTimer.INSTANCE.milliTime() - startTime);
+ : Math.min(timeout, totalTimeout - (SystemTimer.INSTANCE.milliTime() - startTime));
}
public Route getRoute() {