Search in sources :

Example 1 with ServerStats

use of io.grpc.InternalChannelz.ServerStats in project grpc-java by grpc.

the class ServerCallImplTest method callTracer0.

private void callTracer0(Status status) {
    CallTracer tracer = CallTracer.getDefaultFactory().create();
    ServerStats.Builder beforeBuilder = new ServerStats.Builder();
    tracer.updateBuilder(beforeBuilder);
    ServerStats before = beforeBuilder.build();
    assertEquals(0, before.callsStarted);
    assertEquals(0, before.lastCallStartedNanos);
    call = new ServerCallImpl<>(stream, UNARY_METHOD, requestHeaders, context, DecompressorRegistry.getDefaultInstance(), CompressorRegistry.getDefaultInstance(), tracer, PerfMark.createTag());
    // required boilerplate
    call.sendHeaders(new Metadata());
    call.sendMessage(123L);
    // end: required boilerplate
    call.close(status, new Metadata());
    ServerStats.Builder afterBuilder = new ServerStats.Builder();
    tracer.updateBuilder(afterBuilder);
    ServerStats after = afterBuilder.build();
    assertEquals(1, after.callsStarted);
    if (status.isOk()) {
        assertEquals(1, after.callsSucceeded);
    } else {
        assertEquals(1, after.callsFailed);
    }
}
Also used : ServerStats(io.grpc.InternalChannelz.ServerStats) Metadata(io.grpc.Metadata)

Example 2 with ServerStats

use of io.grpc.InternalChannelz.ServerStats in project grpc-java by grpc.

the class ChannelzProtoUtil method toServer.

static Server toServer(InternalInstrumented<ServerStats> obj) {
    ServerStats stats = getFuture(obj.getStats());
    Server.Builder builder = Server.newBuilder().setRef(toServerRef(obj)).setData(toServerData(stats));
    for (InternalInstrumented<SocketStats> listenSocket : stats.listenSockets) {
        builder.addListenSocket(toSocketRef(listenSocket));
    }
    return builder.build();
}
Also used : Server(io.grpc.channelz.v1.Server) ServerStats(io.grpc.InternalChannelz.ServerStats) SocketStats(io.grpc.InternalChannelz.SocketStats)

Example 3 with ServerStats

use of io.grpc.InternalChannelz.ServerStats in project grpc-java by grpc.

the class InternalChannelzTest method getServers_onePage.

@Test
public void getServers_onePage() {
    InternalInstrumented<ServerStats> server1 = create();
    channelz.addServer(server1);
    ServerList page = channelz.getServers(/*fromId=*/
    0, /*maxPageSize=*/
    1);
    assertTrue(page.end);
    assertThat(page.servers).containsExactly(server1);
}
Also used : ServerStats(io.grpc.InternalChannelz.ServerStats) ServerList(io.grpc.InternalChannelz.ServerList) Test(org.junit.Test)

Example 4 with ServerStats

use of io.grpc.InternalChannelz.ServerStats in project grpc-java by grpc.

the class InternalChannelzTest method getServers_paginate.

@Test
public void getServers_paginate() {
    InternalInstrumented<ServerStats> server1 = create();
    InternalInstrumented<ServerStats> server2 = create();
    channelz.addServer(server1);
    channelz.addServer(server2);
    ServerList page1 = channelz.getServers(/*fromId=*/
    0, /*maxPageSize=*/
    1);
    assertFalse(page1.end);
    assertThat(page1.servers).containsExactly(server1);
    ServerList page2 = channelz.getServers(/*fromId=*/
    id(server1) + 1, /*maxPageSize=*/
    1);
    assertTrue(page2.end);
    assertThat(page2.servers).containsExactly(server2);
}
Also used : ServerStats(io.grpc.InternalChannelz.ServerStats) ServerList(io.grpc.InternalChannelz.ServerList) Test(org.junit.Test)

Example 5 with ServerStats

use of io.grpc.InternalChannelz.ServerStats in project grpc-java by grpc.

the class InternalChannelzTest method getServers_remove.

@Test
public void getServers_remove() {
    InternalInstrumented<ServerStats> server1 = create();
    channelz.addServer(server1);
    channelz.removeServer(server1);
    ServerList page = channelz.getServers(/*fromId=*/
    0, /*maxPageSize=*/
    1);
    assertTrue(page.end);
    assertThat(page.servers).isEmpty();
}
Also used : ServerStats(io.grpc.InternalChannelz.ServerStats) ServerList(io.grpc.InternalChannelz.ServerList) Test(org.junit.Test)

Aggregations

ServerStats (io.grpc.InternalChannelz.ServerStats)10 Test (org.junit.Test)7 ServerList (io.grpc.InternalChannelz.ServerList)5 SocketStats (io.grpc.InternalChannelz.SocketStats)3 ServerSocketsList (io.grpc.InternalChannelz.ServerSocketsList)2 Metadata (io.grpc.Metadata)1 StatusRuntimeException (io.grpc.StatusRuntimeException)1 GetServerResponse (io.grpc.channelz.v1.GetServerResponse)1 Server (io.grpc.channelz.v1.Server)1 TestServer (io.grpc.protobuf.services.ChannelzTestHelper.TestServer)1