Search in sources :

Example 1 with Link

use of org.openkilda.wfm.topology.flowmonitoring.model.Link 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 2 with Link

use of org.openkilda.wfm.topology.flowmonitoring.model.Link in project open-kilda by telstra.

the class IslCacheBolt method handleInput.

@Override
protected void handleInput(Tuple input) throws PipelineException {
    if (!active) {
        return;
    }
    if (ComponentId.ISL_SPLITTER_BOLT.name().equals(input.getSourceComponent())) {
        InfoData data = pullValue(input, INFO_DATA_FIELD, InfoData.class);
        if (ISL_UPDATE_STREAM_ID.name().equals(input.getSourceStreamId())) {
            if (data instanceof IslChangedInfoData) {
                islCacheService.handleIslChangedData((IslChangedInfoData) data);
            } else {
                unhandledInput(input);
            }
        } else if (data instanceof IslOneWayLatency) {
            islCacheService.handleOneWayLatency((IslOneWayLatency) data);
        } else if (data instanceof IslRoundTripLatency) {
            islCacheService.handleRoundTripLatency((IslRoundTripLatency) data);
        } else {
            unhandledInput(input);
        }
        return;
    }
    if (ComponentId.FLOW_CACHE_BOLT.name().equals(input.getSourceComponent())) {
        String requestId = pullValue(input, REQUEST_ID_FIELD, String.class);
        String flowId = pullValue(input, FLOW_ID_FIELD, String.class);
        Link link = pullValue(input, LINK_FIELD, Link.class);
        Duration latency = islCacheService.getLatencyForLink(link);
        emit(input, new Values(requestId, flowId, link, latency, getCommandContext()));
    } else {
        unhandledInput(input);
    }
}
Also used : IslChangedInfoData(org.openkilda.messaging.info.event.IslChangedInfoData) IslRoundTripLatency(org.openkilda.messaging.info.event.IslRoundTripLatency) InfoData(org.openkilda.messaging.info.InfoData) IslChangedInfoData(org.openkilda.messaging.info.event.IslChangedInfoData) Values(org.apache.storm.tuple.Values) Duration(java.time.Duration) Link(org.openkilda.wfm.topology.flowmonitoring.model.Link) IslOneWayLatency(org.openkilda.messaging.info.event.IslOneWayLatency)

Example 3 with Link

use of org.openkilda.wfm.topology.flowmonitoring.model.Link 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 4 with Link

use of org.openkilda.wfm.topology.flowmonitoring.model.Link in project open-kilda by telstra.

the class IslCacheService method handleOneWayLatency.

/**
 * Update one way latency for ISL.
 */
public void handleOneWayLatency(IslOneWayLatency data) {
    Link link = Link.builder().srcSwitchId(data.getSrcSwitchId()).srcPort(data.getSrcPortNo()).destSwitchId(data.getDstSwitchId()).destPort(data.getDstPortNo()).build();
    LinkState linkState = linkStates.get(link);
    if (linkState == null) {
        linkStates.put(link, LinkState.builder().oneWayLatency(data.getLatency()).build());
    } else {
        linkState.setOneWayLatency(data.getLatency());
    }
}
Also used : Link(org.openkilda.wfm.topology.flowmonitoring.model.Link) LinkState(org.openkilda.wfm.topology.flowmonitoring.model.LinkState)

Example 5 with Link

use of org.openkilda.wfm.topology.flowmonitoring.model.Link in project open-kilda by telstra.

the class IslCacheService method handleRoundTripLatency.

/**
 * Update RTT latency for ISL.
 */
public void handleRoundTripLatency(IslRoundTripLatency data) {
    List<Link> links = linkStates.keySet().stream().filter(link -> link.srcEquals(data.getSrcSwitchId(), data.getSrcPortNo())).collect(Collectors.toList());
    Instant instant = clock.instant();
    links.forEach(link -> {
        LinkState linkState = linkStates.get(link);
        if (linkState == null) {
            linkStates.put(link, LinkState.builder().rttLatency(data.getLatency()).rttTimestamp(instant).build());
        } else {
            linkState.setRttLatency(data.getLatency());
            linkState.setRttTimestamp(instant);
        }
    });
}
Also used : HashMap(java.util.HashMap) LinkState(org.openkilda.wfm.topology.flowmonitoring.model.LinkState) Instant(java.time.Instant) Collectors(java.util.stream.Collectors) Slf4j(lombok.extern.slf4j.Slf4j) List(java.util.List) IslRoundTripLatency(org.openkilda.messaging.info.event.IslRoundTripLatency) SwitchId(org.openkilda.model.SwitchId) LinkMapper(org.openkilda.wfm.topology.flowmonitoring.mapper.LinkMapper) IslRepository(org.openkilda.persistence.repositories.IslRepository) Duration(java.time.Duration) Map(java.util.Map) Link(org.openkilda.wfm.topology.flowmonitoring.model.Link) Clock(java.time.Clock) PersistenceManager(org.openkilda.persistence.PersistenceManager) IslChangedInfoData(org.openkilda.messaging.info.event.IslChangedInfoData) IslOneWayLatency(org.openkilda.messaging.info.event.IslOneWayLatency) Instant(java.time.Instant) Link(org.openkilda.wfm.topology.flowmonitoring.model.Link) LinkState(org.openkilda.wfm.topology.flowmonitoring.model.LinkState)

Aggregations

Link (org.openkilda.wfm.topology.flowmonitoring.model.Link)7 Duration (java.time.Duration)3 Test (org.junit.Test)3 Flow (org.openkilda.model.Flow)3 InMemoryGraphBasedTest (org.openkilda.persistence.inmemory.InMemoryGraphBasedTest)3 Instant (java.time.Instant)2 Values (org.apache.storm.tuple.Values)2 IslChangedInfoData (org.openkilda.messaging.info.event.IslChangedInfoData)2 IslOneWayLatency (org.openkilda.messaging.info.event.IslOneWayLatency)2 IslRoundTripLatency (org.openkilda.messaging.info.event.IslRoundTripLatency)2 UpdateFlowCommand (org.openkilda.messaging.info.flow.UpdateFlowCommand)2 FlowRttStatsData (org.openkilda.messaging.info.stats.FlowRttStatsData)2 LinkState (org.openkilda.wfm.topology.flowmonitoring.model.LinkState)2 Clock (java.time.Clock)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Collectors (java.util.stream.Collectors)1 Slf4j (lombok.extern.slf4j.Slf4j)1 InfoData (org.openkilda.messaging.info.InfoData)1