Class PortUtils.ConnectionCheck

java.lang.Object
com.nirima.jenkins.plugins.docker.utils.PortUtils.ConnectionCheck
Enclosing class:
PortUtils

@Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) public static class PortUtils.ConnectionCheck extends Object
  • Field Details

    • DEFAULT_RETRIES

      protected static final int DEFAULT_RETRIES
      See Also:
    • DEFAULT_RETRY_DELAY_SECONDS

      protected static final int DEFAULT_RETRY_DELAY_SECONDS
      See Also:
  • Method Details

    • withRetries

      public PortUtils.ConnectionCheck withRetries(int numberOfRetries)
      Sets the number of retries, such that execute() 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

    • executeOnce

      public boolean executeOnce()
      Returns:
      true if socket opened successfully, false otherwise
    • execute

      public boolean execute() throws InterruptedException
      Tests the connection. If withRetries(int) was set to more than zero then more than one attempt will be made, waiting (for the period specified by withEveryRetryWaitFor(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.