use of org.openkilda.model.YFlow in project open-kilda by telstra.
the class RuleManagerImpl method buildIngressYFlowCommands.
private List<SpeakerData> buildIngressYFlowCommands(FlowPath flowPath, FlowPath altFlowPath, DataAdapter adapter) {
Flow flow = adapter.getFlow(flowPath.getPathId());
Flow altFlow = adapter.getFlow(altFlowPath.getPathId());
if (flow.isProtectedPath(flowPath.getPathId()) || altFlow.isProtectedPath(altFlowPath.getPathId())) {
return Collections.emptyList();
}
YFlow yFlow = adapter.getYFlow(flowPath.getPathId());
if (yFlow == null) {
return Collections.emptyList();
}
SwitchId sharedSwitchId = yFlow.getSharedEndpoint().getSwitchId();
Switch sharedSwitch = adapter.getSwitch(sharedSwitchId);
if (sharedSwitch == null || !sharedSwitchId.equals(flowPath.getSrcSwitchId()) || !sharedSwitchId.equals(altFlowPath.getSrcSwitchId())) {
return Collections.emptyList();
}
FlowTransitEncapsulation encapsulation = getFlowTransitEncapsulation(flowPath.getPathId(), flow, adapter);
FlowTransitEncapsulation altEncapsulation = getFlowTransitEncapsulation(altFlowPath.getPathId(), altFlow, adapter);
MeterId sharedMeterId = yFlow.getSharedEndpointMeterId();
RuleGenerator generator = flowRulesFactory.getIngressYRuleGenerator(flowPath, flow, encapsulation, new HashSet<>(), altFlowPath, altFlow, altEncapsulation, new HashSet<>(), sharedMeterId);
return generator.generateCommands(sharedSwitch);
}
use of org.openkilda.model.YFlow in project open-kilda by telstra.
the class RuleManagerImpl method buildTransitYFlowCommands.
private List<SpeakerData> buildTransitYFlowCommands(FlowPath flowPath, FlowPath altFlowPath, DataAdapter adapter) {
Flow flow = adapter.getFlow(flowPath.getPathId());
Flow altFlow = adapter.getFlow(altFlowPath.getPathId());
YFlow yFlow = adapter.getYFlow(flowPath.getPathId());
if (yFlow == null) {
return Collections.emptyList();
}
SwitchId sharedSwitchId = yFlow.getSharedEndpoint().getSwitchId();
if (sharedSwitchId.equals(flowPath.getSrcSwitchId()) || sharedSwitchId.equals(altFlowPath.getSrcSwitchId())) {
return Collections.emptyList();
}
SwitchId yPointSwitchId = yFlow.getYPoint();
MeterId yPointMeterId = yFlow.getMeterId();
if (flow.isProtectedPath(flowPath.getPathId()) && altFlow.isProtectedPath(altFlowPath.getPathId())) {
yPointSwitchId = yFlow.getProtectedPathYPoint();
yPointMeterId = yFlow.getProtectedPathMeterId();
}
Switch yPointSwitch = adapter.getSwitch(yPointSwitchId);
if (yPointSwitch == null) {
return Collections.emptyList();
}
FlowTransitEncapsulation encapsulation = getFlowTransitEncapsulation(flowPath.getPathId(), flow, adapter);
FlowTransitEncapsulation altEncapsulation = getFlowTransitEncapsulation(altFlowPath.getPathId(), altFlow, adapter);
SwitchPathSegments switchPathSegments = findPathSegmentsForSwitch(yPointSwitchId, flowPath.getSegments());
SwitchPathSegments altSwitchPathSegments = findPathSegmentsForSwitch(yPointSwitchId, altFlowPath.getSegments());
if (switchPathSegments == null || altSwitchPathSegments == null) {
return Collections.emptyList();
}
RuleGenerator generator = flowRulesFactory.getTransitYRuleGenerator(flowPath, encapsulation, switchPathSegments.getFirstPathSegment(), switchPathSegments.getSecondPathSegment(), altFlowPath, altEncapsulation, altSwitchPathSegments.getFirstPathSegment(), altSwitchPathSegments.getSecondPathSegment(), yPointMeterId);
return generator.generateCommands(yPointSwitch);
}
use of org.openkilda.model.YFlow in project open-kilda by telstra.
the class KildaEntryCacheService method refreshYFlowsCache.
private void refreshYFlowsCache() {
CacheAddUpdateHandler cacheHandler = new CacheAddUpdateHandler(cookieToFlow, switchAndMeterToFlow);
for (YFlow entry : yFlowRepository.findAll()) {
if (entry.getSharedEndpointMeterId() == null) {
continue;
}
if (entry.getMeterId() == null) {
continue;
}
updateCache(cacheHandler, entry.getYFlowId(), entry.getSharedEndpoint().getSwitchId(), entry.getSharedEndpointMeterId(), MeasurePoint.Y_FLOW_SHARED);
updateCache(cacheHandler, entry.getYFlowId(), entry.getYPoint(), entry.getMeterId(), MeasurePoint.Y_FLOW_Y_POINT);
}
}
use of org.openkilda.model.YFlow in project open-kilda by telstra.
the class TestYFlowBuilder method build.
/**
* Build {@link YFlow} instance.
*/
public YFlow build() {
boolean allocateProtectedPath = false;
if (protectedPathYPoint != null || protectedPathMeterId != null) {
checkArgument(protectedPathYPoint != null && protectedPathMeterId != null, "Insufficient data provided to make YFlow with protected path");
allocateProtectedPath = true;
}
YFlow.YFlowBuilder yFlowBuilder = YFlow.builder().yFlowId(yFlowId).sharedEndpoint(sharedEndpoint).sharedEndpointMeterId(sharedEndpointMeterId).yPoint(yPoint).meterId(meterId).allocateProtectedPath(allocateProtectedPath).maximumBandwidth(maximumBandwidth).ignoreBandwidth(ignoreBandwidth).strictBandwidth(strictBandwidth).description(description).periodicPings(periodicPings).encapsulationType(encapsulationType).status(status).maxLatency(maxLatency).maxLatencyTier2(maxLatencyTier2).priority(priority).pinned(pinned).pathComputationStrategy(pathComputationStrategy);
if (allocateProtectedPath) {
yFlowBuilder = yFlowBuilder.protectedPathYPoint(protectedPathYPoint).protectedPathMeterId(protectedPathMeterId);
}
YFlow yFlow = yFlowBuilder.build();
Set<YSubFlow> subFlowsGoal = new HashSet<>();
for (TestYSubFlowBuilder subFlowBuilder : subFlows) {
subFlowsGoal.add(subFlowBuilder.yFlow(yFlow).build());
}
yFlow.setSubFlows(subFlowsGoal);
yFlow.setTimeCreate(timeCreate);
yFlow.setTimeModify(timeModify);
return yFlow;
}
use of org.openkilda.model.YFlow in project open-kilda by telstra.
the class UpdateYFlowAction method perform.
@Override
protected void perform(State from, State to, Event event, YFlowUpdateContext context, YFlowUpdateFsm stateMachine) {
YFlowRequest targetFlow = stateMachine.getTargetFlow();
stateMachine.setDiverseFlowId(targetFlow.getDiverseFlowId());
FlowStatus flowStatus = transactionManager.doInTransaction(() -> {
YFlow yFlow = getYFlow(targetFlow.getYFlowId());
saveOldResources(stateMachine, yFlow);
stateMachine.setDeleteOldYFlowCommands(buildYFlowDeleteCommands(yFlow, stateMachine.getCommandContext()));
updateFlow(yFlow, YFlowRequestMapper.INSTANCE.toYFlow(targetFlow));
return yFlow.getStatus();
});
stateMachine.saveActionToHistory(format("The y-flow was updated. The status %s", flowStatus));
}
Aggregations