Class AbstractCentralDogmaBuilder<B extends AbstractCentralDogmaBuilder<B>>

java.lang.Object
com.linecorp.centraldogma.client.AbstractCentralDogmaBuilder<B>
Direct Known Subclasses:
AbstractArmeriaCentralDogmaBuilder, XdsCentralDogmaBuilder

public abstract class AbstractCentralDogmaBuilder<B extends AbstractCentralDogmaBuilder<B>> extends Object
Builds a CentralDogma client.
  • Constructor Details

    • AbstractCentralDogmaBuilder

      public AbstractCentralDogmaBuilder()
  • Method Details

    • self

      protected final B self()
      Returns this.
    • uri

      @Deprecated public final B uri(String uri)
      Deprecated.
      Adds the URI of the Central Dogma server.
      Parameters:
      uri - the URI of the Central Dogma server. e.g. tbinary+http://example.com:36462/cd/thrift/v1
    • host

      public final B host(String host)
      Adds the host name or IP address of the Central Dogma Server and uses the default port number of 36462.
      Parameters:
      host - the host name or IP address of the Central Dogma server
    • host

      public final B host(String host, int port)
      Adds the host name (or IP address) and the port number of the Central Dogma server.
      Parameters:
      host - the host name or IP address of the Central Dogma server
      port - the port number of the Central Dogma server
    • useTls

      public final B useTls()
      Sets the client to use TLS.
    • useTls

      public final B useTls(boolean useTls)
      Sets whether the client uses TLS or not.
    • isUseTls

      protected final boolean isUseTls()
      Returns whether the client uses TLS or not.
      See Also:
    • profileResources

      public final B profileResources(String... paths)
      Sets the paths to look for to read the .json file that contains the client profiles. The paths are tried in the order of iteration. The default value of this property is [ "centraldogma-profiles-test.json", "centraldogma-profiles.json" ], which means the builder will check if "centraldogma-profiles-test.json" exists first and will try "centraldogma-profiles.json" only if "centraldogma-profiles-test.json" is missing.
    • profileResources

      public final B profileResources(Iterable<String> paths)
      Sets the paths to look for to read the .json file that contains the client profiles. The paths are tried in the order of iteration. The default value of this property is [ "centraldogma-profiles-test.json", "centraldogma-profiles.json" ], which means the builder will check if "centraldogma-profiles-test.json" exists first and will try "centraldogma-profiles.json" only if "centraldogma-profiles-test.json" is missing.
    • profile

      public final B profile(String... profiles)
      Adds the host names (or IP addresses) and the port numbers of the Central Dogma servers loaded from the client profile resources. When more than one profile is matched, the last matching one will be used. See Using client profiles for more information.
      Parameters:
      profiles - the list of profile names
      Throws:
      IllegalArgumentException - if failed to load any hosts from all the specified profiles
    • profile

      public final B profile(ClassLoader classLoader, String... profiles)
      Adds the host names (or IP addresses) and the port numbers of the Central Dogma servers loaded from the client profile resources. When more than one profile is matched, the last matching one will be used. See Using client profiles for more information.
      Parameters:
      profiles - the list of profile names
      Throws:
      IllegalArgumentException - if failed to load any hosts from all the specified profiles
    • profile

      public final B profile(Iterable<String> profiles)
      Adds the host names (or IP address) and the port numbers of the Central Dogma servers loaded from the client profile resources. When more than one profile is matched, the last matching one will be used. See Using client profiles for more information.
      Parameters:
      profiles - the list of profile names
      Throws:
      IllegalArgumentException - if failed to load any hosts from all the specified profiles
    • profile

      public final B profile(ClassLoader classLoader, Iterable<String> profiles)
      Adds the host names (or IP address) and the port numbers of the Central Dogma servers loaded from the client profile resources. When more than one profile is matched, the last matching one will be used. See Using client profiles for more information.
      Parameters:
      profiles - the list of profile names
      Throws:
      IllegalArgumentException - if failed to load any hosts from all the specified profiles
    • selectedProfile

      @Nullable protected final String selectedProfile()
      Returns the name of the selected profile.
      Returns:
      the profile name, or null if no profile was specified or matched
    • hosts

      protected final Set<InetSocketAddress> hosts()
      Returns the hosts added via host(String, int) or profile(String...).
    • accessToken

      public final B accessToken(String accessToken)
      Sets the access token to use when authenticating a client.
    • accessToken

      protected String accessToken()
      Returns the access token to use when authenticating a client.
    • maxNumRetriesOnReplicationLag

      public final B maxNumRetriesOnReplicationLag(int maxRetriesOnReplicationLag)
      Sets the maximum number of retries to perform when replication lag is detected. For example, without replication lag detection and retries, the getFile() in the following example might fail with a RevisionNotFoundException when replication is enabled on the server side:
      
       CentralDogma dogma = ...;
       // getFile() may fail if:
       // 1) the replica A serves getFile() while the replica B serves the normalizeRevision() and
       // 2) the replica A did not catch up all the commits made in the replica B.
       Revision headRevision = dogma.normalizeRevision("proj", "repo", Revision.HEAD).join();
       Entry<String> entry = dogma.getFile("proj", "repo", headRevision, Query.ofText("/a.txt")).join();
       

      Setting a value greater than 0 to this property will make the client detect such situations and retry automatically. By default, the client will retry up to 5 times.

    • maxNumRetriesOnReplicationLag

      protected int maxNumRetriesOnReplicationLag()
      Returns the maximum number of retries to perform when replication lag is detected.
    • retryIntervalOnReplicationLag

      public final B retryIntervalOnReplicationLag(Duration retryIntervalOnReplicationLag)
      Sets the interval between retries which occurred due to replication lag. By default, the interval between retries is 2 seconds.
    • retryIntervalOnReplicationLagMillis

      public final B retryIntervalOnReplicationLagMillis(long retryIntervalOnReplicationLagMillis)
      Sets the interval between retries which occurred due to replication lag in milliseconds. By default, the interval between retries is 2 seconds.
    • retryIntervalOnReplicationLagMillis

      protected long retryIntervalOnReplicationLagMillis()
      Returns the interval between retries which occurred due to replication lag in milliseconds.