Change in asterixdb[master]: ASTERIXDB-1687 - Configure Timeout On HTTP Connection
Michael Blow has uploaded a new change for review. https://asterix-gerrit.ics.uci.edu/1276 Change subject: ASTERIXDB-1687 - Configure Timeout On HTTP Connection .. ASTERIXDB-1687 - Configure Timeout On HTTP Connection Fixes ASTERIXDB-1687 - asterixhelper get_cluster_state can hang forever, by configuring a timeout on connect and read for HTTP calls, in the event the CC is in a bad state and cannot answer requests Change-Id: Ice9606acaec8f27b56d1d8ed947cc1588074ff2f --- M asterixdb/asterix-client-helper/src/main/java/org/apache/asterix/clienthelper/commands/RemoteCommand.java 1 file changed, 3 insertions(+), 0 deletions(-) git pull ssh://asterix-gerrit.ics.uci.edu:29418/asterixdb refs/changes/76/1276/1 diff --git a/asterixdb/asterix-client-helper/src/main/java/org/apache/asterix/clienthelper/commands/RemoteCommand.java b/asterixdb/asterix-client-helper/src/main/java/org/apache/asterix/clienthelper/commands/RemoteCommand.java index 031a721..7e1e318 100644 --- a/asterixdb/asterix-client-helper/src/main/java/org/apache/asterix/clienthelper/commands/RemoteCommand.java +++ b/asterixdb/asterix-client-helper/src/main/java/org/apache/asterix/clienthelper/commands/RemoteCommand.java @@ -23,6 +23,7 @@ import java.net.HttpURLConnection; import java.net.MalformedURLException; import java.net.URL; +import java.util.concurrent.TimeUnit; import org.apache.asterix.clienthelper.Args; @@ -64,6 +65,8 @@ protected HttpURLConnection openConnection(String path, Method method) throws IOException { URL url = new URL("http://"; + hostPort + "/" + path); HttpURLConnection conn = (HttpURLConnection)url.openConnection(); +conn.setConnectTimeout((int) TimeUnit.SECONDS.toMillis(args.getTimeoutSecs())); +conn.setReadTimeout((int) TimeUnit.SECONDS.toMillis(args.getTimeoutSecs())); conn.setRequestMethod(method.name()); return conn; } -- To view, visit https://asterix-gerrit.ics.uci.edu/1276 To unsubscribe, visit https://asterix-gerrit.ics.uci.edu/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ice9606acaec8f27b56d1d8ed947cc1588074ff2f Gerrit-PatchSet: 1 Gerrit-Project: asterixdb Gerrit-Branch: master Gerrit-Owner: Michael Blow
Change in asterixdb[master]: ASTERIXDB-1687 - Configure Timeout On HTTP Connection
Jenkins has posted comments on this change. Change subject: ASTERIXDB-1687 - Configure Timeout On HTTP Connection .. Patch Set 1: Build Started https://asterix-jenkins.ics.uci.edu/job/asterix-gerrit-notopic/2993/ -- To view, visit https://asterix-gerrit.ics.uci.edu/1276 To unsubscribe, visit https://asterix-gerrit.ics.uci.edu/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ice9606acaec8f27b56d1d8ed947cc1588074ff2f Gerrit-PatchSet: 1 Gerrit-Project: asterixdb Gerrit-Branch: master Gerrit-Owner: Michael Blow Gerrit-Reviewer: Jenkins Gerrit-Reviewer: Till Westmann Gerrit-HasComments: No
Change in asterixdb[master]: ASTERIXDB-1687 - Configure Timeout On HTTP Connection
Jenkins has posted comments on this change. Change subject: ASTERIXDB-1687 - Configure Timeout On HTTP Connection .. Patch Set 1: Integration Tests Started https://asterix-jenkins.ics.uci.edu/job/asterix-gerrit-integration-tests/903/ -- To view, visit https://asterix-gerrit.ics.uci.edu/1276 To unsubscribe, visit https://asterix-gerrit.ics.uci.edu/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ice9606acaec8f27b56d1d8ed947cc1588074ff2f Gerrit-PatchSet: 1 Gerrit-Project: asterixdb Gerrit-Branch: master Gerrit-Owner: Michael Blow Gerrit-Reviewer: Jenkins Gerrit-Reviewer: Till Westmann Gerrit-HasComments: No
Change in asterixdb[master]: ASTERIXDB-1687 - Configure Timeout On HTTP Connection
Jenkins has posted comments on this change. Change subject: ASTERIXDB-1687 - Configure Timeout On HTTP Connection .. Patch Set 1: Integration-Tests-1 Integration Tests Timed Out https://asterix-jenkins.ics.uci.edu/job/asterix-gerrit-integration-tests/903/ : ABORTED -- To view, visit https://asterix-gerrit.ics.uci.edu/1276 To unsubscribe, visit https://asterix-gerrit.ics.uci.edu/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ice9606acaec8f27b56d1d8ed947cc1588074ff2f Gerrit-PatchSet: 1 Gerrit-Project: asterixdb Gerrit-Branch: master Gerrit-Owner: Michael Blow Gerrit-Reviewer: Jenkins Gerrit-Reviewer: Till Westmann Gerrit-HasComments: No
Change in asterixdb[master]: ASTERIXDB-1687 - Configure Timeout On HTTP Connection
Hello Jenkins, I'd like you to reexamine a change. Please visit https://asterix-gerrit.ics.uci.edu/1276 to look at the new patch set (#2). Change subject: ASTERIXDB-1687 - Configure Timeout On HTTP Connection .. ASTERIXDB-1687 - Configure Timeout On HTTP Connection Fixes ASTERIXDB-1687 - asterixhelper get_cluster_state can hang forever, by configuring a timeout on connect and read for HTTP calls, in the event the CC is in a bad state and cannot answer requests Change-Id: Ice9606acaec8f27b56d1d8ed947cc1588074ff2f --- M asterixdb/asterix-client-helper/src/main/java/org/apache/asterix/clienthelper/Args.java M asterixdb/asterix-client-helper/src/main/java/org/apache/asterix/clienthelper/commands/RemoteCommand.java M asterixdb/asterix-client-helper/src/main/java/org/apache/asterix/clienthelper/commands/WaitForClusterCommand.java 3 files changed, 15 insertions(+), 5 deletions(-) git pull ssh://asterix-gerrit.ics.uci.edu:29418/asterixdb refs/changes/76/1276/2 -- To view, visit https://asterix-gerrit.ics.uci.edu/1276 To unsubscribe, visit https://asterix-gerrit.ics.uci.edu/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: Ice9606acaec8f27b56d1d8ed947cc1588074ff2f Gerrit-PatchSet: 2 Gerrit-Project: asterixdb Gerrit-Branch: master Gerrit-Owner: Michael Blow Gerrit-Reviewer: Jenkins Gerrit-Reviewer: Till Westmann
Change in asterixdb[master]: ASTERIXDB-1687 - Configure Timeout On HTTP Connection
Jenkins has posted comments on this change. Change subject: ASTERIXDB-1687 - Configure Timeout On HTTP Connection .. Patch Set 2: Build Started https://asterix-jenkins.ics.uci.edu/job/asterix-gerrit-notopic/2996/ -- To view, visit https://asterix-gerrit.ics.uci.edu/1276 To unsubscribe, visit https://asterix-gerrit.ics.uci.edu/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ice9606acaec8f27b56d1d8ed947cc1588074ff2f Gerrit-PatchSet: 2 Gerrit-Project: asterixdb Gerrit-Branch: master Gerrit-Owner: Michael Blow Gerrit-Reviewer: Jenkins Gerrit-Reviewer: Till Westmann Gerrit-HasComments: No
Change in asterixdb[master]: ASTERIXDB-1687 - Configure Timeout On HTTP Connection
Jenkins has posted comments on this change. Change subject: ASTERIXDB-1687 - Configure Timeout On HTTP Connection .. Patch Set 2: Integration Tests Started https://asterix-jenkins.ics.uci.edu/job/asterix-gerrit-integration-tests/905/ -- To view, visit https://asterix-gerrit.ics.uci.edu/1276 To unsubscribe, visit https://asterix-gerrit.ics.uci.edu/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ice9606acaec8f27b56d1d8ed947cc1588074ff2f Gerrit-PatchSet: 2 Gerrit-Project: asterixdb Gerrit-Branch: master Gerrit-Owner: Michael Blow Gerrit-Reviewer: Jenkins Gerrit-Reviewer: Till Westmann Gerrit-HasComments: No
Change in asterixdb[master]: ASTERIXDB-1687 - Configure Timeout On HTTP Connection
Jenkins has posted comments on this change. Change subject: ASTERIXDB-1687 - Configure Timeout On HTTP Connection .. Patch Set 2: Integration-Tests+1 Integration Tests Successful https://asterix-jenkins.ics.uci.edu/job/asterix-gerrit-integration-tests/905/ : SUCCESS -- To view, visit https://asterix-gerrit.ics.uci.edu/1276 To unsubscribe, visit https://asterix-gerrit.ics.uci.edu/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ice9606acaec8f27b56d1d8ed947cc1588074ff2f Gerrit-PatchSet: 2 Gerrit-Project: asterixdb Gerrit-Branch: master Gerrit-Owner: Michael Blow Gerrit-Reviewer: Jenkins Gerrit-Reviewer: Till Westmann Gerrit-HasComments: No
Change in asterixdb[master]: ASTERIXDB-1687 - Configure Timeout On HTTP Connection
Till Westmann has posted comments on this change. Change subject: ASTERIXDB-1687 - Configure Timeout On HTTP Connection .. Patch Set 2: Code-Review+2 -- To view, visit https://asterix-gerrit.ics.uci.edu/1276 To unsubscribe, visit https://asterix-gerrit.ics.uci.edu/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ice9606acaec8f27b56d1d8ed947cc1588074ff2f Gerrit-PatchSet: 2 Gerrit-Project: asterixdb Gerrit-Branch: master Gerrit-Owner: Michael Blow Gerrit-Reviewer: Jenkins Gerrit-Reviewer: Till Westmann Gerrit-HasComments: No
Change in asterixdb[master]: ASTERIXDB-1687 - Configure Timeout On HTTP Connection
Michael Blow has submitted this change and it was merged. Change subject: ASTERIXDB-1687 - Configure Timeout On HTTP Connection .. ASTERIXDB-1687 - Configure Timeout On HTTP Connection Fixes ASTERIXDB-1687 - asterixhelper get_cluster_state can hang forever, by configuring a timeout on connect and read for HTTP calls, in the event the CC is in a bad state and cannot answer requests Change-Id: Ice9606acaec8f27b56d1d8ed947cc1588074ff2f Reviewed-on: https://asterix-gerrit.ics.uci.edu/1276 Sonar-Qube: Jenkins Tested-by: Jenkins Integration-Tests: Jenkins Reviewed-by: Till Westmann --- M asterixdb/asterix-client-helper/src/main/java/org/apache/asterix/clienthelper/Args.java M asterixdb/asterix-client-helper/src/main/java/org/apache/asterix/clienthelper/commands/RemoteCommand.java M asterixdb/asterix-client-helper/src/main/java/org/apache/asterix/clienthelper/commands/WaitForClusterCommand.java 3 files changed, 15 insertions(+), 5 deletions(-) Approvals: Till Westmann: Looks good to me, approved Jenkins: Verified; No violations found; Verified diff --git a/asterixdb/asterix-client-helper/src/main/java/org/apache/asterix/clienthelper/Args.java b/asterixdb/asterix-client-helper/src/main/java/org/apache/asterix/clienthelper/Args.java index e767f28..ceb873d 100644 --- a/asterixdb/asterix-client-helper/src/main/java/org/apache/asterix/clienthelper/Args.java +++ b/asterixdb/asterix-client-helper/src/main/java/org/apache/asterix/clienthelper/Args.java @@ -45,7 +45,7 @@ @Option(name = "-timeout", metaVar = "", usage = "Timeout for wait commands in seconds") -protected int timeoutSecs = -1; +protected int timeoutSecs = 0; @Option(name = "-quiet", aliases = "-q", usage = "Suppress all normal output") protected boolean quiet; diff --git a/asterixdb/asterix-client-helper/src/main/java/org/apache/asterix/clienthelper/commands/RemoteCommand.java b/asterixdb/asterix-client-helper/src/main/java/org/apache/asterix/clienthelper/commands/RemoteCommand.java index 031a721..e7b6be3 100644 --- a/asterixdb/asterix-client-helper/src/main/java/org/apache/asterix/clienthelper/commands/RemoteCommand.java +++ b/asterixdb/asterix-client-helper/src/main/java/org/apache/asterix/clienthelper/commands/RemoteCommand.java @@ -23,10 +23,14 @@ import java.net.HttpURLConnection; import java.net.MalformedURLException; import java.net.URL; +import java.util.concurrent.TimeUnit; import org.apache.asterix.clienthelper.Args; public abstract class RemoteCommand extends ClientCommand { + +public static final int MAX_CONNECTION_TIMEOUT_SECS = 60; + protected enum Method { GET, POST @@ -64,6 +68,10 @@ protected HttpURLConnection openConnection(String path, Method method) throws IOException { URL url = new URL("http://"; + hostPort + "/" + path); HttpURLConnection conn = (HttpURLConnection)url.openConnection(); +final int timeoutMillis = +(int) TimeUnit.SECONDS.toMillis(Math.max(MAX_CONNECTION_TIMEOUT_SECS, args.getTimeoutSecs())); +conn.setConnectTimeout(timeoutMillis); +conn.setReadTimeout(timeoutMillis); conn.setRequestMethod(method.name()); return conn; } diff --git a/asterixdb/asterix-client-helper/src/main/java/org/apache/asterix/clienthelper/commands/WaitForClusterCommand.java b/asterixdb/asterix-client-helper/src/main/java/org/apache/asterix/clienthelper/commands/WaitForClusterCommand.java index 390ce7b..b0b4c6f 100644 --- a/asterixdb/asterix-client-helper/src/main/java/org/apache/asterix/clienthelper/commands/WaitForClusterCommand.java +++ b/asterixdb/asterix-client-helper/src/main/java/org/apache/asterix/clienthelper/commands/WaitForClusterCommand.java @@ -21,6 +21,7 @@ import java.io.IOException; import java.net.HttpURLConnection; import java.nio.charset.StandardCharsets; +import java.util.concurrent.TimeUnit; import javax.servlet.http.HttpServletResponse; @@ -38,17 +39,18 @@ @Override @SuppressWarnings("squid:S2142") // interrupted exception public int execute() throws IOException { +final int timeoutSecs = args.getTimeoutSecs(); log("Waiting " -+ (args.getTimeoutSecs() > 0 ? "up to " + args.getTimeoutSecs() + " seconds " : "") ++ (timeoutSecs > 0 ? "up to " + timeoutSecs + " seconds " : "") + "for cluster " + hostPort + " to be available."); long startTime = System.currentTimeMillis(); +long timeoutMillis = TimeUnit.SECONDS.toMillis(timeoutSecs); boolean first = true; String lastState = null; while (true) { if (!first) { -if (args.getTimeoutSecs() >= 0 -&& (startTime + (args.getTimeoutSecs() * 1000) < System.currentTimeMillis())) { +if (timeoutMillis > 0 && (startTime + timeoutMillis < Syste