use of org.openkilda.messaging.MessageContext in project open-kilda by telstra.
the class SpeakerFlowSegmentRequestBuilder method makeTransitSegmentRequest.
private FlowSegmentRequestFactory makeTransitSegmentRequest(CommandContext context, FlowPath path, FlowTransitEncapsulation encapsulation, PathSegment ingress, PathSegment egress) {
final PathSegmentSide inboundSide = makePathSegmentDestSide(ingress);
final PathSegmentSide outboundSide = makePathSegmentSourceSide(egress);
final IslEndpoint ingressEndpoint = inboundSide.getEndpoint();
final IslEndpoint egressEndpoint = outboundSide.getEndpoint();
assert ingressEndpoint.getSwitchId().equals(egressEndpoint.getSwitchId()) : "Only neighbor segments can be used for for transit segment request creation";
UUID commandId = commandIdGenerator.generate();
MessageContext messageContext = new MessageContext(commandId.toString(), context.getCorrelationId());
return TransitFlowSegmentRequestFactory.builder().messageContext(messageContext).switchId(ingressEndpoint.getSwitchId()).metadata(makeMetadata(path, ensureEqualMultiTableFlag(inboundSide.isMultiTable(), outboundSide.isMultiTable(), String.format("Flow(id:%s, path:%s) have incompatible multi-table flags between segments %s " + "and %s", path.getFlow().getFlowId(), path.getPathId(), ingress, egress)))).ingressIslPort(ingressEndpoint.getPortNumber()).egressIslPort(egressEndpoint.getPortNumber()).encapsulation(encapsulation).build();
}
use of org.openkilda.messaging.MessageContext in project open-kilda by telstra.
the class SpeakerFlowSegmentRequestBuilder method makeLoopRequests.
private List<FlowSegmentRequestFactory> makeLoopRequests(CommandContext context, FlowPath path, FlowTransitEncapsulation encapsulation, FlowSideAdapter ingressSide, FlowSideAdapter egressSide, PathSegment segment) {
List<FlowSegmentRequestFactory> result = new ArrayList<>(2);
PathSegmentSide segmentSide = makePathSegmentSourceSide(segment);
UUID commandId = commandIdGenerator.generate();
MessageContext messageContext = new MessageContext(commandId.toString(), context.getCorrelationId());
FlowSegmentCookie cookie = path.getCookie().toBuilder().looped(true).build();
result.add(IngressFlowLoopSegmentRequestFactory.builder().messageContext(messageContext).metadata(makeMetadata(path.getFlow().getFlowId(), cookie, segmentSide.isMultiTable())).endpoint(ingressSide.getEndpoint()).build());
FlowPathDirection reverse = cookie.getDirection() == FlowPathDirection.FORWARD ? FlowPathDirection.REVERSE : FlowPathDirection.FORWARD;
Cookie transitCookie = path.getCookie().toBuilder().looped(true).direction(reverse).build();
result.add(TransitFlowLoopSegmentRequestFactory.builder().messageContext(messageContext).switchId(segment.getSrcSwitch().getSwitchId()).egressSwitchId(egressSide.getEndpoint().getSwitchId()).metadata(makeMetadata(path.getFlow().getFlowId(), transitCookie, segmentSide.isMultiTable())).port(segment.getSrcPort()).encapsulation(encapsulation).build());
return result;
}
use of org.openkilda.messaging.MessageContext in project open-kilda by telstra.
the class SpeakerFlowSegmentRequestBuilder method makeIngressSegmentRequests.
private List<FlowSegmentRequestFactory> makeIngressSegmentRequests(CommandContext context, FlowPath path, FlowTransitEncapsulation encapsulation, FlowSideAdapter flowSide, PathSegment segment, FlowSideAdapter egressFlowSide, RulesContext rulesContext, MirrorContext mirrorContext) {
PathSegmentSide segmentSide = makePathSegmentSourceSide(segment);
UUID commandId = commandIdGenerator.generate();
MessageContext messageContext = new MessageContext(commandId.toString(), context.getCorrelationId());
FlowSegmentMetadata metadata = makeMetadata(path, ensureEqualMultiTableFlag(path.isSrcWithMultiTable(), segmentSide.isMultiTable(), String.format("First flow(id:%s, path:%s) segment and flow path level multi-table flag values " + "are incompatible to each other - flow path(%s) != segment(%s)", path.getFlow().getFlowId(), path.getPathId(), path.isSrcWithMultiTable(), segmentSide.isMultiTable())));
List<FlowSegmentRequestFactory> ingressFactories = new ArrayList<>();
if (!mirrorContext.isBuildMirrorFactoryOnly()) {
ingressFactories.add(IngressFlowSegmentRequestFactory.builder().messageContext(messageContext).metadata(metadata).endpoint(flowSide.getEndpoint()).meterConfig(getMeterConfig(path)).egressSwitchId(egressFlowSide.getEndpoint().getSwitchId()).islPort(segmentSide.getEndpoint().getPortNumber()).encapsulation(encapsulation).rulesContext(rulesContext).build());
}
Optional<MirrorConfig> mirrorConfig = makeMirrorConfig(path, segmentSide.getEndpoint(), mirrorContext);
if (mirrorConfig.isPresent() || mirrorContext.isRemoveFlowOperation()) {
FlowSegmentCookie mirrorCookie = path.getCookie().toBuilder().mirror(true).build();
ingressFactories.add(IngressMirrorFlowSegmentRequestFactory.builder().messageContext(new MessageContext(commandIdGenerator.generate().toString(), context.getCorrelationId())).metadata(makeMetadata(metadata.getFlowId(), mirrorCookie, metadata.isMultiTable())).endpoint(flowSide.getEndpoint()).meterConfig(getMeterConfig(path)).egressSwitchId(egressFlowSide.getEndpoint().getSwitchId()).islPort(segmentSide.getEndpoint().getPortNumber()).encapsulation(encapsulation).rulesContext(rulesContext.toBuilder().updateMeter(false).installServer42IngressRule(false).installServer42InputRule(false).installServer42OuterVlanMatchSharedRule(false).build()).mirrorConfig(mirrorConfig.orElse(null)).build());
}
return ingressFactories;
}
use of org.openkilda.messaging.MessageContext in project open-kilda by telstra.
the class MeterVerifyCommandTest method shouldVerifyInaccurateMeterBandwidth.
@Test
public void shouldVerifyInaccurateMeterBandwidth() throws Exception {
MeterConfig validConfig = new MeterConfig(new MeterId(1), 100);
MeterVerifyCommand command1 = new MeterVerifyCommand(new MessageContext(), mapSwitchId(dpId), validConfig);
switchFeaturesSetup(sw, SwitchFeature.METERS, SwitchFeature.INACCURATE_METER);
SettableFuture<List<OFMeterConfigStatsReply>> statsReplyProxy = setupMeterConfigStatsReply();
// for command2
setupMeterConfigStatsReply();
replayAll();
CompletableFuture<MeterVerifyReport> result = command1.execute(commandProcessor);
// make one more command with altered config, to produce meter config flags/bands
MeterConfig invalidConfig = new MeterConfig(validConfig.getId(), validConfig.getBandwidth() + 1);
MeterVerifyCommand command2 = new MeterVerifyCommand(command1.getMessageContext(), command1.getSwitchId(), invalidConfig);
// must be executed, for let .setup() method to initialize all dependencies
command2.execute(commandProcessor);
OFMeterConfig reply = sw.getOFFactory().buildMeterConfig().setMeterId(validConfig.getId().getValue()).setFlags(command2.makeMeterFlags()).setEntries(command2.makeMeterBands()).build();
statsReplyProxy.set(wrapMeterStatsReply(reply));
verifySuccessCompletion(result);
}
use of org.openkilda.messaging.MessageContext in project open-kilda by telstra.
the class TransitFlowSegmentInstallCommandTest method makeCommand.
protected TransitFlowSegmentInstallCommand makeCommand(FlowTransitEncapsulation encapsulation, FlowSegmentMetadata metadata) {
MessageContext messageContext = new MessageContext();
UUID commandId = UUID.randomUUID();
int ingressIslPort = 2;
int egressIslPort = 4;
return new TransitFlowSegmentInstallCommand(messageContext, mapSwitchId(dpIdNext), commandId, metadata, ingressIslPort, encapsulation, egressIslPort, null);
}
Aggregations