Search in sources :

Example 1 with YFlowResources

use of org.openkilda.wfm.topology.flowhs.model.yflow.YFlowResources in project open-kilda by telstra.

the class YFlowProcessingFsm method newYFlowStatsInfoFactory.

private YFlowStatsInfoFactory newYFlowStatsInfoFactory(YFlowResources resources) throws InsufficientDataException {
    YFlowResources.EndpointResources sharedEndpoint = resources.getSharedEndpointResources();
    YFlowResources.EndpointResources yPoint = resources.getMainPathYPointResources();
    String missing;
    if (sharedEndpoint == null && yPoint == null) {
        missing = "shared and y-point endpoints";
    } else if (sharedEndpoint == null) {
        missing = "shared endpoint";
    } else if (yPoint == null) {
        missing = "y-point endpoint";
    } else {
        missing = null;
    }
    if (missing != null) {
        throw new InsufficientDataException(String.format("%s data are empty (is null)", missing));
    }
    return new YFlowStatsInfoFactory(getYFlowId(), new YFlowEndpointResources(sharedEndpoint.getEndpoint(), sharedEndpoint.getMeterId()), new YFlowEndpointResources(yPoint.getEndpoint(), yPoint.getMeterId()));
}
Also used : YFlowResources(org.openkilda.wfm.topology.flowhs.model.yflow.YFlowResources) InsufficientDataException(org.openkilda.wfm.topology.flowhs.exception.InsufficientDataException) YFlowStatsInfoFactory(org.openkilda.messaging.info.stats.YFlowStatsInfoFactory) YFlowEndpointResources(org.openkilda.messaging.payload.yflow.YFlowEndpointResources)

Example 2 with YFlowResources

use of org.openkilda.wfm.topology.flowhs.model.yflow.YFlowResources in project open-kilda by telstra.

the class RevertYFlowAction method perform.

@Override
protected void perform(State from, State to, Event event, YFlowUpdateContext context, YFlowUpdateFsm stateMachine) {
    YFlowRequest originalFlow = stateMachine.getOriginalFlow();
    YFlowResources resources = stateMachine.getOldResources();
    FlowStatus flowStatus = transactionManager.doInTransaction(() -> {
        YFlow yFlow = getYFlow(originalFlow.getYFlowId());
        revertFlow(yFlow, YFlowRequestMapper.INSTANCE.toYFlow(originalFlow), resources);
        return yFlow.getStatus();
    });
    stateMachine.saveActionToHistory(format("The y-flow was reverted. The status %s", flowStatus));
}
Also used : YFlow(org.openkilda.model.YFlow) YFlowResources(org.openkilda.wfm.topology.flowhs.model.yflow.YFlowResources) YFlowRequest(org.openkilda.messaging.command.yflow.YFlowRequest) FlowStatus(org.openkilda.model.FlowStatus)

Example 3 with YFlowResources

use of org.openkilda.wfm.topology.flowhs.model.yflow.YFlowResources in project open-kilda by telstra.

the class UpdateYFlowAction method saveOldResources.

private void saveOldResources(YFlowUpdateFsm stateMachine, YFlow yFlow) {
    stateMachine.setOriginalFlow(YFlowRequestMapper.INSTANCE.toYFlowRequest(yFlow));
    YFlowResources oldYFlowResources = new YFlowResources();
    oldYFlowResources.setMainPathYPointResources(EndpointResources.builder().endpoint(yFlow.getYPoint()).meterId(yFlow.getMeterId()).build());
    oldYFlowResources.setProtectedPathYPointResources(EndpointResources.builder().endpoint(yFlow.getProtectedPathYPoint()).meterId(yFlow.getProtectedPathMeterId()).build());
    oldYFlowResources.setSharedEndpointResources(EndpointResources.builder().endpoint(yFlow.getSharedEndpoint().getSwitchId()).meterId(yFlow.getSharedEndpointMeterId()).build());
    stateMachine.setOldResources(oldYFlowResources);
}
Also used : YFlowResources(org.openkilda.wfm.topology.flowhs.model.yflow.YFlowResources)

Example 4 with YFlowResources

use of org.openkilda.wfm.topology.flowhs.model.yflow.YFlowResources in project open-kilda by telstra.

