use of org.apache.sshd.common.RuntimeSshException in project tesb-studio-se by Talend.
the class RuntimeClient method connectWithRetries.
private static ClientSession connectWithRetries(SshClient client, ClientConfig config) throws Exception, InterruptedException {
ClientSession session = null;
int retries = 0;
do {
try {
ConnectFuture future = client.connect(config.getUser(), config.getHost(), config.getPort());
future.await();
session = future.getSession();
} catch (RuntimeSshException ex) {
if (++retries < 10) {
TimeUnit.SECONDS.sleep(2);
} else {
throw ex;
}
}
} while (session == null);
return session;
}
use of org.apache.sshd.common.RuntimeSshException in project karaf by apache.
the class ClientMojo method connect.
private ClientSession connect(SshClient client) throws IOException, InterruptedException {
int retries = 0;
ClientSession session = null;
do {
final ConnectFuture future = client.connect(user, host, port);
future.await();
try {
session = future.getSession();
} catch (RuntimeSshException ex) {
if (retries++ < attempts) {
Thread.sleep(TimeUnit.SECONDS.toMillis(delay));
getLog().info("retrying (attempt " + retries + ") ...");
} else {
throw ex;
}
}
} while (session == null);
return session;
}
Aggregations