Search in sources :

Example 36 with IslInfoData

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

the class PathVerificationService method handleDiscoveryPacket.

private void handleDiscoveryPacket(OfInput input, IOFSwitch destSwitch, DiscoveryPacketData data) {
    OFPort inPort = OFMessageUtils.getInPort((OFPacketIn) input.getMessage());
    long latencyMs = measureLatency(input, data.getTimestamp());
    dashboardLogger.onIslDiscovery(data.getRemoteSwitchId(), data.getRemotePort(), input.getDpId(), inPort, latencyMs, data.getPacketId(), input.getMessage().getXid());
    // this discovery packet was sent from remote switch/port to received switch/port
    // so the link direction is from remote switch/port to received switch/port
    PathNode source = new PathNode(new SwitchId(data.getRemoteSwitchId().getLong()), data.getRemotePort().getPortNumber(), 0);
    PathNode destination = new PathNode(new SwitchId(input.getDpId().getLong()), inPort.getPortNumber(), 1);
    long speed = getSwitchPortSpeed(destSwitch, inPort);
    IslInfoData path = IslInfoData.builder().source(source).destination(destination).speed(speed).state(IslChangeType.DISCOVERED).availableBandwidth(getAvailableBandwidth(speed)).packetId(data.getPacketId()).build();
    sendDiscovery(path);
    logger.debug("packet_in processed for {}-{}", input.getDpId(), inPort);
    IslOneWayLatency islOneWayLatency = new IslOneWayLatency(source.getSwitchId(), source.getPortNo(), destination.getSwitchId(), destination.getPortNo(), // TODO(surabujin): do we really need fake ns accuracy?
    scaleLatencyMsToNs(latencyMs), data.getPacketId());
    sendLatency(islOneWayLatency, source.getSwitchId());
}
Also used : OFPort(org.projectfloodlight.openflow.types.OFPort) SwitchId(org.openkilda.model.SwitchId) IslInfoData(org.openkilda.messaging.info.event.IslInfoData) PathNode(org.openkilda.messaging.info.event.PathNode) IslOneWayLatency(org.openkilda.messaging.info.event.IslOneWayLatency)

Example 37 with IslInfoData

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

the class NetworkUniIslServiceTest method replugIntoSelfLoop.

@Test
public void replugIntoSelfLoop() {
    NetworkUniIslService service = new NetworkUniIslService(carrier);
    Endpoint endpointA = Endpoint.of(alphaDatapath, 1);
    Endpoint endpointZ = Endpoint.of(betaDatapath, 2);
    verifyNoMoreInteractions(carrier);
    service.uniIslSetup(endpointA, null);
    Isl genericIsl = makeIslBuilder(endpointA, endpointZ).build();
    IslInfoData genericData = IslMapper.INSTANCE.map(genericIsl);
    service.uniIslDiscovery(endpointA, genericData);
    verify(carrier).notifyIslUp(eq(endpointA), eq(IslReference.of(genericIsl)), eq(new IslDataHolder(genericData)));
    // replug into self-loop
    Isl selfLoopIsl = makeIslBuilder(endpointA, Endpoint.of(endpointA.getDatapath(), endpointA.getPortNumber() + 1)).build();
    IslInfoData selfLoopData = IslMapper.INSTANCE.map((selfLoopIsl));
    service.uniIslDiscovery(endpointA, selfLoopData);
    verify(carrier, times(1)).notifyIslMove(eq(endpointA), eq(IslReference.of(genericIsl)));
    verify(carrier, times(0)).notifyIslUp(eq(endpointA), eq(IslReference.of(selfLoopIsl)), eq(new IslDataHolder(selfLoopData)));
    service.uniIslDiscovery(endpointA, selfLoopData);
    // no new move events and no discovery notifications for self-looped ISL
    verify(carrier, times(1)).notifyIslMove(eq(endpointA), eq(IslReference.of(genericIsl)));
    verify(carrier, times(0)).notifyIslUp(eq(endpointA), eq(IslReference.of(selfLoopIsl)), eq(new IslDataHolder(selfLoopData)));
}
Also used : Isl(org.openkilda.model.Isl) Endpoint(org.openkilda.wfm.share.model.Endpoint) IslInfoData(org.openkilda.messaging.info.event.IslInfoData) IslDataHolder(org.openkilda.wfm.topology.network.model.IslDataHolder) Test(org.junit.Test)

Example 38 with IslInfoData

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

the class NetworkUniIslServiceTest method shouldProxyRoundTripStatus.

@Test
public void shouldProxyRoundTripStatus() {
    final NetworkUniIslService service = new NetworkUniIslService(carrier);
    final Endpoint endpointAlpha = Endpoint.of(alphaDatapath, 1);
    final Endpoint endpointBeta = Endpoint.of(betaDatapath, 1);
    service.uniIslSetup(endpointAlpha, null);
    Switch alphaSwitch = Switch.builder().switchId(endpointAlpha.getDatapath()).build();
    Switch betaSwitch = Switch.builder().switchId(endpointBeta.getDatapath()).build();
    Isl islA1toB1 = Isl.builder().srcSwitch(alphaSwitch).srcPort(endpointAlpha.getPortNumber()).destSwitch(betaSwitch).destPort(endpointBeta.getPortNumber()).build();
    IslInfoData discovery = IslMapper.INSTANCE.map(islA1toB1);
    service.uniIslDiscovery(endpointAlpha, discovery);
    verifyProxyRoundTripStatus(service, endpointAlpha, endpointBeta);
    service.uniIslPhysicalDown(endpointAlpha);
    verifyProxyRoundTripStatus(service, endpointAlpha, endpointBeta);
    service.uniIslDiscovery(endpointAlpha, discovery);
    verifyProxyRoundTripStatus(service, endpointAlpha, endpointBeta);
}
Also used : Isl(org.openkilda.model.Isl) Endpoint(org.openkilda.wfm.share.model.Endpoint) Switch(org.openkilda.model.Switch) IslInfoData(org.openkilda.messaging.info.event.IslInfoData) Test(org.junit.Test)

