Skip to content

Commit

Permalink
all: add toString() to Server to improve debug info
Browse files Browse the repository at this point in the history
  • Loading branch information
dapengzhang0 authored Apr 13, 2018
1 parent 0eafb8e commit a6811d5
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 0 deletions.
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

0 comments on commit a6811d5

Please sign in to comment.