diff --git a/grpclb/build.gradle b/grpclb/build.gradle index ed48c1a5eba..82ddb89c397 100644 --- a/grpclb/build.gradle +++ b/grpclb/build.gradle @@ -26,3 +26,7 @@ dependencies { } configureProtoCompilation() + +javadoc { + exclude 'io/grpc/grpclb/Internal*' +} diff --git a/grpclb/src/main/java/io/grpc/grpclb/GrpclbConstants.java b/grpclb/src/main/java/io/grpc/grpclb/GrpclbConstants.java index db5e84f08c6..75267757273 100644 --- a/grpclb/src/main/java/io/grpc/grpclb/GrpclbConstants.java +++ b/grpclb/src/main/java/io/grpc/grpclb/GrpclbConstants.java @@ -43,7 +43,6 @@ public final class GrpclbConstants { Attributes.Key.create("lb-token"); @SuppressWarnings("deprecation") - @EquivalentAddressGroup.Attr static final Attributes.Key> ATTR_LB_ADDRS = io.grpc.internal.GrpcAttributes.ATTR_LB_ADDRS; diff --git a/grpclb/src/main/java/io/grpc/grpclb/GrpclbLoadBalancer.java b/grpclb/src/main/java/io/grpc/grpclb/GrpclbLoadBalancer.java index 922a8b61970..00af68f844b 100644 --- a/grpclb/src/main/java/io/grpc/grpclb/GrpclbLoadBalancer.java +++ b/grpclb/src/main/java/io/grpc/grpclb/GrpclbLoadBalancer.java @@ -30,7 +30,6 @@ import io.grpc.Status; import io.grpc.grpclb.GrpclbState.Mode; import io.grpc.internal.BackoffPolicy; -import io.grpc.internal.GrpcAttributes; import io.grpc.internal.ServiceConfigUtil; import io.grpc.internal.ServiceConfigUtil.LbConfig; import io.grpc.internal.TimeProvider; @@ -92,7 +91,7 @@ public void handleSubchannelState(Subchannel subchannel, ConnectivityStateInfo n @SuppressWarnings("deprecation") // TODO(creamsoup) migrate to use parsed service config public void handleResolvedAddresses(ResolvedAddresses resolvedAddresses) { Attributes attributes = resolvedAddresses.getAttributes(); - List newLbAddresses = attributes.get(GrpcAttributes.ATTR_LB_ADDRS); + List newLbAddresses = attributes.get(GrpclbConstants.ATTR_LB_ADDRS); if ((newLbAddresses == null || newLbAddresses.isEmpty()) && resolvedAddresses.getAddresses().isEmpty()) { handleNameResolutionError( diff --git a/grpclb/src/main/java/io/grpc/grpclb/InternalGrpclbConstantsAccessor.java b/grpclb/src/main/java/io/grpc/grpclb/InternalGrpclbConstantsAccessor.java new file mode 100644 index 00000000000..298add4b738 --- /dev/null +++ b/grpclb/src/main/java/io/grpc/grpclb/InternalGrpclbConstantsAccessor.java @@ -0,0 +1,49 @@ +/* + * Copyright 2020 The gRPC Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.grpc.grpclb; + +import io.grpc.Attributes; +import io.grpc.EquivalentAddressGroup; +import io.grpc.Internal; +import java.util.List; + +/** + * Internal {@link GrpclbConstants} accessor. This is intended for usage internal to the gRPC + * team. If you *really* think you need to use this, contact the gRPC team first. + */ +@Internal +public class InternalGrpclbConstantsAccessor { + + // Prevent instantiation. + private InternalGrpclbConstantsAccessor() { + } + + /** + * Sets attribute for gRPC LB address authority. + */ + public static Attributes setLbAddrAuthorityAttr( + @EquivalentAddressGroup.Attr Attributes attrs, String authority) { + return attrs.toBuilder().set(GrpclbConstants.ATTR_LB_ADDR_AUTHORITY, authority).build(); + } + + /** + * Sets attribute for gRPC LB addresses. + */ + public static Attributes setLbAddrAttr(Attributes attrs, List lbAddrs) { + return attrs.toBuilder().set(GrpclbConstants.ATTR_LB_ADDRS, lbAddrs).build(); + } +}