Search in sources :

Example 51 with Isl

use of org.openkilda.model.Isl in project open-kilda by telstra.

the class FermaIslRepository method findIslPortsBySwitchIds.

@Override
public Map<SwitchId, Set<Integer>> findIslPortsBySwitchIds(Set<SwitchId> switchIds) {
    Set<String> graphSwitchIds = switchIds.stream().map(SwitchIdConverter.INSTANCE::toGraphProperty).collect(toSet());
    List<Isl> result = new ArrayList<>();
    framedGraph().traverse(g -> g.E().hasLabel(IslFrame.FRAME_LABEL).has(IslFrame.SRC_SWITCH_ID_PROPERTY, P.within(graphSwitchIds))).frameExplicit(IslFrame.class).forEachRemaining(frame -> result.add(addIslConfigToIsl(new Isl(frame))));
    return result.stream().collect(groupingBy(Isl::getSrcSwitchId, mapping(Isl::getSrcPort, toSet())));
}
Also used : Isl(org.openkilda.model.Isl) IslFrame(org.openkilda.persistence.ferma.frames.IslFrame) SwitchIdConverter(org.openkilda.persistence.ferma.frames.converters.SwitchIdConverter) ArrayList(java.util.ArrayList)

Example 52 with Isl

use of org.openkilda.model.Isl in project open-kilda by telstra.

the class NetworkIslServiceTest method movedOverrideRoundTripState.

@Test
public void movedOverrideRoundTripState() {
    setupIslStorageStub();
    final IslReference reference = prepareActiveIsl();
    // inject round-trip status
    service.roundTripStatusNotification(reference, new RoundTripStatus(reference.getDest(), IslStatus.ACTIVE));
    Optional<Isl> forward = islStorage.lookup(reference.getSource(), reference.getDest());
    Assert.assertTrue(forward.isPresent());
    Assert.assertNotEquals(IslStatus.ACTIVE, forward.get().getRoundTripStatus());
    Assert.assertEquals(IslStatus.ACTIVE, forward.get().getStatus());
    Optional<Isl> reverse = islStorage.lookup(reference.getDest(), reference.getSource());
    Assert.assertTrue(reverse.isPresent());
    Assert.assertEquals(IslStatus.ACTIVE, reverse.get().getRoundTripStatus());
    Assert.assertEquals(IslStatus.ACTIVE, reverse.get().getStatus());
    service.islMove(reference.getSource(), reference);
    verify(dashboardLogger).onIslMoved(eq(reference), any());
    forward = islStorage.lookup(reference.getSource(), reference.getDest());
    Assert.assertTrue(forward.isPresent());
    Assert.assertEquals(IslStatus.MOVED, forward.get().getActualStatus());
    Assert.assertEquals(IslStatus.MOVED, forward.get().getStatus());
    reverse = islStorage.lookup(reference.getDest(), reference.getSource());
    Assert.assertTrue(reverse.isPresent());
    Assert.assertNotEquals(IslStatus.MOVED, reverse.get().getActualStatus());
    Assert.assertEquals(IslStatus.MOVED, reverse.get().getStatus());
    verify(carrier).islStatusUpdateNotification(any(IslStatusUpdateNotification.class));
    verify(carrier).triggerReroute(any(RerouteAffectedFlows.class));
}
Also used : Isl(org.openkilda.model.Isl) IslStatusUpdateNotification(org.openkilda.messaging.info.event.IslStatusUpdateNotification) IslReference(org.openkilda.wfm.share.model.IslReference) RerouteAffectedFlows(org.openkilda.messaging.command.reroute.RerouteAffectedFlows) RoundTripStatus(org.openkilda.wfm.topology.network.model.RoundTripStatus) Test(org.junit.Test)

Example 53 with Isl

use of org.openkilda.model.Isl in project open-kilda by telstra.

the class NetworkIslServiceTest method verifyIslBandwidthUpdate.

private void verifyIslBandwidthUpdate(long expectedForward, long expectedReverse) {
    Isl forward = lookupIsl(endpointAlpha1, endpointBeta2);
    Assert.assertEquals(expectedForward, forward.getMaxBandwidth());
    Assert.assertEquals(expectedForward, forward.getAvailableBandwidth());
    Isl reverse = lookupIsl(endpointBeta2, endpointAlpha1);
    Assert.assertEquals(expectedReverse, reverse.getMaxBandwidth());
    Assert.assertEquals(expectedReverse, reverse.getAvailableBandwidth());
}
Also used : Isl(org.openkilda.model.Isl)

Example 54 with Isl

use of org.openkilda.model.Isl in project open-kilda by telstra.

the class NetworkIslServiceTest method considerLinkPropsDataOnRediscovery.

