Search in sources :

Example 1 with IslNotFoundException

use of org.openkilda.wfm.error.IslNotFoundException in project open-kilda by telstra.

the class CacheService method handleGetDataFromCache.

/**
 * Get data about specified ISL from cache.
 *
 * @param roundTripLatency round trip latency info data with source endpoint
 */
public void handleGetDataFromCache(IslRoundTripLatency roundTripLatency) {
    Endpoint source = Endpoint.of(roundTripLatency.getSrcSwitchId(), roundTripLatency.getSrcPortNo());
    Endpoint destination = cache.get(source);
    try {
        if (destination == null) {
            destination = updateCache(source);
        }
        carrier.emitCachedData(roundTripLatency, destination);
    } catch (IslNotFoundException e) {
        log.debug(String.format("Could not update ISL cache: %s", e.getMessage()), e);
    } catch (IllegalIslStateException e) {
        log.error(String.format("Could not update ISL cache: %s", e.getMessage()), e);
    }
}
Also used : Endpoint(org.openkilda.wfm.share.model.Endpoint) IslNotFoundException(org.openkilda.wfm.error.IslNotFoundException) IllegalIslStateException(org.openkilda.wfm.error.IllegalIslStateException)

Example 2 with IslNotFoundException

use of org.openkilda.wfm.error.IslNotFoundException in project open-kilda by telstra.

the class LinkOperationsBolt method bfdPropertiesRead.

private BfdPropertiesResponse bfdPropertiesRead(BfdPropertiesReadRequest request) {
    Endpoint source = new Endpoint(request.getSource());
    Endpoint destination = new Endpoint(request.getDestination());
    try {
        return linkOperationsService.readBfdProperties(source, destination);
    } catch (IslNotFoundException e) {
        throw new MessageException(ErrorType.NOT_FOUND, e.getMessage(), "ISL was not found.");
    }
}
Also used : IslEndpoint(org.openkilda.model.IslEndpoint) Endpoint(org.openkilda.wfm.share.model.Endpoint) MessageException(org.openkilda.messaging.error.MessageException) IslNotFoundException(org.openkilda.wfm.error.IslNotFoundException)

Example 3 with IslNotFoundException

use of org.openkilda.wfm.error.IslNotFoundException 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)

Example 4 with IslNotFoundException

use of org.openkilda.wfm.error.IslNotFoundException in project open-kilda by telstra.

the class FlowOperationsBolt method processGetFlowsForLinkRequest.

@TimedExecution("get_flows_for_link")
private List<FlowResponse> processGetFlowsForLinkRequest(GetFlowsForIslRequest request) {
    SwitchId srcSwitch = request.getSource().getDatapath();
    Integer srcPort = request.getSource().getPortNumber();
    SwitchId dstSwitch = request.getDestination().getDatapath();
    Integer dstPort = request.getDestination().getPortNumber();
    try {
        return flowOperationsService.getFlowPathsForLink(srcSwitch, srcPort, dstSwitch, dstPort).stream().filter(flowPath -> flowPath.getFlow().isActualPathId(flowPath.getPathId())).map(FlowPath::getFlow).distinct().map(flowOperationsService::buildFlowResponse).collect(Collectors.toList());
    } catch (IslNotFoundException e) {
        throw new MessageException(ErrorType.NOT_FOUND, e.getMessage(), "ISL was not found.");
    }
}
Also used : MessageException(org.openkilda.messaging.error.MessageException) SwitchId(org.openkilda.model.SwitchId) IslNotFoundException(org.openkilda.wfm.error.IslNotFoundException) TimedExecution(org.openkilda.wfm.share.metrics.TimedExecution)

Example 5 with IslNotFoundException

use of org.openkilda.wfm.error.IslNotFoundException in project open-kilda by telstra.

the class FlowOperationsBolt method processRerouteFlowsForLinkRequest.

@TimedExecution("reroute_flows_for_link")
private List<FlowsResponse> processRerouteFlowsForLinkRequest(RerouteFlowsForIslRequest message) {
    SwitchId srcSwitch = message.getSource().getDatapath();
    Integer srcPort = message.getSource().getPortNumber();
    SwitchId dstSwitch = message.getDestination().getDatapath();
    Integer dstPort = message.getDestination().getPortNumber();
    Collection<FlowPath> paths;
    try {
        paths = flowOperationsService.getFlowPathsForLink(srcSwitch, srcPort, dstSwitch, dstPort);
    } catch (IslNotFoundException e) {
        throw new MessageException(ErrorType.NOT_FOUND, e.getMessage(), "ISL was not found.");
    }
    Set<IslEndpoint> affectedIslEndpoints = new HashSet<>();
    affectedIslEndpoints.add(new IslEndpoint(srcSwitch, srcPort));
    affectedIslEndpoints.add(new IslEndpoint(dstSwitch, dstPort));
    sendRerouteRequest(paths, affectedIslEndpoints, format("initiated via Northbound, reroute all flows that go over the link %s_%d - %s_%d", srcSwitch, srcPort, dstSwitch, dstPort));
    List<String> flowIds = paths.stream().map(FlowPath::getFlow).map(Flow::getFlowId).distinct().collect(Collectors.toList());
    return Collections.singletonList(new FlowsResponse(flowIds));
}
Also used : IslEndpoint(org.openkilda.model.IslEndpoint) FlowsResponse(org.openkilda.messaging.info.flow.FlowsResponse) SwitchId(org.openkilda.model.SwitchId) Flow(org.openkilda.model.Flow) MessageException(org.openkilda.messaging.error.MessageException) IslNotFoundException(org.openkilda.wfm.error.IslNotFoundException) FlowPath(org.openkilda.model.FlowPath) HashSet(java.util.HashSet) TimedExecution(org.openkilda.wfm.share.metrics.TimedExecution)

Aggregations

IslNotFoundException (org.openkilda.wfm.error.IslNotFoundException)8 MessageException (org.openkilda.messaging.error.MessageException)6 IslEndpoint (org.openkilda.model.IslEndpoint)4 Isl (org.openkilda.model.Isl)3 SwitchId (org.openkilda.model.SwitchId)3 Endpoint (org.openkilda.wfm.share.model.Endpoint)3 HashSet (java.util.HashSet)2 Values (org.apache.storm.tuple.Values)2 FlowPath (org.openkilda.model.FlowPath)2 IllegalIslStateException (org.openkilda.wfm.error.IllegalIslStateException)2 IslMapper (org.openkilda.wfm.share.mappers.IslMapper)2 TimedExecution (org.openkilda.wfm.share.metrics.TimedExecution)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 FlowRerouteRequest (org.openkilda.messaging.command.flow.FlowRerouteRequest)1 DeactivateIslInfoData (org.openkilda.messaging.info.event.DeactivateIslInfoData)1 IslInfoData (org.openkilda.messaging.info.event.IslInfoData)1 FlowsResponse (org.openkilda.messaging.info.flow.FlowsResponse)1 Flow (org.openkilda.model.Flow)1 CommandContext (org.openkilda.wfm.CommandContext)1