jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/374989 )

Change subject: Throttling - treat HTTP 4xx and 5xx as failures
......................................................................


Throttling - treat HTTP 4xx and 5xx as failures

We were considering only Exceptions as failure condition in a servlet. An
HTTP response of 4xx or 5xx should also be considered as a failure.

Change-Id: Ibab92c9e7706fa29eb4a7ed26084be235efad69c
---
M 
blazegraph/src/main/java/org/wikidata/query/rdf/blazegraph/throttling/ThrottlingFilter.java
1 file changed, 8 insertions(+), 1 deletion(-)

Approvals:
  Smalyshev: Looks good to me, approved
  jenkins-bot: Verified



diff --git 
a/blazegraph/src/main/java/org/wikidata/query/rdf/blazegraph/throttling/ThrottlingFilter.java
 
b/blazegraph/src/main/java/org/wikidata/query/rdf/blazegraph/throttling/ThrottlingFilter.java
index c6d5a71..b9f7cbe 100644
--- 
a/blazegraph/src/main/java/org/wikidata/query/rdf/blazegraph/throttling/ThrottlingFilter.java
+++ 
b/blazegraph/src/main/java/org/wikidata/query/rdf/blazegraph/throttling/ThrottlingFilter.java
@@ -242,8 +242,15 @@
         Stopwatch stopwatch = Stopwatch.createStarted();
         try {
             chain.doFilter(request, response);
-            throttler.success(httpRequest, stopwatch.elapsed());
+            // for throttling purpose, consider all 1xx and 2xx status codes as
+            // success, 4xx and 5xx as failure
+            if (httpResponse.getStatus() < 400) {
+                throttler.success(httpRequest, stopwatch.elapsed());
+            } else {
+                throttler.failure(httpRequest, stopwatch.elapsed());
+            }
         } catch (IOException | ServletException e) {
+            // an exception processing the request is treated as a failure
             throttler.failure(httpRequest, stopwatch.elapsed());
             throw e;
         }

-- 
To view, visit https://gerrit.wikimedia.org/r/374989
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ibab92c9e7706fa29eb4a7ed26084be235efad69c
Gerrit-PatchSet: 2
Gerrit-Project: wikidata/query/rdf
Gerrit-Branch: master
Gerrit-Owner: Gehel <guillaume.leder...@wikimedia.org>
Gerrit-Reviewer: Smalyshev <smalys...@wikimedia.org>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to