Search in sources :

Example 1 with FlowRttStatsData

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);
}
Also used : FlowRttStatsData(org.openkilda.messaging.info.stats.FlowRttStatsData) Instant(java.time.Instant) Link(org.openkilda.wfm.topology.flowmonitoring.model.Link) Flow(org.openkilda.model.Flow) InMemoryGraphBasedTest(org.openkilda.persistence.inmemory.InMemoryGraphBasedTest) Test(org.junit.Test)

Example 2 with FlowRttStatsData

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");
}
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 3 with FlowRttStatsData

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);
    }
}
Also used : UpdateFlowCommand(org.openkilda.messaging.info.flow.UpdateFlowCommand) FlowRttStatsData(org.openkilda.messaging.info.stats.FlowRttStatsData) Values(org.apache.storm.tuple.Values) Duration(java.time.Duration) Link(org.openkilda.wfm.topology.flowmonitoring.model.Link)

Example 4 with 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);
    }
}
Also used : UpdateFlowCommand(org.openkilda.messaging.info.flow.UpdateFlowCommand) InfoMessage(org.openkilda.messaging.info.InfoMessage) Message(org.openkilda.messaging.Message) CommandMessage(org.openkilda.messaging.command.CommandMessage) FlowRttStatsData(org.openkilda.messaging.info.stats.FlowRttStatsData) InfoMessage(org.openkilda.messaging.info.InfoMessage) InfoData(org.openkilda.messaging.info.InfoData) Values(org.apache.storm.tuple.Values) RemoveFlowCommand(org.openkilda.messaging.info.flow.RemoveFlowCommand) CommandData(org.openkilda.messaging.command.CommandData) CommandMessage(org.openkilda.messaging.command.CommandMessage)

Example 5 with FlowRttStatsData

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());
}
Also used : Datapoint(org.openkilda.messaging.info.Datapoint) FlowRttStatsData(org.openkilda.messaging.info.stats.FlowRttStatsData) InfoMessage(org.openkilda.messaging.info.InfoMessage) AbstractStormTest(org.openkilda.wfm.AbstractStormTest) Test(org.junit.Test)

Aggregations

FlowRttStatsData (org.openkilda.messaging.info.stats.FlowRttStatsData)7 InfoMessage (org.openkilda.messaging.info.InfoMessage)5 Test (org.junit.Test)3 Values (org.apache.storm.tuple.Values)2 UpdateFlowCommand (org.openkilda.messaging.info.flow.UpdateFlowCommand)2 FlowLatencyPacket (org.openkilda.server42.stats.messaging.Statistics.FlowLatencyPacket)2 Link (org.openkilda.wfm.topology.flowmonitoring.model.Link)2 Duration (java.time.Duration)1 Instant (java.time.Instant)1 Message (org.openkilda.messaging.Message)1 CommandData (org.openkilda.messaging.command.CommandData)1 CommandMessage (org.openkilda.messaging.command.CommandMessage)1 Datapoint (org.openkilda.messaging.info.Datapoint)1 InfoData (org.openkilda.messaging.info.InfoData)1 RemoveFlowCommand (org.openkilda.messaging.info.flow.RemoveFlowCommand)1 IslRttStatsData (org.openkilda.messaging.info.stats.IslRttStatsData)1 Flow (org.openkilda.model.Flow)1 InMemoryGraphBasedTest (org.openkilda.persistence.inmemory.InMemoryGraphBasedTest)1 IslLatencyPacket (org.openkilda.server42.stats.messaging.Statistics.IslLatencyPacket)1 Builder (org.openkilda.server42.stats.messaging.Statistics.LatencyPacketBucket.Builder)1