Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

all: add toString() to Server to improve debug info #4340

Merged
merged 1 commit into from
Apr 13, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions alts/src/main/java/io/grpc/alts/AltsServerBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package io.grpc.alts;

import com.google.common.base.MoreObjects;
import io.grpc.BindableService;
import io.grpc.CompressorRegistry;
import io.grpc.DecompressorRegistry;
Expand Down Expand Up @@ -248,5 +249,10 @@ public boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedE
public void awaitTermination() throws InterruptedException {
delegate.awaitTermination();
}

@Override
public String toString() {
return MoreObjects.toStringHelper(this).add("delegate", delegate).toString();
}
}
}
6 changes: 6 additions & 0 deletions core/src/main/java/io/grpc/inprocess/InProcessServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import static com.google.common.base.Preconditions.checkNotNull;

import com.google.common.base.MoreObjects;
import io.grpc.ServerStreamTracer;
import io.grpc.internal.Channelz.SocketStats;
import io.grpc.internal.Instrumented;
Expand Down Expand Up @@ -95,6 +96,11 @@ public void shutdown() {
}
}

@Override
public String toString() {
return MoreObjects.toStringHelper(this).add("name", name).toString();
}

synchronized ServerTransportListener register(InProcessTransport transport) {
if (shutdown) {
return null;
Expand Down
9 changes: 9 additions & 0 deletions core/src/main/java/io/grpc/internal/ServerImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import static java.util.concurrent.TimeUnit.NANOSECONDS;

import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.MoreObjects;
import com.google.common.base.Preconditions;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.SettableFuture;
Expand Down Expand Up @@ -580,6 +581,14 @@ public ListenableFuture<ServerStats> getStats() {
return ret;
}

@Override
public String toString() {
return MoreObjects.toStringHelper(this)
.add("logId", logId)
.add("transportServer", transportServer)
.toString();
}

private static final class NoopListener implements ServerStreamListener {
@Override
public void messagesAvailable(MessageProducer producer) {
Expand Down
9 changes: 9 additions & 0 deletions netty/src/main/java/io/grpc/netty/NettyServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import static io.netty.channel.ChannelOption.SO_BACKLOG;
import static io.netty.channel.ChannelOption.SO_KEEPALIVE;

import com.google.common.base.MoreObjects;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import com.google.common.util.concurrent.ListenableFuture;
Expand Down Expand Up @@ -304,6 +305,14 @@ public LogId getLogId() {
return logId;
}

@Override
public String toString() {
return MoreObjects.toStringHelper(this)
.add("logId", logId)
.add("address", address)
.toString();
}

class EventLoopReferenceCounter extends AbstractReferenceCounted {
@Override
protected void deallocate() {
Expand Down