Search in sources :

Example 1 with FlowLatencyPacket

use of org.openkilda.server42.stats.messaging.Statistics.FlowLatencyPacket in project open-kilda by telstra.

the class StatsCollectorTest method sendStatsTest.

@Test
public void sendStatsTest() throws Exception {
    Builder bucketBuilder = LatencyPacketBucket.newBuilder();
    FlowLatencyPacket packet1 = FlowLatencyPacket.newBuilder().setFlowId("some-flow-id-1").setDirection(false).setT0(100).setT1(150).setPacketId(1).build();
    FlowLatencyPacket packet2 = FlowLatencyPacket.newBuilder().setDirection(true).setT0(200).setT1(250).setPacketId(2).build();
    bucketBuilder.addFlowLatencyPacket(packet1);
    bucketBuilder.addFlowLatencyPacket(packet2);
    statsCollector.sendStats(bucketBuilder.build());
    ArgumentCaptor<InfoMessage> argument = ArgumentCaptor.forClass(InfoMessage.class);
    verify(template).send(eq(toStorm), eq(packet1.getFlowId()), argument.capture());
    InfoMessage packet1Message = argument.getValue();
    FlowRttStatsData statsPacket1 = (FlowRttStatsData) packet1Message.getData();
    assertThat(statsPacket1).extracting(FlowRttStatsData::getFlowId, FlowRttStatsData::getT0, FlowRttStatsData::getT1).contains(packet1.getFlowId(), packet1.getT0(), packet1.getT1());
    assertThat(statsPacket1).extracting(FlowRttStatsData::getDirection).isEqualTo("forward");
    verify(template).send(eq(toStorm), eq(packet2.getFlowId()), argument.capture());
    InfoMessage packet2Message = argument.getValue();
    FlowRttStatsData statsPacket2 = (FlowRttStatsData) packet2Message.getData();
    assertThat(statsPacket2).extracting(FlowRttStatsData::getFlowId, FlowRttStatsData::getT0, FlowRttStatsData::getT1).contains(packet2.getFlowId(), packet2.getT0(), packet2.getT1());
    assertThat(statsPacket2).extracting(FlowRttStatsData::getDirection).isEqualTo("reverse");
}
Also used : FlowRttStatsData(org.openkilda.messaging.info.stats.FlowRttStatsData) InfoMessage(org.openkilda.messaging.info.InfoMessage) Builder(org.openkilda.server42.stats.messaging.Statistics.LatencyPacketBucket.Builder) FlowLatencyPacket(org.openkilda.server42.stats.messaging.Statistics.FlowLatencyPacket) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 2 with FlowLatencyPacket

use of org.openkilda.server42.stats.messaging.Statistics.FlowLatencyPacket in project open-kilda by telstra.

the class StatsCollector method sendStats.

void sendStats(LatencyPacketBucket latencyPacketBucket) throws InvalidProtocolBufferException {
    long currentTimeMillis = System.currentTimeMillis();
    for (FlowLatencyPacket packet : latencyPacketBucket.getFlowLatencyPacketList()) {
        FlowRttStatsData data = new FlowRttStatsData(packet.getFlowId(), FlowDirection.fromBoolean(packet.getDirection()).name().toLowerCase(), packet.getT0(), packet.getT1());
        InfoMessage message = new InfoMessage(data, currentTimeMillis, format("stats42-%s-%d", sessionId, packet.getPacketId()));
        log.debug("InfoMessage {}", message);
        template.send(flowStatToStormTopic, packet.getFlowId(), message);
    }
    for (IslLatencyPacket packet : latencyPacketBucket.getIslLatencyPacketList()) {
        IslRttStatsData data = new IslRttStatsData(packet.getSwitchId(), packet.getPort(), packet.getT0(), packet.getT1(), "server42");
        String key = format("%s-%d", packet.getSwitchId(), packet.getPort());
        InfoMessage message = new InfoMessage(data, currentTimeMillis, format("stats42-%s-isl-%s", sessionId, key));
        log.debug("InfoMessage {}", message);
        template.send(islStatToStormTopic, key, message);
    }
}
Also used : FlowRttStatsData(org.openkilda.messaging.info.stats.FlowRttStatsData) IslLatencyPacket(org.openkilda.server42.stats.messaging.Statistics.IslLatencyPacket) InfoMessage(org.openkilda.messaging.info.InfoMessage) FlowLatencyPacket(org.openkilda.server42.stats.messaging.Statistics.FlowLatencyPacket) IslRttStatsData(org.openkilda.messaging.info.stats.IslRttStatsData)

Aggregations

InfoMessage (org.openkilda.messaging.info.InfoMessage)2 FlowRttStatsData (org.openkilda.messaging.info.stats.FlowRttStatsData)2 FlowLatencyPacket (org.openkilda.server42.stats.messaging.Statistics.FlowLatencyPacket)2 Test (org.junit.Test)1 IslRttStatsData (org.openkilda.messaging.info.stats.IslRttStatsData)1 IslLatencyPacket (org.openkilda.server42.stats.messaging.Statistics.IslLatencyPacket)1 Builder (org.openkilda.server42.stats.messaging.Statistics.LatencyPacketBucket.Builder)1 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)1