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");
}
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);
}
}
Aggregations