Skip to content

Commit 543e762

Browse files
committed
accept local cluster instead of service name
1 parent de33ce6 commit 543e762

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

client/java-armeria-xds/src/main/java/com/linecorp/centraldogma/client/armeria/xds/XdsCentralDogmaBuilder.java

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
import io.envoyproxy.envoy.config.bootstrap.v3.Bootstrap;
5353
import io.envoyproxy.envoy.config.bootstrap.v3.Bootstrap.DynamicResources;
5454
import io.envoyproxy.envoy.config.bootstrap.v3.Bootstrap.StaticResources;
55+
import io.envoyproxy.envoy.config.bootstrap.v3.ClusterManager;
5556
import io.envoyproxy.envoy.config.cluster.v3.Cluster;
5657
import io.envoyproxy.envoy.config.cluster.v3.Cluster.DiscoveryType;
5758
import io.envoyproxy.envoy.config.core.v3.Address;
@@ -109,7 +110,7 @@ public final class XdsCentralDogmaBuilder extends AbstractCentralDogmaBuilder<Xd
109110
private String listenerName = DEFAULT_LISTENER_NAME;
110111
private Locality locality = Locality.getDefaultInstance();
111112
// an empty string means no local cluster
112-
private String serviceCluster = "";
113+
private String localClusterName = "";
113114

114115
// TODO: @jrhee17 remove this once xDS TLS is fully supported
115116
private Function<Bootstrap, XdsBootstrap> xdsBootstrapFactory = XdsBootstrap::of;
@@ -139,17 +140,17 @@ public XdsCentralDogmaBuilder serviceZone(String serviceZone) {
139140
}
140141

141142
/**
142-
* Sets the name of the local service cluster which this client will be located in.
143+
* Sets the name of the local cluster name which this client will be located in.
143144
* This may be used in applying
144145
* <a href="https://www.envoyproxy.io/docs/envoy/latest/intro/arch_overview/upstream/load_balancing/zone_aware">zone aware routing</a>
145146
* and is analogous to
146-
* <a href="https://www.envoyproxy.io/docs/envoy/latest/operations/cli#cmdoption-service-cluster">service-cluster</a>.
147-
* This value will be set to {@link Node#getCluster()} in the {@link Bootstrap}.
147+
* <a href="https://www.envoyproxy.io/docs/envoy/latest/api-v3/config/bootstrap/v3/bootstrap.proto#envoy-v3-api-field-config-bootstrap-v3-clustermanager-local-cluster-name">service-cluster</a>.
148+
* This value will be set to {@link ClusterManager#getLocalClusterName()} in the {@link Bootstrap}.
148149
*/
149150
@UnstableApi
150-
public XdsCentralDogmaBuilder serviceCluster(String serviceCluster) {
151-
requireNonNull(serviceCluster, "serviceCluster");
152-
this.serviceCluster = serviceCluster;
151+
public XdsCentralDogmaBuilder localClusterName(String localClusterName) {
152+
requireNonNull(localClusterName, "localClusterName");
153+
this.localClusterName = localClusterName;
153154
return this;
154155
}
155156

@@ -270,9 +271,10 @@ private XdsBootstrap xdsBootstrap() {
270271
DynamicResources.newBuilder().setAdsConfig(apiConfigSource).build();
271272
final Bootstrap bootstrap =
272273
Bootstrap.newBuilder()
274+
.setClusterManager(ClusterManager.newBuilder()
275+
.setLocalClusterName(localClusterName))
273276
.setDynamicResources(dynamicResources)
274277
.setNode(Node.newBuilder()
275-
.setCluster(serviceCluster)
276278
.setLocality(locality))
277279
.setStaticResources(StaticResources.newBuilder().addClusters(bootstrapCluster()))
278280
.build();

0 commit comments

Comments
 (0)