use of org.openkilda.messaging.info.stats.FlowRttStatsData in project open-kilda by telstra.
the class FlowCacheServiceTest method shouldSendCheckFlowSlaRequests.
@Test
public void shouldSendCheckFlowSlaRequests() {
Flow flow = createFlow();
Instant now = Instant.now();
when(clock.instant()).thenReturn(now);
service = new FlowCacheService(persistenceManager, clock, FLOW_RTT_STATS_EXPIRATION_TIME, carrier);
long t0 = (now.getEpochSecond() << 32) + 1234;
long t1 = (now.getEpochSecond() << 32) + 2345;
FlowRttStatsData flowRttStatsData = FlowRttStatsData.builder().flowId(flow.getFlowId()).direction(FlowDirection.FORWARD.name().toLowerCase()).t0(t0).t1(t1).build();
service.processFlowRttStatsData(flowRttStatsData);
service.processFlowLatencyCheck(flow.getFlowId());
List<Link> expectedForwardPath = getLinks(SRC_SWITCH, ISL_SRC_PORT, DST_SWITCH, ISL_DST_PORT);
verify(carrier).emitCheckFlowLatencyRequest(flow.getFlowId(), FlowDirection.FORWARD, TimestampHelper.noviflowTimestampsToDuration(t0, t1));
List<Link> expectedReversePath = reverse(expectedForwardPath);
verify(carrier).emitCalculateFlowLatencyRequest(flow.getFlowId(), FlowDirection.REVERSE, expectedReversePath);
verifyNoMoreInteractions(carrier);
}
use of org.openkilda.messaging.info.stats.FlowRttStatsData 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.messaging.info.stats.FlowRttStatsData in project open-kilda by telstra.
the class FlowCacheBolt method handleInput.
@Override
protected void handleInput(Tuple input) throws PipelineException {
if (active) {
if (ComponentId.FLOW_STATE_CACHE_BOLT.name().equals(input.getSourceComponent())) {
if (FLOW_UPDATE_STREAM_ID.name().equals(input.getSourceStreamId())) {
UpdateFlowCommand updateFlowCommand = pullValue(input, COMMAND_DATA_FIELD, UpdateFlowCommand.class);
flowCacheService.updateFlowInfo(updateFlowCommand);
emit(FLOW_UPDATE_STREAM_ID.name(), input, new Values(updateFlowCommand.getFlowId(), updateFlowCommand, getCommandContext()));
} else if (FLOW_REMOVE_STREAM_ID.name().equals(input.getSourceStreamId())) {
String flowId = pullValue(input, FLOW_ID_FIELD, String.class);
flowCacheService.removeFlowInfo(flowId);
emit(FLOW_REMOVE_STREAM_ID.name(), input, new Values(flowId, getCommandContext()));
} else {
String flowId = pullValue(input, FLOW_ID_FIELD, String.class);
flowCacheService.processFlowLatencyCheck(flowId);
}
return;
}
if (ComponentId.ISL_CACHE_BOLT.name().equals(input.getSourceComponent())) {
String requestId = pullValue(input, REQUEST_ID_FIELD, String.class);
Link link = pullValue(input, LINK_FIELD, Link.class);
Duration latency = pullValue(input, LATENCY_FIELD, Duration.class);
calculateFlowLatencyService.handleGetLinkLatencyResponse(requestId, link, latency);
return;
}
FlowRttStatsData flowRttStatsData = pullValue(input, INFO_DATA_FIELD, FlowRttStatsData.class);
flowCacheService.processFlowRttStatsData(flowRttStatsData);
}
}
use of org.openkilda.messaging.info.stats.FlowRttStatsData in project open-kilda by telstra.
the class FlowSplitterBolt method handleInput.
@Override
protected void handleInput(Tuple input) throws PipelineException {
Message message = pullValue(input, FIELD_ID_PAYLOAD, Message.class);
if (message instanceof InfoMessage) {
InfoData infoData = ((InfoMessage) message).getData();
if (infoData instanceof FlowRttStatsData) {
FlowRttStatsData flowRttStatsData = (FlowRttStatsData) infoData;
emit(input, new Values(flowRttStatsData.getFlowId(), flowRttStatsData, getCommandContext()));
} else {
unhandledInput(input);
}
return;
}
if (message instanceof CommandMessage) {
CommandData commandData = pullValue(input, FIELD_ID_PAYLOAD, CommandMessage.class).getData();
if (commandData instanceof UpdateFlowCommand) {
UpdateFlowCommand updateFlowCommand = (UpdateFlowCommand) commandData;
emit(FLOW_UPDATE_STREAM_ID.name(), input, new Values(updateFlowCommand.getFlowId(), updateFlowCommand, getCommandContext()));
} else if (commandData instanceof RemoveFlowCommand) {
RemoveFlowCommand removeFlowCommand = (RemoveFlowCommand) commandData;
emit(FLOW_REMOVE_STREAM_ID.name(), input, new Values(removeFlowCommand.getFlowId(), getCommandContext()));
} else {
unhandledInput(input);
}
} else {
unhandledInput(input);
}
}
use of org.openkilda.messaging.info.stats.FlowRttStatsData in project open-kilda by telstra.
the class StatsTopologyTest method flowRttTest.
@Test
public void flowRttTest() {
FlowRttStatsData flowRttStatsData = FlowRttStatsData.builder().flowId(flowId).direction("forward").t0(123456789_987654321L).t1(123456789_987654321L + 1).build();
long seconds = (123456789_987654321L >> 32);
long nanoseconds = (123456789_987654321L & 0xFFFFFFFFL);
long timestamp = TimeUnit.NANOSECONDS.toMillis(TimeUnit.SECONDS.toNanos(seconds) + nanoseconds);
InfoMessage infoMessage = new InfoMessage(flowRttStatsData, timestamp, UUID.randomUUID().toString(), Destination.WFM_STATS, null);
sendMessage(infoMessage, statsTopologyConfig.getServer42StatsFlowRttTopic());
List<Datapoint> datapoints = pollDatapoints(1);
assertEquals(1, datapoints.size());
Datapoint datapoint = datapoints.get(0);
assertEquals(METRIC_PREFIX + "flow.rtt", datapoint.getMetric());
assertEquals(1, datapoint.getValue());
assertEquals("forward", datapoint.getTags().get("direction"));
assertEquals(flowId, datapoint.getTags().get("flowid"));
assertEquals(timestamp, datapoint.getTime().longValue());
}
Aggregations