use of io.grpc.InternalChannelz.TransportStats in project grpc-java by grpc.
the class AbstractTransportTest method transportTracer_server_send_msg.
@Test
public void transportTracer_server_send_msg() throws Exception {
server.start(serverListener);
client = newClientTransport(server);
startTransport(client, mockClientTransportListener);
ClientStream clientStream = client.newStream(methodDescriptor, new Metadata(), callOptions, tracers);
ClientStreamListenerBase clientStreamListener = new ClientStreamListenerBase();
clientStream.start(clientStreamListener);
MockServerTransportListener serverTransportListener = serverListener.takeListenerOrFail(TIMEOUT_MS, TimeUnit.MILLISECONDS);
StreamCreation serverStreamCreation = serverTransportListener.takeStreamOrFail(TIMEOUT_MS, TimeUnit.MILLISECONDS);
ServerStream serverStream = serverStreamCreation.stream;
if (!haveTransportTracer()) {
return;
}
TransportStats serverBefore = getTransportStats(serverTransportListener.transport);
assertEquals(0, serverBefore.messagesSent);
assertEquals(0, serverBefore.lastMessageSentTimeNanos);
TransportStats clientBefore = getTransportStats(client);
assertEquals(0, clientBefore.messagesReceived);
assertEquals(0, clientBefore.lastMessageReceivedTimeNanos);
clientStream.request(1);
serverStream.writeHeaders(new Metadata());
serverStream.writeMessage(methodDescriptor.streamResponse("response"));
serverStream.flush();
verifyMessageCountAndClose(clientStreamListener.messageQueue, 1);
TransportStats serverAfter = getTransportStats(serverTransportListener.transport);
assertEquals(1, serverAfter.messagesSent);
assertEquals(fakeCurrentTimeNanos(), serverAfter.lastMessageSentTimeNanos);
TransportStats clientAfter = getTransportStats(client);
assertEquals(1, clientAfter.messagesReceived);
assertEquals(fakeCurrentTimeNanos(), clientAfter.lastMessageReceivedTimeNanos);
serverStream.close(Status.OK, new Metadata());
}
use of io.grpc.InternalChannelz.TransportStats in project grpc-java by grpc.
the class ChannelzProtoUtil method extractSocketData.
static SocketData extractSocketData(SocketStats socketStats) {
SocketData.Builder builder = SocketData.newBuilder();
if (socketStats.data != null) {
TransportStats s = socketStats.data;
builder.setStreamsStarted(s.streamsStarted).setStreamsSucceeded(s.streamsSucceeded).setStreamsFailed(s.streamsFailed).setMessagesSent(s.messagesSent).setMessagesReceived(s.messagesReceived).setKeepAlivesSent(s.keepAlivesSent).setLastLocalStreamCreatedTimestamp(Timestamps.fromNanos(s.lastLocalStreamCreatedTimeNanos)).setLastRemoteStreamCreatedTimestamp(Timestamps.fromNanos(s.lastRemoteStreamCreatedTimeNanos)).setLastMessageSentTimestamp(Timestamps.fromNanos(s.lastMessageSentTimeNanos)).setLastMessageReceivedTimestamp(Timestamps.fromNanos(s.lastMessageReceivedTimeNanos)).setLocalFlowControlWindow(Int64Value.of(s.localFlowControlWindow)).setRemoteFlowControlWindow(Int64Value.of(s.remoteFlowControlWindow));
}
builder.addAllOption(toSocketOptionsList(socketStats.socketOptions));
return builder.build();
}
Aggregations