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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected StringReturns the access token to use when authenticating a client.final BaccessToken(String accessToken) Sets the access token to use when authenticating a client.final BAdds the host name or IP address of the Central Dogma Server and uses the default port number of 36462.final BAdds 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 booleanisUseTls()Returns whether the client uses TLS or not.protected intReturns the maximum number of retries to perform when replication lag is detected.final BmaxNumRetriesOnReplicationLag(int maxRetriesOnReplicationLag) Sets the maximum number of retries to perform when replication lag is detected.protected final MeterRegistryReturns theMeterRegistry.meterRegistry(MeterRegistry meterRegistry) If you want to record metrics using Micrometer, please specify aMeterRegistry.final Bprofile(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 Bprofile(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 BAdds the host names (or IP address) and the port numbers of the Central Dogma servers loaded from the client profile resources.final BAdds the host names (or IP addresses) and the port numbers of the Central Dogma servers loaded from the client profile resources.final BprofileResources(Iterable<String> paths) Sets the paths to look for to read the.jsonfile that contains the client profiles.final BprofileResources(String... paths) Sets the paths to look for to read the.jsonfile that contains the client profiles.final BretryIntervalOnReplicationLag(Duration retryIntervalOnReplicationLag) Sets the interval between retries which occurred due to replication lag.protected longReturns the interval between retries which occurred due to replication lag in milliseconds.final BretryIntervalOnReplicationLagMillis(long retryIntervalOnReplicationLagMillis) Sets the interval between retries which occurred due to replication lag in milliseconds.protected final StringReturns the name of the selected profile.protected final Bself()Returnsthis.final BDeprecated.final BuseTls()Sets the client to use TLS.final BuseTls(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 theURIof 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.jsonfile 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.jsonfile 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
nullif 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 aRevisionNotFoundExceptionwhen 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
0to 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. -
meterRegistry
If you want to record metrics using Micrometer, please specify aMeterRegistry. -
meterRegistry
Returns theMeterRegistry.
-
host(String)orprofile(String...).