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();
}
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;
}
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);
}
}
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);
}
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());
}
Aggregations