Search in sources :

Example 1 with IslEndpoint

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

the class AbstractYFlowTest method buildPathSegment.

private Segment buildPathSegment(IslDirectionalReference reference) {
    IslEndpoint source = reference.getSourceEndpoint();
    IslEndpoint dest = reference.getDestEndpoint();
    return Segment.builder().srcSwitchId(source.getSwitchId()).srcPort(source.getPortNumber()).destSwitchId(dest.getSwitchId()).destPort(dest.getPortNumber()).build();
}
Also used : IslEndpoint(org.openkilda.model.IslEndpoint)

Example 2 with IslEndpoint

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

the class FlowRerouteServiceTest method extractIslEndpoint.

private IslEndpoint extractIslEndpoint(Flow flow) {
    FlowPath forwardPath = flow.getForwardPath();
    assertNotNull(forwardPath);
    List<PathSegment> forwardSegments = forwardPath.getSegments();
    assertFalse(forwardSegments.isEmpty());
    PathSegment firstSegment = forwardSegments.get(0);
    return new IslEndpoint(firstSegment.getSrcSwitchId(), firstSegment.getSrcPort());
}
Also used : IslEndpoint(org.openkilda.model.IslEndpoint) PathSegment(org.openkilda.model.PathSegment) FlowPath(org.openkilda.model.FlowPath)

Example 3 with IslEndpoint

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

the class FlowRerouteServiceTest method shouldProcessRerouteForValidRequest.

@Test
public void shouldProcessRerouteForValidRequest() throws RecoverableException, UnroutableFlowException, UnknownKeyException {
    Flow origin = makeFlow();
    origin.setTargetPathComputationStrategy(LATENCY);
    setupFlowRepositorySpy().findById(origin.getFlowId()).ifPresent(foundPath -> foundPath.setTargetPathComputationStrategy(LATENCY));
    preparePathComputation(origin.getFlowId(), make3SwitchesPathPair());
    FlowRerouteService service = makeService();
    IslEndpoint affectedEndpoint = extractIslEndpoint(origin);
    FlowRerouteRequest request = new FlowRerouteRequest(origin.getFlowId(), false, true, false, Collections.singleton(affectedEndpoint), null, false);
    service.handleRequest(currentRequestKey, request, commandContext);
    verifyFlowStatus(origin.getFlowId(), FlowStatus.IN_PROGRESS);
    FlowSegmentRequest speakerRequest;
    while ((speakerRequest = requests.poll()) != null) {
        produceAsyncResponse(service, speakerRequest);
    }
    Flow result = verifyFlowStatus(origin.getFlowId(), FlowStatus.UP);
    verifyPathReplace(origin, result);
    assertEquals(LATENCY, result.getPathComputationStrategy());
    assertNull(result.getTargetPathComputationStrategy());
}
Also used : IslEndpoint(org.openkilda.model.IslEndpoint) FlowSegmentRequest(org.openkilda.floodlight.api.request.FlowSegmentRequest) FlowRerouteRequest(org.openkilda.messaging.command.flow.FlowRerouteRequest) Flow(org.openkilda.model.Flow) Test(org.junit.Test)

Example 4 with IslEndpoint

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

the class AbstractFlowTest method makePathSegment.

private Segment makePathSegment(IslDirectionalReference reference) {
    IslEndpoint source = reference.getSourceEndpoint();
    IslEndpoint dest = reference.getDestEndpoint();
    return Segment.builder().srcSwitchId(source.getSwitchId()).srcPort(source.getPortNumber()).destSwitchId(dest.getSwitchId()).destPort(dest.getPortNumber()).build();
}
Also used : IslEndpoint(org.openkilda.model.IslEndpoint)

Example 5 with IslEndpoint

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

the class LinkOperationsBolt method updateLinkUnderMaintenanceFlag.

