Class DbServerTargetBuilder
DbServerTarget. A caller that knows which single endpoint served an operation collects that one
endpoint instead, and reports the result as network.peer.address and
network.peer.port.
Every endpoint is validated as a host name, an IPv4 literal, or an IPv6 literal without any name resolution. When one endpoint cannot be validated the whole target is dropped, because a partial list describes a deployment the client was never pointed at. Endpoints are validated before the list is truncated, so an unsafe endpoint beyond the cap still drops the target.
Duplicate endpoints are kept. A single endpoint is rendered as a bare host with its port reported separately, and it is reported only when it differs from the default port. Several endpoints are rendered as a comma separated list. Their ports are omitted when every endpoint listens on its default port. Otherwise known ports are included, while endpoints without either a configured or known default port remain bare.
Instances are not thread safe.
This class is internal and is hence not for public use. Its APIs are unstable and can change at any time.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionaddEndpoint(String host, int port) Add an endpoint.addEndpoint(String host, int port, int defaultPort) Add an endpoint whose default port differs from the target's default port, such as an endpoint whose default port follows from its scheme.addEndpoint(InetSocketAddress address) Add an endpoint from a socket address.build()Returns the target, ornullwhen it cannot be rendered safely.static booleanisValidHost(String host) Returns whetherhostcan be represented safely as a database server host.setPortAlwaysInline(boolean portAlwaysInline) Always render ports inside the address instead of reporting a single endpoint's port separately.setSorted(boolean sorted) Sort the rendered endpoints in natural string order.Appendsuffixto the address as a path segment, identifying the logical subset of the endpoints that the client selects.
-
Field Details
-
MAX_ENDPOINTS
public static final int MAX_ENDPOINTS- See Also:
-
-
Method Details
-
isValidHost
-
setSorted
Sort the rendered endpoints in natural string order. Default is to preserve the configured order. Turn sorting on only when endpoint order carries no semantic meaning. -
setPortAlwaysInline
Always render ports inside the address instead of reporting a single endpoint's port separately. Default is to report a single endpoint's port separately. Turn this on for a target that names a discovery or coordination service rather than the server that runs the operation. -
setSuffix
Appendsuffixto the address as a path segment, identifying the logical subset of the endpoints that the client selects. A suffix that is not a safe path segment is dropped and the remaining target is kept. Ports are always rendered inline when a suffix is set, so that the suffix cannot be read as part of an endpoint. -
addEndpoint
Add an endpoint. A negativeportmeans that the endpoint has no configured port. The target's default port is used when known. -
addEndpoint
@CanIgnoreReturnValue public DbServerTargetBuilder addEndpoint(@Nullable String host, int port, int defaultPort) Add an endpoint whose default port differs from the target's default port, such as an endpoint whose default port follows from its scheme. -
addEndpoint
Add an endpoint from a socket address. The host is read without resolving it, so an address created from a name keeps that name and an address created from a numeric address keeps its literal form. -
build
Returns the target, ornullwhen it cannot be rendered safely.
-