Search in sources :

Example 1 with SwitchValidateRequest

use of org.openkilda.messaging.command.switches.SwitchValidateRequest in project open-kilda by telstra.

the class FeatureTogglesBolt method requestSwitchSync.

@Override
public void requestSwitchSync(SwitchId switchId) {
    SwitchValidateRequest data = SwitchValidateRequest.builder().switchId(switchId).performSync(true).processMeters(true).removeExcess(true).build();
    getOutput().emit(StreamType.TO_SWITCH_MANAGER.toString(), getCurrentTuple(), new Values(data, KeyProvider.generateChainedKey(getCorrelationId())));
}
Also used : Values(org.apache.storm.tuple.Values) SwitchValidateRequest(org.openkilda.messaging.command.switches.SwitchValidateRequest)

Example 2 with SwitchValidateRequest

use of org.openkilda.messaging.command.switches.SwitchValidateRequest in project open-kilda by telstra.

the class SwitchManagerHub method onRequest.

@Override
protected void onRequest(Tuple input) throws PipelineException {
    if (!active) {
        log.info("Switch Manager Topology is inactive");
        return;
    }
    String key = input.getStringByField(MessageKafkaTranslator.FIELD_ID_KEY);
    CommandMessage message = pullValue(input, MessageKafkaTranslator.FIELD_ID_PAYLOAD, CommandMessage.class);
    CommandData data = message.getData();
    if (data instanceof SwitchValidateRequest) {
        validateService.handleSwitchValidateRequest(key, (SwitchValidateRequest) data);
    } else if (data instanceof SwitchRulesDeleteRequest) {
        switchRuleService.deleteRules(key, (SwitchRulesDeleteRequest) data);
    } else if (data instanceof SwitchRulesInstallRequest) {
        switchRuleService.installRules(key, (SwitchRulesInstallRequest) data);
    } else if (data instanceof CreateLagPortRequest) {
        createLagPortService.handleCreateLagRequest(key, (CreateLagPortRequest) data);
    } else if (data instanceof DeleteLagPortRequest) {
        deleteLagPortService.handleDeleteLagRequest(key, (DeleteLagPortRequest) data);
    } else {
        log.warn("Receive unexpected CommandMessage for key {}: {}", key, data);
    }
}
Also used : SwitchRulesInstallRequest(org.openkilda.messaging.command.switches.SwitchRulesInstallRequest) CreateLagPortRequest(org.openkilda.messaging.swmanager.request.CreateLagPortRequest) DeleteLagPortRequest(org.openkilda.messaging.swmanager.request.DeleteLagPortRequest) SwitchRulesDeleteRequest(org.openkilda.messaging.command.switches.SwitchRulesDeleteRequest) SwitchValidateRequest(org.openkilda.messaging.command.switches.SwitchValidateRequest) CommandData(org.openkilda.messaging.command.CommandData) CommandMessage(org.openkilda.messaging.command.CommandMessage)

Example 3 with SwitchValidateRequest

use of org.openkilda.messaging.command.switches.SwitchValidateRequest in project open-kilda by telstra.

the class SwitchOperationsBolt method requestSwitchSync.

@Override
public void requestSwitchSync(SwitchId switchId) {
    SwitchValidateRequest data = SwitchValidateRequest.builder().switchId(switchId).performSync(true).processMeters(true).removeExcess(true).build();
    getOutput().emit(StreamType.TO_SWITCH_MANAGER.toString(), getCurrentTuple(), new Values(data, KeyProvider.generateChainedKey(getCorrelationId())));
}
Also used : Values(org.apache.storm.tuple.Values) SwitchValidateRequest(org.openkilda.messaging.command.switches.SwitchValidateRequest)

Example 4 with SwitchValidateRequest

use of org.openkilda.messaging.command.switches.SwitchValidateRequest in project open-kilda by telstra.

the class MessageEncoder method handleInput.