Example 39 with IslInfoData

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

the class NetworkWatcherServiceTest method discovery.

@Test
public void discovery() {
    NetworkWatcherService w = makeService();
    w.addWatch(Endpoint.of(new SwitchId(1), 1), 1);
    w.addWatch(Endpoint.of(new SwitchId(1), 2), 1);
    w.addWatch(Endpoint.of(new SwitchId(2), 1), 2);
    w.addWatch(Endpoint.of(new SwitchId(2), 1), 2);
    w.addWatch(Endpoint.of(new SwitchId(2), 2), 3);
    assertThat(w.getConfirmedPackets().size(), is(0));
    assertThat(w.getTimeouts().size(), is(3));
    verify(carrier, times(5)).sendDiscovery(any(DiscoverIslCommandData.class));
    w.confirmation(Endpoint.of(new SwitchId(1), 1), 0);
    w.confirmation(Endpoint.of(new SwitchId(2), 1), 2);
    assertThat(w.getConfirmedPackets().size(), is(2));
    PathNode source = new PathNode(new SwitchId(1), 1, 0);
    PathNode destination = new PathNode(new SwitchId(2), 1, 0);
    IslInfoData islAlphaBeta = IslInfoData.builder().source(source).destination(destination).packetId(0L).build();
    IslInfoData islBetaAlpha = IslInfoData.builder().source(destination).destination(source).packetId(2L).build();
    w.discovery(islAlphaBeta);
    w.discovery(islBetaAlpha);
    w.tick(100);
    assertThat(w.getConfirmedPackets().size(), is(0));
    verify(carrier).oneWayDiscoveryReceived(eq(new Endpoint(islAlphaBeta.getSource())), eq(0L), eq(islAlphaBeta), anyLong());
    verify(carrier).oneWayDiscoveryReceived(eq(new Endpoint(islBetaAlpha.getSource())), eq(2L), eq(islBetaAlpha), anyLong());
    verify(carrier, times(2)).oneWayDiscoveryReceived(any(Endpoint.class), anyLong(), any(IslInfoData.class), anyLong());
    assertThat(w.getTimeouts().size(), is(0));
}
Also used : DiscoverIslCommandData(org.openkilda.messaging.command.discovery.DiscoverIslCommandData) Endpoint(org.openkilda.wfm.share.model.Endpoint) SwitchId(org.openkilda.model.SwitchId) IslInfoData(org.openkilda.messaging.info.event.IslInfoData) PathNode(org.openkilda.messaging.info.event.PathNode) Test(org.junit.Test)

Example 40 with IslInfoData

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

the class LinkOperationsBolt method deleteLink.

private List<IslInfoData> deleteLink(DeleteLinkRequest request) {
    try {
        Collection<Isl> operationsResult = linkOperationsService.deleteIsl(request.getSrcSwitch(), request.getSrcPort(), request.getDstSwitch(), request.getDstPort(), request.isForce());
        List<IslInfoData> responseResult = operationsResult.stream().map(IslMapper.INSTANCE::map).collect(Collectors.toList());
        for (IslInfoData isl : responseResult) {
            DeactivateIslInfoData data = new DeactivateIslInfoData(isl.getSource(), isl.getDestination());
            getOutput().emit(StreamType.DISCO.toString(), getCurrentTuple(), new Values(data, getCorrelationId()));
        }
        return responseResult;
    } catch (IslNotFoundException e) {
        throw new MessageException(ErrorType.NOT_FOUND, e.getMessage(), "ISL was not found.");
    } catch (IllegalIslStateException e) {
        throw new MessageException(ErrorType.REQUEST_INVALID, e.getMessage(), "ISL is in illegal state.");
    }
}
Also used : DeactivateIslInfoData(org.openkilda.messaging.info.event.DeactivateIslInfoData) Isl(org.openkilda.model.Isl) MessageException(org.openkilda.messaging.error.MessageException) Values(org.apache.storm.tuple.Values) IslNotFoundException(org.openkilda.wfm.error.IslNotFoundException) DeactivateIslInfoData(org.openkilda.messaging.info.event.DeactivateIslInfoData) IslInfoData(org.openkilda.messaging.info.event.IslInfoData) IslMapper(org.openkilda.wfm.share.mappers.IslMapper) IllegalIslStateException(org.openkilda.wfm.error.IllegalIslStateException)

Aggregations

IslInfoData (org.openkilda.messaging.info.event.IslInfoData)51 PathNode (org.openkilda.messaging.info.event.PathNode)29 Test (org.junit.Test)25 Endpoint (org.openkilda.wfm.share.model.Endpoint)12 SwitchId (org.openkilda.model.SwitchId)10 SwitchInfoData (org.openkilda.messaging.info.event.SwitchInfoData)9 Isl (org.openkilda.model.Isl)9 InfoMessage (org.openkilda.messaging.info.InfoMessage)8 ArrayList (java.util.ArrayList)6 When (cucumber.api.java.en.When)5 IOException (java.io.IOException)5 InfoData (org.openkilda.messaging.info.InfoData)5 Switch (org.openkilda.model.Switch)5 Then (cucumber.api.java.en.Then)4 List (java.util.List)4 CommandMessage (org.openkilda.messaging.command.CommandMessage)4 Comparator (java.util.Comparator)3 Collectors (java.util.stream.Collectors)3 Message (org.openkilda.messaging.Message)3 CacheException (org.openkilda.messaging.error.CacheException)3