From 1535afe158610aaf8642ece90a400c5be7462d9a Mon Sep 17 00:00:00 2001 From: Sudhansu Date: Tue, 21 Mar 2017 16:19:44 +0530 Subject: [PATCH] CLOUDSTACK-9843 : Performance improvement of deployVirtualMachine, createFirewallRule, createPortForwardingRule removed 1 sec sleep in SSHHelper. (cherry picked from commit 28bb8ba1e4568fc891831772e2051c474e81d528) Signed-off-by: Rohit Yadav --- .../main/java/com/cloud/utils/ssh/SshHelper.java | 13 +------------ .../java/com/cloud/utils/ssh/SshHelperTest.java | 2 +- 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/utils/src/main/java/com/cloud/utils/ssh/SshHelper.java b/utils/src/main/java/com/cloud/utils/ssh/SshHelper.java index a86a4850b13..88be5774225 100644 --- a/utils/src/main/java/com/cloud/utils/ssh/SshHelper.java +++ b/utils/src/main/java/com/cloud/utils/ssh/SshHelper.java @@ -39,12 +39,6 @@ public class SshHelper { private static final int DEFAULT_CONNECT_TIMEOUT = 180000; private static final int DEFAULT_KEX_TIMEOUT = 60000; - /** - * Waiting time to check if the SSH session was successfully opened. This value (of 1000 - * milliseconds) represents one (1) second. - */ - private static final long WAITING_OPEN_SSH_SESSION = 1000; - private static final Logger s_logger = Logger.getLogger(SshHelper.class); public static Pair sshExecute(String host, int port, String user, File pemKeyFile, String password, String command) throws Exception { @@ -236,14 +230,9 @@ public class SshHelper { } } - /** - * It gets a {@link Session} from the given {@link Connection}; then, it waits - * {@value #WAITING_OPEN_SSH_SESSION} milliseconds before returning the session, given a time to - * ensure that the connection is open before proceeding the execution. - */ + protected static Session openConnectionSession(Connection conn) throws IOException, InterruptedException { Session sess = conn.openSession(); - Thread.sleep(WAITING_OPEN_SSH_SESSION); return sess; } diff --git a/utils/src/test/java/com/cloud/utils/ssh/SshHelperTest.java b/utils/src/test/java/com/cloud/utils/ssh/SshHelperTest.java index 355a51416bc..18e7171c925 100644 --- a/utils/src/test/java/com/cloud/utils/ssh/SshHelperTest.java +++ b/utils/src/test/java/com/cloud/utils/ssh/SshHelperTest.java @@ -146,6 +146,6 @@ public class SshHelperTest { Mockito.verify(conn).openSession(); PowerMockito.verifyStatic(); - Thread.sleep(Mockito.anyLong()); + } }