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