Skip to content

Commit

Permalink
Merge pull request #4 from vergoh/master
Browse files Browse the repository at this point in the history
Client side options for changing retry behaviour
  • Loading branch information
mindjiver committed Jul 31, 2014
2 parents 9674e9c + 049982b commit d5e1faa
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions client/src/main/java/hudson/plugins/swarm/Client.java
Expand Up @@ -76,6 +76,12 @@ public class Client {
@Option(name = "-disableSslVerification", usage = "Disables SSL verification in the HttpClient.")
public boolean disableSslVerification;

@Option(name = "-noRetryAfterConnected", usage = "Do not retry if a successful connection gets closed.")
public boolean noRetryAfterConnected;

@Option(name = "-retry", usage = "Number of retries before giving up. Unlimited if not specified.")
public int retry = -1;

@Option(
name = "-mode",
usage = "The mode controlling how Jenkins allocates jobs to slaves. Can be either '" + ModeOptionHandler.NORMAL + "' " +
Expand Down Expand Up @@ -154,6 +160,10 @@ public void run() throws InterruptedException {
// create a new swarm slave
createSwarmSlave();
connect();
if (noRetryAfterConnected) {
System.out.println("Connection closed, exiting...");
System.exit(0);
}
} catch (IOException e) {
e.printStackTrace();
} catch (ParserConfigurationException e) {
Expand All @@ -165,6 +175,16 @@ public void run() throws InterruptedException {
}
}

if (retry >= 0) {
if (retry == 0) {
System.out.println("Retry limit reached, exiting...");
System.exit(-1);
} else {
System.out.println("Remaining retries: " + retry);
retry--;
}
}

// retry
System.out.println("Retrying in 10 seconds");
Thread.sleep(10 * 1000);
Expand Down

0 comments on commit d5e1faa

Please sign in to comment.