Class ServiceLocation

java.lang.Object
org.apache.druid.rpc.ServiceLocation

public class ServiceLocation extends Object
Represents a service location at a particular point in time.
  • Constructor Details

    • ServiceLocation

      public ServiceLocation(String host, int plaintextPort, int tlsPort, String basePath)
      Create a service location.
      Parameters:
      host - hostname or address
      plaintextPort - plaintext port
      tlsPort - TLS port
      basePath - base path; must be encoded and must not include trailing "/". In particular, to use root as the base path, pass "" for this parameter.
  • Method Details

    • fromDruidNode

      public static ServiceLocation fromDruidNode(DruidNode druidNode)
      Create a service location based on a DruidNode, without a base path.
    • fromUri

      public static ServiceLocation fromUri(URI uri)
      Create a service location based on a URI.
      Throws:
      IllegalArgumentException - if the URI cannot be mapped to a service location.
    • fromDruidServerMetadata

      public static ServiceLocation fromDruidServerMetadata(DruidServerMetadata druidServerMetadata)
      Create a service location based on a DruidServerMetadata.
      Throws:
      IllegalArgumentException - if the server metadata cannot be mapped to a service location.
    • getHost

      public String getHost()
    • getHostAndPort

      public String getHostAndPort()
      Returns a host:port string for the preferred port (TLS if available; plaintext otherwise).
    • getPlaintextPort

      public int getPlaintextPort()
    • getTlsPort

      public int getTlsPort()
    • getBasePath

      public String getBasePath()
    • withBasePath

      public ServiceLocation withBasePath(String newBasePath)
    • toURL

      public URL toURL(@Nullable String encodedPathAndQueryString)
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object