diff --git a/alts/BUILD.bazel b/alts/BUILD.bazel index ff973dba51..cf67059fa0 100644 --- a/alts/BUILD.bazel +++ b/alts/BUILD.bazel @@ -11,6 +11,7 @@ java_library( ":handshaker_java_proto", "//api", "//core:internal", + "//grpclb", "//netty", "//stub", "@com_google_code_findbugs_jsr305//jar", @@ -32,7 +33,6 @@ java_library( "src/main/java/io/grpc/alts/*.java", ]), visibility = ["//visibility:public"], - runtime_deps = ["//grpclb"], deps = [ ":alts_internal", ":handshaker_java_grpc", diff --git a/alts/build.gradle b/alts/build.gradle index b534277028..b6110b8054 100644 --- a/alts/build.gradle +++ b/alts/build.gradle @@ -15,6 +15,7 @@ targetCompatibility = 1.7 dependencies { compile project(':grpc-auth'), project(':grpc-core'), + project(':grpc-grpclb'), project(':grpc-netty'), project(':grpc-protobuf'), project(':grpc-stub'), @@ -28,7 +29,6 @@ dependencies { exclude group: 'io.grpc', module: 'grpc-context' } compileOnly libraries.javax_annotation - runtime project(':grpc-grpclb') testCompile project(':grpc-testing'), project(':grpc-testing-proto'), libraries.guava, diff --git a/alts/src/main/java/io/grpc/alts/internal/AltsProtocolNegotiator.java b/alts/src/main/java/io/grpc/alts/internal/AltsProtocolNegotiator.java index 2a77e15bbb..c5adbd7376 100644 --- a/alts/src/main/java/io/grpc/alts/internal/AltsProtocolNegotiator.java +++ b/alts/src/main/java/io/grpc/alts/internal/AltsProtocolNegotiator.java @@ -29,7 +29,7 @@ import io.grpc.InternalChannelz.Security; import io.grpc.SecurityLevel; import io.grpc.Status; import io.grpc.alts.internal.RpcProtocolVersionsUtil.RpcVersionsCheckResult; -import io.grpc.internal.GrpcAttributes; +import io.grpc.grpclb.GrpclbConstants; import io.grpc.internal.ObjectPool; import io.grpc.netty.GrpcHttp2ConnectionHandler; import io.grpc.netty.InternalNettyChannelBuilder; @@ -223,13 +223,13 @@ public final class AltsProtocolNegotiator { return SCHEME; } - @SuppressWarnings("deprecation") @Override public ChannelHandler newHandler(GrpcHttp2ConnectionHandler grpcHandler) { ChannelHandler gnh = InternalProtocolNegotiators.grpcNegotiationHandler(grpcHandler); ChannelHandler securityHandler; - if (grpcHandler.getEagAttributes().get(GrpcAttributes.ATTR_LB_ADDR_AUTHORITY) != null - || grpcHandler.getEagAttributes().get(GrpcAttributes.ATTR_LB_PROVIDED_BACKEND) != null) { + if (grpcHandler.getEagAttributes().get(GrpclbConstants.ATTR_LB_ADDR_AUTHORITY) != null + || grpcHandler.getEagAttributes().get( + GrpclbConstants.ATTR_LB_PROVIDED_BACKEND) != null) { TsiHandshaker handshaker = handshakerFactory.newHandshaker(grpcHandler.getAuthority()); NettyTsiHandshaker nettyHandshaker = new NettyTsiHandshaker(handshaker); securityHandler = diff --git a/alts/src/test/java/io/grpc/alts/internal/GoogleDefaultProtocolNegotiatorTest.java b/alts/src/test/java/io/grpc/alts/internal/GoogleDefaultProtocolNegotiatorTest.java index 15c3ae4cc8..5858fc3f52 100644 --- a/alts/src/test/java/io/grpc/alts/internal/GoogleDefaultProtocolNegotiatorTest.java +++ b/alts/src/test/java/io/grpc/alts/internal/GoogleDefaultProtocolNegotiatorTest.java @@ -24,8 +24,8 @@ import com.google.common.collect.ImmutableList; import io.grpc.Attributes; import io.grpc.Channel; import io.grpc.ManagedChannel; +import io.grpc.grpclb.GrpclbConstants; import io.grpc.inprocess.InProcessChannelBuilder; -import io.grpc.internal.GrpcAttributes; import io.grpc.internal.ObjectPool; import io.grpc.netty.GrpcHttp2ConnectionHandler; import io.grpc.netty.GrpcSslContexts; @@ -80,7 +80,7 @@ public final class GoogleDefaultProtocolNegotiatorTest { @Test public void altsHandler() { Attributes eagAttributes = - Attributes.newBuilder().set(GrpcAttributes.ATTR_LB_PROVIDED_BACKEND, true).build(); + Attributes.newBuilder().set(GrpclbConstants.ATTR_LB_PROVIDED_BACKEND, true).build(); GrpcHttp2ConnectionHandler mockHandler = mock(GrpcHttp2ConnectionHandler.class); when(mockHandler.getEagAttributes()).thenReturn(eagAttributes); diff --git a/core/src/main/java/io/grpc/internal/GrpcAttributes.java b/core/src/main/java/io/grpc/internal/GrpcAttributes.java index 0887466b10..da43ae1480 100644 --- a/core/src/main/java/io/grpc/internal/GrpcAttributes.java +++ b/core/src/main/java/io/grpc/internal/GrpcAttributes.java @@ -25,25 +25,6 @@ import io.grpc.SecurityLevel; * Special attributes that are only useful to gRPC. */ public final class GrpcAttributes { - /** - * The naming authority of a gRPC LB server address. It is an address-group-level attribute, - * present when the address group is a LoadBalancer. - * - *

Deprecated: this will be used for grpclb specific logic, which will be moved out of core. - */ - @Deprecated - @EquivalentAddressGroup.Attr - public static final Attributes.Key ATTR_LB_ADDR_AUTHORITY = - Attributes.Key.create("io.grpc.grpclb.lbAddrAuthority"); - - /** - * Whether this EquivalentAddressGroup was provided by a GRPCLB server. It would be rare for this - * value to be {@code false}; generally it would be better to not have the key present at all. - */ - @EquivalentAddressGroup.Attr - public static final Attributes.Key ATTR_LB_PROVIDED_BACKEND = - Attributes.Key.create("io.grpc.grpclb.lbProvidedBackend"); - /** * The security level of the transport. If it's not present, {@link SecurityLevel#NONE} should be * assumed. diff --git a/grpclb/src/main/java/io/grpc/grpclb/GrpclbConstants.java b/grpclb/src/main/java/io/grpc/grpclb/GrpclbConstants.java index 8d2ca418e5..efc945a2fc 100644 --- a/grpclb/src/main/java/io/grpc/grpclb/GrpclbConstants.java +++ b/grpclb/src/main/java/io/grpc/grpclb/GrpclbConstants.java @@ -48,10 +48,21 @@ public final class GrpclbConstants { static final Attributes.Key> ATTR_LB_ADDRS = Attributes.Key.create("io.grpc.grpclb.lbAddrs"); - @SuppressWarnings("deprecation") + /** + * The naming authority of a gRPC LB server address. It is an address-group-level attribute, + * present when the address group is a LoadBalancer. + */ @EquivalentAddressGroup.Attr - static final Attributes.Key ATTR_LB_ADDR_AUTHORITY = - io.grpc.internal.GrpcAttributes.ATTR_LB_ADDR_AUTHORITY; + public static final Attributes.Key ATTR_LB_ADDR_AUTHORITY = + Attributes.Key.create("io.grpc.grpclb.lbAddrAuthority"); + + /** + * Whether this EquivalentAddressGroup was provided by a GRPCLB server. It would be rare for this + * value to be {@code false}; generally it would be better to not have the key present at all. + */ + @EquivalentAddressGroup.Attr + public static final Attributes.Key ATTR_LB_PROVIDED_BACKEND = + Attributes.Key.create("io.grpc.grpclb.lbProvidedBackend"); private GrpclbConstants() { } } diff --git a/grpclb/src/main/java/io/grpc/grpclb/GrpclbState.java b/grpclb/src/main/java/io/grpc/grpclb/GrpclbState.java index 85f7d6b766..38c70e5bcf 100644 --- a/grpclb/src/main/java/io/grpc/grpclb/GrpclbState.java +++ b/grpclb/src/main/java/io/grpc/grpclb/GrpclbState.java @@ -47,7 +47,6 @@ import io.grpc.Status; import io.grpc.SynchronizationContext; import io.grpc.SynchronizationContext.ScheduledHandle; import io.grpc.internal.BackoffPolicy; -import io.grpc.internal.GrpcAttributes; import io.grpc.internal.TimeProvider; import io.grpc.lb.v1.ClientStats; import io.grpc.lb.v1.InitialLoadBalanceRequest; @@ -86,7 +85,7 @@ import javax.annotation.concurrent.NotThreadSafe; final class GrpclbState { static final long FALLBACK_TIMEOUT_MS = TimeUnit.SECONDS.toMillis(10); private static final Attributes LB_PROVIDED_BACKEND_ATTRS = - Attributes.newBuilder().set(GrpcAttributes.ATTR_LB_PROVIDED_BACKEND, true).build(); + Attributes.newBuilder().set(GrpclbConstants.ATTR_LB_PROVIDED_BACKEND, true).build(); @VisibleForTesting static final PickResult DROP_PICK_RESULT = diff --git a/grpclb/src/test/java/io/grpc/grpclb/GrpclbLoadBalancerTest.java b/grpclb/src/test/java/io/grpc/grpclb/GrpclbLoadBalancerTest.java index 2a07d2786c..2b6908436e 100644 --- a/grpclb/src/test/java/io/grpc/grpclb/GrpclbLoadBalancerTest.java +++ b/grpclb/src/test/java/io/grpc/grpclb/GrpclbLoadBalancerTest.java @@ -76,7 +76,6 @@ import io.grpc.inprocess.InProcessChannelBuilder; import io.grpc.inprocess.InProcessServerBuilder; import io.grpc.internal.BackoffPolicy; import io.grpc.internal.FakeClock; -import io.grpc.internal.GrpcAttributes; import io.grpc.internal.JsonParser; import io.grpc.lb.v1.ClientStats; import io.grpc.lb.v1.ClientStatsPerToken; @@ -142,7 +141,7 @@ public class GrpclbLoadBalancerTest { } }; private static final Attributes LB_BACKEND_ATTRS = - Attributes.newBuilder().set(GrpcAttributes.ATTR_LB_PROVIDED_BACKEND, true).build(); + Attributes.newBuilder().set(GrpclbConstants.ATTR_LB_PROVIDED_BACKEND, true).build(); @Mock private Helper helper;