Search in sources :

Example 1 with FlowTransitData

use of org.openkilda.floodlight.model.FlowTransitData in project open-kilda by telstra.

the class RecordHandler method doInstallGroupRequest.

private void doInstallGroupRequest(CommandMessage message) {
    SwitchId switchId = ((InstallGroupRequest) message.getData()).getSwitchId();
    MirrorConfig mirrorConfig = ((InstallGroupRequest) message.getData()).getMirrorConfig();
    FlowTransitEncapsulation encapsulation = ((InstallGroupRequest) message.getData()).getEncapsulation();
    SwitchId egressSwitchId = ((InstallGroupRequest) message.getData()).getEgressSwitchId();
    FlowTransitData flowTransitData = null;
    if (encapsulation != null) {
        flowTransitData = FlowTransitData.builder().ingressSwitchId(switchId).egressSwitchId(egressSwitchId).encapsulation(encapsulation).build();
    }
    logger.debug("Install group '{}' for switch '{}'", mirrorConfig.getGroupId().intValue(), switchId);
    handleSpeakerCommand(new GroupInstallCommand(new MessageContext(message), switchId, mirrorConfig, flowTransitData));
    InstallGroupResponse response = new InstallGroupResponse(switchId, mirrorConfig.getGroupId().intValue());
    String correlationId = message.getCorrelationId();
    InfoMessage infoMessage = new InfoMessage(response, System.currentTimeMillis(), correlationId);
    getKafkaProducer().sendMessageAndTrack(context.getKafkaSwitchManagerTopic(), correlationId, infoMessage);
}
Also used : FlowTransitData(org.openkilda.floodlight.model.FlowTransitData) InstallGroupRequest(org.openkilda.messaging.command.switches.InstallGroupRequest) MirrorConfig(org.openkilda.model.MirrorConfig) InfoMessage(org.openkilda.messaging.info.InfoMessage) InstallGroupResponse(org.openkilda.messaging.info.switches.InstallGroupResponse) FlowTransitEncapsulation(org.openkilda.model.FlowTransitEncapsulation) SwitchId(org.openkilda.model.SwitchId) MessageContext(org.openkilda.messaging.MessageContext) GroupInstallCommand(org.openkilda.floodlight.command.group.GroupInstallCommand)

Example 2 with FlowTransitData

use of org.openkilda.floodlight.model.FlowTransitData in project open-kilda by telstra.

the class RecordHandler method doModifyGroupRequest.

private void doModifyGroupRequest(CommandMessage message) {
    SwitchId switchId = ((ModifyGroupRequest) message.getData()).getSwitchId();
    MirrorConfig mirrorConfig = ((ModifyGroupRequest) message.getData()).getMirrorConfig();
    FlowTransitEncapsulation encapsulation = ((ModifyGroupRequest) message.getData()).getEncapsulation();
    SwitchId egressSwitchId = ((ModifyGroupRequest) message.getData()).getEgressSwitchId();
    FlowTransitData flowTransitData = null;
    if (encapsulation != null) {
        flowTransitData = FlowTransitData.builder().ingressSwitchId(switchId).egressSwitchId(egressSwitchId).encapsulation(encapsulation).build();
    }
    logger.debug("Modify group '{}' for switch '{}'", mirrorConfig.getGroupId().intValue(), switchId);
    handleSpeakerCommand(new GroupModifyCommand(new MessageContext(message), switchId, mirrorConfig, flowTransitData));
    ModifyGroupResponse response = new ModifyGroupResponse(switchId, mirrorConfig.getGroupId().intValue());
    String correlationId = message.getCorrelationId();
    InfoMessage infoMessage = new InfoMessage(response, System.currentTimeMillis(), correlationId);
    getKafkaProducer().sendMessageAndTrack(context.getKafkaSwitchManagerTopic(), correlationId, infoMessage);
}
Also used : FlowTransitData(org.openkilda.floodlight.model.FlowTransitData) MirrorConfig(org.openkilda.model.MirrorConfig) InfoMessage(org.openkilda.messaging.info.InfoMessage) ModifyGroupResponse(org.openkilda.messaging.info.switches.ModifyGroupResponse) FlowTransitEncapsulation(org.openkilda.model.FlowTransitEncapsulation) SwitchId(org.openkilda.model.SwitchId) MessageContext(org.openkilda.messaging.MessageContext) GroupModifyCommand(org.openkilda.floodlight.command.group.GroupModifyCommand) ModifyGroupRequest(org.openkilda.messaging.command.switches.ModifyGroupRequest)

Example 3 with FlowTransitData

