diff --git a/agent/conf/agent.properties b/agent/conf/agent.properties index 188007bfef2..ac98de0df8f 100644 --- a/agent/conf/agent.properties +++ b/agent/conf/agent.properties @@ -418,3 +418,9 @@ iscsi.session.cleanup.enabled=false # Implicit host tags managed by agent.properties # host.tags= + +# Timeout(in seconds) for SSL handshake when agent connects to server +#ssl.handshake.timeout= + +# Wait(in seconds) during agent reconnections +#backoff.seconds= \ No newline at end of file diff --git a/agent/src/main/java/com/cloud/agent/AgentShell.java b/agent/src/main/java/com/cloud/agent/AgentShell.java index ff265e01921..22e897384e9 100644 --- a/agent/src/main/java/com/cloud/agent/AgentShell.java +++ b/agent/src/main/java/com/cloud/agent/AgentShell.java @@ -51,7 +51,7 @@ import com.cloud.utils.LogUtils; import com.cloud.utils.ProcessUtil; import com.cloud.utils.PropertiesUtil; import com.cloud.utils.backoff.BackoffAlgorithm; -import com.cloud.utils.backoff.impl.RangeTimeBackoff; +import com.cloud.utils.backoff.impl.ConstantTimeBackoff; import com.cloud.utils.exception.CloudRuntimeException; public class AgentShell implements IAgentShell, Daemon { @@ -405,12 +405,11 @@ public class AgentShell implements IAgentShell, Daemon { _properties.put(cmdLineProp.getKey(), cmdLineProp.getValue()); } - s_logger.info("Defaulting to the range time backoff algorithm"); - _backoff = new RangeTimeBackoff(); + s_logger.info("Defaulting to the constant time backoff algorithm"); + _backoff = new ConstantTimeBackoff(); Map map = new HashMap<>(); - map.put("minSeconds", _properties.getProperty("backoff.min.seconds")); - map.put("maxSeconds", _properties.getProperty("backoff.max.seconds")); - _backoff.configure("RangeTimeBackoff", map); + map.put("seconds", _properties.getProperty("backoff.seconds")); + _backoff.configure("ConstantTimeBackoff", map); } private void launchAgent() throws ConfigurationException { diff --git a/utils/src/test/java/com/cloud/utils/backoff/impl/RangeTimeBackoffTest.java b/utils/src/test/java/com/cloud/utils/backoff/impl/RangeTimeBackoffTest.java deleted file mode 100644 index 668417c5f3f..00000000000 --- a/utils/src/test/java/com/cloud/utils/backoff/impl/RangeTimeBackoffTest.java +++ /dev/null @@ -1,87 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -package com.cloud.utils.backoff.impl; - -import java.util.HashMap; -import java.util.Map; - -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.junit.MockitoJUnitRunner; - -@RunWith(MockitoJUnitRunner.class) -public class RangeTimeBackoffTest { - - @Test - public void testWaitValidValue() { - RangeTimeBackoff backoff = new RangeTimeBackoff(); - Map map = new HashMap<>(); - int min = 1; - int max = 3; - map.put("minSeconds", String.valueOf(min)); - map.put("maxSeconds", String.valueOf(max)); - backoff.configure("RangeTimeBackoff", map); - long startTime = System.currentTimeMillis(); - backoff.waitBeforeRetry(); - long timeTaken = System.currentTimeMillis() - startTime; - Assert.assertTrue(timeTaken >= min * 1000L); - Assert.assertTrue(timeTaken <= max * 1000L); - } - - private void checkTimeTakenBetweenDelta(long timeTaken, int value) { - long min = (value * 1000L) - 10L; - long max = (value* 1000L) + 10L; - Assert.assertTrue(min <= timeTaken && timeTaken <= max); - } - - @Test - public void testWaitEmptyValue() { - RangeTimeBackoff backoff = new RangeTimeBackoff(); - Map map = new HashMap<>(); - map.put("minSeconds", ""); - map.put("maxSeconds", ""); - backoff.configure("RangeTimeBackoff", map); - long startTime = System.currentTimeMillis(); - backoff.waitBeforeRetry(); - checkTimeTakenBetweenDelta(System.currentTimeMillis() - startTime, RangeTimeBackoff.DEFAULT_MIN_TIME); - } - - @Test - public void testWaitNullValue() { - RangeTimeBackoff backoff = new RangeTimeBackoff(); - Map map = new HashMap<>(); - backoff.configure("RangeTimeBackoff", map); - long startTime = System.currentTimeMillis(); - backoff.waitBeforeRetry(); - checkTimeTakenBetweenDelta(System.currentTimeMillis() - startTime, RangeTimeBackoff.DEFAULT_MIN_TIME); - } - - @Test - public void testWaitVMinHigherThanMax() { - RangeTimeBackoff backoff = new RangeTimeBackoff(); - Map map = new HashMap<>(); - int min = 3; - int max = 2; - map.put("minSeconds", String.valueOf(min)); - map.put("maxSeconds", String.valueOf(max)); - backoff.configure("RangeTimeBackoff", map); - long startTime = System.currentTimeMillis(); - backoff.waitBeforeRetry(); - checkTimeTakenBetweenDelta(System.currentTimeMillis() - startTime, min); - } -}