diff --git a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/hc/HttpConnectionServerChecker.java b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/hc/HttpConnectionServerChecker.java index f4cedcf22c97..9b11807b3fe7 100644 --- a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/hc/HttpConnectionServerChecker.java +++ b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/hc/HttpConnectionServerChecker.java @@ -34,9 +34,10 @@ public HttpConnectionServerChecker( String serverRef, long period, long timeout, + int successThreshold, TimeUnit timeUnit, Timer timer) { - super(machineName, serverRef, period, timeout, timeUnit, timer); + super(machineName, serverRef, period, timeout, successThreshold, timeUnit, timer); this.url = url; } diff --git a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/hc/ServerChecker.java b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/hc/ServerChecker.java index 9512c19c1706..9fa95ef2bed8 100644 --- a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/hc/ServerChecker.java +++ b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/hc/ServerChecker.java @@ -28,6 +28,7 @@ public abstract class ServerChecker { private final String serverRef; private final long period; private final long deadLine; + private final int successThreshold; private final CompletableFuture reportFuture; private final Timer timer; @@ -37,6 +38,8 @@ public abstract class ServerChecker { * @param machineName name of machine to whom the server belongs * @param serverRef reference of the server * @param period period between unsuccessful availability checks, measured in {@code timeUnit} + * @param successThreshold number of sequential successful pings of server after which it is + * treated as available * @param timeout max time allowed for the server availability checks to last before server is * treated unavailable, measured in {@code timeUnit} * @param timeUnit measurement unit for {@code period} and {@code timeout} parameters @@ -46,10 +49,12 @@ protected ServerChecker( String serverRef, long period, long timeout, + int successThreshold, TimeUnit timeUnit, Timer timer) { this.machineName = machineName; this.serverRef = serverRef; + this.successThreshold = successThreshold; this.timer = timer; this.period = TimeUnit.MILLISECONDS.convert(period, timeUnit); this.reportFuture = new CompletableFuture<>(); diff --git a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/hc/ServersChecker.java b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/hc/ServersChecker.java index 1b7ab435d8a6..f495a9b32a6c 100644 --- a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/hc/ServersChecker.java +++ b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/hc/ServersChecker.java @@ -195,10 +195,10 @@ ServerChecker doCreateChecker(URL url, String serverRef) { // workaround needed because terminal server doesn't have endpoint to check it readiness if ("terminal".equals(serverRef)) { return new TerminalHttpConnectionServerChecker( - url, machineName, serverRef, 3, 180, TimeUnit.SECONDS, timer); + url, machineName, serverRef, 3, 180, 1, TimeUnit.SECONDS, timer); } // TODO do not hardcode timeouts, use server conf instead return new HttpConnectionServerChecker( - url, machineName, serverRef, 3, 180, TimeUnit.SECONDS, timer); + url, machineName, serverRef, 3, 180, 1, TimeUnit.SECONDS, timer); } } diff --git a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/hc/TerminalHttpConnectionServerChecker.java b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/hc/TerminalHttpConnectionServerChecker.java index 05abbdd02db4..6b19c0475884 100644 --- a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/hc/TerminalHttpConnectionServerChecker.java +++ b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/hc/TerminalHttpConnectionServerChecker.java @@ -30,9 +30,10 @@ class TerminalHttpConnectionServerChecker extends HttpConnectionServerChecker { String serverRef, long period, long timeout, + int successThreshold, TimeUnit timeUnit, Timer timer) { - super(url, machineName, serverRef, period, timeout, timeUnit, timer); + super(url, machineName, serverRef, period, timeout, successThreshold, timeUnit, timer); } @Override diff --git a/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/hc/HttpConnectionServerCheckerTest.java b/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/hc/HttpConnectionServerCheckerTest.java index f37ff19e710d..1735337c7140 100644 --- a/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/hc/HttpConnectionServerCheckerTest.java +++ b/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/hc/HttpConnectionServerCheckerTest.java @@ -50,7 +50,7 @@ public void setUp() throws Exception { checker = spy( new HttpConnectionServerChecker( - SERVER_URL, MACHINE_NAME, SERVER_REF, 1, 10, TimeUnit.SECONDS, timer)); + SERVER_URL, MACHINE_NAME, SERVER_REF, 1, 10, 1, TimeUnit.SECONDS, timer)); doReturn(conn).when(checker).createConnection(nullable(URL.class)); when(conn.getResponseCode()).thenReturn(200); diff --git a/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/hc/TerminalHttpConnectionServerCheckerTest.java b/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/hc/TerminalHttpConnectionServerCheckerTest.java index a60ac59e962a..0f3a27e5622b 100644 --- a/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/hc/TerminalHttpConnectionServerCheckerTest.java +++ b/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/hc/TerminalHttpConnectionServerCheckerTest.java @@ -39,7 +39,7 @@ public class TerminalHttpConnectionServerCheckerTest { public void setUp() throws Exception { checker = new TerminalHttpConnectionServerChecker( - new URL("http://localhost"), MACHINE_NAME, SERVER_REF, 1, 10, TimeUnit.SECONDS, timer); + new URL("http://localhost"), MACHINE_NAME, SERVER_REF, 1, 10, 1, TimeUnit.SECONDS, timer); } @Test