Search in sources :

Example 6 with IslNotFoundException

use of org.openkilda.wfm.error.IslNotFoundException 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.");
    }
}
Also used : DeactivateIslInfoData(org.openkilda.messaging.info.event.DeactivateIslInfoData) Isl(org.openkilda.model.Isl) MessageException(org.openkilda.messaging.error.MessageException) Values(org.apache.storm.tuple.Values) IslNotFoundException(org.openkilda.wfm.error.IslNotFoundException) DeactivateIslInfoData(org.openkilda.messaging.info.event.DeactivateIslInfoData) IslInfoData(org.openkilda.messaging.info.event.IslInfoData) IslMapper(org.openkilda.wfm.share.mappers.IslMapper) IllegalIslStateException(org.openkilda.wfm.error.IllegalIslStateException)

Example 7 with IslNotFoundException

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

the class LinkOperationsBolt method bfdPropertiesWrite.

private BfdPropertiesResponse bfdPropertiesWrite(BfdPropertiesWriteRequest request) {
    Endpoint source = new Endpoint(request.getSource());
    Endpoint destination = new Endpoint(request.getDestination());
    try {
        return linkOperationsService.writeBfdProperties(source, destination, request.getProperties());
    } 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 8 with IslNotFoundException

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

the class IslLatencyService method updateIslLatency.

/**
 * Update latency of isl by source and destination endpoint.
 *
 * @param srcSwitchId ID of source switch.
 * @param srcPort source port.
 * @param dstSwitchId ID of destination switch.
 * @param dstPort destination port.
 * @param latency latency to update
 *
 * @throws SwitchNotFoundException if src or dst switch is not found
 * @throws IslNotFoundException if isl is not found
 */
@VisibleForTesting
void updateIslLatency(SwitchId srcSwitchId, int srcPort, SwitchId dstSwitchId, int dstPort, long latency) throws SwitchNotFoundException, IslNotFoundException {
    transactionManager.doInTransaction(() -> {
        Isl isl = islRepository.findByEndpoints(srcSwitchId, srcPort, dstSwitchId, dstPort).orElseThrow(() -> new IslNotFoundException(srcSwitchId, srcPort, dstSwitchId, dstPort));
        isl.setLatency(latency);
    });
}
Also used : Isl(org.openkilda.model.Isl) IslNotFoundException(org.openkilda.wfm.error.IslNotFoundException) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

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