Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ and what APIs have changed, if applicable.

## [Unreleased]

## [29.77.0] - 2025-09-18
- Add XdsClientValidator to pre check xDS client connection

## [29.76.0] - 2025-09-16
- Add D2 service MethodLevelProperties configuration support

Expand Down Expand Up @@ -5900,7 +5903,8 @@ patch operations can re-use these classes for generating patch messages.

## [0.14.1]

[Unreleased]: https://github.com/linkedin/rest.li/compare/v29.76.0...master
[Unreleased]: https://github.com/linkedin/rest.li/compare/v29.77.0...master
[29.77.0]: https://github.com/linkedin/rest.li/compare/v29.76.0...v29.77.0
[29.76.0]: https://github.com/linkedin/rest.li/compare/v29.75.3...v29.76.0
[29.75.4]: https://github.com/linkedin/rest.li/compare/v29.75.3...v29.75.4
[29.75.3]: https://github.com/linkedin/rest.li/compare/v29.75.2...v29.75.3
Expand Down
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ project.ext.externalDependency = [
'grpcNettyShaded' : 'io.grpc:grpc-netty-shaded:1.68.3',
'grpcProtobuf' : 'io.grpc:grpc-protobuf:1.68.3',
'grpcStub' : 'io.grpc:grpc-stub:1.68.3',
'grpcServices' : 'io.grpc:grpc-services:1.68.3',
'protoc' : 'com.google.protobuf:protoc:3.25.5',
'protobufJava' : 'com.google.protobuf:protobuf-java:3.25.5',
'protobufJavaUtil' : 'com.google.protobuf:protobuf-java-util:3.25.5',
Expand Down
1 change: 1 addition & 0 deletions d2/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ dependencies {
compile externalDependency.grpcNettyShaded
compile externalDependency.grpcProtobuf
compile externalDependency.grpcStub
compile externalDependency.grpcServices
compile externalDependency.protobufJava
compile externalDependency.protobufJavaUtil
compile externalDependency.envoyApi
Expand Down
18 changes: 17 additions & 1 deletion d2/src/main/java/com/linkedin/d2/balancer/D2ClientBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import com.linkedin.d2.balancer.clients.FailoutRedirectStrategy;
import com.linkedin.d2.balancer.clients.DynamicClient;
import com.linkedin.d2.balancer.clients.RequestTimeoutClient;
import javax.annotation.Nonnull;
import com.linkedin.d2.balancer.clients.RetryClient;
import com.linkedin.d2.balancer.clusterfailout.FailoutConfigProviderFactory;
import com.linkedin.d2.balancer.dualread.DualReadStateManager;
Expand All @@ -50,6 +51,7 @@
import com.linkedin.d2.discovery.stores.zk.ZooKeeper;
import com.linkedin.d2.jmx.XdsServerMetricsProvider;
import com.linkedin.d2.jmx.JmxManager;
import com.linkedin.d2.xds.XdsClientValidator;
import com.linkedin.d2.jmx.NoOpJmxManager;
import com.linkedin.r2.transport.common.TransportClientFactory;
import com.linkedin.r2.transport.http.client.HttpClientFactory;
Expand Down Expand Up @@ -236,7 +238,9 @@ public D2Client build()
_config.disableDetectLiRawD2Client,
_config.isLiRawD2Client,
_config.xdsStreamMaxRetryBackoffSeconds,
_config.xdsChannelKeepAliveTimeMins
_config.xdsChannelKeepAliveTimeMins,
_config.xdsMinimumJavaVersion,
_config.actionOnPrecheckFailure
);

final LoadBalancerWithFacilitiesFactory loadBalancerFactory = (_config.lbWithFacilitiesFactory == null) ?
Expand Down Expand Up @@ -853,6 +857,18 @@ public D2ClientBuilder setXdsStreamMaxRetryBackoffSeconds(int xdsStreamMaxRetryB
return this;
}

public D2ClientBuilder setXdsMinimumJavaVersion(String xdsMinimumJavaVersion)
{
_config.xdsMinimumJavaVersion = xdsMinimumJavaVersion;
return this;
}

public D2ClientBuilder setActionOnPrecheckFailure(XdsClientValidator.ActionOnPrecheckFailure actionOnPrecheckFailure)
{
_config.actionOnPrecheckFailure = actionOnPrecheckFailure;
return this;
}

private Map<String, TransportClientFactory> createDefaultTransportClientFactories()
{
final Map<String, TransportClientFactory> clientFactories = new HashMap<>();
Expand Down
12 changes: 11 additions & 1 deletion d2/src/main/java/com/linkedin/d2/balancer/D2ClientConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,15 @@
import com.linkedin.d2.balancer.util.downstreams.DownstreamServicesFetcher;
import com.linkedin.d2.balancer.util.healthcheck.HealthCheckOperations;
import com.linkedin.d2.balancer.util.partitions.PartitionAccessorRegistry;
import com.linkedin.d2.xds.XdsClientValidator;
import com.linkedin.d2.balancer.zkfs.ZKFSTogglingLoadBalancerFactoryImpl;
import com.linkedin.d2.balancer.zkfs.ZKFSTogglingLoadBalancerFactoryImpl.ComponentFactory;
import com.linkedin.d2.discovery.event.LogOnlyServiceDiscoveryEventEmitter;
import com.linkedin.d2.discovery.event.ServiceDiscoveryEventEmitter;
import com.linkedin.d2.discovery.stores.zk.ZKPersistentConnection;
import com.linkedin.d2.discovery.stores.zk.ZooKeeper;
import com.linkedin.d2.discovery.stores.zk.ZooKeeperStore;
import com.linkedin.d2.xds.XdsClientValidator.ActionOnPrecheckFailure;
import com.linkedin.d2.jmx.XdsServerMetricsProvider;
import com.linkedin.d2.jmx.JmxManager;
import com.linkedin.d2.jmx.NoOpXdsServerMetricsProvider;
Expand All @@ -52,6 +54,8 @@
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLParameters;

import static com.linkedin.d2.xds.XdsClientValidator.DEFAULT_MINIMUM_JAVA_VERSION;

public class D2ClientConfig
{
// default values for some configs, to be shared with other classes
Expand Down Expand Up @@ -178,6 +182,8 @@ public class D2ClientConfig
public boolean loadBalanceStreamException = false;
public boolean xdsInitialResourceVersionsEnabled = false;
public Integer xdsStreamMaxRetryBackoffSeconds = null;
public String xdsMinimumJavaVersion = DEFAULT_MINIMUM_JAVA_VERSION;
public XdsClientValidator.ActionOnPrecheckFailure actionOnPrecheckFailure = ActionOnPrecheckFailure.ERROR;

/**
* D2 client builder by default will detect if it's used to build a raw D2 client (as opposed to used by standard
Expand Down Expand Up @@ -272,7 +278,9 @@ public D2ClientConfig()
boolean disableDetectLiRawD2Client,
boolean isLiRawD2Client,
Integer xdsStreamMaxRetryBackoffSeconds,
Long xdsChannelKeepAliveTimeMins)
Long xdsChannelKeepAliveTimeMins,
String xdsMinimumJavaVersion,
XdsClientValidator.ActionOnPrecheckFailure actionOnPrecheckFailure)
{
this.zkHosts = zkHosts;
this.xdsServer = xdsServer;
Expand Down Expand Up @@ -352,5 +360,7 @@ public D2ClientConfig()
this.disableDetectLiRawD2Client = disableDetectLiRawD2Client;
this.isLiRawD2Client = isLiRawD2Client;
this.xdsStreamMaxRetryBackoffSeconds = xdsStreamMaxRetryBackoffSeconds;
this.xdsMinimumJavaVersion = xdsMinimumJavaVersion;
this.actionOnPrecheckFailure = actionOnPrecheckFailure;
}
}
32 changes: 32 additions & 0 deletions d2/src/main/java/com/linkedin/d2/xds/XdsClientImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicLong;
import java.util.function.BiConsumer;
import java.util.function.Function;
Expand Down Expand Up @@ -111,6 +112,9 @@ public class XdsClientImpl extends XdsClient
private final XdsClientJmx _xdsClientJmx;
private final XdsServerMetricsProvider _serverMetricsProvider;
private final boolean _initialResourceVersionsEnabled;
private final String _minimumJavaVersion;
private final XdsClientValidator.ActionOnPrecheckFailure _actionOnPrecheckFailure;
private final AtomicBoolean _started = new AtomicBoolean();

@Deprecated
public XdsClientImpl(Node node, ManagedChannel managedChannel, ScheduledExecutorService executorService)
Expand Down Expand Up @@ -168,6 +172,7 @@ public XdsClientImpl(Node node,
irvSupport, null);
}

@Deprecated
public XdsClientImpl(Node node,
ManagedChannel managedChannel,
ScheduledExecutorService executorService,
Expand All @@ -176,6 +181,21 @@ public XdsClientImpl(Node node,
XdsServerMetricsProvider serverMetricsProvider,
boolean irvSupport,
Integer maxRetryBackoffSeconds)
{
this(node, managedChannel, executorService, readyTimeoutMillis, subscribeToUriGlobCollection,
serverMetricsProvider, irvSupport, maxRetryBackoffSeconds, XdsClientValidator.DEFAULT_MINIMUM_JAVA_VERSION, XdsClientValidator.DEFAULT_ACTION_ON_PRECHECK_FAILURE);
}

public XdsClientImpl(Node node,
ManagedChannel managedChannel,
ScheduledExecutorService executorService,
long readyTimeoutMillis,
boolean subscribeToUriGlobCollection,
XdsServerMetricsProvider serverMetricsProvider,
boolean irvSupport,
Integer maxRetryBackoffSeconds,
String minimumJavaVersion,
XdsClientValidator.ActionOnPrecheckFailure actionOnPrecheckFailure)
{
_readyTimeoutMillis = readyTimeoutMillis;
_node = node;
Expand All @@ -195,6 +215,12 @@ public XdsClientImpl(Node node,
_log.info("XDS initial resource versions support enabled");
}

_minimumJavaVersion = minimumJavaVersion;
_log.info("Minimum Java version required: {}", _minimumJavaVersion);

_actionOnPrecheckFailure = actionOnPrecheckFailure;
_log.info("Action on pre-check failure: {}", _actionOnPrecheckFailure);

_retryBackoffPolicy = _backoffPolicyProvider.get();
Integer backoffSecs = (maxRetryBackoffSeconds != null && maxRetryBackoffSeconds > 0)
? maxRetryBackoffSeconds : DEFAULT_MAX_RETRY_BACKOFF_SECS;
Expand All @@ -205,7 +231,13 @@ public XdsClientImpl(Node node,
@Override
public void start()
{
if (!_started.compareAndSet(false, true))
{
throw new IllegalStateException("Cannot start XdsClient more than once");
}

_xdsClientJmx.setXdsClient(this);
XdsClientValidator.preCheckForIndisConnection(_managedChannel, _readyTimeoutMillis, _minimumJavaVersion, _actionOnPrecheckFailure);
startRpcStream();
}

Expand Down
Loading