diff options
Diffstat (limited to 'vespa-http-client/src/main/java/com')
3 files changed, 29 insertions, 3 deletions
diff --git a/vespa-http-client/src/main/java/com/yahoo/vespa/http/client/config/FeedParams.java b/vespa-http-client/src/main/java/com/yahoo/vespa/http/client/config/FeedParams.java index c1469790f37..26761530d39 100644 --- a/vespa-http-client/src/main/java/com/yahoo/vespa/http/client/config/FeedParams.java +++ b/vespa-http-client/src/main/java/com/yahoo/vespa/http/client/config/FeedParams.java @@ -1,6 +1,7 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.http.client.config; +import com.google.common.annotations.Beta; import net.jcip.annotations.Immutable; import java.util.concurrent.TimeUnit; @@ -24,6 +25,8 @@ public final class FeedParams { return maxSleepTimeMs; } + public boolean getSilentUpgrade() { return silentUpgrade; } + /** * Enumeration of data formats that are acceptable by the OutputStream * returned by {@link com.yahoo.vespa.http.client.Session#stream(CharSequence)}. @@ -49,7 +52,21 @@ public final class FeedParams { private String priority = null; private boolean denyIfBusyV3 = true; private long maxSleepTimeMs = 3000; + private boolean silentUpgrade = false; + /** + * Make server not throw 4xx/5xx for situations that are normal during upgrade as this can esily mask + * other problems. This feature need to be supported on server side to work, but it is still safe + * to enable it, even if server does not yet support it. As of Nov 22 2016 it is not yet implemented on + * the server side. + * @param silentUpgrade true for reducing "false" 4xx/5xx. + * @return this, for chaining + */ + @Beta + public Builder withSilentUpgrade(boolean silentUpgrade) { + this.silentUpgrade = silentUpgrade; + return this; + } /** * When throttling the load due to transient errors on gateway, what is the most time to wait between @@ -215,7 +232,7 @@ public final class FeedParams { return new FeedParams( dataFormat, serverTimeout, clientTimeout, route, maxChunkSizeBytes, maxInFlightRequests, localQueueTimeOut, priority, - denyIfBusyV3, maxSleepTimeMs); + denyIfBusyV3, maxSleepTimeMs, silentUpgrade); } public long getClientTimeout(TimeUnit unit) { @@ -253,10 +270,13 @@ public final class FeedParams { private final String priority; private final boolean denyIfBusyV3; private final long maxSleepTimeMs; + private final boolean silentUpgrade; + private FeedParams(DataFormat dataFormat, long serverTimeout, long clientTimeout, String route, int maxChunkSizeBytes, final int maxInFlightRequests, - long localQueueTimeOut, String priority, boolean denyIfBusyV3, long maxSleepTimeMs) { + long localQueueTimeOut, String priority, boolean denyIfBusyV3, long maxSleepTimeMs, + boolean silentUpgrade) { this.dataFormat = dataFormat; this.serverTimeoutMillis = serverTimeout; this.clientTimeoutMillis = clientTimeout; @@ -267,6 +287,7 @@ public final class FeedParams { this.priority = priority; this.denyIfBusyV3 = denyIfBusyV3; this.maxSleepTimeMs = maxSleepTimeMs; + this.silentUpgrade = silentUpgrade; } public DataFormat getDataFormat() { diff --git a/vespa-http-client/src/main/java/com/yahoo/vespa/http/client/core/Headers.java b/vespa-http-client/src/main/java/com/yahoo/vespa/http/client/core/Headers.java index ea2111727f2..ae734c7df5f 100644 --- a/vespa-http-client/src/main/java/com/yahoo/vespa/http/client/core/Headers.java +++ b/vespa-http-client/src/main/java/com/yahoo/vespa/http/client/core/Headers.java @@ -32,4 +32,6 @@ public final class Headers { public static final String CLIENT_ID = "X-Yahoo-Client-Id"; public static final String OUTSTANDING_REQUESTS = "X-Yahoo-Outstanding-Requests"; public static final String HOSTNAME = "X-Yahoo-Hostname"; + public static final String SILENTUPGRADE = "X-Yahoo-Silent-Upgrade"; + } diff --git a/vespa-http-client/src/main/java/com/yahoo/vespa/http/client/core/communication/ApacheGatewayConnection.java b/vespa-http-client/src/main/java/com/yahoo/vespa/http/client/core/communication/ApacheGatewayConnection.java index 8a42dcc3a22..d8a2d2ddd12 100644 --- a/vespa-http-client/src/main/java/com/yahoo/vespa/http/client/core/communication/ApacheGatewayConnection.java +++ b/vespa-http-client/src/main/java/com/yahoo/vespa/http/client/core/communication/ApacheGatewayConnection.java @@ -220,6 +220,9 @@ class ApacheGatewayConnection implements GatewayConnection { httpPost.setHeader(Headers.DENY_IF_BUSY, "true"); } } + if (feedParams.getSilentUpgrade()) { + httpPost.setHeader(Headers.SILENTUPGRADE, "true"); + } httpPost.setHeader(Headers.TIMEOUT, "" + feedParams.getServerTimeout(TimeUnit.SECONDS)); for (Map.Entry<String, String> extraHeader : connectionParams.getHeaders()) { @@ -257,7 +260,7 @@ class ApacheGatewayConnection implements GatewayConnection { } private void verifyServerResponseCode(StatusLine statusLine) throws ServerResponseException { - if (statusLine.getStatusCode() > 199 && statusLine.getStatusCode() < 300) { + if (statusLine.getStatusCode() > 199 && statusLine.getStatusCode() < 260) { return; } throw new ServerResponseException(statusLine.getStatusCode(), statusLine.getReasonPhrase()); |