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