use of org.openkilda.wfm.CommandContext in project open-kilda by telstra.
the class FlowRerouteQueueBolt method sendRerouteRequest.
@Override
public void sendRerouteRequest(String correlationId, FlowRerouteRequest request) {
log.info("Send reroute request {} with correlationId {}", request, correlationId);
// emit without anchor to prevent a possible loop
emit(STREAM_OPERATION_QUEUE_ID, new Values(request.getFlowId(), request, new CommandContext(correlationId)));
registerCallback(correlationId);
}
use of org.openkilda.wfm.CommandContext in project open-kilda by telstra.
the class RerouteBolt method emitRerouteCommand.
/**
* Emit reroute command for consumer.
*
* @param flowId flow id
* @param flowThrottlingData flow throttling data
*/
@Override
public void emitRerouteCommand(String flowId, FlowThrottlingData flowThrottlingData) {
String newCorrelationId = new CommandContext(flowThrottlingData.getCorrelationId()).fork(flowId).getCorrelationId();
flowThrottlingData.setCorrelationId(newCorrelationId);
emitWithContext(STREAM_REROUTE_REQUEST_ID, getCurrentTuple(), new Values(flowId, flowThrottlingData));
log.warn("Flow {} reroute command message sent with correlationId {}, reason \"{}\"", flowId, flowThrottlingData.getCorrelationId(), flowThrottlingData.getReason());
}
use of org.openkilda.wfm.CommandContext in project open-kilda by telstra.
the class TimeWindowBolt method init.
@Override
protected void init() {
super.init();
// Imitate flush window event on bolt startup to prevent data loss when this bolt is restarted
getOutput().emit(new Values(new CommandContext()));
}
use of org.openkilda.wfm.CommandContext in project open-kilda by telstra.
the class ResourcesAllocationAction method createSpeakerRequestFactories.
private void createSpeakerRequestFactories(FlowCreateFsm stateMachine, Flow flow) {
final FlowCommandBuilder commandBuilder = commandBuilderFactory.getBuilder(flow.getEncapsulationType());
final CommandContext commandContext = stateMachine.getCommandContext();
List<FlowSegmentRequestFactory> requestFactories;
// ingress
requestFactories = stateMachine.getIngressCommands();
SpeakerRequestBuildContext buildContext = buildBaseSpeakerContextForInstall(flow.getSrcSwitchId(), flow.getDestSwitchId());
requestFactories.addAll(commandBuilder.buildIngressOnly(stateMachine.getCommandContext(), flow, buildContext));
// non ingress
requestFactories = stateMachine.getNonIngressCommands();
requestFactories.addAll(commandBuilder.buildAllExceptIngress(commandContext, flow));
if (flow.isAllocateProtectedPath()) {
requestFactories.addAll(commandBuilder.buildAllExceptIngress(commandContext, flow, flow.getProtectedForwardPath(), flow.getProtectedReversePath()));
}
}
use of org.openkilda.wfm.CommandContext in project open-kilda by telstra.
the class FlowCreateServiceTest method shouldRollbackIfEgressRuleNotInstalled.
@Test
public void shouldRollbackIfEgressRuleNotInstalled() throws Exception {
when(pathComputer.getPath(any(Flow.class))).thenReturn(make3SwitchesPathPair());
String key = "failed_flow_create";
FlowRequest flowRequest = makeRequest().flowId("failed_flow_id").build();
FlowCreateService service = makeService();
service.handleRequest(key, new CommandContext(), flowRequest);
Flow inProgress = verifyFlowStatus(flowRequest.getFlowId(), FlowStatus.IN_PROGRESS);
verifyFlowPathStatus(inProgress.getForwardPath(), FlowPathStatus.IN_PROGRESS, "forward");
verifyFlowPathStatus(inProgress.getReversePath(), FlowPathStatus.IN_PROGRESS, "reverse");
verifyNorthboundSuccessResponse(carrier);
FlowSegmentRequest request;
int installCommands = 0;
int deleteCommands = 0;
while ((request = requests.poll()) != null) {
try {
if (request.isVerifyRequest()) {
service.handleAsyncResponse(key, buildResponseOnVerifyRequest(request));
} else if (request.isInstallRequest()) {
installCommands++;
if (requests.size() > 1) {
handleResponse(service, key, request);
} else {
handleErrorResponse(service, key, request, ErrorCode.UNKNOWN);
}
} else if (request.isRemoveRequest()) {
deleteCommands++;
handleResponse(service, key, request);
}
} catch (UnknownKeyException ex) {
// skip
}
}
assertEquals("All installed rules should be deleted", installCommands, deleteCommands);
Flow result = verifyFlowStatus(flowRequest.getFlowId(), FlowStatus.DOWN);
// TODO(surabujin): do we really want to create flow without paths?
Assert.assertNull(result.getForwardPath());
Assert.assertNull(result.getReversePath());
}
Aggregations