Class PortUtils.ConnectionCheck
- java.lang.Object
-
- com.nirima.jenkins.plugins.docker.utils.PortUtils.ConnectionCheck
-
-
Field Summary
Fields Modifier and Type Field Description protected static int
DEFAULT_RETRIES
protected static int
DEFAULT_RETRY_DELAY_SECONDS
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
execute()
Tests the connection.boolean
executeOnce()
PortUtils.ConnectionCheckSSH
useSSH()
PortUtils.ConnectionCheck
withEveryRetryWaitFor(int time, TimeUnit units)
Sets the delay between tries.PortUtils.ConnectionCheck
withRetries(int numberOfRetries)
Sets the number of retries, such thatexecute()
will try once more than this.
-
-
-
Field Detail
-
DEFAULT_RETRIES
protected static final int DEFAULT_RETRIES
- See Also:
- Constant Field Values
-
DEFAULT_RETRY_DELAY_SECONDS
protected static final int DEFAULT_RETRY_DELAY_SECONDS
- See Also:
- Constant Field Values
-
-
Method Detail
-
withRetries
public PortUtils.ConnectionCheck withRetries(int numberOfRetries)
Sets the number of retries, such thatexecute()
will try once more than this. If this is not set then a default of 10 will be used.- Parameters:
numberOfRetries
- Number of retries. Negative values will be treated as zero.- Returns:
- this
-
withEveryRetryWaitFor
public PortUtils.ConnectionCheck withEveryRetryWaitFor(int time, TimeUnit units)
Sets the delay between tries. If this is not set then a default of 2 seconds will be used.- Parameters:
time
- The lengthy of time.units
- The units of that length.- Returns:
- this
-
useSSH
public PortUtils.ConnectionCheckSSH useSSH()
-
executeOnce
public boolean executeOnce()
- Returns:
- true if socket opened successfully, false otherwise
-
execute
public boolean execute() throws InterruptedException
Tests the connection. IfwithRetries(int)
was set to more than zero then more than one attempt will be made, waiting (for the period specified bywithEveryRetryWaitFor(int, TimeUnit)
) between attempts.- Returns:
- true if the connection succeeded, false if it failed despite any retries.
- Throws:
InterruptedException
- if interrupted while waiting between retries.
-
-