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.
This commit is contained in:
zpencer 2018-09-05 18:48:42 -07:00 committed by GitHub
parent 1b6adaff61
commit 2fca42feb9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
39 changed files with 294 additions and 284 deletions

View File

@ -17,11 +17,11 @@
package io.grpc.internal; package io.grpc.internal;
import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.ListenableFuture;
import io.grpc.Instrumented;
import io.grpc.InternalChannelz; import io.grpc.InternalChannelz;
import io.grpc.InternalChannelz.ServerStats; import io.grpc.InternalChannelz.ServerStats;
import io.grpc.InternalChannelz.SocketStats; import io.grpc.InternalChannelz.SocketStats;
import io.grpc.LogId; import io.grpc.InternalInstrumented;
import io.grpc.InternalLogId;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.BenchmarkMode;
@ -43,13 +43,13 @@ public class ChannelzBenchmark {
public InternalChannelz channelz = new InternalChannelz(); public InternalChannelz channelz = new InternalChannelz();
public Instrumented<ServerStats> serverToRemove; public InternalInstrumented<ServerStats> serverToRemove;
public Instrumented<ServerStats> serverToAdd; public InternalInstrumented<ServerStats> serverToAdd;
public Instrumented<ServerStats> serverForServerSocket; public InternalInstrumented<ServerStats> serverForServerSocket;
public Instrumented<SocketStats> serverSocketToAdd; public InternalInstrumented<SocketStats> serverSocketToAdd;
public Instrumented<SocketStats> serverSocketToRemove; public InternalInstrumented<SocketStats> serverSocketToRemove;
/** /**
* Javadoc. * Javadoc.
@ -76,11 +76,11 @@ public class ChannelzBenchmark {
private void populate(int count) { private void populate(int count) {
for (int i = 0; i < count; i++) { for (int i = 0; i < count; i++) {
// for addNavigable / removeNavigable // for addNavigable / removeNavigable
Instrumented<ServerStats> srv = create(); InternalInstrumented<ServerStats> srv = create();
channelz.addServer(srv); channelz.addServer(srv);
// for add / remove // for add / remove
Instrumented<SocketStats> sock = create(); InternalInstrumented<SocketStats> sock = create();
channelz.addClientSocket(sock); channelz.addClientSocket(sock);
// for addServerSocket / removeServerSocket // for addServerSocket / removeServerSocket
@ -130,9 +130,9 @@ public class ChannelzBenchmark {
channelz.removeServerSocket(serverForServerSocket, serverSocketToRemove); channelz.removeServerSocket(serverForServerSocket, serverSocketToRemove);
} }
private static <T> Instrumented<T> create() { private static <T> InternalInstrumented<T> create() {
return new Instrumented<T>() { return new InternalInstrumented<T>() {
final LogId id = LogId.allocate("fake-tag"); final InternalLogId id = InternalLogId.allocate("fake-tag");
@Override @Override
public ListenableFuture<T> getStats() { public ListenableFuture<T> getStats() {
@ -140,7 +140,7 @@ public class ChannelzBenchmark {
} }
@Override @Override
public LogId getLogId() { public InternalLogId getLogId() {
return id; return id;
} }
}; };

View File

@ -49,21 +49,21 @@ public final class InternalChannelz {
private static final Logger log = Logger.getLogger(InternalChannelz.class.getName()); private static final Logger log = Logger.getLogger(InternalChannelz.class.getName());
private static final InternalChannelz INSTANCE = new InternalChannelz(); private static final InternalChannelz INSTANCE = new InternalChannelz();
private final ConcurrentNavigableMap<Long, Instrumented<ServerStats>> servers private final ConcurrentNavigableMap<Long, InternalInstrumented<ServerStats>> servers
= new ConcurrentSkipListMap<Long, Instrumented<ServerStats>>(); = new ConcurrentSkipListMap<Long, InternalInstrumented<ServerStats>>();
private final ConcurrentNavigableMap<Long, Instrumented<ChannelStats>> rootChannels private final ConcurrentNavigableMap<Long, InternalInstrumented<ChannelStats>> rootChannels
= new ConcurrentSkipListMap<Long, Instrumented<ChannelStats>>(); = new ConcurrentSkipListMap<Long, InternalInstrumented<ChannelStats>>();
private final ConcurrentMap<Long, Instrumented<ChannelStats>> subchannels private final ConcurrentMap<Long, InternalInstrumented<ChannelStats>> subchannels
= new ConcurrentHashMap<Long, Instrumented<ChannelStats>>(); = new ConcurrentHashMap<Long, InternalInstrumented<ChannelStats>>();
// An InProcessTransport can appear in both otherSockets and perServerSockets simultaneously // An InProcessTransport can appear in both otherSockets and perServerSockets simultaneously
private final ConcurrentMap<Long, Instrumented<SocketStats>> otherSockets private final ConcurrentMap<Long, InternalInstrumented<SocketStats>> otherSockets
= new ConcurrentHashMap<Long, Instrumented<SocketStats>>(); = new ConcurrentHashMap<Long, InternalInstrumented<SocketStats>>();
private final ConcurrentMap<Long, ServerSocketMap> perServerSockets private final ConcurrentMap<Long, ServerSocketMap> perServerSockets
= new ConcurrentHashMap<Long, ServerSocketMap>(); = new ConcurrentHashMap<Long, ServerSocketMap>();
// A convenience class to avoid deeply nested types. // A convenience class to avoid deeply nested types.
private static final class ServerSocketMap private static final class ServerSocketMap
extends ConcurrentSkipListMap<Long, Instrumented<SocketStats>> { extends ConcurrentSkipListMap<Long, InternalInstrumented<SocketStats>> {
private static final long serialVersionUID = -7883772124944661414L; private static final long serialVersionUID = -7883772124944661414L;
} }
@ -76,65 +76,66 @@ public final class InternalChannelz {
} }
/** Adds a server. */ /** Adds a server. */
public void addServer(Instrumented<ServerStats> server) { public void addServer(InternalInstrumented<ServerStats> server) {
ServerSocketMap prev = perServerSockets.put(id(server), new ServerSocketMap()); ServerSocketMap prev = perServerSockets.put(id(server), new ServerSocketMap());
assert prev == null; assert prev == null;
add(servers, server); add(servers, server);
} }
/** Adds a subchannel. */ /** Adds a subchannel. */
public void addSubchannel(Instrumented<ChannelStats> subchannel) { public void addSubchannel(InternalInstrumented<ChannelStats> subchannel) {
add(subchannels, subchannel); add(subchannels, subchannel);
} }
/** Adds a root channel. */ /** Adds a root channel. */
public void addRootChannel(Instrumented<ChannelStats> rootChannel) { public void addRootChannel(InternalInstrumented<ChannelStats> rootChannel) {
add(rootChannels, rootChannel); add(rootChannels, rootChannel);
} }
/** Adds a socket. */ /** Adds a socket. */
public void addClientSocket(Instrumented<SocketStats> socket) { public void addClientSocket(InternalInstrumented<SocketStats> socket) {
add(otherSockets, socket); add(otherSockets, socket);
} }
public void addListenSocket(Instrumented<SocketStats> socket) { public void addListenSocket(InternalInstrumented<SocketStats> socket) {
add(otherSockets, socket); add(otherSockets, socket);
} }
/** Adds a server socket. */ /** Adds a server socket. */
public void addServerSocket(Instrumented<ServerStats> server, Instrumented<SocketStats> socket) { public void addServerSocket(
InternalInstrumented<ServerStats> server, InternalInstrumented<SocketStats> socket) {
ServerSocketMap serverSockets = perServerSockets.get(id(server)); ServerSocketMap serverSockets = perServerSockets.get(id(server));
assert serverSockets != null; assert serverSockets != null;
add(serverSockets, socket); add(serverSockets, socket);
} }
/** Removes a server. */ /** Removes a server. */
public void removeServer(Instrumented<ServerStats> server) { public void removeServer(InternalInstrumented<ServerStats> server) {
remove(servers, server); remove(servers, server);
ServerSocketMap prev = perServerSockets.remove(id(server)); ServerSocketMap prev = perServerSockets.remove(id(server));
assert prev != null; assert prev != null;
assert prev.isEmpty(); assert prev.isEmpty();
} }
public void removeSubchannel(Instrumented<ChannelStats> subchannel) { public void removeSubchannel(InternalInstrumented<ChannelStats> subchannel) {
remove(subchannels, subchannel); remove(subchannels, subchannel);
} }
public void removeRootChannel(Instrumented<ChannelStats> channel) { public void removeRootChannel(InternalInstrumented<ChannelStats> channel) {
remove(rootChannels, channel); remove(rootChannels, channel);
} }
public void removeClientSocket(Instrumented<SocketStats> socket) { public void removeClientSocket(InternalInstrumented<SocketStats> socket) {
remove(otherSockets, socket); remove(otherSockets, socket);
} }
public void removeListenSocket(Instrumented<SocketStats> socket) { public void removeListenSocket(InternalInstrumented<SocketStats> socket) {
remove(otherSockets, socket); remove(otherSockets, socket);
} }
/** Removes a server socket. */ /** Removes a server socket. */
public void removeServerSocket( public void removeServerSocket(
Instrumented<ServerStats> server, Instrumented<SocketStats> socket) { InternalInstrumented<ServerStats> server, InternalInstrumented<SocketStats> socket) {
ServerSocketMap socketsOfServer = perServerSockets.get(id(server)); ServerSocketMap socketsOfServer = perServerSockets.get(id(server));
assert socketsOfServer != null; assert socketsOfServer != null;
remove(socketsOfServer, socket); remove(socketsOfServer, socket);
@ -142,8 +143,9 @@ public final class InternalChannelz {
/** Returns a {@link RootChannelList}. */ /** Returns a {@link RootChannelList}. */
public RootChannelList getRootChannels(long fromId, int maxPageSize) { public RootChannelList getRootChannels(long fromId, int maxPageSize) {
List<Instrumented<ChannelStats>> channelList = new ArrayList<Instrumented<ChannelStats>>(); List<InternalInstrumented<ChannelStats>> channelList
Iterator<Instrumented<ChannelStats>> iterator = new ArrayList<InternalInstrumented<ChannelStats>>();
Iterator<InternalInstrumented<ChannelStats>> iterator
= rootChannels.tailMap(fromId).values().iterator(); = rootChannels.tailMap(fromId).values().iterator();
while (iterator.hasNext() && channelList.size() < maxPageSize) { while (iterator.hasNext() && channelList.size() < maxPageSize) {
@ -154,21 +156,22 @@ public final class InternalChannelz {
/** Returns a channel. */ /** Returns a channel. */
@Nullable @Nullable
public Instrumented<ChannelStats> getChannel(long id) { public InternalInstrumented<ChannelStats> getChannel(long id) {
return rootChannels.get(id); return rootChannels.get(id);
} }
/** Returns a subchannel. */ /** Returns a subchannel. */
@Nullable @Nullable
public Instrumented<ChannelStats> getSubchannel(long id) { public InternalInstrumented<ChannelStats> getSubchannel(long id) {
return subchannels.get(id); return subchannels.get(id);
} }
/** Returns a server list. */ /** Returns a server list. */
public ServerList getServers(long fromId, int maxPageSize) { public ServerList getServers(long fromId, int maxPageSize) {
List<Instrumented<ServerStats>> serverList List<InternalInstrumented<ServerStats>> serverList
= new ArrayList<Instrumented<ServerStats>>(maxPageSize); = new ArrayList<InternalInstrumented<ServerStats>>(maxPageSize);
Iterator<Instrumented<ServerStats>> iterator = servers.tailMap(fromId).values().iterator(); Iterator<InternalInstrumented<ServerStats>> iterator
= servers.tailMap(fromId).values().iterator();
while (iterator.hasNext() && serverList.size() < maxPageSize) { while (iterator.hasNext() && serverList.size() < maxPageSize) {
serverList.add(iterator.next()); serverList.add(iterator.next());
@ -183,8 +186,8 @@ public final class InternalChannelz {
if (serverSockets == null) { if (serverSockets == null) {
return null; return null;
} }
List<WithLogId> socketList = new ArrayList<WithLogId>(maxPageSize); List<InternalWithLogId> socketList = new ArrayList<InternalWithLogId>(maxPageSize);
Iterator<Instrumented<SocketStats>> iterator Iterator<InternalInstrumented<SocketStats>> iterator
= serverSockets.tailMap(fromId).values().iterator(); = serverSockets.tailMap(fromId).values().iterator();
while (socketList.size() < maxPageSize && iterator.hasNext()) { while (socketList.size() < maxPageSize && iterator.hasNext()) {
socketList.add(iterator.next()); socketList.add(iterator.next());
@ -194,17 +197,17 @@ public final class InternalChannelz {
/** Returns a socket. */ /** Returns a socket. */
@Nullable @Nullable
public Instrumented<SocketStats> getSocket(long id) { public InternalInstrumented<SocketStats> getSocket(long id) {
Instrumented<SocketStats> clientSocket = otherSockets.get(id); InternalInstrumented<SocketStats> clientSocket = otherSockets.get(id);
if (clientSocket != null) { if (clientSocket != null) {
return clientSocket; return clientSocket;
} }
return getServerSocket(id); return getServerSocket(id);
} }
private Instrumented<SocketStats> getServerSocket(long id) { private InternalInstrumented<SocketStats> getServerSocket(long id) {
for (ServerSocketMap perServerSockets : perServerSockets.values()) { for (ServerSocketMap perServerSockets : perServerSockets.values()) {
Instrumented<SocketStats> serverSocket = perServerSockets.get(id); InternalInstrumented<SocketStats> serverSocket = perServerSockets.get(id);
if (serverSocket != null) { if (serverSocket != null) {
return serverSocket; return serverSocket;
} }
@ -213,66 +216,67 @@ public final class InternalChannelz {
} }
@VisibleForTesting @VisibleForTesting
public boolean containsServer(LogId serverRef) { public boolean containsServer(InternalLogId serverRef) {
return contains(servers, serverRef); return contains(servers, serverRef);
} }
@VisibleForTesting @VisibleForTesting
public boolean containsSubchannel(LogId subchannelRef) { public boolean containsSubchannel(InternalLogId subchannelRef) {
return contains(subchannels, subchannelRef); return contains(subchannels, subchannelRef);
} }
public Instrumented<ChannelStats> getRootChannel(long id) { public InternalInstrumented<ChannelStats> getRootChannel(long id) {
return rootChannels.get(id); return rootChannels.get(id);
} }
@VisibleForTesting @VisibleForTesting
public boolean containsClientSocket(LogId transportRef) { public boolean containsClientSocket(InternalLogId transportRef) {
return contains(otherSockets, transportRef); return contains(otherSockets, transportRef);
} }
private static <T extends Instrumented<?>> void add(Map<Long, T> map, T object) { private static <T extends InternalInstrumented<?>> void add(Map<Long, T> map, T object) {
T prev = map.put(object.getLogId().getId(), object); T prev = map.put(object.getLogId().getId(), object);
assert prev == null; assert prev == null;
} }
private static <T extends Instrumented<?>> void remove(Map<Long, T> map, T object) { private static <T extends InternalInstrumented<?>> void remove(Map<Long, T> map, T object) {
T prev = map.remove(id(object)); T prev = map.remove(id(object));
assert prev != null; assert prev != null;
} }
private static <T extends Instrumented<?>> boolean contains(Map<Long, T> map, LogId id) { private static <T extends InternalInstrumented<?>> boolean contains(
Map<Long, T> map, InternalLogId id) {
return map.containsKey(id.getId()); return map.containsKey(id.getId());
} }
public static final class RootChannelList { public static final class RootChannelList {
public final List<Instrumented<ChannelStats>> channels; public final List<InternalInstrumented<ChannelStats>> channels;
public final boolean end; public final boolean end;
/** Creates an instance. */ /** Creates an instance. */
public RootChannelList(List<Instrumented<ChannelStats>> channels, boolean end) { public RootChannelList(List<InternalInstrumented<ChannelStats>> channels, boolean end) {
this.channels = checkNotNull(channels); this.channels = checkNotNull(channels);
this.end = end; this.end = end;
} }
} }
public static final class ServerList { public static final class ServerList {
public final List<Instrumented<ServerStats>> servers; public final List<InternalInstrumented<ServerStats>> servers;
public final boolean end; public final boolean end;
/** Creates an instance. */ /** Creates an instance. */
public ServerList(List<Instrumented<ServerStats>> servers, boolean end) { public ServerList(List<InternalInstrumented<ServerStats>> servers, boolean end) {
this.servers = checkNotNull(servers); this.servers = checkNotNull(servers);
this.end = end; this.end = end;
} }
} }
public static final class ServerSocketsList { public static final class ServerSocketsList {
public final List<WithLogId> sockets; public final List<InternalWithLogId> sockets;
public final boolean end; public final boolean end;
/** Creates an instance. */ /** Creates an instance. */
public ServerSocketsList(List<WithLogId> sockets, boolean end) { public ServerSocketsList(List<InternalWithLogId> sockets, boolean end) {
this.sockets = sockets; this.sockets = sockets;
this.end = end; this.end = end;
} }
@ -284,7 +288,7 @@ public final class InternalChannelz {
public final long callsSucceeded; public final long callsSucceeded;
public final long callsFailed; public final long callsFailed;
public final long lastCallStartedNanos; public final long lastCallStartedNanos;
public final List<Instrumented<SocketStats>> listenSockets; public final List<InternalInstrumented<SocketStats>> listenSockets;
/** /**
* Creates an instance. * Creates an instance.
@ -294,7 +298,7 @@ public final class InternalChannelz {
long callsSucceeded, long callsSucceeded,
long callsFailed, long callsFailed,
long lastCallStartedNanos, long lastCallStartedNanos,
List<Instrumented<SocketStats>> listenSockets) { List<InternalInstrumented<SocketStats>> listenSockets) {
this.callsStarted = callsStarted; this.callsStarted = callsStarted;
this.callsSucceeded = callsSucceeded; this.callsSucceeded = callsSucceeded;
this.callsFailed = callsFailed; this.callsFailed = callsFailed;
@ -307,7 +311,7 @@ public final class InternalChannelz {
private long callsSucceeded; private long callsSucceeded;
private long callsFailed; private long callsFailed;
private long lastCallStartedNanos; private long lastCallStartedNanos;
public List<Instrumented<SocketStats>> listenSockets = Collections.emptyList(); public List<InternalInstrumented<SocketStats>> listenSockets = Collections.emptyList();
public Builder setCallsStarted(long callsStarted) { public Builder setCallsStarted(long callsStarted) {
this.callsStarted = callsStarted; this.callsStarted = callsStarted;
@ -330,10 +334,10 @@ public final class InternalChannelz {
} }
/** Sets the listen sockets. */ /** Sets the listen sockets. */
public Builder setListenSockets(List<Instrumented<SocketStats>> listenSockets) { public Builder setListenSockets(List<InternalInstrumented<SocketStats>> listenSockets) {
checkNotNull(listenSockets); checkNotNull(listenSockets);
this.listenSockets = Collections.unmodifiableList( this.listenSockets = Collections.unmodifiableList(
new ArrayList<Instrumented<SocketStats>>(listenSockets)); new ArrayList<InternalInstrumented<SocketStats>>(listenSockets));
return this; return this;
} }
@ -363,8 +367,8 @@ public final class InternalChannelz {
public final long callsSucceeded; public final long callsSucceeded;
public final long callsFailed; public final long callsFailed;
public final long lastCallStartedNanos; public final long lastCallStartedNanos;
public final List<WithLogId> subchannels; public final List<InternalWithLogId> subchannels;
public final List<WithLogId> sockets; public final List<InternalWithLogId> sockets;
/** /**
* Creates an instance. * Creates an instance.
@ -377,8 +381,8 @@ public final class InternalChannelz {
long callsSucceeded, long callsSucceeded,
long callsFailed, long callsFailed,
long lastCallStartedNanos, long lastCallStartedNanos,
List<WithLogId> subchannels, List<InternalWithLogId> subchannels,
List<WithLogId> sockets) { List<InternalWithLogId> sockets) {
checkState( checkState(
subchannels.isEmpty() || sockets.isEmpty(), subchannels.isEmpty() || sockets.isEmpty(),
"channels can have subchannels only, subchannels can have either sockets OR subchannels, " "channels can have subchannels only, subchannels can have either sockets OR subchannels, "
@ -402,8 +406,8 @@ public final class InternalChannelz {
private long callsSucceeded; private long callsSucceeded;
private long callsFailed; private long callsFailed;
private long lastCallStartedNanos; private long lastCallStartedNanos;
private List<WithLogId> subchannels = Collections.emptyList(); private List<InternalWithLogId> subchannels = Collections.emptyList();
private List<WithLogId> sockets = Collections.emptyList(); private List<InternalWithLogId> sockets = Collections.emptyList();
public Builder setTarget(String target) { public Builder setTarget(String target) {
this.target = target; this.target = target;
@ -441,14 +445,14 @@ public final class InternalChannelz {
} }
/** Sets the subchannels. */ /** Sets the subchannels. */
public Builder setSubchannels(List<WithLogId> subchannels) { public Builder setSubchannels(List<InternalWithLogId> subchannels) {
checkState(sockets.isEmpty()); checkState(sockets.isEmpty());
this.subchannels = Collections.unmodifiableList(checkNotNull(subchannels)); this.subchannels = Collections.unmodifiableList(checkNotNull(subchannels));
return this; return this;
} }
/** Sets the sockets. */ /** Sets the sockets. */
public Builder setSockets(List<WithLogId> sockets) { public Builder setSockets(List<InternalWithLogId> sockets) {
checkState(subchannels.isEmpty()); checkState(subchannels.isEmpty());
this.sockets = Collections.unmodifiableList(checkNotNull(sockets)); this.sockets = Collections.unmodifiableList(checkNotNull(sockets));
return this; return this;
@ -519,8 +523,8 @@ public final class InternalChannelz {
public final long timestampNanos; public final long timestampNanos;
// the oneof child_ref field in proto: one of channelRef and channelRef // the oneof child_ref field in proto: one of channelRef and channelRef
@Nullable public final WithLogId channelRef; @Nullable public final InternalWithLogId channelRef;
@Nullable public final WithLogId subchannelRef; @Nullable public final InternalWithLogId subchannelRef;
public enum Severity { public enum Severity {
CT_UNKNOWN, CT_INFO, CT_WARNING, CT_ERROR CT_UNKNOWN, CT_INFO, CT_WARNING, CT_ERROR
@ -528,7 +532,7 @@ public final class InternalChannelz {
private Event( private Event(
String description, Severity severity, long timestampNanos, String description, Severity severity, long timestampNanos,
@Nullable WithLogId channelRef, @Nullable WithLogId subchannelRef) { @Nullable InternalWithLogId channelRef, @Nullable InternalWithLogId subchannelRef) {
this.description = description; this.description = description;
this.severity = checkNotNull(severity, "severity"); this.severity = checkNotNull(severity, "severity");
this.timestampNanos = timestampNanos; this.timestampNanos = timestampNanos;
@ -569,8 +573,8 @@ public final class InternalChannelz {
private String description; private String description;
private Severity severity; private Severity severity;
private Long timestampNanos; private Long timestampNanos;
private WithLogId channelRef; private InternalWithLogId channelRef;
private WithLogId subchannelRef; private InternalWithLogId subchannelRef;
public Builder setDescription(String description) { public Builder setDescription(String description) {
this.description = description; this.description = description;
@ -587,12 +591,12 @@ public final class InternalChannelz {
return this; return this;
} }
public Builder setChannelRef(WithLogId channelRef) { public Builder setChannelRef(InternalWithLogId channelRef) {
this.channelRef = channelRef; this.channelRef = channelRef;
return this; return this;
} }
public Builder setSubchannelRef(WithLogId subchannelRef) { public Builder setSubchannelRef(InternalWithLogId subchannelRef) {
this.subchannelRef = subchannelRef; this.subchannelRef = subchannelRef;
return this; return this;
} }
@ -1087,8 +1091,8 @@ public final class InternalChannelz {
} }
} }
/** Unwraps a {@link LogId} to return a {@code long}. */ /** Unwraps a {@link InternalLogId} to return a {@code long}. */
public static long id(WithLogId withLogId) { public static long id(InternalWithLogId withLogId) {
return withLogId.getLogId().getId(); return withLogId.getLogId().getId();
} }
} }

View File

@ -25,7 +25,7 @@ import com.google.common.util.concurrent.ListenableFuture;
* support instrumentation, then the future will return a {@code null}. * support instrumentation, then the future will return a {@code null}.
*/ */
@Internal @Internal
public interface Instrumented<T> extends WithLogId { public interface InternalInstrumented<T> extends InternalWithLogId {
/** /**
* Returns the stats object. * Returns the stats object.

View File

@ -24,15 +24,15 @@ import java.util.concurrent.atomic.AtomicLong;
*<p>An object that has an ID that is unique within the JVM, primarily for debug logging. *<p>An object that has an ID that is unique within the JVM, primarily for debug logging.
*/ */
@Internal @Internal
public final class LogId { public final class InternalLogId {
private static final AtomicLong idAlloc = new AtomicLong(); private static final AtomicLong idAlloc = new AtomicLong();
/** /**
* @param tag a loggable tag associated with this tag. The ID that is allocated is guaranteed * @param tag a loggable tag associated with this tag. The ID that is allocated is guaranteed
* to be unique and increasing, irrespective of the tag. * to be unique and increasing, irrespective of the tag.
*/ */
public static LogId allocate(String tag) { public static InternalLogId allocate(String tag) {
return new LogId(tag, getNextId()); return new InternalLogId(tag, getNextId());
} }
static long getNextId() { static long getNextId() {
@ -42,7 +42,7 @@ public final class LogId {
private final String tag; private final String tag;
private final long id; private final long id;
protected LogId(String tag, long id) { protected InternalLogId(String tag, long id) {
this.tag = tag; this.tag = tag;
this.id = id; this.id = id;
} }

View File

@ -22,7 +22,7 @@ package io.grpc;
* <p>A loggable ID, unique for the duration of the program. * <p>A loggable ID, unique for the duration of the program.
*/ */
@Internal @Internal
public interface WithLogId { public interface InternalWithLogId {
/** /**
* Returns an ID that is primarily used in debug logs. It usually contains the class name and a * Returns an ID that is primarily used in debug logs. It usually contains the class name and a
* numeric ID that is unique among the instances. * numeric ID that is unique among the instances.
@ -30,5 +30,5 @@ public interface WithLogId {
* <p>The subclasses of this interface usually want to include the log ID in their {@link * <p>The subclasses of this interface usually want to include the log ID in their {@link
* #toString} results. * #toString} results.
*/ */
LogId getLogId(); InternalLogId getLogId();
} }

View File

@ -19,8 +19,8 @@ package io.grpc.inprocess;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
import com.google.common.base.MoreObjects; import com.google.common.base.MoreObjects;
import io.grpc.Instrumented;
import io.grpc.InternalChannelz.SocketStats; import io.grpc.InternalChannelz.SocketStats;
import io.grpc.InternalInstrumented;
import io.grpc.ServerStreamTracer; import io.grpc.ServerStreamTracer;
import io.grpc.internal.InternalServer; import io.grpc.internal.InternalServer;
import io.grpc.internal.ObjectPool; import io.grpc.internal.ObjectPool;
@ -80,7 +80,7 @@ final class InProcessServer implements InternalServer {
} }
@Override @Override
public List<Instrumented<SocketStats>> getListenSockets() { public List<InternalInstrumented<SocketStats>> getListenSockets() {
return Collections.emptyList(); return Collections.emptyList();
} }

View File

@ -32,7 +32,7 @@ import io.grpc.Decompressor;
import io.grpc.DecompressorRegistry; import io.grpc.DecompressorRegistry;
import io.grpc.Grpc; import io.grpc.Grpc;
import io.grpc.InternalChannelz.SocketStats; import io.grpc.InternalChannelz.SocketStats;
import io.grpc.LogId; import io.grpc.InternalLogId;
import io.grpc.Metadata; import io.grpc.Metadata;
import io.grpc.MethodDescriptor; import io.grpc.MethodDescriptor;
import io.grpc.SecurityLevel; import io.grpc.SecurityLevel;
@ -71,7 +71,7 @@ import javax.annotation.concurrent.ThreadSafe;
final class InProcessTransport implements ServerTransport, ConnectionClientTransport { final class InProcessTransport implements ServerTransport, ConnectionClientTransport {
private static final Logger log = Logger.getLogger(InProcessTransport.class.getName()); private static final Logger log = Logger.getLogger(InProcessTransport.class.getName());
private final LogId logId = LogId.allocate(getClass().getName()); private final InternalLogId logId = InternalLogId.allocate(getClass().getName());
private final String name; private final String name;
private final String authority; private final String authority;
private final String userAgent; private final String userAgent;
@ -223,7 +223,7 @@ final class InProcessTransport implements ServerTransport, ConnectionClientTrans
} }
@Override @Override
public LogId getLogId() { public InternalLogId getLogId() {
return logId; return logId;
} }

View File

@ -17,8 +17,8 @@
package io.grpc.internal; package io.grpc.internal;
import com.google.common.annotations.VisibleForTesting; import com.google.common.annotations.VisibleForTesting;
import io.grpc.Instrumented;
import io.grpc.InternalChannelz.ChannelStats; import io.grpc.InternalChannelz.ChannelStats;
import io.grpc.InternalInstrumented;
import io.grpc.LoadBalancer; import io.grpc.LoadBalancer;
import javax.annotation.Nullable; import javax.annotation.Nullable;
@ -39,5 +39,5 @@ abstract class AbstractSubchannel extends LoadBalancer.Subchannel {
* unit tests. * unit tests.
*/ */
@VisibleForTesting @VisibleForTesting
abstract Instrumented<ChannelStats> getInternalSubchannel(); abstract InternalInstrumented<ChannelStats> getInternalSubchannel();
} }

View File

@ -17,8 +17,8 @@
package io.grpc.internal; package io.grpc.internal;
import io.grpc.CallOptions; import io.grpc.CallOptions;
import io.grpc.Instrumented;
import io.grpc.InternalChannelz.SocketStats; import io.grpc.InternalChannelz.SocketStats;
import io.grpc.InternalInstrumented;
import io.grpc.Metadata; import io.grpc.Metadata;
import io.grpc.MethodDescriptor; import io.grpc.MethodDescriptor;
import java.util.concurrent.Executor; import java.util.concurrent.Executor;
@ -31,7 +31,7 @@ import javax.annotation.concurrent.ThreadSafe;
* are expected to execute quickly. * are expected to execute quickly.
*/ */
@ThreadSafe @ThreadSafe
public interface ClientTransport extends Instrumented<SocketStats> { public interface ClientTransport extends InternalInstrumented<SocketStats> {
/** /**
* Creates a new stream for sending messages to a remote end-point. * Creates a new stream for sending messages to a remote end-point.

View File

@ -22,10 +22,10 @@ import com.google.common.util.concurrent.SettableFuture;
import io.grpc.CallOptions; import io.grpc.CallOptions;
import io.grpc.Context; import io.grpc.Context;
import io.grpc.InternalChannelz.SocketStats; import io.grpc.InternalChannelz.SocketStats;
import io.grpc.InternalLogId;
import io.grpc.LoadBalancer.PickResult; import io.grpc.LoadBalancer.PickResult;
import io.grpc.LoadBalancer.PickSubchannelArgs; import io.grpc.LoadBalancer.PickSubchannelArgs;
import io.grpc.LoadBalancer.SubchannelPicker; import io.grpc.LoadBalancer.SubchannelPicker;
import io.grpc.LogId;
import io.grpc.Metadata; import io.grpc.Metadata;
import io.grpc.MethodDescriptor; import io.grpc.MethodDescriptor;
import io.grpc.Status; import io.grpc.Status;
@ -48,7 +48,7 @@ import javax.annotation.concurrent.GuardedBy;
* thus the delayed transport stops owning the stream. * thus the delayed transport stops owning the stream.
*/ */
final class DelayedClientTransport implements ManagedClientTransport { final class DelayedClientTransport implements ManagedClientTransport {
private final LogId lodId = LogId.allocate(getClass().getName()); private final InternalLogId lodId = InternalLogId.allocate(getClass().getName());
private final Object lock = new Object(); private final Object lock = new Object();
@ -339,7 +339,7 @@ final class DelayedClientTransport implements ManagedClientTransport {
// TODO(carl-mastrangelo): remove this once the Subchannel change is in. // TODO(carl-mastrangelo): remove this once the Subchannel change is in.
@Override @Override
public LogId getLogId() { public InternalLogId getLogId() {
return lodId; return lodId;
} }

View File

@ -22,7 +22,7 @@ import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.SettableFuture; import com.google.common.util.concurrent.SettableFuture;
import io.grpc.CallOptions; import io.grpc.CallOptions;
import io.grpc.InternalChannelz.SocketStats; import io.grpc.InternalChannelz.SocketStats;
import io.grpc.LogId; import io.grpc.InternalLogId;
import io.grpc.Metadata; import io.grpc.Metadata;
import io.grpc.MethodDescriptor; import io.grpc.MethodDescriptor;
import io.grpc.Status; import io.grpc.Status;
@ -66,7 +66,7 @@ class FailingClientTransport implements ClientTransport {
} }
@Override @Override
public LogId getLogId() { public InternalLogId getLogId() {
throw new UnsupportedOperationException("Not a real transport"); throw new UnsupportedOperationException("Not a real transport");
} }
} }

View File

@ -21,7 +21,7 @@ import com.google.common.util.concurrent.ListenableFuture;
import io.grpc.Attributes; import io.grpc.Attributes;
import io.grpc.CallOptions; import io.grpc.CallOptions;
import io.grpc.InternalChannelz.SocketStats; import io.grpc.InternalChannelz.SocketStats;
import io.grpc.LogId; import io.grpc.InternalLogId;
import io.grpc.Metadata; import io.grpc.Metadata;
import io.grpc.MethodDescriptor; import io.grpc.MethodDescriptor;
import io.grpc.Status; import io.grpc.Status;
@ -55,7 +55,7 @@ abstract class ForwardingConnectionClientTransport implements ConnectionClientTr
} }
@Override @Override
public LogId getLogId() { public InternalLogId getLogId() {
return delegate().getLogId(); return delegate().getLogId();
} }

View File

@ -30,11 +30,11 @@ import com.google.common.util.concurrent.ThreadFactoryBuilder;
import io.grpc.CallOptions; import io.grpc.CallOptions;
import io.grpc.ClientStreamTracer; import io.grpc.ClientStreamTracer;
import io.grpc.InternalChannelz.SocketStats; import io.grpc.InternalChannelz.SocketStats;
import io.grpc.InternalLogId;
import io.grpc.InternalMetadata; import io.grpc.InternalMetadata;
import io.grpc.InternalMetadata.TrustedAsciiMarshaller; import io.grpc.InternalMetadata.TrustedAsciiMarshaller;
import io.grpc.LoadBalancer.PickResult; import io.grpc.LoadBalancer.PickResult;
import io.grpc.LoadBalancer.Subchannel; import io.grpc.LoadBalancer.Subchannel;
import io.grpc.LogId;
import io.grpc.Metadata; import io.grpc.Metadata;
import io.grpc.MethodDescriptor; import io.grpc.MethodDescriptor;
import io.grpc.Status; import io.grpc.Status;
@ -689,7 +689,7 @@ public final class GrpcUtil {
} }
@Override @Override
public LogId getLogId() { public InternalLogId getLogId() {
return transport.getLogId(); return transport.getLogId();
} }

View File

@ -16,8 +16,8 @@
package io.grpc.internal; package io.grpc.internal;
import io.grpc.Instrumented;
import io.grpc.InternalChannelz.SocketStats; import io.grpc.InternalChannelz.SocketStats;
import io.grpc.InternalInstrumented;
import java.io.IOException; import java.io.IOException;
import java.util.List; import java.util.List;
import javax.annotation.concurrent.ThreadSafe; import javax.annotation.concurrent.ThreadSafe;
@ -54,5 +54,5 @@ public interface InternalServer {
/** /**
* Returns the listen sockets of this server. May return an empty list but never returns null. * Returns the listen sockets of this server. May return an empty list but never returns null.
*/ */
List<Instrumented<SocketStats>> getListenSockets(); List<InternalInstrumented<SocketStats>> getListenSockets();
} }

View File

@ -35,15 +35,15 @@ import io.grpc.CallOptions;
import io.grpc.ConnectivityState; import io.grpc.ConnectivityState;
import io.grpc.ConnectivityStateInfo; import io.grpc.ConnectivityStateInfo;
import io.grpc.EquivalentAddressGroup; import io.grpc.EquivalentAddressGroup;
import io.grpc.Instrumented;
import io.grpc.InternalChannelz; import io.grpc.InternalChannelz;
import io.grpc.InternalChannelz.ChannelStats; import io.grpc.InternalChannelz.ChannelStats;
import io.grpc.InternalChannelz.ChannelTrace; import io.grpc.InternalChannelz.ChannelTrace;
import io.grpc.LogId; import io.grpc.InternalInstrumented;
import io.grpc.InternalLogId;
import io.grpc.InternalWithLogId;
import io.grpc.Metadata; import io.grpc.Metadata;
import io.grpc.MethodDescriptor; import io.grpc.MethodDescriptor;
import io.grpc.Status; import io.grpc.Status;
import io.grpc.WithLogId;
import java.net.SocketAddress; import java.net.SocketAddress;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
@ -63,10 +63,10 @@ import javax.annotation.concurrent.ThreadSafe;
* Transports for a single {@link SocketAddress}. * Transports for a single {@link SocketAddress}.
*/ */
@ThreadSafe @ThreadSafe
final class InternalSubchannel implements Instrumented<ChannelStats> { final class InternalSubchannel implements InternalInstrumented<ChannelStats> {
private static final Logger log = Logger.getLogger(InternalSubchannel.class.getName()); private static final Logger log = Logger.getLogger(InternalSubchannel.class.getName());
private final LogId logId = LogId.allocate(getClass().getName()); private final InternalLogId logId = InternalLogId.allocate(getClass().getName());
private final String authority; private final String authority;
private final String userAgent; private final String userAgent;
private final BackoffPolicy.Provider backoffPolicyProvider; private final BackoffPolicy.Provider backoffPolicyProvider;
@ -489,7 +489,7 @@ final class InternalSubchannel implements Instrumented<ChannelStats> {
} }
@Override @Override
public LogId getLogId() { public InternalLogId getLogId() {
return logId; return logId;
} }
@ -500,10 +500,10 @@ final class InternalSubchannel implements Instrumented<ChannelStats> {
ChannelStats.Builder builder = new ChannelStats.Builder(); ChannelStats.Builder builder = new ChannelStats.Builder();
List<EquivalentAddressGroup> addressGroupsSnapshot; List<EquivalentAddressGroup> addressGroupsSnapshot;
List<WithLogId> transportsSnapshot; List<InternalWithLogId> transportsSnapshot;
synchronized (lock) { synchronized (lock) {
addressGroupsSnapshot = addressIndex.getGroups(); addressGroupsSnapshot = addressIndex.getGroups();
transportsSnapshot = new ArrayList<WithLogId>(transports); transportsSnapshot = new ArrayList<InternalWithLogId>(transports);
} }
builder.setTarget(addressGroupsSnapshot.toString()).setState(getState()); builder.setTarget(addressGroupsSnapshot.toString()).setState(getState());

View File

@ -44,21 +44,21 @@ import io.grpc.ConnectivityStateInfo;
import io.grpc.Context; import io.grpc.Context;
import io.grpc.DecompressorRegistry; import io.grpc.DecompressorRegistry;
import io.grpc.EquivalentAddressGroup; import io.grpc.EquivalentAddressGroup;
import io.grpc.Instrumented;
import io.grpc.InternalChannelz; import io.grpc.InternalChannelz;
import io.grpc.InternalChannelz.ChannelStats; import io.grpc.InternalChannelz.ChannelStats;
import io.grpc.InternalChannelz.ChannelTrace; import io.grpc.InternalChannelz.ChannelTrace;
import io.grpc.InternalInstrumented;
import io.grpc.InternalLogId;
import io.grpc.InternalWithLogId;
import io.grpc.LoadBalancer; import io.grpc.LoadBalancer;
import io.grpc.LoadBalancer.PickResult; import io.grpc.LoadBalancer.PickResult;
import io.grpc.LoadBalancer.PickSubchannelArgs; import io.grpc.LoadBalancer.PickSubchannelArgs;
import io.grpc.LoadBalancer.SubchannelPicker; import io.grpc.LoadBalancer.SubchannelPicker;
import io.grpc.LogId;
import io.grpc.ManagedChannel; import io.grpc.ManagedChannel;
import io.grpc.Metadata; import io.grpc.Metadata;
import io.grpc.MethodDescriptor; import io.grpc.MethodDescriptor;
import io.grpc.NameResolver; import io.grpc.NameResolver;
import io.grpc.Status; import io.grpc.Status;
import io.grpc.WithLogId;
import io.grpc.internal.ClientCallImpl.ClientTransportProvider; import io.grpc.internal.ClientCallImpl.ClientTransportProvider;
import io.grpc.internal.RetriableStream.ChannelBufferMeter; import io.grpc.internal.RetriableStream.ChannelBufferMeter;
import io.grpc.internal.RetriableStream.Throttle; import io.grpc.internal.RetriableStream.Throttle;
@ -86,7 +86,8 @@ import javax.annotation.concurrent.ThreadSafe;
/** A communication channel for making outgoing RPCs. */ /** A communication channel for making outgoing RPCs. */
@ThreadSafe @ThreadSafe
final class ManagedChannelImpl extends ManagedChannel implements Instrumented<ChannelStats> { final class ManagedChannelImpl extends ManagedChannel implements
InternalInstrumented<ChannelStats> {
static final Logger logger = Logger.getLogger(ManagedChannelImpl.class.getName()); static final Logger logger = Logger.getLogger(ManagedChannelImpl.class.getName());
// Matching this pattern means the target string is a URI target or at least intended to be one. // Matching this pattern means the target string is a URI target or at least intended to be one.
@ -112,7 +113,7 @@ final class ManagedChannelImpl extends ManagedChannel implements Instrumented<Ch
static final Status SUBCHANNEL_SHUTDOWN_STATUS = static final Status SUBCHANNEL_SHUTDOWN_STATUS =
Status.UNAVAILABLE.withDescription("Subchannel shutdown invoked"); Status.UNAVAILABLE.withDescription("Subchannel shutdown invoked");
private final LogId logId = LogId.allocate(getClass().getName()); private final InternalLogId logId = InternalLogId.allocate(getClass().getName());
private final String target; private final String target;
private final NameResolver.Factory nameResolverFactory; private final NameResolver.Factory nameResolverFactory;
private final Attributes nameResolverParams; private final Attributes nameResolverParams;
@ -307,7 +308,7 @@ final class ManagedChannelImpl extends ManagedChannel implements Instrumented<Ch
channelTracer.updateBuilder(builder); channelTracer.updateBuilder(builder);
} }
builder.setTarget(target).setState(channelStateManager.getState()); builder.setTarget(target).setState(channelStateManager.getState());
List<WithLogId> children = new ArrayList<WithLogId>(); List<InternalWithLogId> children = new ArrayList<InternalWithLogId>();
children.addAll(subchannels); children.addAll(subchannels);
children.addAll(oobChannels); children.addAll(oobChannels);
builder.setSubchannels(children); builder.setSubchannels(children);
@ -318,7 +319,7 @@ final class ManagedChannelImpl extends ManagedChannel implements Instrumented<Ch
} }
@Override @Override
public LogId getLogId() { public InternalLogId getLogId() {
return logId; return logId;
} }
@ -1389,7 +1390,7 @@ final class ManagedChannelImpl extends ManagedChannel implements Instrumented<Ch
} }
@Override @Override
Instrumented<ChannelStats> getInternalSubchannel() { InternalInstrumented<ChannelStats> getInternalSubchannel() {
return subchannel; return subchannel;
} }

View File

@ -30,21 +30,21 @@ import io.grpc.ConnectivityState;
import io.grpc.ConnectivityStateInfo; import io.grpc.ConnectivityStateInfo;
import io.grpc.Context; import io.grpc.Context;
import io.grpc.EquivalentAddressGroup; import io.grpc.EquivalentAddressGroup;
import io.grpc.Instrumented;
import io.grpc.InternalChannelz; import io.grpc.InternalChannelz;
import io.grpc.InternalChannelz.ChannelStats; import io.grpc.InternalChannelz.ChannelStats;
import io.grpc.InternalChannelz.ChannelTrace; import io.grpc.InternalChannelz.ChannelTrace;
import io.grpc.InternalInstrumented;
import io.grpc.InternalLogId;
import io.grpc.InternalWithLogId;
import io.grpc.LoadBalancer; import io.grpc.LoadBalancer;
import io.grpc.LoadBalancer.PickResult; import io.grpc.LoadBalancer.PickResult;
import io.grpc.LoadBalancer.PickSubchannelArgs; import io.grpc.LoadBalancer.PickSubchannelArgs;
import io.grpc.LoadBalancer.Subchannel; import io.grpc.LoadBalancer.Subchannel;
import io.grpc.LoadBalancer.SubchannelPicker; import io.grpc.LoadBalancer.SubchannelPicker;
import io.grpc.LogId;
import io.grpc.ManagedChannel; import io.grpc.ManagedChannel;
import io.grpc.Metadata; import io.grpc.Metadata;
import io.grpc.MethodDescriptor; import io.grpc.MethodDescriptor;
import io.grpc.Status; import io.grpc.Status;
import io.grpc.WithLogId;
import io.grpc.internal.ClientCallImpl.ClientTransportProvider; import io.grpc.internal.ClientCallImpl.ClientTransportProvider;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
@ -63,14 +63,14 @@ import javax.annotation.concurrent.ThreadSafe;
* to its own RPC needs. * to its own RPC needs.
*/ */
@ThreadSafe @ThreadSafe
final class OobChannel extends ManagedChannel implements Instrumented<ChannelStats> { final class OobChannel extends ManagedChannel implements InternalInstrumented<ChannelStats> {
private static final Logger log = Logger.getLogger(OobChannel.class.getName()); private static final Logger log = Logger.getLogger(OobChannel.class.getName());
private InternalSubchannel subchannel; private InternalSubchannel subchannel;
private AbstractSubchannel subchannelImpl; private AbstractSubchannel subchannelImpl;
private SubchannelPicker subchannelPicker; private SubchannelPicker subchannelPicker;
private final LogId logId = LogId.allocate(getClass().getName()); private final InternalLogId logId = InternalLogId.allocate(getClass().getName());
private final String authority; private final String authority;
private final DelayedClientTransport delayedTransport; private final DelayedClientTransport delayedTransport;
private final InternalChannelz channelz; private final InternalChannelz channelz;
@ -154,7 +154,7 @@ final class OobChannel extends ManagedChannel implements Instrumented<ChannelSta
} }
@Override @Override
Instrumented<ChannelStats> getInternalSubchannel() { InternalInstrumented<ChannelStats> getInternalSubchannel() {
return subchannel; return subchannel;
} }
@ -299,13 +299,13 @@ final class OobChannel extends ManagedChannel implements Instrumented<ChannelSta
builder builder
.setTarget(authority) .setTarget(authority)
.setState(subchannel.getState()) .setState(subchannel.getState())
.setSubchannels(Collections.<WithLogId>singletonList(subchannel)); .setSubchannels(Collections.<InternalWithLogId>singletonList(subchannel));
ret.set(builder.build()); ret.set(builder.build());
return ret; return ret;
} }
@Override @Override
public LogId getLogId() { public InternalLogId getLogId() {
return logId; return logId;
} }

View File

@ -36,11 +36,11 @@ import io.grpc.Context;
import io.grpc.Decompressor; import io.grpc.Decompressor;
import io.grpc.DecompressorRegistry; import io.grpc.DecompressorRegistry;
import io.grpc.HandlerRegistry; import io.grpc.HandlerRegistry;
import io.grpc.Instrumented;
import io.grpc.InternalChannelz; import io.grpc.InternalChannelz;
import io.grpc.InternalChannelz.ServerStats; import io.grpc.InternalChannelz.ServerStats;
import io.grpc.InternalInstrumented;
import io.grpc.InternalLogId;
import io.grpc.InternalServerInterceptors; import io.grpc.InternalServerInterceptors;
import io.grpc.LogId;
import io.grpc.Metadata; import io.grpc.Metadata;
import io.grpc.ServerCall; import io.grpc.ServerCall;
import io.grpc.ServerCallHandler; import io.grpc.ServerCallHandler;
@ -78,11 +78,11 @@ import javax.annotation.concurrent.GuardedBy;
* <p>Starting the server starts the underlying transport for servicing requests. Stopping the * <p>Starting the server starts the underlying transport for servicing requests. Stopping the
* server stops servicing new requests and waits for all connections to terminate. * server stops servicing new requests and waits for all connections to terminate.
*/ */
public final class ServerImpl extends io.grpc.Server implements Instrumented<ServerStats> { public final class ServerImpl extends io.grpc.Server implements InternalInstrumented<ServerStats> {
private static final Logger log = Logger.getLogger(ServerImpl.class.getName()); private static final Logger log = Logger.getLogger(ServerImpl.class.getName());
private static final ServerStreamListener NOOP_LISTENER = new NoopListener(); private static final ServerStreamListener NOOP_LISTENER = new NoopListener();
private final LogId logId = LogId.allocate(getClass().getName()); private final InternalLogId logId = InternalLogId.allocate(getClass().getName());
private final ObjectPool<? extends Executor> executorPool; private final ObjectPool<? extends Executor> executorPool;
/** Executor for application processing. Safe to read after {@link #start()}. */ /** Executor for application processing. Safe to read after {@link #start()}. */
private Executor executor; private Executor executor;
@ -570,7 +570,7 @@ public final class ServerImpl extends io.grpc.Server implements Instrumented<Ser
} }
@Override @Override
public LogId getLogId() { public InternalLogId getLogId() {
return logId; return logId;
} }

View File

@ -16,13 +16,13 @@
package io.grpc.internal; package io.grpc.internal;
import io.grpc.Instrumented;
import io.grpc.InternalChannelz.SocketStats; import io.grpc.InternalChannelz.SocketStats;
import io.grpc.InternalInstrumented;
import io.grpc.Status; import io.grpc.Status;
import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledExecutorService;
/** An inbound connection. */ /** An inbound connection. */
public interface ServerTransport extends Instrumented<SocketStats> { public interface ServerTransport extends InternalInstrumented<SocketStats> {
/** /**
* Initiates an orderly shutdown of the transport. Existing streams continue, but new streams will * Initiates an orderly shutdown of the transport. Existing streams continue, but new streams will
* eventually begin failing. New streams "eventually" begin failing because shutdown may need to * eventually begin failing. New streams "eventually" begin failing because shutdown may need to

View File

@ -55,7 +55,7 @@ public final class InternalChannelzTest {
@Test @Test
public void getRootChannels_onePage() { public void getRootChannels_onePage() {
Instrumented<ChannelStats> root1 = create(); InternalInstrumented<ChannelStats> root1 = create();
channelz.addRootChannel(root1); channelz.addRootChannel(root1);
RootChannelList page = channelz.getRootChannels(/*fromId=*/ 0, /*maxPageSize=*/ 1); RootChannelList page = channelz.getRootChannels(/*fromId=*/ 0, /*maxPageSize=*/ 1);
assertTrue(page.end); assertTrue(page.end);
@ -64,8 +64,8 @@ public final class InternalChannelzTest {
@Test @Test
public void getRootChannels_onePage_multi() { public void getRootChannels_onePage_multi() {
Instrumented<ChannelStats> root1 = create(); InternalInstrumented<ChannelStats> root1 = create();
Instrumented<ChannelStats> root2 = create(); InternalInstrumented<ChannelStats> root2 = create();
channelz.addRootChannel(root1); channelz.addRootChannel(root1);
channelz.addRootChannel(root2); channelz.addRootChannel(root2);
RootChannelList page = channelz.getRootChannels(/*fromId=*/ 0, /*maxPageSize=*/ 2); RootChannelList page = channelz.getRootChannels(/*fromId=*/ 0, /*maxPageSize=*/ 2);
@ -75,8 +75,8 @@ public final class InternalChannelzTest {
@Test @Test
public void getRootChannels_paginate() { public void getRootChannels_paginate() {
Instrumented<ChannelStats> root1 = create(); InternalInstrumented<ChannelStats> root1 = create();
Instrumented<ChannelStats> root2 = create(); InternalInstrumented<ChannelStats> root2 = create();
channelz.addRootChannel(root1); channelz.addRootChannel(root1);
channelz.addRootChannel(root2); channelz.addRootChannel(root2);
RootChannelList page1 = channelz.getRootChannels(/*fromId=*/ 0, /*maxPageSize=*/ 1); RootChannelList page1 = channelz.getRootChannels(/*fromId=*/ 0, /*maxPageSize=*/ 1);
@ -90,7 +90,7 @@ public final class InternalChannelzTest {
@Test @Test
public void getRootChannels_remove() { public void getRootChannels_remove() {
Instrumented<ChannelStats> root1 = create(); InternalInstrumented<ChannelStats> root1 = create();
channelz.addRootChannel(root1); channelz.addRootChannel(root1);
channelz.removeRootChannel(root1); channelz.removeRootChannel(root1);
RootChannelList page = channelz.getRootChannels(/*fromId=*/ 0, /*maxPageSize=*/ 1); RootChannelList page = channelz.getRootChannels(/*fromId=*/ 0, /*maxPageSize=*/ 1);
@ -100,7 +100,7 @@ public final class InternalChannelzTest {
@Test @Test
public void getRootChannels_addAfterLastPage() { public void getRootChannels_addAfterLastPage() {
Instrumented<ChannelStats> root1 = create(); InternalInstrumented<ChannelStats> root1 = create();
{ {
channelz.addRootChannel(root1); channelz.addRootChannel(root1);
RootChannelList page1 = channelz.getRootChannels(/*fromId=*/ 0, /*maxPageSize=*/ 1); RootChannelList page1 = channelz.getRootChannels(/*fromId=*/ 0, /*maxPageSize=*/ 1);
@ -108,7 +108,7 @@ public final class InternalChannelzTest {
assertThat(page1.channels).containsExactly(root1); assertThat(page1.channels).containsExactly(root1);
} }
Instrumented<ChannelStats> root2 = create(); InternalInstrumented<ChannelStats> root2 = create();
{ {
channelz.addRootChannel(root2); channelz.addRootChannel(root2);
RootChannelList page2 RootChannelList page2
@ -127,7 +127,7 @@ public final class InternalChannelzTest {
@Test @Test
public void getServers_onePage() { public void getServers_onePage() {
Instrumented<ServerStats> server1 = create(); InternalInstrumented<ServerStats> server1 = create();
channelz.addServer(server1); channelz.addServer(server1);
ServerList page = channelz.getServers(/*fromId=*/ 0, /*maxPageSize=*/ 1); ServerList page = channelz.getServers(/*fromId=*/ 0, /*maxPageSize=*/ 1);
assertTrue(page.end); assertTrue(page.end);
@ -136,8 +136,8 @@ public final class InternalChannelzTest {
@Test @Test
public void getServers_onePage_multi() { public void getServers_onePage_multi() {
Instrumented<ServerStats> server1 = create(); InternalInstrumented<ServerStats> server1 = create();
Instrumented<ServerStats> server2 = create(); InternalInstrumented<ServerStats> server2 = create();
channelz.addServer(server1); channelz.addServer(server1);
channelz.addServer(server2); channelz.addServer(server2);
ServerList page = channelz.getServers(/*fromId=*/ 0, /*maxPageSize=*/ 2); ServerList page = channelz.getServers(/*fromId=*/ 0, /*maxPageSize=*/ 2);
@ -147,8 +147,8 @@ public final class InternalChannelzTest {
@Test @Test
public void getServers_paginate() { public void getServers_paginate() {
Instrumented<ServerStats> server1 = create(); InternalInstrumented<ServerStats> server1 = create();
Instrumented<ServerStats> server2 = create(); InternalInstrumented<ServerStats> server2 = create();
channelz.addServer(server1); channelz.addServer(server1);
channelz.addServer(server2); channelz.addServer(server2);
ServerList page1 = channelz.getServers(/*fromId=*/ 0, /*maxPageSize=*/ 1); ServerList page1 = channelz.getServers(/*fromId=*/ 0, /*maxPageSize=*/ 1);
@ -162,7 +162,7 @@ public final class InternalChannelzTest {
@Test @Test
public void getServers_remove() { public void getServers_remove() {
Instrumented<ServerStats> server1 = create(); InternalInstrumented<ServerStats> server1 = create();
channelz.addServer(server1); channelz.addServer(server1);
channelz.removeServer(server1); channelz.removeServer(server1);
ServerList page = channelz.getServers(/*fromId=*/ 0, /*maxPageSize=*/ 1); ServerList page = channelz.getServers(/*fromId=*/ 0, /*maxPageSize=*/ 1);
@ -172,7 +172,7 @@ public final class InternalChannelzTest {
@Test @Test
public void getServers_addAfterLastPage() { public void getServers_addAfterLastPage() {
Instrumented<ServerStats> server1 = create(); InternalInstrumented<ServerStats> server1 = create();
{ {
channelz.addServer(server1); channelz.addServer(server1);
ServerList page = channelz.getServers(/*fromId=*/ 0, /*maxPageSize=*/ 1); ServerList page = channelz.getServers(/*fromId=*/ 0, /*maxPageSize=*/ 1);
@ -180,7 +180,7 @@ public final class InternalChannelzTest {
assertThat(page.servers).containsExactly(server1); assertThat(page.servers).containsExactly(server1);
} }
Instrumented<ServerStats> server2 = create(); InternalInstrumented<ServerStats> server2 = create();
{ {
channelz.addServer(server2); channelz.addServer(server2);
ServerList page ServerList page
@ -192,7 +192,7 @@ public final class InternalChannelzTest {
@Test @Test
public void getChannel() { public void getChannel() {
Instrumented<ChannelStats> root = create(); InternalInstrumented<ChannelStats> root = create();
assertNull(channelz.getChannel(id(root))); assertNull(channelz.getChannel(id(root)));
channelz.addRootChannel(root); channelz.addRootChannel(root);
@ -205,7 +205,7 @@ public final class InternalChannelzTest {
@Test @Test
public void getSubchannel() { public void getSubchannel() {
Instrumented<ChannelStats> sub = create(); InternalInstrumented<ChannelStats> sub = create();
assertNull(channelz.getSubchannel(id(sub))); assertNull(channelz.getSubchannel(id(sub)));
channelz.addSubchannel(sub); channelz.addSubchannel(sub);
@ -218,7 +218,7 @@ public final class InternalChannelzTest {
@Test @Test
public void getSocket() { public void getSocket() {
Instrumented<SocketStats> socket = create(); InternalInstrumented<SocketStats> socket = create();
assertNull(channelz.getSocket(id(socket))); assertNull(channelz.getSocket(id(socket)));
channelz.addClientSocket(socket); channelz.addClientSocket(socket);
@ -235,10 +235,10 @@ public final class InternalChannelzTest {
@Test @Test
public void serverSocket() { public void serverSocket() {
Instrumented<ServerStats> server = create(); InternalInstrumented<ServerStats> server = create();
channelz.addServer(server); channelz.addServer(server);
Instrumented<SocketStats> socket = create(); InternalInstrumented<SocketStats> socket = create();
assertEmptyServerSocketsPage(id(server), id(socket)); assertEmptyServerSocketsPage(id(server), id(socket));
channelz.addServerSocket(server, socket); channelz.addServerSocket(server, socket);
@ -254,11 +254,11 @@ public final class InternalChannelzTest {
@Test @Test
public void serverSocket_eachServerSeparate() { public void serverSocket_eachServerSeparate() {
Instrumented<ServerStats> server1 = create(); InternalInstrumented<ServerStats> server1 = create();
Instrumented<ServerStats> server2 = create(); InternalInstrumented<ServerStats> server2 = create();
Instrumented<SocketStats> socket1 = create(); InternalInstrumented<SocketStats> socket1 = create();
Instrumented<SocketStats> socket2 = create(); InternalInstrumented<SocketStats> socket2 = create();
channelz.addServer(server1); channelz.addServer(server1);
channelz.addServer(server2); channelz.addServer(server2);
@ -301,16 +301,16 @@ public final class InternalChannelzTest {
assertThat(emptyPage.sockets).isEmpty(); assertThat(emptyPage.sockets).isEmpty();
} }
private static <T> Instrumented<T> create() { private static <T> InternalInstrumented<T> create() {
return new Instrumented<T>() { return new InternalInstrumented<T>() {
final LogId id = LogId.allocate("fake-tag"); final InternalLogId id = InternalLogId.allocate("fake-tag");
@Override @Override
public ListenableFuture<T> getStats() { public ListenableFuture<T> getStats() {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@Override @Override
public LogId getLogId() { public InternalLogId getLogId() {
return id; return id;
} }
}; };

View File

@ -42,8 +42,8 @@ import io.grpc.Attributes;
import io.grpc.ConnectivityStateInfo; import io.grpc.ConnectivityStateInfo;
import io.grpc.EquivalentAddressGroup; import io.grpc.EquivalentAddressGroup;
import io.grpc.InternalChannelz; import io.grpc.InternalChannelz;
import io.grpc.InternalWithLogId;
import io.grpc.Status; import io.grpc.Status;
import io.grpc.WithLogId;
import io.grpc.internal.InternalSubchannel.CallTracingTransport; import io.grpc.internal.InternalSubchannel.CallTracingTransport;
import io.grpc.internal.InternalSubchannel.Index; import io.grpc.internal.InternalSubchannel.Index;
import io.grpc.internal.TestUtils.MockClientTransportInfo; import io.grpc.internal.TestUtils.MockClientTransportInfo;
@ -983,7 +983,7 @@ public class InternalSubchannelTest {
createInternalSubchannel(addr); createInternalSubchannel(addr);
internalSubchannel.obtainActiveTransport(); internalSubchannel.obtainActiveTransport();
WithLogId registeredTransport InternalWithLogId registeredTransport
= Iterables.getOnlyElement(internalSubchannel.getStats().get().sockets); = Iterables.getOnlyElement(internalSubchannel.getStats().get().sockets);
MockClientTransportInfo actualTransport = Iterables.getOnlyElement(transports); MockClientTransportInfo actualTransport = Iterables.getOnlyElement(transports);
assertEquals(actualTransport.transport.getLogId(), registeredTransport.getLogId()); assertEquals(actualTransport.transport.getLogId(), registeredTransport.getLogId());

View File

@ -68,11 +68,11 @@ import io.grpc.ConnectivityState;
import io.grpc.ConnectivityStateInfo; import io.grpc.ConnectivityStateInfo;
import io.grpc.Context; import io.grpc.Context;
import io.grpc.EquivalentAddressGroup; import io.grpc.EquivalentAddressGroup;
import io.grpc.Instrumented;
import io.grpc.IntegerMarshaller; import io.grpc.IntegerMarshaller;
import io.grpc.InternalChannelz; import io.grpc.InternalChannelz;
import io.grpc.InternalChannelz.ChannelStats; import io.grpc.InternalChannelz.ChannelStats;
import io.grpc.InternalChannelz.ChannelTrace; import io.grpc.InternalChannelz.ChannelTrace;
import io.grpc.InternalInstrumented;
import io.grpc.LoadBalancer; import io.grpc.LoadBalancer;
import io.grpc.LoadBalancer.Helper; import io.grpc.LoadBalancer.Helper;
import io.grpc.LoadBalancer.PickResult; import io.grpc.LoadBalancer.PickResult;
@ -2950,7 +2950,7 @@ public class ManagedChannelImplTest {
} }
private static ChannelStats getStats( private static ChannelStats getStats(
Instrumented<ChannelStats> instrumented) throws Exception { InternalInstrumented<ChannelStats> instrumented) throws Exception {
return instrumented.getStats().get(); return instrumented.getStats().get();
} }

View File

@ -54,13 +54,13 @@ import io.grpc.Compressor;
import io.grpc.Context; import io.grpc.Context;
import io.grpc.Grpc; import io.grpc.Grpc;
import io.grpc.HandlerRegistry; import io.grpc.HandlerRegistry;
import io.grpc.Instrumented;
import io.grpc.IntegerMarshaller; import io.grpc.IntegerMarshaller;
import io.grpc.InternalChannelz; import io.grpc.InternalChannelz;
import io.grpc.InternalChannelz.ServerSocketsList; import io.grpc.InternalChannelz.ServerSocketsList;
import io.grpc.InternalChannelz.SocketStats; import io.grpc.InternalChannelz.SocketStats;
import io.grpc.InternalInstrumented;
import io.grpc.InternalLogId;
import io.grpc.InternalServerInterceptors; import io.grpc.InternalServerInterceptors;
import io.grpc.LogId;
import io.grpc.Metadata; import io.grpc.Metadata;
import io.grpc.MethodDescriptor; import io.grpc.MethodDescriptor;
import io.grpc.ServerCall; import io.grpc.ServerCall;
@ -1364,7 +1364,7 @@ public class ServerImplTest {
} }
@Override @Override
public List<Instrumented<SocketStats>> getListenSockets() { public List<InternalInstrumented<SocketStats>> getListenSockets() {
return Collections.emptyList(); return Collections.emptyList();
} }
@ -1380,7 +1380,7 @@ public class ServerImplTest {
private class SimpleServerTransport implements ServerTransport { private class SimpleServerTransport implements ServerTransport {
ServerTransportListener listener; ServerTransportListener listener;
LogId id = LogId.allocate(getClass().getName()); InternalLogId id = InternalLogId.allocate(getClass().getName());
@Override @Override
public void shutdown() { public void shutdown() {
@ -1393,7 +1393,7 @@ public class ServerImplTest {
} }
@Override @Override
public LogId getLogId() { public InternalLogId getLogId() {
return id; return id;
} }

View File

@ -22,7 +22,7 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when; import static org.mockito.Mockito.when;
import io.grpc.CallOptions; import io.grpc.CallOptions;
import io.grpc.LogId; import io.grpc.InternalLogId;
import io.grpc.Metadata; import io.grpc.Metadata;
import io.grpc.MethodDescriptor; import io.grpc.MethodDescriptor;
import java.net.SocketAddress; import java.net.SocketAddress;
@ -75,7 +75,7 @@ final class TestUtils {
@Override @Override
public ConnectionClientTransport answer(InvocationOnMock invocation) throws Throwable { public ConnectionClientTransport answer(InvocationOnMock invocation) throws Throwable {
final ConnectionClientTransport mockTransport = mock(ConnectionClientTransport.class); final ConnectionClientTransport mockTransport = mock(ConnectionClientTransport.class);
when(mockTransport.getLogId()).thenReturn(LogId.allocate("mocktransport")); when(mockTransport.getLogId()).thenReturn(InternalLogId.allocate("mocktransport"));
when(mockTransport.newStream( when(mockTransport.newStream(
any(MethodDescriptor.class), any(Metadata.class), any(CallOptions.class))) any(MethodDescriptor.class), any(Metadata.class), any(CallOptions.class)))
.thenReturn(mock(ClientStream.class)); .thenReturn(mock(ClientStream.class));

View File

@ -23,7 +23,7 @@ import io.grpc.Attributes;
import io.grpc.CallCredentials; import io.grpc.CallCredentials;
import io.grpc.CallOptions; import io.grpc.CallOptions;
import io.grpc.InternalChannelz.SocketStats; import io.grpc.InternalChannelz.SocketStats;
import io.grpc.LogId; import io.grpc.InternalLogId;
import io.grpc.Metadata; import io.grpc.Metadata;
import io.grpc.MethodDescriptor; import io.grpc.MethodDescriptor;
import io.grpc.SecurityLevel; import io.grpc.SecurityLevel;
@ -46,7 +46,7 @@ import javax.annotation.concurrent.GuardedBy;
* A cronet-based {@link ConnectionClientTransport} implementation. * A cronet-based {@link ConnectionClientTransport} implementation.
*/ */
class CronetClientTransport implements ConnectionClientTransport { class CronetClientTransport implements ConnectionClientTransport {
private final LogId logId = LogId.allocate(getClass().getName()); private final InternalLogId logId = InternalLogId.allocate(getClass().getName());
private final InetSocketAddress address; private final InetSocketAddress address;
private final String authority; private final String authority;
private final String userAgent; private final String userAgent;
@ -231,7 +231,7 @@ class CronetClientTransport implements ConnectionClientTransport {
} }
@Override @Override
public LogId getLogId() { public InternalLogId getLogId() {
return logId; return logId;
} }

View File

@ -22,10 +22,10 @@ import com.google.common.annotations.VisibleForTesting;
import io.grpc.Attributes; import io.grpc.Attributes;
import io.grpc.ConnectivityStateInfo; import io.grpc.ConnectivityStateInfo;
import io.grpc.EquivalentAddressGroup; import io.grpc.EquivalentAddressGroup;
import io.grpc.InternalLogId;
import io.grpc.InternalWithLogId;
import io.grpc.LoadBalancer; import io.grpc.LoadBalancer;
import io.grpc.LogId;
import io.grpc.Status; import io.grpc.Status;
import io.grpc.WithLogId;
import io.grpc.internal.BackoffPolicy; import io.grpc.internal.BackoffPolicy;
import io.grpc.internal.GrpcAttributes; import io.grpc.internal.GrpcAttributes;
import io.grpc.internal.ObjectPool; import io.grpc.internal.ObjectPool;
@ -34,7 +34,6 @@ import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledExecutorService;
import javax.annotation.Nullable; import javax.annotation.Nullable;
/** /**
@ -43,9 +42,9 @@ import javax.annotation.Nullable;
* <p>Optionally, when requested by the naming system, will delegate the work to a local pick-first * <p>Optionally, when requested by the naming system, will delegate the work to a local pick-first
* or round-robin balancer. * or round-robin balancer.
*/ */
class GrpclbLoadBalancer extends LoadBalancer implements WithLogId { class GrpclbLoadBalancer extends LoadBalancer implements InternalWithLogId {
private final LogId logId = LogId.allocate(getClass().getName()); private final InternalLogId logId = InternalLogId.allocate(getClass().getName());
private final SubchannelPool subchannelPool; private final SubchannelPool subchannelPool;
private final ObjectPool<ScheduledExecutorService> timerServicePool; private final ObjectPool<ScheduledExecutorService> timerServicePool;
@ -73,7 +72,7 @@ class GrpclbLoadBalancer extends LoadBalancer implements WithLogId {
} }
@Override @Override
public LogId getLogId() { public InternalLogId getLogId() {
return logId; return logId;
} }

View File

@ -33,12 +33,12 @@ import io.grpc.Attributes;
import io.grpc.ConnectivityState; import io.grpc.ConnectivityState;
import io.grpc.ConnectivityStateInfo; import io.grpc.ConnectivityStateInfo;
import io.grpc.EquivalentAddressGroup; import io.grpc.EquivalentAddressGroup;
import io.grpc.InternalLogId;
import io.grpc.LoadBalancer.Helper; import io.grpc.LoadBalancer.Helper;
import io.grpc.LoadBalancer.PickResult; import io.grpc.LoadBalancer.PickResult;
import io.grpc.LoadBalancer.PickSubchannelArgs; import io.grpc.LoadBalancer.PickSubchannelArgs;
import io.grpc.LoadBalancer.Subchannel; import io.grpc.LoadBalancer.Subchannel;
import io.grpc.LoadBalancer.SubchannelPicker; import io.grpc.LoadBalancer.SubchannelPicker;
import io.grpc.LogId;
import io.grpc.ManagedChannel; import io.grpc.ManagedChannel;
import io.grpc.Metadata; import io.grpc.Metadata;
import io.grpc.Status; import io.grpc.Status;
@ -49,8 +49,8 @@ import io.grpc.lb.v1.ClientStats;
import io.grpc.lb.v1.InitialLoadBalanceRequest; import io.grpc.lb.v1.InitialLoadBalanceRequest;
import io.grpc.lb.v1.InitialLoadBalanceResponse; import io.grpc.lb.v1.InitialLoadBalanceResponse;
import io.grpc.lb.v1.LoadBalanceRequest; import io.grpc.lb.v1.LoadBalanceRequest;
import io.grpc.lb.v1.LoadBalanceResponse.LoadBalanceResponseTypeCase;
import io.grpc.lb.v1.LoadBalanceResponse; import io.grpc.lb.v1.LoadBalanceResponse;
import io.grpc.lb.v1.LoadBalanceResponse.LoadBalanceResponseTypeCase;
import io.grpc.lb.v1.LoadBalancerGrpc; import io.grpc.lb.v1.LoadBalancerGrpc;
import io.grpc.lb.v1.Server; import io.grpc.lb.v1.Server;
import io.grpc.lb.v1.ServerList; import io.grpc.lb.v1.ServerList;
@ -105,7 +105,7 @@ final class GrpclbState {
} }
}; };
private final LogId logId; private final InternalLogId logId;
private final String serviceName; private final String serviceName;
private final Helper helper; private final Helper helper;
private final SubchannelPool subchannelPool; private final SubchannelPool subchannelPool;
@ -152,7 +152,7 @@ final class GrpclbState {
TimeProvider time, TimeProvider time,
ScheduledExecutorService timerService, ScheduledExecutorService timerService,
BackoffPolicy.Provider backoffPolicyProvider, BackoffPolicy.Provider backoffPolicyProvider,
LogId logId) { InternalLogId logId) {
this.helper = checkNotNull(helper, "helper"); this.helper = checkNotNull(helper, "helper");
this.subchannelPool = checkNotNull(subchannelPool, "subchannelPool"); this.subchannelPool = checkNotNull(subchannelPool, "subchannelPool");
this.time = checkNotNull(time, "time provider"); this.time = checkNotNull(time, "time provider");

View File

@ -45,8 +45,9 @@ public abstract class GrpcHttp2ConnectionHandler extends Http2ConnectionHandler
} }
/** /**
* Same as {@link #handleProtocolNegotiationCompleted(Attributes, InternalChannelz.Security)} * Same as {@link #handleProtocolNegotiationCompleted(
* but with no {@link InternalChannelz.Security}. * Attributes, io.grpc.InternalChannelz.Security)}
* but with no {@link io.grpc.InternalChannelz.Security}.
* *
* @deprecated Use the two argument method instead. * @deprecated Use the two argument method instead.
*/ */

View File

@ -27,7 +27,7 @@ import com.google.common.util.concurrent.SettableFuture;
import io.grpc.Attributes; import io.grpc.Attributes;
import io.grpc.CallOptions; import io.grpc.CallOptions;
import io.grpc.InternalChannelz.SocketStats; import io.grpc.InternalChannelz.SocketStats;
import io.grpc.LogId; import io.grpc.InternalLogId;
import io.grpc.Metadata; import io.grpc.Metadata;
import io.grpc.MethodDescriptor; import io.grpc.MethodDescriptor;
import io.grpc.Status; import io.grpc.Status;
@ -64,7 +64,7 @@ import javax.annotation.Nullable;
*/ */
class NettyClientTransport implements ConnectionClientTransport { class NettyClientTransport implements ConnectionClientTransport {
private static final Logger log = Logger.getLogger(NettyServerTransport.class.getName()); private static final Logger log = Logger.getLogger(NettyServerTransport.class.getName());
private final LogId logId = LogId.allocate(getClass().getName()); private final InternalLogId logId = InternalLogId.allocate(getClass().getName());
private final Map<ChannelOption<?>, ?> channelOptions; private final Map<ChannelOption<?>, ?> channelOptions;
private final SocketAddress address; private final SocketAddress address;
private final Class<? extends Channel> channelType; private final Class<? extends Channel> channelType;
@ -310,7 +310,7 @@ class NettyClientTransport implements ConnectionClientTransport {
} }
@Override @Override
public LogId getLogId() { public InternalLogId getLogId() {
return logId; return logId;
} }

View File

@ -26,12 +26,12 @@ import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.SettableFuture; import com.google.common.util.concurrent.SettableFuture;
import io.grpc.Instrumented;
import io.grpc.InternalChannelz; import io.grpc.InternalChannelz;
import io.grpc.InternalChannelz.SocketStats; import io.grpc.InternalChannelz.SocketStats;
import io.grpc.LogId; import io.grpc.InternalInstrumented;
import io.grpc.InternalLogId;
import io.grpc.InternalWithLogId;
import io.grpc.ServerStreamTracer; import io.grpc.ServerStreamTracer;
import io.grpc.WithLogId;
import io.grpc.internal.InternalServer; import io.grpc.internal.InternalServer;
import io.grpc.internal.ServerListener; import io.grpc.internal.ServerListener;
import io.grpc.internal.ServerTransportListener; import io.grpc.internal.ServerTransportListener;
@ -64,10 +64,10 @@ import javax.annotation.Nullable;
/** /**
* Netty-based server implementation. * Netty-based server implementation.
*/ */
class NettyServer implements InternalServer, WithLogId { class NettyServer implements InternalServer, InternalWithLogId {
private static final Logger log = Logger.getLogger(InternalServer.class.getName()); private static final Logger log = Logger.getLogger(InternalServer.class.getName());
private final LogId logId = LogId.allocate(getClass().getName()); private final InternalLogId logId = InternalLogId.allocate(getClass().getName());
private final SocketAddress address; private final SocketAddress address;
private final Class<? extends ServerChannel> channelType; private final Class<? extends ServerChannel> channelType;
private final Map<ChannelOption<?>, ?> channelOptions; private final Map<ChannelOption<?>, ?> channelOptions;
@ -95,7 +95,8 @@ class NettyServer implements InternalServer, WithLogId {
private final InternalChannelz channelz; private final InternalChannelz channelz;
// Only modified in event loop but safe to read any time. Set at startup and unset at shutdown. // Only modified in event loop but safe to read any time. Set at startup and unset at shutdown.
// In the future we may have >1 listen socket. // In the future we may have >1 listen socket.
private volatile ImmutableList<Instrumented<SocketStats>> listenSockets = ImmutableList.of(); private volatile ImmutableList<InternalInstrumented<SocketStats>> listenSockets
= ImmutableList.of();
NettyServer( NettyServer(
SocketAddress address, Class<? extends ServerChannel> channelType, SocketAddress address, Class<? extends ServerChannel> channelType,
@ -147,7 +148,7 @@ class NettyServer implements InternalServer, WithLogId {
} }
@Override @Override
public List<Instrumented<SocketStats>> getListenSockets() { public List<InternalInstrumented<SocketStats>> getListenSockets() {
return listenSockets; return listenSockets;
} }
@ -255,7 +256,7 @@ class NettyServer implements InternalServer, WithLogId {
Future<?> channelzFuture = channel.eventLoop().submit(new Runnable() { Future<?> channelzFuture = channel.eventLoop().submit(new Runnable() {
@Override @Override
public void run() { public void run() {
Instrumented<SocketStats> listenSocket = new ListenSocket(channel); InternalInstrumented<SocketStats> listenSocket = new ListenSocket(channel);
listenSockets = ImmutableList.of(listenSocket); listenSockets = ImmutableList.of(listenSocket);
channelz.addListenSocket(listenSocket); channelz.addListenSocket(listenSocket);
} }
@ -279,7 +280,7 @@ class NettyServer implements InternalServer, WithLogId {
if (!future.isSuccess()) { if (!future.isSuccess()) {
log.log(Level.WARNING, "Error shutting down server", future.cause()); log.log(Level.WARNING, "Error shutting down server", future.cause());
} }
for (Instrumented<SocketStats> listenSocket : listenSockets) { for (InternalInstrumented<SocketStats> listenSocket : listenSockets) {
channelz.removeListenSocket(listenSocket); channelz.removeListenSocket(listenSocket);
} }
listenSockets = null; listenSockets = null;
@ -301,7 +302,7 @@ class NettyServer implements InternalServer, WithLogId {
} }
@Override @Override
public LogId getLogId() { public InternalLogId getLogId() {
return logId; return logId;
} }
@ -341,8 +342,8 @@ class NettyServer implements InternalServer, WithLogId {
/** /**
* A class that can answer channelz queries about the server listen sockets. * A class that can answer channelz queries about the server listen sockets.
*/ */
private static final class ListenSocket implements Instrumented<SocketStats> { private static final class ListenSocket implements InternalInstrumented<SocketStats> {
private final LogId id = LogId.allocate(getClass().getName()); private final InternalLogId id = InternalLogId.allocate(getClass().getName());
private final Channel ch; private final Channel ch;
ListenSocket(Channel ch) { ListenSocket(Channel ch) {
@ -389,7 +390,7 @@ class NettyServer implements InternalServer, WithLogId {
} }
@Override @Override
public LogId getLogId() { public InternalLogId getLogId() {
return id; return id;
} }

View File

@ -23,7 +23,7 @@ import com.google.common.collect.ImmutableList;
import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.SettableFuture; import com.google.common.util.concurrent.SettableFuture;
import io.grpc.InternalChannelz.SocketStats; import io.grpc.InternalChannelz.SocketStats;
import io.grpc.LogId; import io.grpc.InternalLogId;
import io.grpc.ServerStreamTracer; import io.grpc.ServerStreamTracer;
import io.grpc.Status; import io.grpc.Status;
import io.grpc.internal.ServerTransport; import io.grpc.internal.ServerTransport;
@ -55,7 +55,7 @@ class NettyServerTransport implements ServerTransport {
"Connection reset by peer", "Connection reset by peer",
"An existing connection was forcibly closed by the remote host"); "An existing connection was forcibly closed by the remote host");
private final LogId logId = LogId.allocate(getClass().getName()); private final InternalLogId logId = InternalLogId.allocate(getClass().getName());
private final Channel channel; private final Channel channel;
private final ChannelPromise channelUnused; private final ChannelPromise channelUnused;
private final ProtocolNegotiator protocolNegotiator; private final ProtocolNegotiator protocolNegotiator;
@ -162,7 +162,7 @@ class NettyServerTransport implements ServerTransport {
} }
@Override @Override
public LogId getLogId() { public InternalLogId getLogId() {
return logId; return logId;
} }

View File

@ -24,9 +24,9 @@ import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame; import static org.junit.Assert.assertSame;
import com.google.common.util.concurrent.SettableFuture; import com.google.common.util.concurrent.SettableFuture;
import io.grpc.Instrumented;
import io.grpc.InternalChannelz; import io.grpc.InternalChannelz;
import io.grpc.InternalChannelz.SocketStats; import io.grpc.InternalChannelz.SocketStats;
import io.grpc.InternalInstrumented;
import io.grpc.ServerStreamTracer; import io.grpc.ServerStreamTracer;
import io.grpc.internal.ServerListener; import io.grpc.internal.ServerListener;
import io.grpc.internal.ServerTransport; import io.grpc.internal.ServerTransport;
@ -212,7 +212,7 @@ public class NettyServerTest {
}); });
assertThat(ns.getPort()).isGreaterThan(0); assertThat(ns.getPort()).isGreaterThan(0);
Instrumented<SocketStats> listenSocket = getOnlyElement(ns.getListenSockets()); InternalInstrumented<SocketStats> listenSocket = getOnlyElement(ns.getListenSockets());
assertSame(listenSocket, channelz.getSocket(id(listenSocket))); assertSame(listenSocket, channelz.getSocket(id(listenSocket)));
// very basic sanity check of the contents // very basic sanity check of the contents

View File

@ -36,7 +36,7 @@ import io.grpc.CallOptions;
import io.grpc.Grpc; import io.grpc.Grpc;
import io.grpc.InternalChannelz; import io.grpc.InternalChannelz;
import io.grpc.InternalChannelz.SocketStats; import io.grpc.InternalChannelz.SocketStats;
import io.grpc.LogId; import io.grpc.InternalLogId;
import io.grpc.Metadata; import io.grpc.Metadata;
import io.grpc.MethodDescriptor; import io.grpc.MethodDescriptor;
import io.grpc.MethodDescriptor.MethodType; import io.grpc.MethodDescriptor.MethodType;
@ -144,7 +144,7 @@ class OkHttpClientTransport implements ConnectionClientTransport, TransportExcep
private AsyncFrameWriter frameWriter; private AsyncFrameWriter frameWriter;
private OutboundFlowController outboundFlow; private OutboundFlowController outboundFlow;
private final Object lock = new Object(); private final Object lock = new Object();
private final LogId logId = LogId.allocate(getClass().getName()); private final InternalLogId logId = InternalLogId.allocate(getClass().getName());
@GuardedBy("lock") @GuardedBy("lock")
private int nextStreamId; private int nextStreamId;
@GuardedBy("lock") @GuardedBy("lock")
@ -629,7 +629,7 @@ class OkHttpClientTransport implements ConnectionClientTransport, TransportExcep
} }
@Override @Override
public LogId getLogId() { public InternalLogId getLogId() {
return logId; return logId;
} }

View File

@ -55,9 +55,9 @@ import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.MoreExecutors; import com.google.common.util.concurrent.MoreExecutors;
import com.google.common.util.concurrent.SettableFuture; import com.google.common.util.concurrent.SettableFuture;
import io.grpc.CallOptions; import io.grpc.CallOptions;
import io.grpc.Instrumented;
import io.grpc.InternalChannelz.SocketStats; import io.grpc.InternalChannelz.SocketStats;
import io.grpc.InternalChannelz.TransportStats; import io.grpc.InternalChannelz.TransportStats;
import io.grpc.InternalInstrumented;
import io.grpc.InternalStatus; import io.grpc.InternalStatus;
import io.grpc.Metadata; import io.grpc.Metadata;
import io.grpc.MethodDescriptor; import io.grpc.MethodDescriptor;
@ -2037,7 +2037,7 @@ public class OkHttpClientTransportTest {
} }
} }
private static TransportStats getTransportStats(Instrumented<SocketStats> obj) private static TransportStats getTransportStats(InternalInstrumented<SocketStats> obj)
throws ExecutionException, InterruptedException { throws ExecutionException, InterruptedException {
return obj.getStats().get().data; return obj.getStats().get().data;
} }

View File

@ -24,7 +24,6 @@ import com.google.protobuf.Int64Value;
import com.google.protobuf.util.Durations; import com.google.protobuf.util.Durations;
import com.google.protobuf.util.Timestamps; import com.google.protobuf.util.Timestamps;
import io.grpc.ConnectivityState; import io.grpc.ConnectivityState;
import io.grpc.Instrumented;
import io.grpc.InternalChannelz; import io.grpc.InternalChannelz;
import io.grpc.InternalChannelz.ChannelStats; import io.grpc.InternalChannelz.ChannelStats;
import io.grpc.InternalChannelz.ChannelTrace.Event; import io.grpc.InternalChannelz.ChannelTrace.Event;
@ -34,8 +33,9 @@ import io.grpc.InternalChannelz.ServerSocketsList;
import io.grpc.InternalChannelz.ServerStats; import io.grpc.InternalChannelz.ServerStats;
import io.grpc.InternalChannelz.SocketStats; import io.grpc.InternalChannelz.SocketStats;
import io.grpc.InternalChannelz.TransportStats; import io.grpc.InternalChannelz.TransportStats;
import io.grpc.InternalInstrumented;
import io.grpc.InternalWithLogId;
import io.grpc.Status; import io.grpc.Status;
import io.grpc.WithLogId;
import io.grpc.channelz.v1.Address; import io.grpc.channelz.v1.Address;
import io.grpc.channelz.v1.Address.OtherAddress; import io.grpc.channelz.v1.Address.OtherAddress;
import io.grpc.channelz.v1.Address.TcpIpAddress; import io.grpc.channelz.v1.Address.TcpIpAddress;
@ -88,7 +88,7 @@ final class ChannelzProtoUtil {
// do not instantiate. // do not instantiate.
} }
static ChannelRef toChannelRef(WithLogId obj) { static ChannelRef toChannelRef(InternalWithLogId obj) {
return ChannelRef return ChannelRef
.newBuilder() .newBuilder()
.setChannelId(obj.getLogId().getId()) .setChannelId(obj.getLogId().getId())
@ -96,7 +96,7 @@ final class ChannelzProtoUtil {
.build(); .build();
} }
static SubchannelRef toSubchannelRef(WithLogId obj) { static SubchannelRef toSubchannelRef(InternalWithLogId obj) {
return SubchannelRef return SubchannelRef
.newBuilder() .newBuilder()
.setSubchannelId(obj.getLogId().getId()) .setSubchannelId(obj.getLogId().getId())
@ -104,7 +104,7 @@ final class ChannelzProtoUtil {
.build(); .build();
} }
static ServerRef toServerRef(WithLogId obj) { static ServerRef toServerRef(InternalWithLogId obj) {
return ServerRef return ServerRef
.newBuilder() .newBuilder()
.setServerId(obj.getLogId().getId()) .setServerId(obj.getLogId().getId())
@ -112,7 +112,7 @@ final class ChannelzProtoUtil {
.build(); .build();
} }
static SocketRef toSocketRef(WithLogId obj) { static SocketRef toSocketRef(InternalWithLogId obj) {
return SocketRef return SocketRef
.newBuilder() .newBuilder()
.setSocketId(obj.getLogId().getId()) .setSocketId(obj.getLogId().getId())
@ -120,13 +120,13 @@ final class ChannelzProtoUtil {
.build(); .build();
} }
static Server toServer(Instrumented<ServerStats> obj) { static Server toServer(InternalInstrumented<ServerStats> obj) {
ServerStats stats = getFuture(obj.getStats()); ServerStats stats = getFuture(obj.getStats());
Server.Builder builder = Server Server.Builder builder = Server
.newBuilder() .newBuilder()
.setRef(toServerRef(obj)) .setRef(toServerRef(obj))
.setData(toServerData(stats)); .setData(toServerData(stats));
for (Instrumented<SocketStats> listenSocket : stats.listenSockets) { for (InternalInstrumented<SocketStats> listenSocket : stats.listenSockets) {
builder.addListenSocket(toSocketRef(listenSocket)); builder.addListenSocket(toSocketRef(listenSocket));
} }
return builder.build(); 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()); SocketStats socketStats = getFuture(obj.getStats());
Builder builder = Socket.newBuilder() Builder builder = Socket.newBuilder()
.setRef(toSocketRef(obj)) .setRef(toSocketRef(obj))
@ -339,13 +339,13 @@ final class ChannelzProtoUtil {
return ret; return ret;
} }
static Channel toChannel(Instrumented<ChannelStats> channel) { static Channel toChannel(InternalInstrumented<ChannelStats> channel) {
ChannelStats stats = getFuture(channel.getStats()); ChannelStats stats = getFuture(channel.getStats());
Channel.Builder channelBuilder = Channel Channel.Builder channelBuilder = Channel
.newBuilder() .newBuilder()
.setRef(toChannelRef(channel)) .setRef(toChannelRef(channel))
.setData(extractChannelData(stats)); .setData(extractChannelData(stats));
for (WithLogId subchannel : stats.subchannels) { for (InternalWithLogId subchannel : stats.subchannels) {
channelBuilder.addSubchannelRef(toSubchannelRef(subchannel)); 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()); ChannelStats stats = getFuture(subchannel.getStats());
Subchannel.Builder subchannelBuilder = Subchannel Subchannel.Builder subchannelBuilder = Subchannel
.newBuilder() .newBuilder()
.setRef(toSubchannelRef(subchannel)) .setRef(toSubchannelRef(subchannel))
.setData(extractChannelData(stats)); .setData(extractChannelData(stats));
Preconditions.checkState(stats.sockets.isEmpty() || stats.subchannels.isEmpty()); Preconditions.checkState(stats.sockets.isEmpty() || stats.subchannels.isEmpty());
for (WithLogId childSocket : stats.sockets) { for (InternalWithLogId childSocket : stats.sockets) {
subchannelBuilder.addSocketRef(toSocketRef(childSocket)); subchannelBuilder.addSocketRef(toSocketRef(childSocket));
} }
for (WithLogId childSubchannel : stats.subchannels) { for (InternalWithLogId childSubchannel : stats.subchannels) {
subchannelBuilder.addSubchannelRef(toSubchannelRef(childSubchannel)); subchannelBuilder.addSubchannelRef(toSubchannelRef(childSubchannel));
} }
return subchannelBuilder.build(); return subchannelBuilder.build();
@ -427,7 +427,7 @@ final class ChannelzProtoUtil {
GetTopChannelsResponse.Builder responseBuilder = GetTopChannelsResponse GetTopChannelsResponse.Builder responseBuilder = GetTopChannelsResponse
.newBuilder() .newBuilder()
.setEnd(rootChannels.end); .setEnd(rootChannels.end);
for (Instrumented<ChannelStats> c : rootChannels.channels) { for (InternalInstrumented<ChannelStats> c : rootChannels.channels) {
responseBuilder.addChannel(ChannelzProtoUtil.toChannel(c)); responseBuilder.addChannel(ChannelzProtoUtil.toChannel(c));
} }
return responseBuilder.build(); return responseBuilder.build();
@ -437,7 +437,7 @@ final class ChannelzProtoUtil {
GetServersResponse.Builder responseBuilder = GetServersResponse GetServersResponse.Builder responseBuilder = GetServersResponse
.newBuilder() .newBuilder()
.setEnd(servers.end); .setEnd(servers.end);
for (Instrumented<ServerStats> s : servers.servers) { for (InternalInstrumented<ServerStats> s : servers.servers) {
responseBuilder.addServer(ChannelzProtoUtil.toServer(s)); responseBuilder.addServer(ChannelzProtoUtil.toServer(s));
} }
return responseBuilder.build(); return responseBuilder.build();
@ -447,7 +447,7 @@ final class ChannelzProtoUtil {
GetServerSocketsResponse.Builder responseBuilder = GetServerSocketsResponse GetServerSocketsResponse.Builder responseBuilder = GetServerSocketsResponse
.newBuilder() .newBuilder()
.setEnd(serverSockets.end); .setEnd(serverSockets.end);
for (WithLogId s : serverSockets.sockets) { for (InternalWithLogId s : serverSockets.sockets) {
responseBuilder.addSocketRef(ChannelzProtoUtil.toSocketRef(s)); responseBuilder.addSocketRef(ChannelzProtoUtil.toSocketRef(s));
} }
return responseBuilder.build(); return responseBuilder.build();

View File

@ -18,12 +18,12 @@ package io.grpc.services;
import com.google.common.annotations.VisibleForTesting; import com.google.common.annotations.VisibleForTesting;
import io.grpc.ExperimentalApi; import io.grpc.ExperimentalApi;
import io.grpc.Instrumented;
import io.grpc.InternalChannelz; import io.grpc.InternalChannelz;
import io.grpc.InternalChannelz.ChannelStats; import io.grpc.InternalChannelz.ChannelStats;
import io.grpc.InternalChannelz.ServerList; import io.grpc.InternalChannelz.ServerList;
import io.grpc.InternalChannelz.ServerSocketsList; import io.grpc.InternalChannelz.ServerSocketsList;
import io.grpc.InternalChannelz.SocketStats; import io.grpc.InternalChannelz.SocketStats;
import io.grpc.InternalInstrumented;
import io.grpc.ServerInterceptors; import io.grpc.ServerInterceptors;
import io.grpc.ServerServiceDefinition; import io.grpc.ServerServiceDefinition;
import io.grpc.Status; import io.grpc.Status;
@ -92,7 +92,7 @@ public final class ChannelzService extends ChannelzGrpc.ChannelzImplBase {
@Override @Override
public void getChannel( public void getChannel(
GetChannelRequest request, StreamObserver<GetChannelResponse> responseObserver) { GetChannelRequest request, StreamObserver<GetChannelResponse> responseObserver) {
Instrumented<ChannelStats> s = channelz.getRootChannel(request.getChannelId()); InternalInstrumented<ChannelStats> s = channelz.getRootChannel(request.getChannelId());
if (s == null) { if (s == null) {
responseObserver.onError(Status.NOT_FOUND.asRuntimeException()); responseObserver.onError(Status.NOT_FOUND.asRuntimeException());
return; return;
@ -120,7 +120,7 @@ public final class ChannelzService extends ChannelzGrpc.ChannelzImplBase {
@Override @Override
public void getSubchannel( public void getSubchannel(
GetSubchannelRequest request, StreamObserver<GetSubchannelResponse> responseObserver) { GetSubchannelRequest request, StreamObserver<GetSubchannelResponse> responseObserver) {
Instrumented<ChannelStats> s = channelz.getSubchannel(request.getSubchannelId()); InternalInstrumented<ChannelStats> s = channelz.getSubchannel(request.getSubchannelId());
if (s == null) { if (s == null) {
responseObserver.onError(Status.NOT_FOUND.asRuntimeException()); responseObserver.onError(Status.NOT_FOUND.asRuntimeException());
return; return;
@ -138,7 +138,7 @@ public final class ChannelzService extends ChannelzGrpc.ChannelzImplBase {
@Override @Override
public void getSocket( public void getSocket(
GetSocketRequest request, StreamObserver<GetSocketResponse> responseObserver) { GetSocketRequest request, StreamObserver<GetSocketResponse> responseObserver) {
Instrumented<SocketStats> s = channelz.getSocket(request.getSocketId()); InternalInstrumented<SocketStats> s = channelz.getSocket(request.getSocketId());
if (s == null) { if (s == null) {
responseObserver.onError(Status.NOT_FOUND.asRuntimeException()); responseObserver.onError(Status.NOT_FOUND.asRuntimeException());
return; return;

View File

@ -32,7 +32,6 @@ import com.google.protobuf.Message;
import com.google.protobuf.util.Durations; import com.google.protobuf.util.Durations;
import com.google.protobuf.util.Timestamps; import com.google.protobuf.util.Timestamps;
import io.grpc.ConnectivityState; import io.grpc.ConnectivityState;
import io.grpc.Instrumented;
import io.grpc.InternalChannelz; import io.grpc.InternalChannelz;
import io.grpc.InternalChannelz.ChannelStats; import io.grpc.InternalChannelz.ChannelStats;
import io.grpc.InternalChannelz.ChannelTrace.Event; import io.grpc.InternalChannelz.ChannelTrace.Event;
@ -43,7 +42,8 @@ import io.grpc.InternalChannelz.ServerSocketsList;
import io.grpc.InternalChannelz.ServerStats; import io.grpc.InternalChannelz.ServerStats;
import io.grpc.InternalChannelz.SocketOptions; import io.grpc.InternalChannelz.SocketOptions;
import io.grpc.InternalChannelz.SocketStats; 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;
import io.grpc.channelz.v1.Address.OtherAddress; import io.grpc.channelz.v1.Address.OtherAddress;
import io.grpc.channelz.v1.Address.TcpIpAddress; import io.grpc.channelz.v1.Address.TcpIpAddress;
@ -538,7 +538,7 @@ public final class ChannelzProtoUtilTest {
// 1 listen socket // 1 listen socket
server.serverStats = toBuilder(server.serverStats) server.serverStats = toBuilder(server.serverStats)
.setListenSockets(ImmutableList.<Instrumented<SocketStats>>of(listenSocket)) .setListenSockets(ImmutableList.<InternalInstrumented<SocketStats>>of(listenSocket))
.build(); .build();
assertEquals( assertEquals(
serverProto serverProto
@ -552,7 +552,7 @@ public final class ChannelzProtoUtilTest {
SocketRef otherListenSocketRef = ChannelzProtoUtil.toSocketRef(otherListenSocket); SocketRef otherListenSocketRef = ChannelzProtoUtil.toSocketRef(otherListenSocket);
server.serverStats = toBuilder(server.serverStats) server.serverStats = toBuilder(server.serverStats)
.setListenSockets( .setListenSockets(
ImmutableList.<Instrumented<SocketStats>>of(listenSocket, otherListenSocket)) ImmutableList.<InternalInstrumented<SocketStats>>of(listenSocket, otherListenSocket))
.build(); .build();
assertEquals( assertEquals(
serverProto serverProto
@ -573,7 +573,7 @@ public final class ChannelzProtoUtilTest {
assertEquals(channelProto, ChannelzProtoUtil.toChannel(channel)); assertEquals(channelProto, ChannelzProtoUtil.toChannel(channel));
channel.stats = toBuilder(channel.stats) channel.stats = toBuilder(channel.stats)
.setSubchannels(ImmutableList.<WithLogId>of(subchannel)) .setSubchannels(ImmutableList.<InternalWithLogId>of(subchannel))
.build(); .build();
assertEquals( assertEquals(
@ -585,7 +585,7 @@ public final class ChannelzProtoUtilTest {
TestChannel otherSubchannel = new TestChannel(); TestChannel otherSubchannel = new TestChannel();
channel.stats = toBuilder(channel.stats) channel.stats = toBuilder(channel.stats)
.setSubchannels(ImmutableList.<WithLogId>of(subchannel, otherSubchannel)) .setSubchannels(ImmutableList.<InternalWithLogId>of(subchannel, otherSubchannel))
.build(); .build();
assertEquals( assertEquals(
channelProto channelProto
@ -611,7 +611,7 @@ public final class ChannelzProtoUtilTest {
@Test @Test
public void toSubchannel_socketChildren() throws Exception { public void toSubchannel_socketChildren() throws Exception {
subchannel.stats = toBuilder(subchannel.stats) subchannel.stats = toBuilder(subchannel.stats)
.setSockets(ImmutableList.<WithLogId>of(socket)) .setSockets(ImmutableList.<InternalWithLogId>of(socket))
.build(); .build();
assertEquals( assertEquals(
@ -622,7 +622,7 @@ public final class ChannelzProtoUtilTest {
TestSocket otherSocket = new TestSocket(); TestSocket otherSocket = new TestSocket();
subchannel.stats = toBuilder(subchannel.stats) subchannel.stats = toBuilder(subchannel.stats)
.setSockets(ImmutableList.<WithLogId>of(socket, otherSocket)) .setSockets(ImmutableList.<InternalWithLogId>of(socket, otherSocket))
.build(); .build();
assertEquals( assertEquals(
subchannelProto subchannelProto
@ -637,7 +637,7 @@ public final class ChannelzProtoUtilTest {
public void toSubchannel_subchannelChildren() throws Exception { public void toSubchannel_subchannelChildren() throws Exception {
TestChannel subchannel1 = new TestChannel(); TestChannel subchannel1 = new TestChannel();
subchannel.stats = toBuilder(subchannel.stats) subchannel.stats = toBuilder(subchannel.stats)
.setSubchannels(ImmutableList.<WithLogId>of(subchannel1)) .setSubchannels(ImmutableList.<InternalWithLogId>of(subchannel1))
.build(); .build();
assertEquals( assertEquals(
subchannelProto.toBuilder() subchannelProto.toBuilder()
@ -647,7 +647,7 @@ public final class ChannelzProtoUtilTest {
TestChannel subchannel2 = new TestChannel(); TestChannel subchannel2 = new TestChannel();
subchannel.stats = toBuilder(subchannel.stats) subchannel.stats = toBuilder(subchannel.stats)
.setSubchannels(ImmutableList.<WithLogId>of(subchannel1, subchannel2)) .setSubchannels(ImmutableList.<InternalWithLogId>of(subchannel1, subchannel2))
.build(); .build();
assertEquals( assertEquals(
subchannelProto subchannelProto
@ -664,7 +664,8 @@ public final class ChannelzProtoUtilTest {
assertEquals( assertEquals(
GetTopChannelsResponse.newBuilder().setEnd(true).build(), GetTopChannelsResponse.newBuilder().setEnd(true).build(),
ChannelzProtoUtil.toGetTopChannelResponse( ChannelzProtoUtil.toGetTopChannelResponse(
new RootChannelList(Collections.<Instrumented<ChannelStats>>emptyList(), true))); new RootChannelList(
Collections.<InternalInstrumented<ChannelStats>>emptyList(), true)));
// 1 result, paginated // 1 result, paginated
assertEquals( assertEquals(
@ -673,7 +674,8 @@ public final class ChannelzProtoUtilTest {
.addChannel(channelProto) .addChannel(channelProto)
.build(), .build(),
ChannelzProtoUtil.toGetTopChannelResponse( ChannelzProtoUtil.toGetTopChannelResponse(
new RootChannelList(ImmutableList.<Instrumented<ChannelStats>>of(channel), false))); new RootChannelList(
ImmutableList.<InternalInstrumented<ChannelStats>>of(channel), false)));
// 1 result, end // 1 result, end
assertEquals( assertEquals(
@ -683,7 +685,8 @@ public final class ChannelzProtoUtilTest {
.setEnd(true) .setEnd(true)
.build(), .build(),
ChannelzProtoUtil.toGetTopChannelResponse( ChannelzProtoUtil.toGetTopChannelResponse(
new RootChannelList(ImmutableList.<Instrumented<ChannelStats>>of(channel), true))); new RootChannelList(
ImmutableList.<InternalInstrumented<ChannelStats>>of(channel), true)));
// 2 results, end // 2 results, end
TestChannel channel2 = new TestChannel(); TestChannel channel2 = new TestChannel();
@ -696,7 +699,7 @@ public final class ChannelzProtoUtilTest {
.build(), .build(),
ChannelzProtoUtil.toGetTopChannelResponse( ChannelzProtoUtil.toGetTopChannelResponse(
new RootChannelList( new RootChannelList(
ImmutableList.<Instrumented<ChannelStats>>of(channel, channel2), true))); ImmutableList.<InternalInstrumented<ChannelStats>>of(channel, channel2), true)));
} }
@Test @Test
@ -705,7 +708,7 @@ public final class ChannelzProtoUtilTest {
assertEquals( assertEquals(
GetServersResponse.getDefaultInstance(), GetServersResponse.getDefaultInstance(),
ChannelzProtoUtil.toGetServersResponse( ChannelzProtoUtil.toGetServersResponse(
new ServerList(Collections.<Instrumented<ServerStats>>emptyList(), false))); new ServerList(Collections.<InternalInstrumented<ServerStats>>emptyList(), false)));
// 1 result, paginated // 1 result, paginated
assertEquals( assertEquals(
@ -714,7 +717,7 @@ public final class ChannelzProtoUtilTest {
.addServer(serverProto) .addServer(serverProto)
.build(), .build(),
ChannelzProtoUtil.toGetServersResponse( ChannelzProtoUtil.toGetServersResponse(
new ServerList(ImmutableList.<Instrumented<ServerStats>>of(server), false))); new ServerList(ImmutableList.<InternalInstrumented<ServerStats>>of(server), false)));
// 1 result, end // 1 result, end
assertEquals( assertEquals(
@ -724,7 +727,7 @@ public final class ChannelzProtoUtilTest {
.setEnd(true) .setEnd(true)
.build(), .build(),
ChannelzProtoUtil.toGetServersResponse( ChannelzProtoUtil.toGetServersResponse(
new ServerList(ImmutableList.<Instrumented<ServerStats>>of(server), true))); new ServerList(ImmutableList.<InternalInstrumented<ServerStats>>of(server), true)));
TestServer server2 = new TestServer(); TestServer server2 = new TestServer();
// 2 results, end // 2 results, end
@ -736,7 +739,8 @@ public final class ChannelzProtoUtilTest {
.setEnd(true) .setEnd(true)
.build(), .build(),
ChannelzProtoUtil.toGetServersResponse( ChannelzProtoUtil.toGetServersResponse(
new ServerList(ImmutableList.<Instrumented<ServerStats>>of(server, server2), true))); new ServerList(
ImmutableList.<InternalInstrumented<ServerStats>>of(server, server2), true)));
} }
@Test @Test
@ -745,7 +749,7 @@ public final class ChannelzProtoUtilTest {
assertEquals( assertEquals(
GetServerSocketsResponse.getDefaultInstance(), GetServerSocketsResponse.getDefaultInstance(),
ChannelzProtoUtil.toGetServerSocketsResponse( ChannelzProtoUtil.toGetServerSocketsResponse(
new ServerSocketsList(Collections.<WithLogId>emptyList(), false))); new ServerSocketsList(Collections.<InternalWithLogId>emptyList(), false)));
// 1 result, paginated // 1 result, paginated
assertEquals( assertEquals(
@ -754,7 +758,7 @@ public final class ChannelzProtoUtilTest {
.addSocketRef(socketRef) .addSocketRef(socketRef)
.build(), .build(),
ChannelzProtoUtil.toGetServerSocketsResponse( ChannelzProtoUtil.toGetServerSocketsResponse(
new ServerSocketsList(ImmutableList.<WithLogId>of(socket), false))); new ServerSocketsList(ImmutableList.<InternalWithLogId>of(socket), false)));
// 1 result, end // 1 result, end
assertEquals( assertEquals(
@ -764,7 +768,7 @@ public final class ChannelzProtoUtilTest {
.setEnd(true) .setEnd(true)
.build(), .build(),
ChannelzProtoUtil.toGetServerSocketsResponse( ChannelzProtoUtil.toGetServerSocketsResponse(
new ServerSocketsList(ImmutableList.<WithLogId>of(socket), true))); new ServerSocketsList(ImmutableList.<InternalWithLogId>of(socket), true)));
TestSocket socket2 = new TestSocket(); TestSocket socket2 = new TestSocket();
// 2 results, end // 2 results, end
@ -776,7 +780,7 @@ public final class ChannelzProtoUtilTest {
.setEnd(true) .setEnd(true)
.build(), .build(),
ChannelzProtoUtil.toGetServerSocketsResponse( ChannelzProtoUtil.toGetServerSocketsResponse(
new ServerSocketsList(ImmutableList.<WithLogId>of(socket, socket2), true))); new ServerSocketsList(ImmutableList.<InternalWithLogId>of(socket, socket2), true)));
} }
@Test @Test

View File

@ -20,7 +20,6 @@ import com.google.common.base.MoreObjects;
import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.SettableFuture; import com.google.common.util.concurrent.SettableFuture;
import io.grpc.ConnectivityState; import io.grpc.ConnectivityState;
import io.grpc.Instrumented;
import io.grpc.InternalChannelz; import io.grpc.InternalChannelz;
import io.grpc.InternalChannelz.ChannelStats; import io.grpc.InternalChannelz.ChannelStats;
import io.grpc.InternalChannelz.Security; import io.grpc.InternalChannelz.Security;
@ -28,8 +27,9 @@ import io.grpc.InternalChannelz.ServerStats;
import io.grpc.InternalChannelz.SocketOptions; import io.grpc.InternalChannelz.SocketOptions;
import io.grpc.InternalChannelz.SocketStats; import io.grpc.InternalChannelz.SocketStats;
import io.grpc.InternalChannelz.TransportStats; import io.grpc.InternalChannelz.TransportStats;
import io.grpc.LogId; import io.grpc.InternalInstrumented;
import io.grpc.WithLogId; import io.grpc.InternalLogId;
import io.grpc.InternalWithLogId;
import java.net.InetSocketAddress; import java.net.InetSocketAddress;
import java.net.SocketAddress; import java.net.SocketAddress;
import java.util.Collections; import java.util.Collections;
@ -40,8 +40,8 @@ import java.util.Collections;
*/ */
final class ChannelzTestHelper { final class ChannelzTestHelper {
static final class TestSocket implements Instrumented<SocketStats> { static final class TestSocket implements InternalInstrumented<SocketStats> {
private final LogId id = LogId.allocate("socket"); private final InternalLogId id = InternalLogId.allocate("socket");
TransportStats transportStats = new TransportStats( TransportStats transportStats = new TransportStats(
/*streamsStarted=*/ 1, /*streamsStarted=*/ 1,
/*lastLocalStreamCreatedTimeNanos=*/ 2, /*lastLocalStreamCreatedTimeNanos=*/ 2,
@ -75,7 +75,7 @@ final class ChannelzTestHelper {
} }
@Override @Override
public LogId getLogId() { public InternalLogId getLogId() {
return id; return id;
} }
@ -87,8 +87,8 @@ final class ChannelzTestHelper {
} }
} }
static final class TestListenSocket implements Instrumented<SocketStats> { static final class TestListenSocket implements InternalInstrumented<SocketStats> {
private final LogId id = LogId.allocate("listensocket"); private final InternalLogId id = InternalLogId.allocate("listensocket");
SocketAddress listenAddress = new InetSocketAddress("10.0.0.1", 1234); SocketAddress listenAddress = new InetSocketAddress("10.0.0.1", 1234);
@Override @Override
@ -105,7 +105,7 @@ final class ChannelzTestHelper {
} }
@Override @Override
public LogId getLogId() { public InternalLogId getLogId() {
return id; return id;
} }
@ -117,14 +117,14 @@ final class ChannelzTestHelper {
} }
} }
static final class TestServer implements Instrumented<ServerStats> { static final class TestServer implements InternalInstrumented<ServerStats> {
private final LogId id = LogId.allocate("server"); private final InternalLogId id = InternalLogId.allocate("server");
ServerStats serverStats = new ServerStats( ServerStats serverStats = new ServerStats(
/*callsStarted=*/ 1, /*callsStarted=*/ 1,
/*callsSucceeded=*/ 2, /*callsSucceeded=*/ 2,
/*callsFailed=*/ 3, /*callsFailed=*/ 3,
/*lastCallStartedNanos=*/ 4, /*lastCallStartedNanos=*/ 4,
Collections.<Instrumented<SocketStats>>emptyList()); Collections.<InternalInstrumented<SocketStats>>emptyList());
@Override @Override
public ListenableFuture<ServerStats> getStats() { public ListenableFuture<ServerStats> getStats() {
@ -134,7 +134,7 @@ final class ChannelzTestHelper {
} }
@Override @Override
public LogId getLogId() { public InternalLogId getLogId() {
return id; return id;
} }
@ -146,8 +146,8 @@ final class ChannelzTestHelper {
} }
} }
static final class TestChannel implements Instrumented<ChannelStats> { static final class TestChannel implements InternalInstrumented<ChannelStats> {
private final LogId id = LogId.allocate("channel-or-subchannel"); private final InternalLogId id = InternalLogId.allocate("channel-or-subchannel");
ChannelStats stats = new ChannelStats.Builder() ChannelStats stats = new ChannelStats.Builder()
.setTarget("sometarget") .setTarget("sometarget")
@ -156,8 +156,8 @@ final class ChannelzTestHelper {
.setCallsSucceeded(2) .setCallsSucceeded(2)
.setCallsFailed(3) .setCallsFailed(3)
.setLastCallStartedNanos(4) .setLastCallStartedNanos(4)
.setSubchannels(Collections.<WithLogId>emptyList()) .setSubchannels(Collections.<InternalWithLogId>emptyList())
.setSockets(Collections.<WithLogId>emptyList()) .setSockets(Collections.<InternalWithLogId>emptyList())
.build(); .build();
@Override @Override
@ -168,7 +168,7 @@ final class ChannelzTestHelper {
} }
@Override @Override
public LogId getLogId() { public InternalLogId getLogId() {
return id; return id;
} }

View File

@ -48,9 +48,9 @@ import io.grpc.CallCredentials;
import io.grpc.CallOptions; import io.grpc.CallOptions;
import io.grpc.ClientStreamTracer; import io.grpc.ClientStreamTracer;
import io.grpc.Grpc; import io.grpc.Grpc;
import io.grpc.Instrumented;
import io.grpc.InternalChannelz.SocketStats; import io.grpc.InternalChannelz.SocketStats;
import io.grpc.InternalChannelz.TransportStats; import io.grpc.InternalChannelz.TransportStats;
import io.grpc.InternalInstrumented;
import io.grpc.Metadata; import io.grpc.Metadata;
import io.grpc.MethodDescriptor; import io.grpc.MethodDescriptor;
import io.grpc.ServerStreamTracer; import io.grpc.ServerStreamTracer;
@ -2043,7 +2043,7 @@ public abstract class AbstractTransportTest {
} }
} }
private static TransportStats getTransportStats(Instrumented<SocketStats> socket) private static TransportStats getTransportStats(InternalInstrumented<SocketStats> socket)
throws ExecutionException, InterruptedException { throws ExecutionException, InterruptedException {
return socket.getStats().get().data; return socket.getStats().get().data;
} }