aboutsummaryrefslogtreecommitdiff
path: root/services
diff options
context:
space:
mode:
authorzpencer <spencerfang@google.com>2018-09-05 18:48:42 -0700
committerGitHub <noreply@github.com>2018-09-05 18:48:42 -0700
commit2fca42feb93f1bda1a80f6649d1e6304e9a67b08 (patch)
treefc016159bd41af9108ece6e5e5d1cdcb58ed9262 /services
parent1b6adaff61eb47f9753997b464e1e3edef5346a4 (diff)
downloadgrpc-grpc-java-2fca42feb93f1bda1a80f6649d1e6304e9a67b08.tar.gz
all: prepend internal classes with Internal (#4826)
This is a safer way to hide the classes, because they will not appear in public targets for some build configurations.
Diffstat (limited to 'services')
-rw-r--r--services/src/main/java/io/grpc/services/ChannelzProtoUtil.java34
-rw-r--r--services/src/main/java/io/grpc/services/ChannelzService.java8
-rw-r--r--services/src/test/java/io/grpc/services/ChannelzProtoUtilTest.java48
-rw-r--r--services/src/test/java/io/grpc/services/ChannelzTestHelper.java36
4 files changed, 65 insertions, 61 deletions
diff --git a/services/src/main/java/io/grpc/services/ChannelzProtoUtil.java b/services/src/main/java/io/grpc/services/ChannelzProtoUtil.java
index a8acc7d29..3ee47e445 100644
--- a/services/src/main/java/io/grpc/services/ChannelzProtoUtil.java
+++ b/services/src/main/java/io/grpc/services/ChannelzProtoUtil.java
@@ -24,7 +24,6 @@ import com.google.protobuf.Int64Value;
import com.google.protobuf.util.Durations;
import com.google.protobuf.util.Timestamps;
import io.grpc.ConnectivityState;
-import io.grpc.Instrumented;
import io.grpc.InternalChannelz;
import io.grpc.InternalChannelz.ChannelStats;
import io.grpc.InternalChannelz.ChannelTrace.Event;
@@ -34,8 +33,9 @@ import io.grpc.InternalChannelz.ServerSocketsList;
import io.grpc.InternalChannelz.ServerStats;
import io.grpc.InternalChannelz.SocketStats;
import io.grpc.InternalChannelz.TransportStats;
+import io.grpc.InternalInstrumented;
+import io.grpc.InternalWithLogId;
import io.grpc.Status;
-import io.grpc.WithLogId;
import io.grpc.channelz.v1.Address;
import io.grpc.channelz.v1.Address.OtherAddress;
import io.grpc.channelz.v1.Address.TcpIpAddress;
@@ -88,7 +88,7 @@ final class ChannelzProtoUtil {
// do not instantiate.
}
- static ChannelRef toChannelRef(WithLogId obj) {
+ static ChannelRef toChannelRef(InternalWithLogId obj) {
return ChannelRef
.newBuilder()
.setChannelId(obj.getLogId().getId())
@@ -96,7 +96,7 @@ final class ChannelzProtoUtil {
.build();
}
- static SubchannelRef toSubchannelRef(WithLogId obj) {
+ static SubchannelRef toSubchannelRef(InternalWithLogId obj) {
return SubchannelRef
.newBuilder()
.setSubchannelId(obj.getLogId().getId())
@@ -104,7 +104,7 @@ final class ChannelzProtoUtil {
.build();
}
- static ServerRef toServerRef(WithLogId obj) {
+ static ServerRef toServerRef(InternalWithLogId obj) {
return ServerRef
.newBuilder()
.setServerId(obj.getLogId().getId())
@@ -112,7 +112,7 @@ final class ChannelzProtoUtil {
.build();
}
- static SocketRef toSocketRef(WithLogId obj) {
+ static SocketRef toSocketRef(InternalWithLogId obj) {
return SocketRef
.newBuilder()
.setSocketId(obj.getLogId().getId())
@@ -120,13 +120,13 @@ final class ChannelzProtoUtil {
.build();
}
- static Server toServer(Instrumented<ServerStats> obj) {
+ static Server toServer(InternalInstrumented<ServerStats> obj) {
ServerStats stats = getFuture(obj.getStats());
Server.Builder builder = Server
.newBuilder()
.setRef(toServerRef(obj))
.setData(toServerData(stats));
- for (Instrumented<SocketStats> listenSocket : stats.listenSockets) {
+ for (InternalInstrumented<SocketStats> listenSocket : stats.listenSockets) {
builder.addListenSocket(toSocketRef(listenSocket));
}
return builder.build();
@@ -172,7 +172,7 @@ final class ChannelzProtoUtil {
}
}
- static Socket toSocket(Instrumented<SocketStats> obj) {
+ static Socket toSocket(InternalInstrumented<SocketStats> obj) {
SocketStats socketStats = getFuture(obj.getStats());
Builder builder = Socket.newBuilder()
.setRef(toSocketRef(obj))
@@ -339,13 +339,13 @@ final class ChannelzProtoUtil {
return ret;
}
- static Channel toChannel(Instrumented<ChannelStats> channel) {
+ static Channel toChannel(InternalInstrumented<ChannelStats> channel) {
ChannelStats stats = getFuture(channel.getStats());
Channel.Builder channelBuilder = Channel
.newBuilder()
.setRef(toChannelRef(channel))
.setData(extractChannelData(stats));
- for (WithLogId subchannel : stats.subchannels) {
+ for (InternalWithLogId subchannel : stats.subchannels) {
channelBuilder.addSubchannelRef(toSubchannelRef(subchannel));
}
@@ -407,17 +407,17 @@ final class ChannelzProtoUtil {
}
}
- static Subchannel toSubchannel(Instrumented<ChannelStats> subchannel) {
+ static Subchannel toSubchannel(InternalInstrumented<ChannelStats> subchannel) {
ChannelStats stats = getFuture(subchannel.getStats());
Subchannel.Builder subchannelBuilder = Subchannel
.newBuilder()
.setRef(toSubchannelRef(subchannel))
.setData(extractChannelData(stats));
Preconditions.checkState(stats.sockets.isEmpty() || stats.subchannels.isEmpty());
- for (WithLogId childSocket : stats.sockets) {
+ for (InternalWithLogId childSocket : stats.sockets) {
subchannelBuilder.addSocketRef(toSocketRef(childSocket));
}
- for (WithLogId childSubchannel : stats.subchannels) {
+ for (InternalWithLogId childSubchannel : stats.subchannels) {
subchannelBuilder.addSubchannelRef(toSubchannelRef(childSubchannel));
}
return subchannelBuilder.build();
@@ -427,7 +427,7 @@ final class ChannelzProtoUtil {
GetTopChannelsResponse.Builder responseBuilder = GetTopChannelsResponse
.newBuilder()
.setEnd(rootChannels.end);
- for (Instrumented<ChannelStats> c : rootChannels.channels) {
+ for (InternalInstrumented<ChannelStats> c : rootChannels.channels) {
responseBuilder.addChannel(ChannelzProtoUtil.toChannel(c));
}
return responseBuilder.build();
@@ -437,7 +437,7 @@ final class ChannelzProtoUtil {
GetServersResponse.Builder responseBuilder = GetServersResponse
.newBuilder()
.setEnd(servers.end);
- for (Instrumented<ServerStats> s : servers.servers) {
+ for (InternalInstrumented<ServerStats> s : servers.servers) {
responseBuilder.addServer(ChannelzProtoUtil.toServer(s));
}
return responseBuilder.build();
@@ -447,7 +447,7 @@ final class ChannelzProtoUtil {
GetServerSocketsResponse.Builder responseBuilder = GetServerSocketsResponse
.newBuilder()
.setEnd(serverSockets.end);
- for (WithLogId s : serverSockets.sockets) {
+ for (InternalWithLogId s : serverSockets.sockets) {
responseBuilder.addSocketRef(ChannelzProtoUtil.toSocketRef(s));
}
return responseBuilder.build();
diff --git a/services/src/main/java/io/grpc/services/ChannelzService.java b/services/src/main/java/io/grpc/services/ChannelzService.java
index 81415197e..773c9d4af 100644
--- a/services/src/main/java/io/grpc/services/ChannelzService.java
+++ b/services/src/main/java/io/grpc/services/ChannelzService.java
@@ -18,12 +18,12 @@ package io.grpc.services;
import com.google.common.annotations.VisibleForTesting;
import io.grpc.ExperimentalApi;
-import io.grpc.Instrumented;
import io.grpc.InternalChannelz;
import io.grpc.InternalChannelz.ChannelStats;
import io.grpc.InternalChannelz.ServerList;
import io.grpc.InternalChannelz.ServerSocketsList;
import io.grpc.InternalChannelz.SocketStats;
+import io.grpc.InternalInstrumented;
import io.grpc.ServerInterceptors;
import io.grpc.ServerServiceDefinition;
import io.grpc.Status;
@@ -92,7 +92,7 @@ public final class ChannelzService extends ChannelzGrpc.ChannelzImplBase {
@Override
public void getChannel(
GetChannelRequest request, StreamObserver<GetChannelResponse> responseObserver) {
- Instrumented<ChannelStats> s = channelz.getRootChannel(request.getChannelId());
+ InternalInstrumented<ChannelStats> s = channelz.getRootChannel(request.getChannelId());
if (s == null) {
responseObserver.onError(Status.NOT_FOUND.asRuntimeException());
return;
@@ -120,7 +120,7 @@ public final class ChannelzService extends ChannelzGrpc.ChannelzImplBase {
@Override
public void getSubchannel(
GetSubchannelRequest request, StreamObserver<GetSubchannelResponse> responseObserver) {
- Instrumented<ChannelStats> s = channelz.getSubchannel(request.getSubchannelId());
+ InternalInstrumented<ChannelStats> s = channelz.getSubchannel(request.getSubchannelId());
if (s == null) {
responseObserver.onError(Status.NOT_FOUND.asRuntimeException());
return;
@@ -138,7 +138,7 @@ public final class ChannelzService extends ChannelzGrpc.ChannelzImplBase {
@Override
public void getSocket(
GetSocketRequest request, StreamObserver<GetSocketResponse> responseObserver) {
- Instrumented<SocketStats> s = channelz.getSocket(request.getSocketId());
+ InternalInstrumented<SocketStats> s = channelz.getSocket(request.getSocketId());
if (s == null) {
responseObserver.onError(Status.NOT_FOUND.asRuntimeException());
return;
diff --git a/services/src/test/java/io/grpc/services/ChannelzProtoUtilTest.java b/services/src/test/java/io/grpc/services/ChannelzProtoUtilTest.java
index 9c97beb41..03890fbdd 100644
--- a/services/src/test/java/io/grpc/services/ChannelzProtoUtilTest.java
+++ b/services/src/test/java/io/grpc/services/ChannelzProtoUtilTest.java
@@ -32,7 +32,6 @@ import com.google.protobuf.Message;
import com.google.protobuf.util.Durations;
import com.google.protobuf.util.Timestamps;
import io.grpc.ConnectivityState;
-import io.grpc.Instrumented;
import io.grpc.InternalChannelz;
import io.grpc.InternalChannelz.ChannelStats;
import io.grpc.InternalChannelz.ChannelTrace.Event;
@@ -43,7 +42,8 @@ import io.grpc.InternalChannelz.ServerSocketsList;
import io.grpc.InternalChannelz.ServerStats;
import io.grpc.InternalChannelz.SocketOptions;
import io.grpc.InternalChannelz.SocketStats;
-import io.grpc.WithLogId;
+import io.grpc.InternalInstrumented;
+import io.grpc.InternalWithLogId;
import io.grpc.channelz.v1.Address;
import io.grpc.channelz.v1.Address.OtherAddress;
import io.grpc.channelz.v1.Address.TcpIpAddress;
@@ -538,7 +538,7 @@ public final class ChannelzProtoUtilTest {
// 1 listen socket
server.serverStats = toBuilder(server.serverStats)
- .setListenSockets(ImmutableList.<Instrumented<SocketStats>>of(listenSocket))
+ .setListenSockets(ImmutableList.<InternalInstrumented<SocketStats>>of(listenSocket))
.build();
assertEquals(
serverProto
@@ -552,7 +552,7 @@ public final class ChannelzProtoUtilTest {
SocketRef otherListenSocketRef = ChannelzProtoUtil.toSocketRef(otherListenSocket);
server.serverStats = toBuilder(server.serverStats)
.setListenSockets(
- ImmutableList.<Instrumented<SocketStats>>of(listenSocket, otherListenSocket))
+ ImmutableList.<InternalInstrumented<SocketStats>>of(listenSocket, otherListenSocket))
.build();
assertEquals(
serverProto
@@ -573,7 +573,7 @@ public final class ChannelzProtoUtilTest {
assertEquals(channelProto, ChannelzProtoUtil.toChannel(channel));
channel.stats = toBuilder(channel.stats)
- .setSubchannels(ImmutableList.<WithLogId>of(subchannel))
+ .setSubchannels(ImmutableList.<InternalWithLogId>of(subchannel))
.build();
assertEquals(
@@ -585,7 +585,7 @@ public final class ChannelzProtoUtilTest {
TestChannel otherSubchannel = new TestChannel();
channel.stats = toBuilder(channel.stats)
- .setSubchannels(ImmutableList.<WithLogId>of(subchannel, otherSubchannel))
+ .setSubchannels(ImmutableList.<InternalWithLogId>of(subchannel, otherSubchannel))
.build();
assertEquals(
channelProto
@@ -611,7 +611,7 @@ public final class ChannelzProtoUtilTest {
@Test
public void toSubchannel_socketChildren() throws Exception {
subchannel.stats = toBuilder(subchannel.stats)
- .setSockets(ImmutableList.<WithLogId>of(socket))
+ .setSockets(ImmutableList.<InternalWithLogId>of(socket))
.build();
assertEquals(
@@ -622,7 +622,7 @@ public final class ChannelzProtoUtilTest {
TestSocket otherSocket = new TestSocket();
subchannel.stats = toBuilder(subchannel.stats)
- .setSockets(ImmutableList.<WithLogId>of(socket, otherSocket))
+ .setSockets(ImmutableList.<InternalWithLogId>of(socket, otherSocket))
.build();
assertEquals(
subchannelProto
@@ -637,7 +637,7 @@ public final class ChannelzProtoUtilTest {
public void toSubchannel_subchannelChildren() throws Exception {
TestChannel subchannel1 = new TestChannel();
subchannel.stats = toBuilder(subchannel.stats)
- .setSubchannels(ImmutableList.<WithLogId>of(subchannel1))
+ .setSubchannels(ImmutableList.<InternalWithLogId>of(subchannel1))
.build();
assertEquals(
subchannelProto.toBuilder()
@@ -647,7 +647,7 @@ public final class ChannelzProtoUtilTest {
TestChannel subchannel2 = new TestChannel();
subchannel.stats = toBuilder(subchannel.stats)
- .setSubchannels(ImmutableList.<WithLogId>of(subchannel1, subchannel2))
+ .setSubchannels(ImmutableList.<InternalWithLogId>of(subchannel1, subchannel2))
.build();
assertEquals(
subchannelProto
@@ -664,7 +664,8 @@ public final class ChannelzProtoUtilTest {
assertEquals(
GetTopChannelsResponse.newBuilder().setEnd(true).build(),
ChannelzProtoUtil.toGetTopChannelResponse(
- new RootChannelList(Collections.<Instrumented<ChannelStats>>emptyList(), true)));
+ new RootChannelList(
+ Collections.<InternalInstrumented<ChannelStats>>emptyList(), true)));
// 1 result, paginated
assertEquals(
@@ -673,7 +674,8 @@ public final class ChannelzProtoUtilTest {
.addChannel(channelProto)
.build(),
ChannelzProtoUtil.toGetTopChannelResponse(
- new RootChannelList(ImmutableList.<Instrumented<ChannelStats>>of(channel), false)));
+ new RootChannelList(
+ ImmutableList.<InternalInstrumented<ChannelStats>>of(channel), false)));
// 1 result, end
assertEquals(
@@ -683,7 +685,8 @@ public final class ChannelzProtoUtilTest {
.setEnd(true)
.build(),
ChannelzProtoUtil.toGetTopChannelResponse(
- new RootChannelList(ImmutableList.<Instrumented<ChannelStats>>of(channel), true)));
+ new RootChannelList(
+ ImmutableList.<InternalInstrumented<ChannelStats>>of(channel), true)));
// 2 results, end
TestChannel channel2 = new TestChannel();
@@ -696,7 +699,7 @@ public final class ChannelzProtoUtilTest {
.build(),
ChannelzProtoUtil.toGetTopChannelResponse(
new RootChannelList(
- ImmutableList.<Instrumented<ChannelStats>>of(channel, channel2), true)));
+ ImmutableList.<InternalInstrumented<ChannelStats>>of(channel, channel2), true)));
}
@Test
@@ -705,7 +708,7 @@ public final class ChannelzProtoUtilTest {
assertEquals(
GetServersResponse.getDefaultInstance(),
ChannelzProtoUtil.toGetServersResponse(
- new ServerList(Collections.<Instrumented<ServerStats>>emptyList(), false)));
+ new ServerList(Collections.<InternalInstrumented<ServerStats>>emptyList(), false)));
// 1 result, paginated
assertEquals(
@@ -714,7 +717,7 @@ public final class ChannelzProtoUtilTest {
.addServer(serverProto)
.build(),
ChannelzProtoUtil.toGetServersResponse(
- new ServerList(ImmutableList.<Instrumented<ServerStats>>of(server), false)));
+ new ServerList(ImmutableList.<InternalInstrumented<ServerStats>>of(server), false)));
// 1 result, end
assertEquals(
@@ -724,7 +727,7 @@ public final class ChannelzProtoUtilTest {
.setEnd(true)
.build(),
ChannelzProtoUtil.toGetServersResponse(
- new ServerList(ImmutableList.<Instrumented<ServerStats>>of(server), true)));
+ new ServerList(ImmutableList.<InternalInstrumented<ServerStats>>of(server), true)));
TestServer server2 = new TestServer();
// 2 results, end
@@ -736,7 +739,8 @@ public final class ChannelzProtoUtilTest {
.setEnd(true)
.build(),
ChannelzProtoUtil.toGetServersResponse(
- new ServerList(ImmutableList.<Instrumented<ServerStats>>of(server, server2), true)));
+ new ServerList(
+ ImmutableList.<InternalInstrumented<ServerStats>>of(server, server2), true)));
}
@Test
@@ -745,7 +749,7 @@ public final class ChannelzProtoUtilTest {
assertEquals(
GetServerSocketsResponse.getDefaultInstance(),
ChannelzProtoUtil.toGetServerSocketsResponse(
- new ServerSocketsList(Collections.<WithLogId>emptyList(), false)));
+ new ServerSocketsList(Collections.<InternalWithLogId>emptyList(), false)));
// 1 result, paginated
assertEquals(
@@ -754,7 +758,7 @@ public final class ChannelzProtoUtilTest {
.addSocketRef(socketRef)
.build(),
ChannelzProtoUtil.toGetServerSocketsResponse(
- new ServerSocketsList(ImmutableList.<WithLogId>of(socket), false)));
+ new ServerSocketsList(ImmutableList.<InternalWithLogId>of(socket), false)));
// 1 result, end
assertEquals(
@@ -764,7 +768,7 @@ public final class ChannelzProtoUtilTest {
.setEnd(true)
.build(),
ChannelzProtoUtil.toGetServerSocketsResponse(
- new ServerSocketsList(ImmutableList.<WithLogId>of(socket), true)));
+ new ServerSocketsList(ImmutableList.<InternalWithLogId>of(socket), true)));
TestSocket socket2 = new TestSocket();
// 2 results, end
@@ -776,7 +780,7 @@ public final class ChannelzProtoUtilTest {
.setEnd(true)
.build(),
ChannelzProtoUtil.toGetServerSocketsResponse(
- new ServerSocketsList(ImmutableList.<WithLogId>of(socket, socket2), true)));
+ new ServerSocketsList(ImmutableList.<InternalWithLogId>of(socket, socket2), true)));
}
@Test
diff --git a/services/src/test/java/io/grpc/services/ChannelzTestHelper.java b/services/src/test/java/io/grpc/services/ChannelzTestHelper.java
index 822740056..cd8b67613 100644
--- a/services/src/test/java/io/grpc/services/ChannelzTestHelper.java
+++ b/services/src/test/java/io/grpc/services/ChannelzTestHelper.java
@@ -20,7 +20,6 @@ import com.google.common.base.MoreObjects;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.SettableFuture;
import io.grpc.ConnectivityState;
-import io.grpc.Instrumented;
import io.grpc.InternalChannelz;
import io.grpc.InternalChannelz.ChannelStats;
import io.grpc.InternalChannelz.Security;
@@ -28,8 +27,9 @@ import io.grpc.InternalChannelz.ServerStats;
import io.grpc.InternalChannelz.SocketOptions;
import io.grpc.InternalChannelz.SocketStats;
import io.grpc.InternalChannelz.TransportStats;
-import io.grpc.LogId;
-import io.grpc.WithLogId;
+import io.grpc.InternalInstrumented;
+import io.grpc.InternalLogId;
+import io.grpc.InternalWithLogId;
import java.net.InetSocketAddress;
import java.net.SocketAddress;
import java.util.Collections;
@@ -40,8 +40,8 @@ import java.util.Collections;
*/
final class ChannelzTestHelper {
- static final class TestSocket implements Instrumented<SocketStats> {
- private final LogId id = LogId.allocate("socket");
+ static final class TestSocket implements InternalInstrumented<SocketStats> {
+ private final InternalLogId id = InternalLogId.allocate("socket");
TransportStats transportStats = new TransportStats(
/*streamsStarted=*/ 1,
/*lastLocalStreamCreatedTimeNanos=*/ 2,
@@ -75,7 +75,7 @@ final class ChannelzTestHelper {
}
@Override
- public LogId getLogId() {
+ public InternalLogId getLogId() {
return id;
}
@@ -87,8 +87,8 @@ final class ChannelzTestHelper {
}
}
- static final class TestListenSocket implements Instrumented<SocketStats> {
- private final LogId id = LogId.allocate("listensocket");
+ static final class TestListenSocket implements InternalInstrumented<SocketStats> {
+ private final InternalLogId id = InternalLogId.allocate("listensocket");
SocketAddress listenAddress = new InetSocketAddress("10.0.0.1", 1234);
@Override
@@ -105,7 +105,7 @@ final class ChannelzTestHelper {
}
@Override
- public LogId getLogId() {
+ public InternalLogId getLogId() {
return id;
}
@@ -117,14 +117,14 @@ final class ChannelzTestHelper {
}
}
- static final class TestServer implements Instrumented<ServerStats> {
- private final LogId id = LogId.allocate("server");
+ static final class TestServer implements InternalInstrumented<ServerStats> {
+ private final InternalLogId id = InternalLogId.allocate("server");
ServerStats serverStats = new ServerStats(
/*callsStarted=*/ 1,
/*callsSucceeded=*/ 2,
/*callsFailed=*/ 3,
/*lastCallStartedNanos=*/ 4,
- Collections.<Instrumented<SocketStats>>emptyList());
+ Collections.<InternalInstrumented<SocketStats>>emptyList());
@Override
public ListenableFuture<ServerStats> getStats() {
@@ -134,7 +134,7 @@ final class ChannelzTestHelper {
}
@Override
- public LogId getLogId() {
+ public InternalLogId getLogId() {
return id;
}
@@ -146,8 +146,8 @@ final class ChannelzTestHelper {
}
}
- static final class TestChannel implements Instrumented<ChannelStats> {
- private final LogId id = LogId.allocate("channel-or-subchannel");
+ static final class TestChannel implements InternalInstrumented<ChannelStats> {
+ private final InternalLogId id = InternalLogId.allocate("channel-or-subchannel");
ChannelStats stats = new ChannelStats.Builder()
.setTarget("sometarget")
@@ -156,8 +156,8 @@ final class ChannelzTestHelper {
.setCallsSucceeded(2)
.setCallsFailed(3)
.setLastCallStartedNanos(4)
- .setSubchannels(Collections.<WithLogId>emptyList())
- .setSockets(Collections.<WithLogId>emptyList())
+ .setSubchannels(Collections.<InternalWithLogId>emptyList())
+ .setSockets(Collections.<InternalWithLogId>emptyList())
.build();
@Override
@@ -168,7 +168,7 @@ final class ChannelzTestHelper {
}
@Override
- public LogId getLogId() {
+ public InternalLogId getLogId() {
return id;
}