Search in sources :

Example 1 with SpeakerCommandObserver

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);
    }
}
Also used : SpeakerFlowSegmentResponse(org.openkilda.floodlight.api.response.SpeakerFlowSegmentResponse) SpeakerCommandObserver(org.openkilda.wfm.topology.flowhs.service.SpeakerCommandObserver)

Example 2 with SpeakerCommandObserver

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);
    }
}
Also used : FlowSegmentRequestFactory(org.openkilda.floodlight.api.request.factory.FlowSegmentRequestFactory) FlowSegmentRequest(org.openkilda.floodlight.api.request.FlowSegmentRequest) SpeakerCommandObserver(org.openkilda.wfm.topology.flowhs.service.SpeakerCommandObserver) UUID(java.util.UUID)

Example 3 with SpeakerCommandObserver

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()));
}
Also used : FlowSegmentRequestFactory(org.openkilda.floodlight.api.request.factory.FlowSegmentRequestFactory) FlowSegmentRequest(org.openkilda.floodlight.api.request.FlowSegmentRequest) SpeakerCommandObserver(org.openkilda.wfm.topology.flowhs.service.SpeakerCommandObserver) UUID(java.util.UUID)

Example 4 with SpeakerCommandObserver

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);
    }
}
Also used : FlowSegmentRequestFactory(org.openkilda.floodlight.api.request.factory.FlowSegmentRequestFactory) FlowSegmentRequest(org.openkilda.floodlight.api.request.FlowSegmentRequest) SpeakerCommandObserver(org.openkilda.wfm.topology.flowhs.service.SpeakerCommandObserver) UUID(java.util.UUID)

Aggregations

SpeakerCommandObserver (org.openkilda.wfm.topology.flowhs.service.SpeakerCommandObserver)4 UUID (java.util.UUID)3 FlowSegmentRequest (org.openkilda.floodlight.api.request.FlowSegmentRequest)3 FlowSegmentRequestFactory (org.openkilda.floodlight.api.request.factory.FlowSegmentRequestFactory)3 SpeakerFlowSegmentResponse (org.openkilda.floodlight.api.response.SpeakerFlowSegmentResponse)1