@Test
public void considerLinkPropsDataOnRediscovery() {
    setupIslStorageStub();
    final Isl islAlphaBeta = makeIsl(endpointAlpha1, endpointBeta2, false).defaultMaxBandwidth(300L).availableBandwidth(300L).build();
    final Isl islBetaAlpha = makeIsl(endpointBeta2, endpointAlpha1, false).defaultMaxBandwidth(300L).availableBandwidth(300L).build();
    // initial discovery
    mockPersistenceLinkProps(endpointAlpha1, endpointBeta2, null);
    mockPersistenceLinkProps(endpointBeta2, endpointAlpha1, null);
    IslReference reference = new IslReference(endpointAlpha1, endpointBeta2);
    service.islUp(endpointAlpha1, reference, new IslDataHolder(300L, 300L, 300L));
    service.islUp(endpointBeta2, reference, new IslDataHolder(300L, 300L, 300L));
    verifyIslBandwidthUpdate(300L, 300L);
    // fail
    service.islDown(endpointAlpha1, reference, IslDownReason.POLL_TIMEOUT);
    service.islDown(endpointBeta2, reference, IslDownReason.POLL_TIMEOUT);
    reset(linkPropsRepository);
    // rediscovery
    mockPersistenceLinkProps(endpointAlpha1, endpointBeta2, makeLinkProps(endpointAlpha1, endpointBeta2).maxBandwidth(50L).build());
    mockPersistenceLinkProps(endpointBeta2, endpointAlpha1, null);
    service.islUp(endpointAlpha1, reference, new IslDataHolder(300L, 300L, 300L));
    service.islUp(endpointBeta2, reference, new IslDataHolder(300L, 300L, 300L));
    verifyIslBandwidthUpdate(50L, 300L);
}
Also used : Isl(org.openkilda.model.Isl) IslReference(org.openkilda.wfm.share.model.IslReference) IslDataHolder(org.openkilda.wfm.topology.network.model.IslDataHolder) Test(org.junit.Test)

Example 55 with Isl

use of org.openkilda.model.Isl in project open-kilda by telstra.

the class NetworkUniIslServiceTest method newIslFromUnknownToDownWithRemote.

@Test
public void newIslFromUnknownToDownWithRemote() {
    NetworkUniIslService service = new NetworkUniIslService(carrier);
    Endpoint endpoint1 = Endpoint.of(alphaDatapath, 1);
    Endpoint endpoint2 = Endpoint.of(alphaDatapath, 2);
    Switch alphaSwitch = Switch.builder().switchId(alphaDatapath).build();
    Switch betaSwitch = Switch.builder().switchId(betaDatapath).build();
    Isl islAtoB = Isl.builder().srcSwitch(alphaSwitch).srcPort(1).destSwitch(betaSwitch).destPort(1).build();
    Isl islAtoB2 = Isl.builder().srcSwitch(alphaSwitch).srcPort(2).destSwitch(betaSwitch).destPort(2).build();
    service.uniIslSetup(endpoint1, islAtoB);
    service.uniIslSetup(endpoint2, islAtoB2);
    resetMocks();
    service.uniIslFail(endpoint1);
    service.uniIslPhysicalDown(endpoint2);
    System.out.println(mockingDetails(carrier).printInvocations());
    verify(carrier).notifyIslDown(endpoint1, IslReference.of(islAtoB), IslDownReason.POLL_TIMEOUT);
    verify(carrier).notifyIslDown(endpoint2, IslReference.of(islAtoB2), IslDownReason.PORT_DOWN);
}
Also used : Isl(org.openkilda.model.Isl) Endpoint(org.openkilda.wfm.share.model.Endpoint) Switch(org.openkilda.model.Switch) Test(org.junit.Test)

Aggregations

Isl (org.openkilda.model.Isl)83 Test (org.junit.Test)49 InMemoryGraphBasedTest (org.openkilda.persistence.inmemory.InMemoryGraphBasedTest)25 Endpoint (org.openkilda.wfm.share.model.Endpoint)18 Switch (org.openkilda.model.Switch)17 IslReference (org.openkilda.wfm.share.model.IslReference)11 SwitchId (org.openkilda.model.SwitchId)10 IslInfoData (org.openkilda.messaging.info.event.IslInfoData)9 IslDataHolder (org.openkilda.wfm.topology.network.model.IslDataHolder)8 ArrayList (java.util.ArrayList)6 PathId (org.openkilda.model.PathId)6 Flow (org.openkilda.model.Flow)5 IslRepository (org.openkilda.persistence.repositories.IslRepository)5 Collection (java.util.Collection)4 HashMap (java.util.HashMap)4 List (java.util.List)4 Map (java.util.Map)4 FlowPath (org.openkilda.model.FlowPath)4 PersistenceException (org.openkilda.persistence.exceptions.PersistenceException)4 IslFrame (org.openkilda.persistence.ferma.frames.IslFrame)4