private List<IslInfoData> updateLinkUnderMaintenanceFlag(UpdateLinkUnderMaintenanceRequest request) {
    SwitchId srcSwitch = request.getSource().getDatapath();
    Integer srcPort = request.getSource().getPortNumber();
    SwitchId dstSwitch = request.getDestination().getDatapath();
    Integer dstPort = request.getDestination().getPortNumber();
    boolean underMaintenance = request.isUnderMaintenance();
    boolean evacuate = request.isEvacuate();
    List<Isl> isl;
    try {
        isl = linkOperationsService.updateLinkUnderMaintenanceFlag(srcSwitch, srcPort, dstSwitch, dstPort, underMaintenance);
        if (underMaintenance && evacuate) {
            Set<IslEndpoint> affectedIslEndpoints = new HashSet<>();
            affectedIslEndpoints.add(new IslEndpoint(srcSwitch, srcPort));
            affectedIslEndpoints.add(new IslEndpoint(dstSwitch, dstPort));
            String reason = format("evacuated due to link maintenance %s_%d - %s_%d", srcSwitch, srcPort, dstSwitch, dstPort);
            Collection<FlowPath> targetPaths = flowOperationsService.getFlowPathsForLink(srcSwitch, srcPort, dstSwitch, dstPort);
            for (FlowRerouteRequest reroute : flowOperationsService.makeRerouteRequests(targetPaths, affectedIslEndpoints, reason)) {
                CommandContext forkedContext = getCommandContext().fork(reroute.getFlowId());
                getOutput().emit(StreamType.REROUTE.toString(), getCurrentTuple(), new Values(reroute, forkedContext.getCorrelationId()));
            }
        }
    } catch (IslNotFoundException e) {
        throw new MessageException(ErrorType.NOT_FOUND, e.getMessage(), "ISL was not found.");
    }
    return isl.stream().map(IslMapper.INSTANCE::map).collect(Collectors.toList());
}
Also used : IslEndpoint(org.openkilda.model.IslEndpoint) Isl(org.openkilda.model.Isl) CommandContext(org.openkilda.wfm.CommandContext) Values(org.apache.storm.tuple.Values) SwitchId(org.openkilda.model.SwitchId) MessageException(org.openkilda.messaging.error.MessageException) FlowRerouteRequest(org.openkilda.messaging.command.flow.FlowRerouteRequest) IslNotFoundException(org.openkilda.wfm.error.IslNotFoundException) FlowPath(org.openkilda.model.FlowPath) HashSet(java.util.HashSet) IslMapper(org.openkilda.wfm.share.mappers.IslMapper)

Aggregations

IslEndpoint (org.openkilda.model.IslEndpoint)27 Test (org.junit.Test)13 Flow (org.openkilda.model.Flow)9 FlowThrottlingData (org.openkilda.wfm.topology.reroute.model.FlowThrottlingData)8 FlowRerouteRequest (org.openkilda.messaging.command.flow.FlowRerouteRequest)7 HashSet (java.util.HashSet)6 YFlowRerouteRequest (org.openkilda.messaging.command.yflow.YFlowRerouteRequest)6 FlowPath (org.openkilda.model.FlowPath)6 SwitchId (org.openkilda.model.SwitchId)5 PathNode (org.openkilda.messaging.info.event.PathNode)4 TimedExecution (org.openkilda.wfm.share.metrics.TimedExecution)4 RerouteQueue (org.openkilda.wfm.topology.reroute.model.RerouteQueue)4 Values (org.apache.storm.tuple.Values)3 YFlowRequest (org.openkilda.messaging.command.yflow.YFlowRequest)3 MessageException (org.openkilda.messaging.error.MessageException)3 PathSegment (org.openkilda.model.PathSegment)3 YFlow (org.openkilda.model.YFlow)3 AbstractYFlowTest (org.openkilda.wfm.topology.flowhs.service.AbstractYFlowTest)3 ArrayList (java.util.ArrayList)2 FlowSegmentRequest (org.openkilda.floodlight.api.request.FlowSegmentRequest)2