Class ServiceURI

java.lang.Object
org.apache.bookkeeper.common.net.ServiceURI

@Public @Evolving public class ServiceURI extends Object
ServiceURI represents service uri within bookkeeper cluster.

Service URI syntax and components

At the highest level a service uri is a URI in string form has the syntax.

[service[service-specific-part]:[//authority][path]

where the characters : and / stand for themselves.

The service-specific-part of a service URI consists of the backend information used for services to use. It has the syntax as below:

[(-|+)][backend-part]

where the characters - and + stand as a separator to separate service type from service backend information.

The authority component of a service URI has the same meaning as the authority component in a URI. If specified, it should be server-based. A server-based authority parses according to the familiar syntax

[user-info@]host[:port]

where the characters @ and : stand for themselves.

The path component of a service URI is itself said to be absolute. It typically means which path a service stores metadata or data.

All told, then, a service URI instance has the following components:

serviceString
service-specific-part    String
authorityString
user-infoString
hostString
portint
pathString

Some examples of service URIs are:

zk://localhost:2181/cluster1/ledgers => ledger service uri using default ledger manager
zk+hierarchical://localhost:2181/ledgers => ledger service uri using hierarchical ledger manager
etcd://localhost/ledgers => ledger service uri using etcd as metadata store
distributedlog://localhost:2181/distributedlog => distributedlog namespace
distributedlog-bk://localhost:2181/distributedlog => distributedlog namespace with bk backend
bk://bookkeeper-cluster/ => stream storage service uri
host1:port,host2:port => a list of hosts as bootstrap hosts to a stream storage cluster}
Since:
4.8.0
  • Field Details

    • SERVICE_ZK

      public static final String SERVICE_ZK
      Service string for ledger service that uses zookeeper as metadata store.
      See Also:
    • SERVICE_DLOG

      public static final String SERVICE_DLOG
      Service string for dlog service.
      See Also:
    • SERVICE_BK

      public static final String SERVICE_BK
      Service string for bookkeeper service.
      See Also:
    • SERVICE_BK_PORT

      public static final int SERVICE_BK_PORT
      See Also:
    • DEFAULT_LOCAL_STREAM_STORAGE_SERVICE_URI

      public static final ServiceURI DEFAULT_LOCAL_STREAM_STORAGE_SERVICE_URI
      The default local bk service uri.
  • Method Details

    • create

      public static ServiceURI create(String uriStr)
      Create a service uri instance from a uri string.
      Parameters:
      uriStr - service uri string
      Returns:
      a service uri instance
      Throws:
      NullPointerException - if uriStr is null
      IllegalArgumentException - if the given string violates RFC 2396
    • create

      public static ServiceURI create(URI uri)
      Create a service uri instance from a URI instance.
      Parameters:
      uri - URI instance
      Returns:
      a service uri instance
      Throws:
      NullPointerException - if uriStr is null
      IllegalArgumentException - if the given string violates RFC 2396
    • getServiceInfos

      public String[] getServiceInfos()
    • getServiceHosts

      public String[] getServiceHosts()
    • getServiceName

      public String getServiceName()
    • getServiceUser

      public String getServiceUser()
    • getServicePath

      public String getServicePath()
    • getUri

      public URI getUri()
    • equals

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

      protected boolean canEqual(Object other)
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object