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

Change subject: Make updater timeouts configurable
......................................................................


Make updater timeouts configurable

Change-Id: I35a4e63ed459c4fc5e9cd733dbc3a165b8f2e133
---
M dist/src/script/runUpdate.sh
M tools/src/main/java/org/wikidata/query/rdf/tool/rdf/RdfRepository.java
2 files changed, 25 insertions(+), 2 deletions(-)

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



diff --git a/dist/src/script/runUpdate.sh b/dist/src/script/runUpdate.sh
index 07a495c..3df3bb9 100755
--- a/dist/src/script/runUpdate.sh
+++ b/dist/src/script/runUpdate.sh
@@ -3,7 +3,7 @@
 HOST=http://localhost:9999
 CONTEXT=bigdata
 
-while getopts h:c:n:l:s option
+while getopts h:c:n:l:t:s option
 do
   case "${option}"
   in
@@ -11,6 +11,7 @@
     c) CONTEXT=${OPTARG};;
     n) NAMESPACE=${OPTARG};;
     l) LANGS=${OPTARG};;
+    t) TMO=${OPTARG};;
     s) SKIPSITE=1;;
   esac
 done
@@ -22,6 +23,12 @@
 then
   echo "Usage: $0 -n <namespace> [-h <host>] [-c <context>]"
   exit 1
+fi
+
+if [ -z "$TMO" ]; then
+    TIMEOUT_ARG=
+else
+    TIMEOUT_ARG="-Dorg.wikidata.query.rdf.tool.rdf.RdfRepository.timeout=$TMO"
 fi
 
 if [ -z "$LANGS" ]; then
@@ -47,4 +54,4 @@
 SPARQL_URL=$HOST/$CONTEXT/namespace/$NAMESPACE/sparql
 AGENT=-javaagent:lib/jolokia-jvm-1.3.1-agent.jar=port=8778,host=localhost
 echo "Updating via $SPARQL_URL"
-java -Xmx2g -cp $CP $LOG $AGENT $MAIN $ARGS --sparqlUrl $SPARQL_URL "$@"
+java -Xmx2g -cp $CP $LOG $TIMEOUT_ARG $AGENT $MAIN $ARGS --sparqlUrl 
$SPARQL_URL "$@"
diff --git 
a/tools/src/main/java/org/wikidata/query/rdf/tool/rdf/RdfRepository.java 
b/tools/src/main/java/org/wikidata/query/rdf/tool/rdf/RdfRepository.java
index f7c0f34..daa291e 100644
--- a/tools/src/main/java/org/wikidata/query/rdf/tool/rdf/RdfRepository.java
+++ b/tools/src/main/java/org/wikidata/query/rdf/tool/rdf/RdfRepository.java
@@ -27,6 +27,7 @@
 import org.apache.http.Consts;
 import org.apache.http.HttpEntity;
 import org.apache.http.NameValuePair;
+import org.apache.http.client.config.RequestConfig;
 import org.apache.http.client.entity.UrlEncodedFormEntity;
 import org.apache.http.client.methods.CloseableHttpResponse;
 import org.apache.http.client.methods.HttpPost;
@@ -139,6 +140,16 @@
         return client;
     }
 
+    /**
+     * HTTP request configuration.
+     */
+    private RequestConfig requestConfig;
+
+    /**
+     * Request timeout property.
+     */
+    public static final String TIMEOUT_PROPERTY = RdfRepository.class + 
".timeout";
+
     public RdfRepository(URI uri, WikibaseUris uris) {
         this.uri = uri;
         this.uris = uris;
@@ -150,6 +161,10 @@
         cleanUnused = loadBody("CleanUnused");
         getRevisions = loadBody("GetRevisions");
         verify = loadBody("verify");
+
+        final int timeout = Integer
+                .parseInt(System.getProperty(TIMEOUT_PROPERTY, "-1")) * 1000;
+        requestConfig = 
RequestConfig.custom().setSocketTimeout(timeout).build();
     }
 
     /**
@@ -576,6 +591,7 @@
      */
     protected <T> T execute(String type, ResponseHandler<T> responseHandler, 
String sparql) {
         HttpPost post = new HttpPost(uri);
+        post.setConfig(requestConfig);
         post.setHeader(new BasicHeader("Content-Type", 
"application/x-www-form-urlencoded; charset=UTF-8"));
         // Note that Blazegraph totally ignores the Accept header for SPARQL
         // updates like this so the response is just html....

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I35a4e63ed459c4fc5e9cd733dbc3a165b8f2e133
Gerrit-PatchSet: 1
Gerrit-Project: wikidata/query/rdf
Gerrit-Branch: master
Gerrit-Owner: Smalyshev <smalys...@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