@Override
protected void handleInput(Tuple input) throws Exception {
    MessageData payload = pullPayload(input);
    try {
        CommandContext commandContext = pullContext(input);
        Message message = wrap(commandContext, payload);
        if (payload instanceof FlowRerouteRequest) {
            getOutput().emit(input.getSourceStreamId(), input, new Values(message));
        } else if (payload instanceof SwitchValidateRequest) {
            getOutput().emit(input.getSourceStreamId(), input, new Values(commandContext.getCorrelationId(), message));
        } else if (payload instanceof ErrorData) {
            getOutput().emit(StreamType.ERROR.toString(), input, new Values(null, message));
        }
    } catch (IllegalArgumentException e) {
        log.error(e.getMessage());
        unhandledInput(input);
    }
}
Also used : CommandContext(org.openkilda.wfm.CommandContext) Message(org.openkilda.messaging.Message) MessageData(org.openkilda.messaging.MessageData) Values(org.apache.storm.tuple.Values) FlowRerouteRequest(org.openkilda.messaging.command.flow.FlowRerouteRequest) SwitchValidateRequest(org.openkilda.messaging.command.switches.SwitchValidateRequest) ErrorData(org.openkilda.messaging.error.ErrorData)

Example 5 with SwitchValidateRequest

use of org.openkilda.messaging.command.switches.SwitchValidateRequest in project open-kilda by telstra.

the class SwitchSyncFsmTest method getModifyDefaultMetersWithFlowMeters.

@Test
public void getModifyDefaultMetersWithFlowMeters() {
    ArrayList<MeterInfoEntry> misconfiguredMeters = newArrayList(MeterInfoEntry.builder().cookie(COOKIE_1).meterId((long) MeterId.MIN_FLOW_METER_ID).build());
    ValidateMetersResult validateMetersResult = new ValidateMetersResult(newArrayList(), misconfiguredMeters, newArrayList(), newArrayList());
    ValidationResult validationResult = new ValidationResult(new ArrayList<>(), true, EMPTY_VALIDATE_RULES_RESULT, validateMetersResult, EMPTY_VALIDATE_GROUPS_RESULT, EMPTY_LOGICAL_PORTS_RESULT);
    SwitchSyncFsm fsm = new SwitchSyncFsm(null, null, null, new SwitchValidateRequest(SWITCH_ID, true, true, true), validationResult);
    assertTrue(fsm.getModifyDefaultMeters().isEmpty());
}
Also used : MeterInfoEntry(org.openkilda.messaging.info.switches.MeterInfoEntry) ValidateMetersResult(org.openkilda.wfm.topology.switchmanager.model.ValidateMetersResult) SwitchValidateRequest(org.openkilda.messaging.command.switches.SwitchValidateRequest) ValidationResult(org.openkilda.wfm.topology.switchmanager.model.ValidationResult) Test(org.junit.Test)

Aggregations

SwitchValidateRequest (org.openkilda.messaging.command.switches.SwitchValidateRequest)6 Values (org.apache.storm.tuple.Values)3 Test (org.junit.Test)2 MeterInfoEntry (org.openkilda.messaging.info.switches.MeterInfoEntry)2 ValidateMetersResult (org.openkilda.wfm.topology.switchmanager.model.ValidateMetersResult)2 ValidationResult (org.openkilda.wfm.topology.switchmanager.model.ValidationResult)2 Message (org.openkilda.messaging.Message)1 MessageData (org.openkilda.messaging.MessageData)1 CommandData (org.openkilda.messaging.command.CommandData)1 CommandMessage (org.openkilda.messaging.command.CommandMessage)1 FlowRerouteRequest (org.openkilda.messaging.command.flow.FlowRerouteRequest)1 SwitchRulesDeleteRequest (org.openkilda.messaging.command.switches.SwitchRulesDeleteRequest)1 SwitchRulesInstallRequest (org.openkilda.messaging.command.switches.SwitchRulesInstallRequest)1 ErrorData (org.openkilda.messaging.error.ErrorData)1 CreateLagPortRequest (org.openkilda.messaging.swmanager.request.CreateLagPortRequest)1 DeleteLagPortRequest (org.openkilda.messaging.swmanager.request.DeleteLagPortRequest)1 CommandContext (org.openkilda.wfm.CommandContext)1 ValidateRulesResult (org.openkilda.wfm.topology.switchmanager.model.ValidateRulesResult)1