the class HandleNotDeallocatedResourcesAction method perform.

protected void perform(State from, State to, Event event, YFlowUpdateContext context, YFlowUpdateFsm stateMachine) {
    String yFlowId = stateMachine.getYFlowId();
    YFlowResources newResources = stateMachine.getNewResources();
    if (newResources == null) {
        log.debug("No resources were allocated for y-flow {}", yFlowId);
        return;
    }
    EndpointResources sharedEndpointResources = newResources.getSharedEndpointResources();
    if (sharedEndpointResources != null) {
        stateMachine.saveErrorToHistory("Failed to deallocate resources", format("Failed to deallocate resources %s of y-flow %s (shared endpoint): %s", sharedEndpointResources, stateMachine.getYFlowId(), context.getError()));
    }
    EndpointResources mainResources = newResources.getMainPathYPointResources();
    if (mainResources != null) {
        stateMachine.saveErrorToHistory("Failed to deallocate resources", format("Failed to deallocate resources %s of y-flow %s (main paths): %s", mainResources, stateMachine.getYFlowId(), context.getError()));
    }
    EndpointResources protectedResources = newResources.getProtectedPathYPointResources();
    if (protectedResources != null) {
        stateMachine.saveErrorToHistory("Failed to deallocate resources", format("Failed to deallocate resources %s of y-flow %s (protected paths): %s", mainResources, stateMachine.getYFlowId(), context.getError()));
    }
}
Also used : YFlowResources(org.openkilda.wfm.topology.flowhs.model.yflow.YFlowResources) EndpointResources(org.openkilda.wfm.topology.flowhs.model.yflow.YFlowResources.EndpointResources)

Example 5 with YFlowResources

use of org.openkilda.wfm.topology.flowhs.model.yflow.YFlowResources in project open-kilda by telstra.

the class StartReroutingYFlowAction method saveOldResources.

private void saveOldResources(YFlowRerouteFsm stateMachine, YFlow yFlow) {
    YFlowResources oldYFlowResources = new YFlowResources();
    oldYFlowResources.setMainPathYPointResources(EndpointResources.builder().endpoint(yFlow.getYPoint()).meterId(yFlow.getMeterId()).build());
    oldYFlowResources.setProtectedPathYPointResources(EndpointResources.builder().endpoint(yFlow.getProtectedPathYPoint()).meterId(yFlow.getProtectedPathMeterId()).build());
    oldYFlowResources.setSharedEndpointResources(EndpointResources.builder().endpoint(yFlow.getSharedEndpoint().getSwitchId()).meterId(yFlow.getSharedEndpointMeterId()).build());
    stateMachine.setOldResources(oldYFlowResources);
}
Also used : YFlowResources(org.openkilda.wfm.topology.flowhs.model.yflow.YFlowResources)

Aggregations

YFlowResources (org.openkilda.wfm.topology.flowhs.model.yflow.YFlowResources)11 EndpointResources (org.openkilda.wfm.topology.flowhs.model.yflow.YFlowResources.EndpointResources)6 SwitchId (org.openkilda.model.SwitchId)3 YFlow (org.openkilda.model.YFlow)3 MeterId (org.openkilda.model.MeterId)2 ArrayList (java.util.ArrayList)1 DeleteSpeakerCommandsRequest (org.openkilda.floodlight.api.request.rulemanager.DeleteSpeakerCommandsRequest)1 YFlowRequest (org.openkilda.messaging.command.yflow.YFlowRequest)1 YFlowStatsInfoFactory (org.openkilda.messaging.info.stats.YFlowStatsInfoFactory)1 YFlowEndpointResources (org.openkilda.messaging.payload.yflow.YFlowEndpointResources)1 Flow (org.openkilda.model.Flow)1 FlowPath (org.openkilda.model.FlowPath)1 FlowStatus (org.openkilda.model.FlowStatus)1 ResourceAllocationException (org.openkilda.wfm.share.flow.resources.ResourceAllocationException)1 FlowProcessingException (org.openkilda.wfm.topology.flowhs.exception.FlowProcessingException)1 InsufficientDataException (org.openkilda.wfm.topology.flowhs.exception.InsufficientDataException)1