Search in sources :

Example 1 with PacketInOutStatsDto

use of org.openkilda.messaging.model.grpc.PacketInOutStatsDto in project open-kilda by telstra.

the class ResponseSerialisationTest method getPacketInOutStatsResponseTest.

@Test
public void getPacketInOutStatsResponseTest() throws IOException {
    GetPacketInOutStatsResponse response = new GetPacketInOutStatsResponse(new SwitchId(1), new PacketInOutStatsDto(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, true, 11));
    String jsonString = mapper.writeValueAsString(response);
    GetPacketInOutStatsResponse objectFromJson = mapper.readValue(jsonString, GetPacketInOutStatsResponse.class);
    Assert.assertEquals(response, objectFromJson);
}
Also used : PacketInOutStatsDto(org.openkilda.messaging.model.grpc.PacketInOutStatsDto) SwitchId(org.openkilda.model.SwitchId) Test(org.junit.Test)

Example 2 with PacketInOutStatsDto

use of org.openkilda.messaging.model.grpc.PacketInOutStatsDto in project open-kilda by telstra.

the class StatsTopologyTest method packetInOutStatsTest.

@Test
public void packetInOutStatsTest() {
    PacketInOutStatsDto data = new PacketInOutStatsDto();
    data.setPacketInTotalPackets(1);
    data.setPacketInTotalPacketsDataplane(2);
    data.setPacketInNoMatchPackets(3);
    data.setPacketInApplyActionPackets(4);
    data.setPacketInInvalidTtlPackets(5);
    data.setPacketInActionSetPackets(6);
    data.setPacketInGroupPackets(7);
    data.setPacketInPacketOutPackets(8);
    data.setPacketOutTotalPacketsDataplane(9);
    data.setPacketOutTotalPacketsHost(10);
    data.setPacketOutEth0InterfaceUp(true);
    sendStatsMessage(new GetPacketInOutStatsResponse(SWITCH_ID_1, data));
    List<Datapoint> datapoints = pollDatapoints(11);
    Map<String, Datapoint> map = createDatapointMap(datapoints);
    assertMetric(data.getPacketInTotalPackets(), "switch.packet-in.total-packets", map);
    assertMetric(data.getPacketInTotalPacketsDataplane(), "switch.packet-in.total-packets.dataplane", map);
    assertMetric(data.getPacketInNoMatchPackets(), "switch.packet-in.no-match.packets", map);
    assertMetric(data.getPacketInApplyActionPackets(), "switch.packet-in.apply-action.packets", map);
    assertMetric(data.getPacketInInvalidTtlPackets(), "switch.packet-in.invalid-ttl.packets", map);
    assertMetric(data.getPacketInActionSetPackets(), "switch.packet-in.action-set.packets", map);
    assertMetric(data.getPacketInGroupPackets(), "switch.packet-in.group.packets", map);
    assertMetric(data.getPacketInPacketOutPackets(), "switch.packet-in.packet-out.packets", map);
    assertMetric(data.getPacketOutTotalPacketsHost(), "switch.packet-out.total-packets.host", map);
    assertMetric(data.getPacketOutTotalPacketsDataplane(), "switch.packet-out.total-packets.dataplane", map);
    assertMetric(1, "switch.packet-out.eth0-interface-up", map);
    datapoints.forEach(datapoint -> {
        assertEquals(1, datapoint.getTags().size());
        assertEquals(SWITCH_ID_1.toOtsdFormat(), datapoint.getTags().get("switchid"));
        assertEquals(timestamp, datapoint.getTime().longValue());
    });
}
Also used : Datapoint(org.openkilda.messaging.info.Datapoint) GetPacketInOutStatsResponse(org.openkilda.messaging.info.grpc.GetPacketInOutStatsResponse) PacketInOutStatsDto(org.openkilda.messaging.model.grpc.PacketInOutStatsDto) AbstractStormTest(org.openkilda.wfm.AbstractStormTest) Test(org.junit.Test)

Example 3 with PacketInOutStatsDto

use of org.openkilda.messaging.model.grpc.PacketInOutStatsDto in project open-kilda by telstra.

the class PacketInOutMetricGenBolt method emit.

private void emit(GetPacketInOutStatsResponse response) {
    long timestamp = getCommandContext().getCreateTime();
    PacketInOutStatsDto stats = response.getStats();
    Map<String, String> tags = ImmutableMap.of("switchid", response.getSwitchId().toOtsdFormat());
    emitMetric("switch.packet-in.total-packets.dataplane", timestamp, stats.getPacketInTotalPacketsDataplane(), tags);
    emitMetric("switch.packet-in.total-packets", timestamp, stats.getPacketInTotalPackets(), tags);
    emitMetric("switch.packet-in.no-match.packets", timestamp, stats.getPacketInNoMatchPackets(), tags);
    emitMetric("switch.packet-in.apply-action.packets", timestamp, stats.getPacketInApplyActionPackets(), tags);
    emitMetric("switch.packet-in.invalid-ttl.packets", timestamp, stats.getPacketInInvalidTtlPackets(), tags);
    emitMetric("switch.packet-in.action-set.packets", timestamp, stats.getPacketInActionSetPackets(), tags);
    emitMetric("switch.packet-in.group.packets", timestamp, stats.getPacketInGroupPackets(), tags);
    emitMetric("switch.packet-in.packet-out.packets", timestamp, stats.getPacketInPacketOutPackets(), tags);
    emitMetric("switch.packet-out.total-packets.host", timestamp, stats.getPacketOutTotalPacketsHost(), tags);
    emitMetric("switch.packet-out.total-packets.dataplane", timestamp, stats.getPacketOutTotalPacketsDataplane(), tags);
    if (stats.getPacketOutEth0InterfaceUp() != null) {
        emitMetric("switch.packet-out.eth0-interface-up", timestamp, stats.getPacketOutEth0InterfaceUp() ? 1 : 0, tags);
    }
}
Also used : PacketInOutStatsDto(org.openkilda.messaging.model.grpc.PacketInOutStatsDto)

Aggregations

PacketInOutStatsDto (org.openkilda.messaging.model.grpc.PacketInOutStatsDto)3 Test (org.junit.Test)2 Datapoint (org.openkilda.messaging.info.Datapoint)1 GetPacketInOutStatsResponse (org.openkilda.messaging.info.grpc.GetPacketInOutStatsResponse)1 SwitchId (org.openkilda.model.SwitchId)1 AbstractStormTest (org.openkilda.wfm.AbstractStormTest)1