Search in sources :

Example 1 with IslChangedInfoData

use of org.openkilda.messaging.info.event.IslChangedInfoData 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 2 with IslChangedInfoData

use of org.openkilda.messaging.info.event.IslChangedInfoData in project open-kilda by telstra.

the class IslCacheServiceTest method shouldHandleMovedIslFromCache.

@Test
public void shouldHandleMovedIslFromCache() {
    IslRoundTripLatency islRoundTripLatency = new IslRoundTripLatency(FIRST_SWITCH, ISL_SRC_PORT, 7, 1L);
    service.handleRoundTripLatency(islRoundTripLatency);
    int newPort = 33;
    IslChangedInfoData islChangedInfoData = IslChangedInfoData.builder().source(NetworkEndpoint.builder().datapath(FIRST_SWITCH).portNumber(ISL_SRC_PORT).build()).destination(NetworkEndpoint.builder().datapath(THIRD_SWITCH).portNumber(newPort).build()).build();
    service.handleIslChangedData(islChangedInfoData);
    long rttLatency = 1000L;
    IslRoundTripLatency isl2RoundTripLatency = new IslRoundTripLatency(FIRST_SWITCH, ISL_SRC_PORT, rttLatency, 1L);
    when(clock.instant()).thenReturn(Instant.now());
    service.handleRoundTripLatency(isl2RoundTripLatency);
    long actual = service.getLatencyForLink(Link.builder().srcSwitchId(FIRST_SWITCH).srcPort(ISL_SRC_PORT).destSwitchId(THIRD_SWITCH).destPort(newPort).build()).getNano();
    assertEquals(rttLatency, actual);
}
Also used : IslChangedInfoData(org.openkilda.messaging.info.event.IslChangedInfoData) IslRoundTripLatency(org.openkilda.messaging.info.event.IslRoundTripLatency) NetworkEndpoint(org.openkilda.messaging.model.NetworkEndpoint) InMemoryGraphBasedTest(org.openkilda.persistence.inmemory.InMemoryGraphBasedTest) Test(org.junit.Test)

Example 3 with IslChangedInfoData

use of org.openkilda.messaging.info.event.IslChangedInfoData in project open-kilda by telstra.

the class IslCacheServiceTest method shouldRemoveDeletedIslFromCache.

@Test
public void shouldRemoveDeletedIslFromCache() {
    long rttLatency = 1000L;
    IslRoundTripLatency islRoundTripLatency = new IslRoundTripLatency(FIRST_SWITCH, ISL_SRC_PORT, rttLatency, 1L);
    service.handleRoundTripLatency(islRoundTripLatency);
    IslChangedInfoData islChangedInfoData = IslChangedInfoData.builder().source(NetworkEndpoint.builder().datapath(FIRST_SWITCH).portNumber(ISL_SRC_PORT).build()).destination(NetworkEndpoint.builder().datapath(SECOND_SWITCH).portNumber(ISL_DST_PORT).build()).removed(true).build();
    service.handleIslChangedData(islChangedInfoData);
    long actual = service.getLatencyForLink(LINK).getNano();
    assertEquals(0, actual);
}
Also used : IslChangedInfoData(org.openkilda.messaging.info.event.IslChangedInfoData) IslRoundTripLatency(org.openkilda.messaging.info.event.IslRoundTripLatency) InMemoryGraphBasedTest(org.openkilda.persistence.inmemory.InMemoryGraphBasedTest) Test(org.junit.Test)

Example 4 with IslChangedInfoData

use of org.openkilda.messaging.info.event.IslChangedInfoData in project open-kilda by telstra.

the class IslDataSplitterBolt method handleInput.

@Override
protected void handleInput(Tuple input) throws PipelineException {
    Message message = pullValue(input, FIELD_ID_PAYLOAD, Message.class);
    InfoData infoData;
    if (message instanceof InfoMessage) {
        infoData = ((InfoMessage) message).getData();
    } else {
        unhandledInput(input);
        return;
    }
    if (infoData instanceof IslChangedInfoData) {
        IslChangedInfoData data = (IslChangedInfoData) infoData;
        emitWithContext(ISL_UPDATE_STREAM_ID.name(), input, new Values(getIslKey(data.getSource().getDatapath(), data.getSource().getPortNumber()), data));
        emitWithContext(ISL_UPDATE_STREAM_ID.name(), input, new Values(getIslKey(data.getDestination().getDatapath(), data.getDestination().getPortNumber()), revert(data)));
    } else if (infoData instanceof IslBaseLatency) {
        IslBaseLatency islBaseLatency = (IslBaseLatency) infoData;
        emit(input, new Values(getIslKey(islBaseLatency.getSrcSwitchId(), islBaseLatency.getSrcPortNo()), infoData, getCommandContext()));
    } else {
        unhandledInput(input);
    }
}
Also used : IslChangedInfoData(org.openkilda.messaging.info.event.IslChangedInfoData) InfoMessage(org.openkilda.messaging.info.InfoMessage) Message(org.openkilda.messaging.Message) InfoData(org.openkilda.messaging.info.InfoData) IslChangedInfoData(org.openkilda.messaging.info.event.IslChangedInfoData) InfoMessage(org.openkilda.messaging.info.InfoMessage) IslBaseLatency(org.openkilda.messaging.info.event.IslBaseLatency) Values(org.apache.storm.tuple.Values)

Example 5 with IslChangedInfoData

use of org.openkilda.messaging.info.event.IslChangedInfoData in project open-kilda by telstra.

the class IslHandler method islChangedNotifyFlowMonitor.

@Override
public void islChangedNotifyFlowMonitor(IslReference reference, boolean removed) {
    Endpoint src = reference.getSource();
    Endpoint dst = reference.getDest();
    IslChangedInfoData islChangedInfoData = IslChangedInfoData.builder().source(new NetworkEndpoint(src.getDatapath(), src.getPortNumber())).destination(new NetworkEndpoint(dst.getDatapath(), dst.getPortNumber())).removed(removed).build();
    emit(STREAM_FLOW_MONITORING_ID, getCurrentTuple(), makeIslChangedTuple(islChangedInfoData));
}
Also used : IslChangedInfoData(org.openkilda.messaging.info.event.IslChangedInfoData) NetworkEndpoint(org.openkilda.messaging.model.NetworkEndpoint) Endpoint(org.openkilda.wfm.share.model.Endpoint) NetworkEndpoint(org.openkilda.messaging.model.NetworkEndpoint)

Aggregations

IslChangedInfoData (org.openkilda.messaging.info.event.IslChangedInfoData)5 IslRoundTripLatency (org.openkilda.messaging.info.event.IslRoundTripLatency)3 Values (org.apache.storm.tuple.Values)2 Test (org.junit.Test)2 InfoData (org.openkilda.messaging.info.InfoData)2 NetworkEndpoint (org.openkilda.messaging.model.NetworkEndpoint)2 InMemoryGraphBasedTest (org.openkilda.persistence.inmemory.InMemoryGraphBasedTest)2 Duration (java.time.Duration)1 Message (org.openkilda.messaging.Message)1 InfoMessage (org.openkilda.messaging.info.InfoMessage)1 IslBaseLatency (org.openkilda.messaging.info.event.IslBaseLatency)1 IslOneWayLatency (org.openkilda.messaging.info.event.IslOneWayLatency)1 Endpoint (org.openkilda.wfm.share.model.Endpoint)1 Link (org.openkilda.wfm.topology.flowmonitoring.model.Link)1