Browse Source

serverAliveInterval and serverAliveCountMax in <sshexec> and <scp>

Patch by Issa Gorissen

https://bz.apache.org/bugzilla/show_bug.cgi?id=59162
master
Stefan Bodewig 9 years ago
parent
commit
851aa5fb56
4 changed files with 54 additions and 0 deletions
  1. +1
    -0
      CONTRIBUTORS
  2. +5
    -0
      WHATSNEW
  3. +4
    -0
      contributors.xml
  4. +44
    -0
      src/main/org/apache/tools/ant/taskdefs/optional/ssh/SSHBase.java

+ 1
- 0
CONTRIBUTORS View File

@@ -154,6 +154,7 @@ Ingenonsya France
Ingmar Stein Ingmar Stein
Irene Rusman Irene Rusman
Isaac Shabtay Isaac Shabtay
Issa Gorissen
Ivan Ivanov Ivan Ivanov
J Bleijenbergh J Bleijenbergh
Jack J. Woehr Jack J. Woehr


+ 5
- 0
WHATSNEW View File

@@ -80,6 +80,11 @@ Other changes:
* <javac> now supports Java9 modules. * <javac> now supports Java9 modules.
https://github.com/apache/ant/pull/16 https://github.com/apache/ant/pull/16


* <sshexec> and <scp> have two new attributes serverAliveInterval and
serverAliveCountMax that can be used to keep a intermediaries from
closing idle connections.
Bugzilla Report 59162

Changes from Ant 1.9.5 TO Ant 1.9.6 Changes from Ant 1.9.5 TO Ant 1.9.6
=================================== ===================================




+ 4
- 0
contributors.xml View File

@@ -640,6 +640,10 @@
<first>Isaac</first> <first>Isaac</first>
<last>Shabtay</last> <last>Shabtay</last>
</name> </name>
<name>
<first>Issa</first>
<last>Gorissen</last>
</name>
<name> <name>
<first>Ivan</first> <first>Ivan</first>
<last>Ivanov</last> <last>Ivanov</last>


+ 44
- 0
src/main/org/apache/tools/ant/taskdefs/optional/ssh/SSHBase.java View File

@@ -42,6 +42,8 @@ public abstract class SSHBase extends Task implements LogListener {
private boolean failOnError = true; private boolean failOnError = true;
private boolean verbose; private boolean verbose;
private final SSHUserInfo userInfo; private final SSHUserInfo userInfo;
private int serverAliveCountMax = 3;
private int serverAliveIntervalSeconds = 0;


/** /**
* Constructor for SSHBase. * Constructor for SSHBase.
@@ -104,6 +106,42 @@ public abstract class SSHBase extends Task implements LogListener {
return verbose; return verbose;
} }


/**
* Set the serverAliveCountMax value.
* @since Ant 1.9.7
*/
public void setServerAliveCountMax(final int countMax) {
if (countMax <= 0) throw new IllegalArgumentException("ssh server alive count max setting cannot be negative or zero");
this.serverAliveCountMax = countMax;
}

/**
* Get the serverAliveCountMax value.
* @return the serverAliveCountMax value
* @since Ant 1.9.7
*/
public int getServerAliveCountMax() {
return serverAliveCountMax;
}

/**
* Set the serverAliveIntervalSeconds value in seconds.
* @since Ant 1.9.7
*/
public void setServerAliveIntervalSeconds(final int interval) {
if (interval < 0) throw new IllegalArgumentException("ssh server alive interval setting cannot be negative");
this.serverAliveIntervalSeconds = interval;
}

/**
* Get the serverAliveIntervalSeconds value in seconds.
* @return the serverAliveIntervalSeconds value in seconds
* @since Ant 1.9.7
*/
public int getServerAliveIntervalSeconds() {
return serverAliveIntervalSeconds;
}

/** /**
* Username known to remote host. * Username known to remote host.
* *
@@ -221,6 +259,12 @@ public abstract class SSHBase extends Task implements LogListener {
session.setConfig("PreferredAuthentications", session.setConfig("PreferredAuthentications",
"publickey,keyboard-interactive,password"); "publickey,keyboard-interactive,password");
session.setUserInfo(userInfo); session.setUserInfo(userInfo);

if (serverAliveIntervalSeconds > 0) {
session.setServerAliveCountMax(serverAliveCountMax);
session.setServerAliveInterval(serverAliveIntervalSeconds * 1000);
}

log("Connecting to " + host + ":" + port); log("Connecting to " + host + ":" + port);
session.connect(); session.connect();
return session; return session;


Loading…
Cancel
Save