Search in sources :

Example 21 with Isl

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

the class NetworkHistoryService method loadNetworkHistory.

// -- private --
private Collection<HistoryFacts> loadNetworkHistory() {
    RepositoryFactory repositoryFactory = persistenceManager.getRepositoryFactory();
    SwitchRepository switchRepository = repositoryFactory.createSwitchRepository();
    HashMap<SwitchId, HistoryFacts> switchById = new HashMap<>();
    for (Switch switchEntry : switchRepository.findAll()) {
        SwitchId switchId = switchEntry.getSwitchId();
        SwitchStatus switchStatus = switchEntry.getStatus();
        switchById.put(switchId, new HistoryFacts(switchId, switchStatus));
    }
    IslRepository islRepository = repositoryFactory.createIslRepository();
    for (Isl islEntry : islRepository.findAll()) {
        HistoryFacts history = switchById.get(islEntry.getSrcSwitchId());
        if (history == null) {
            log.error("Orphaned ISL relation - {}-{} (read race condition?)", islEntry.getSrcSwitchId(), islEntry.getSrcPort());
            continue;
        }
        islRepository.detach(islEntry);
        history.addLink(islEntry);
    }
    return switchById.values();
}
Also used : IslRepository(org.openkilda.persistence.repositories.IslRepository) Isl(org.openkilda.model.Isl) Switch(org.openkilda.model.Switch) HashMap(java.util.HashMap) SwitchRepository(org.openkilda.persistence.repositories.SwitchRepository) SwitchId(org.openkilda.model.SwitchId) RepositoryFactory(org.openkilda.persistence.repositories.RepositoryFactory) HistoryFacts(org.openkilda.wfm.topology.network.model.facts.HistoryFacts) SwitchStatus(org.openkilda.model.SwitchStatus)

Example 22 with Isl

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

the class IslFsm method createIsl.

private Isl createIsl(Anchor source, Anchor dest, Instant timeNow) {
    final Endpoint sourceEndpoint = source.getEndpoint();
    final Endpoint destEndpoint = dest.getEndpoint();
    IslBuilder islBuilder = Isl.builder().srcSwitch(source.getSw()).srcPort(sourceEndpoint.getPortNumber()).destSwitch(dest.getSw()).destPort(destEndpoint.getPortNumber()).underMaintenance(source.getSw().isUnderMaintenance() || dest.getSw().isUnderMaintenance());
    initializeFromLinkProps(sourceEndpoint, destEndpoint, islBuilder);
    Isl link = islBuilder.build();
    log.info("Create new DB object (prefilled): {}", link);
    islRepository.add(link);
    return link;
}
Also used : IslBuilder(org.openkilda.model.Isl.IslBuilder) Isl(org.openkilda.model.Isl) Endpoint(org.openkilda.wfm.share.model.Endpoint)

Example 23 with Isl

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

the class SwitchFsm method applyHistory.

// -- FSM actions --
public void applyHistory(SwitchFsmState from, SwitchFsmState to, SwitchFsmEvent event, SwitchFsmContext context) {
    HistoryFacts historyFacts = context.getHistory();
    for (Isl outgoingLink : historyFacts.getOutgoingLinks()) {
        PhysicalPort port = new PhysicalPort(Endpoint.of(switchId, outgoingLink.getSrcPort()));
        port.setHistory(outgoingLink);
        portAdd(port, context);
    }
    if (SwitchStatus.INACTIVE.equals(historyFacts.getLastRecordedStatus())) {
        fire(SwitchFsmEvent.OFFLINE, context);
    }
}
Also used : Isl(org.openkilda.model.Isl) HistoryFacts(org.openkilda.wfm.topology.network.model.facts.HistoryFacts)

Example 24 with Isl

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

the class NetworkIslServiceTest method testBfdStatusReset.

private void testBfdStatusReset(BfdSessionStatus initialStatus) {
    setupIslStorageStub();
    final Instant start = clock.adjust(Duration.ofSeconds(1));
    Isl alphaToBeta = makeIsl(endpointAlpha1, endpointBeta2, false).bfdSessionStatus(initialStatus).build();
    islStorage.save(alphaToBeta);
    islStorage.save(makeIsl(endpointBeta2, endpointAlpha1, false).bfdSessionStatus(initialStatus).build());
    clock.adjust(Duration.ofSeconds(1));
    IslReference reference = new IslReference(endpointAlpha1, endpointBeta2);
    service.islSetupFromHistory(reference.getSource(), reference, alphaToBeta);
    Optional<Isl> potential = islStorage.lookup(reference.getSource(), reference.getDest());
    Assert.assertTrue(potential.isPresent());
    Isl link = potential.get();
    Assert.assertNull(link.getBfdSessionStatus());
    potential = islStorage.lookup(reference.getDest(), reference.getSource());
    Assert.assertTrue(potential.isPresent());
    link = potential.get();
    Assert.assertNull(link.getBfdSessionStatus());
    service.bfdStatusUpdate(reference.getSource(), reference, BfdStatusUpdate.UP);
    verifyBfdStatus(reference, BfdSessionStatus.UP, null);
    service.bfdStatusUpdate(reference.getDest(), reference, BfdStatusUpdate.UP);
    verifyBfdStatus(reference, BfdSessionStatus.UP, BfdSessionStatus.UP);
}
Also used : Isl(org.openkilda.model.Isl) IslReference(org.openkilda.wfm.share.model.IslReference) Instant(java.time.Instant)

Example 25 with Isl

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

the class NetworkIslServiceTest method setIslUnstableTimeOnPortDown.

@Test
public void setIslUnstableTimeOnPortDown() {
    setupIslStorageStub();
    IslReference reference = prepareActiveIsl();
    Instant updateTime = clock.adjust(Duration.ofSeconds(1));
    // isl fail by PORT DOWN
    service.islDown(endpointAlpha1, reference, IslDownReason.PORT_DOWN);
    // ensure we have marked ISL as unstable
    Isl forward = lookupIsl(reference.getSource(), reference.getDest());
    Assert.assertEquals(updateTime, forward.getTimeUnstable());
    Isl reverse = lookupIsl(reference.getDest(), reference.getSource());
    Assert.assertEquals(updateTime, reverse.getTimeUnstable());
}
Also used : Isl(org.openkilda.model.Isl) IslReference(org.openkilda.wfm.share.model.IslReference) Instant(java.time.Instant) 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