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