Class ConnectionInfo


public class ConnectionInfo extends AbstractLockable<ConnectionInfo>
Informatation such as the address, port, SSH fingerprint and login information that is needed to connect via SSH to the cluster. The information becomes readonly when a OpenGridCluster instance has been created.
Since:
1.0
Author:
nicklas
  • Field Details

    • name

      private String name
    • address

      private String address
    • port

      private int port
    • fingerprint

      private String fingerprint
    • fingerPrintType

      private String fingerPrintType
    • user

      private String user
    • password

      private String password
    • privateKey

      private String privateKey
    • privateKeyFormat

      private String privateKeyFormat
    • privateKeyPassword

      private String privateKeyPassword
  • Constructor Details

    • ConnectionInfo

      public ConnectionInfo()
      Create a new connection information instance. The port is set to 22 by default. All other properties need to be set before an OpenGridCluster instance can be created. After that this instance become locked and it is no longer possible to modify the parameters.
    • ConnectionInfo

      public ConnectionInfo(ConnectionInfo clone)
      Create a new connection information instance and clone the connection information from the given instance. The new instance will be unlocked.
      Parameters:
      clone - The instance to clone from
    • ConnectionInfo

      public ConnectionInfo(FileServer server)
      Create a new connection information and use the information in the file server for configuration. The file server should have all required settings or they need to be provided before a connection can be made.
      Parameters:
      server - A FileServer instance to take parameters from
  • Method Details

    • getName

      public String getName()
      Get the display name of the cluster.
    • setName

      public void setName(String name)
      Set the display name of the cluster.
      Throws:
      IllegalStateException - If this instance has been locked
    • getAddress

      public String getAddress()
      Get the internet address of the primary node.
    • setAddress

      public void setAddress(String address)
      Set the internet address to the primary node.
      Throws:
      IllegalStateException - If this instance has been locked
    • getPort

      public int getPort()
      Get the port number to use for connecting to the primary node.
    • setPort

      public void setPort(int port)
      Set the port number to use for connecting to the primary node.
      Throws:
      IllegalStateException - If this instance has been locked
    • getFingerPrint

      public String getFingerPrint()
      Get the public key SSH fingerprint of the primary node. This is used to verify that we are connecting to the expected host and not to a man-in-the-middle. The fingerprint is a string containing 16 pairs of hexadecimal numbers separated with colon.
    • setFingerPrint

      public void setFingerPrint(String fingerprint)
      Set the public key fingerprint for the host so we can verify that the connection is made to the exepected SSH server. The fingerprint is a string containing 16 pairs of hexadecimal numbers separated with colon.
      Throws:
      IllegalStateException - If this instance has been locked
      IllegalArgumentException - If the fingerprint is not 16 pairs of hexadecimal numbers separated with colon
    • getFingerPrintType

      public String getFingerPrintType()
      Get the fingerprint type. Automatically updated by the setFingerPrint(String) method.
    • getUser

      public String getUser()
      Get the username to use when connecting to the primary node.
    • setUser

      public void setUser(String user)
      Set the username to use for connecting to the primary node.
      Throws:
      IllegalStateException - If this instance has been locked
    • getPassword

      public String getPassword()
      Get the password to use when connecting to the primary node.
    • setPassword

      public void setPassword(String password)
      Set the password to use for connecting to the primary node.
      Throws:
      IllegalStateException - If this instance has been locked
    • getPrivateKey

      public String getPrivateKey()
      Get the private key to use when connecting to the primary node.
      Since:
      1.2
    • setPrivateKey

      public void setPrivateKey(String privateKey)
      Set the private key to use for connecting to the primary node.
      Throws:
      IllegalStateException - If this instance has been locked
      Since:
      1.2
    • getPrivateKeyFormat

      public String getPrivateKeyFormat()
      Get the format of the private key (null = auto-detect)
      Since:
      1.2
    • setPrivateKeyFormat

      public void setPrivateKeyFormat(String privateKeyFormat)
      Set the format of the private key (null = auto-detect). Supported values are: - OpenSSH - OpenSSHv1 - PuTTY - PKCS5 - PKCS8
      Throws:
      IllegalStateException - If this instance has been locked
      Since:
      1.2
    • getPrivateKeyPassword

      public String getPrivateKeyPassword()
      Get the password for unlocking the private key.
      Since:
      1.2
    • setPrivateKeyPassword

      public void setPrivateKeyPassword(String privateKeyPassword)
      Set the password to use for unlocking the private key.
      Throws:
      IllegalStateException - If this instance has been locked
      Since:
      1.2
    • checkValid

      protected void checkValid(boolean forLock)
      Address, fingerprint and user are required. The fingerprint must be a valid string (see SshUtil.FINGERPRINT_PATTERN). The port number must be a positive integer.
      Overrides:
      checkValid in class AbstractLockable<ConnectionInfo>
      Parameters:
      forLock - If TRUE, the instance will be locked after validation
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • asJSONObject

      public org.json.simple.JSONObject asJSONObject(JSONOptions options)
      Get the configuration information as a JSON object. By default the following properties are exposed: - name - address - port - fingerprint - fingerprintType - user If the JSONOption.CONNECTION_PASSWORD option is enabled the password is also included. If the JSONOption.PRIVATE_KEY option is enabled the private key (and password) is also included.