use of org.openkilda.floodlight.model.FlowTransitData in project open-kilda by telstra.

the class GroupInstallCommand method handleOfError.

@Override
public CompletableFuture<Optional<OFMessage>> handleOfError(OFErrorMsg response) {
    CompletableFuture<Optional<OFMessage>> future = new CompletableFuture<>();
    if (!isInstallConflict(response)) {
        future.completeExceptionally(new SwitchErrorResponseException(getSw().getId(), String.format("Can't install group %s - %s", mirrorConfig.getGroupId(), response)));
        return future;
    }
    log.info("Group conflict detected sw:{} group:{}", getSw().getId(), mirrorConfig.getGroupId());
    GroupVerifyCommand verifyCommand = new GroupVerifyCommand(messageContext, switchId, mirrorConfig, flowTransitData);
    propagateFutureResponse(future, commandProcessor.chain(verifyCommand).thenAccept(this::handleGroupVerify).thenApply(ignore -> Optional.empty()));
    return future;
}
Also used : MirrorConfig(org.openkilda.model.MirrorConfig) Getter(lombok.Getter) Session(org.openkilda.floodlight.service.session.Session) OFGroupMod(org.projectfloodlight.openflow.protocol.OFGroupMod) FlowTransitData(org.openkilda.floodlight.model.FlowTransitData) MessageContext(org.openkilda.messaging.MessageContext) CompletableFuture(java.util.concurrent.CompletableFuture) InvalidGroupIdException(org.openkilda.floodlight.error.InvalidGroupIdException) OFGroupModFailedErrorMsg(org.projectfloodlight.openflow.protocol.errormsg.OFGroupModFailedErrorMsg) SwitchIncorrectMirrorGroupException(org.openkilda.floodlight.error.SwitchIncorrectMirrorGroupException) UnsupportedSwitchOperationException(org.openkilda.floodlight.error.UnsupportedSwitchOperationException) OFGroupModFailedCode(org.projectfloodlight.openflow.protocol.OFGroupModFailedCode) SwitchId(org.openkilda.model.SwitchId) SpeakerCommandProcessor(org.openkilda.floodlight.command.SpeakerCommandProcessor) SwitchGroupConflictException(org.openkilda.floodlight.error.SwitchGroupConflictException) OFMessage(org.projectfloodlight.openflow.protocol.OFMessage) Optional(java.util.Optional) SwitchMissingGroupException(org.openkilda.floodlight.error.SwitchMissingGroupException) OFErrorMsg(org.projectfloodlight.openflow.protocol.OFErrorMsg) IOfErrorResponseHandler(org.openkilda.floodlight.command.IOfErrorResponseHandler) GroupId(org.openkilda.model.GroupId) SwitchErrorResponseException(org.openkilda.floodlight.error.SwitchErrorResponseException) CompletableFuture(java.util.concurrent.CompletableFuture) Optional(java.util.Optional) SwitchErrorResponseException(org.openkilda.floodlight.error.SwitchErrorResponseException)

Aggregations

FlowTransitData (org.openkilda.floodlight.model.FlowTransitData)3 MessageContext (org.openkilda.messaging.MessageContext)3 MirrorConfig (org.openkilda.model.MirrorConfig)3 SwitchId (org.openkilda.model.SwitchId)3 InfoMessage (org.openkilda.messaging.info.InfoMessage)2 FlowTransitEncapsulation (org.openkilda.model.FlowTransitEncapsulation)2 Optional (java.util.Optional)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 Getter (lombok.Getter)1 IOfErrorResponseHandler (org.openkilda.floodlight.command.IOfErrorResponseHandler)1 SpeakerCommandProcessor (org.openkilda.floodlight.command.SpeakerCommandProcessor)1 GroupInstallCommand (org.openkilda.floodlight.command.group.GroupInstallCommand)1 GroupModifyCommand (org.openkilda.floodlight.command.group.GroupModifyCommand)1 InvalidGroupIdException (org.openkilda.floodlight.error.InvalidGroupIdException)1 SwitchErrorResponseException (org.openkilda.floodlight.error.SwitchErrorResponseException)1 SwitchGroupConflictException (org.openkilda.floodlight.error.SwitchGroupConflictException)1 SwitchIncorrectMirrorGroupException (org.openkilda.floodlight.error.SwitchIncorrectMirrorGroupException)1 SwitchMissingGroupException (org.openkilda.floodlight.error.SwitchMissingGroupException)1 UnsupportedSwitchOperationException (org.openkilda.floodlight.error.UnsupportedSwitchOperationException)1 Session (org.openkilda.floodlight.service.session.Session)1