use of org.openkilda.wfm.topology.flowhs.service.SpeakerCommandObserver in project open-kilda by telstra.
the class OnReceivedResponseAction method perform.
@Override
protected void perform(State from, State to, Event event, FlowCreateContext context, FlowCreateFsm stateMachine) {
SpeakerFlowSegmentResponse response = context.getSpeakerFlowResponse();
if (!stateMachine.isPendingCommand(response.getCommandId())) {
log.warn("Received response for non-pending command: {}", response.getCommandId());
return;
}
SpeakerCommandObserver commandObserver = stateMachine.getPendingCommands().get(response.getCommandId());
commandObserver.handleResponse(response);
if (commandObserver.isFinished()) {
stateMachine.getPendingCommands().remove(response.getCommandId());
handleResponse(stateMachine, response);
completeStage(stateMachine, context);
}
}
use of org.openkilda.wfm.topology.flowhs.service.SpeakerCommandObserver in project open-kilda by telstra.
the class InstallRulesAction method emitInstallRequests.
protected void emitInstallRequests(FlowCreateFsm stateMachine, List<FlowSegmentRequestFactory> factories) {
Map<UUID, SpeakerCommandObserver> pendingRequests = stateMachine.getPendingCommands();
List<FlowSegmentRequestFactory> sentCommands = stateMachine.getSentCommands();
for (FlowSegmentRequestFactory factory : factories) {
FlowSegmentRequest request = factory.makeInstallRequest(commandIdGenerator.generate());
SpeakerCommandObserver commandObserver = new SpeakerCommandObserver(speakerCommandFsmBuilder, request);
commandObserver.start();
sentCommands.add(factory);
// TODO ensure no conflicts
pendingRequests.put(request.getCommandId(), commandObserver);
}
}
use of org.openkilda.wfm.topology.flowhs.service.SpeakerCommandObserver in project open-kilda by telstra.
the class RollbackInstalledRulesAction method perform.
@Override
protected void perform(State from, State to, Event event, FlowCreateContext context, FlowCreateFsm stateMachine) {
stateMachine.getPendingCommands().clear();
stateMachine.getFailedCommands().clear();
Map<UUID, SpeakerCommandObserver> pendingRequests = stateMachine.getPendingCommands();
for (FlowSegmentRequestFactory factory : stateMachine.getSentCommands()) {
FlowSegmentRequest request = factory.makeRemoveRequest(commandIdGenerator.generate());
SpeakerCommandObserver commandObserver = new SpeakerCommandObserver(speakerCommandFsmBuilder, request);
commandObserver.start();
// TODO ensure no conflicts
pendingRequests.put(request.getCommandId(), commandObserver);
}
stateMachine.saveActionToHistory(String.format("Commands to rollback installed rules have been sent. Total amount: %s", pendingRequests.size()));
}
use of org.openkilda.wfm.topology.flowhs.service.SpeakerCommandObserver in project open-kilda by telstra.
the class EmitVerifyRulesAction method emitVerifyRequests.
protected void emitVerifyRequests(FlowCreateFsm stateMachine, Collection<FlowSegmentRequestFactory> requestFactories) {
final Map<UUID, SpeakerCommandObserver> pendingCommands = stateMachine.getPendingCommands();
for (FlowSegmentRequestFactory factory : requestFactories) {
FlowSegmentRequest request = factory.makeVerifyRequest(commandIdGenerator.generate());
SpeakerCommandObserver commandObserver = new SpeakerCommandObserver(speakerCommandFsmBuilder, Collections.singleton(ErrorCode.MISSING_OF_FLOWS), request);
commandObserver.start();
pendingCommands.put(request.getCommandId(), commandObserver);
}
}
Aggregations