Package com.linecorp.centraldogma.client
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 Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected String
Returns the access token to use when authenticating a client.final B
accessToken
(String accessToken) Sets the access token to use when authenticating a client.final B
Adds the host name or IP address of the Central Dogma Server and uses the default port number of 36462.final B
Adds the host name (or IP address) and the port number of the Central Dogma server.protected final Set
<InetSocketAddress> hosts()
Returns the hosts added viahost(String, int)
orprofile(String...)
.protected final boolean
isUseTls()
Returns whether the client uses TLS or not.protected int
Returns the maximum number of retries to perform when replication lag is detected.final B
maxNumRetriesOnReplicationLag
(int maxRetriesOnReplicationLag) Sets the maximum number of retries to perform when replication lag is detected.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.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.final B
Adds the host names (or IP address) and the port numbers of the Central Dogma servers loaded from the client profile resources.final B
Adds the host names (or IP addresses) and the port numbers of the Central Dogma servers loaded from the client profile resources.final B
profileResources
(Iterable<String> paths) Sets the paths to look for to read the.json
file that contains the client profiles.final B
profileResources
(String... paths) Sets the paths to look for to read the.json
file that contains the client profiles.final B
retryIntervalOnReplicationLag
(Duration retryIntervalOnReplicationLag) Sets the interval between retries which occurred due to replication lag.protected long
Returns the interval between retries which occurred due to replication lag in milliseconds.final B
retryIntervalOnReplicationLagMillis
(long retryIntervalOnReplicationLagMillis) Sets the interval between retries which occurred due to replication lag in milliseconds.protected final String
Returns the name of the selected profile.protected final B
self()
Returnsthis
.final B
Deprecated.final B
useTls()
Sets the client to use TLS.final B
useTls
(boolean useTls) Sets whether the client uses TLS or not.
-
Constructor Details
-
AbstractCentralDogmaBuilder
public AbstractCentralDogmaBuilder()
-
-
Method Details
-
self
Returnsthis
. -
uri
Deprecated.Usehost(String)
orprofile(String...)
.Adds theURI
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
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
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 serverport
- the port number of the Central Dogma server
-
useTls
Sets the client to use TLS. -
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
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
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
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
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
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
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
Returns the name of the selected profile.- Returns:
- the profile name, or
null
if no profile was specified or matched
-
hosts
Returns the hosts added viahost(String, int)
orprofile(String...)
. -
accessToken
Sets the access token to use when authenticating a client. -
accessToken
Returns the access token to use when authenticating a client. -
maxNumRetriesOnReplicationLag
Sets the maximum number of retries to perform when replication lag is detected. For example, without replication lag detection and retries, thegetFile()
in the following example might fail with aRevisionNotFoundException
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
Sets the interval between retries which occurred due to replication lag. By default, the interval between retries is 2 seconds. -
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.
-
host(String)
orprofile(String...)
.