Search in sources :

Example 11 with CommandData

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

the class FlowMeterModifyHubBolt method onRequest.

@Override
protected void onRequest(Tuple input) throws PipelineException {
    String key = input.getStringByField(MessageKafkaTranslator.FIELD_ID_KEY);
    CommandData data = pullValue(input, MessageKafkaTranslator.FIELD_ID_PAYLOAD, CommandData.class);
    if (data instanceof MeterModifyRequest) {
        service.handleRequest(key, (MeterModifyRequest) data, new FlowHubCarrierImpl(input));
    } else {
        unhandledInput(input);
    }
}
Also used : CommandData(org.openkilda.messaging.command.CommandData) MeterModifyRequest(org.openkilda.messaging.nbtopology.request.MeterModifyRequest)

Example 12 with CommandData

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

the class YFlowPingRequestTest method serializeLoop.

@Test
public void serializeLoop() throws Exception {
    YFlowPingRequest origin = new YFlowPingRequest("yFlowId", 5000);
    CommandMessage wrapper = new CommandMessage(origin, System.currentTimeMillis(), getClass().getSimpleName());
    serializer.serialize(wrapper);
    CommandMessage decodedWrapper = (CommandMessage) serializer.deserialize();
    CommandData decoded = decodedWrapper.getData();
    assertEquals(origin, decoded);
}
Also used : CommandData(org.openkilda.messaging.command.CommandData) CommandMessage(org.openkilda.messaging.command.CommandMessage) Test(org.junit.Test)

Example 13 with CommandData

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

the class FlowPingRequestTest method serializeLoop.

@Test
public void serializeLoop() throws Exception {
    FlowPingRequest origin = new FlowPingRequest("flowId", 5000);
    CommandMessage wrapper = new CommandMessage(origin, System.currentTimeMillis(), getClass().getSimpleName());
    serializer.serialize(wrapper);
    CommandMessage decodedWrapper = (CommandMessage) serializer.deserialize();
    CommandData decoded = decodedWrapper.getData();
    Assert.assertEquals(String.format("%s object have been mangled in serialisation/deserialization loop", origin.getClass().getName()), origin, decoded);
}
Also used : CommandData(org.openkilda.messaging.command.CommandData) CommandMessage(org.openkilda.messaging.command.CommandMessage) Test(org.junit.Test)

Example 14 with CommandData

use of org.openkilda.messaging.command.CommandData 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 15 with CommandData

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

the class JsonSerializeAbstractTest method commandSerializeLoop.

protected void commandSerializeLoop(CommandData origin) throws Exception {
    CommandMessage wrapper = new CommandMessage(origin, 0, "serialize-loop");
    serializer.serialize(wrapper);
    CommandMessage decodedWrapper = (CommandMessage) serializer.deserialize();
    CommandData decoded = decodedWrapper.getData();
    validate(origin, decoded);
}
Also used : CommandData(org.openkilda.messaging.command.CommandData) CommandMessage(org.openkilda.messaging.command.CommandMessage)

Aggregations

CommandData (org.openkilda.messaging.command.CommandData)35 CommandMessage (org.openkilda.messaging.command.CommandMessage)14 Values (org.apache.storm.tuple.Values)12 Message (org.openkilda.messaging.Message)11 ErrorMessage (org.openkilda.messaging.error.ErrorMessage)11 InfoData (org.openkilda.messaging.info.InfoData)7 Test (org.junit.Test)6 InfoMessage (org.openkilda.messaging.info.InfoMessage)6 DiscoverIslCommandData (org.openkilda.messaging.command.discovery.DiscoverIslCommandData)5 DumpGroupsForFlowHsRequest (org.openkilda.messaging.command.switches.DumpGroupsForFlowHsRequest)5 DumpMetersForFlowHsRequest (org.openkilda.messaging.command.switches.DumpMetersForFlowHsRequest)5 DumpRulesForFlowHsRequest (org.openkilda.messaging.command.switches.DumpRulesForFlowHsRequest)5 SwitchId (org.openkilda.model.SwitchId)5 IOException (java.io.IOException)4 List (java.util.List)4 DiscoverPathCommandData (org.openkilda.messaging.command.discovery.DiscoverPathCommandData)4 FlowCreateRequest (org.openkilda.messaging.command.flow.FlowCreateRequest)4 ErrorData (org.openkilda.messaging.error.ErrorData)4 NetworkCommandData (org.openkilda.messaging.command.discovery.NetworkCommandData)3 BaseInstallFlow (org.openkilda.messaging.command.flow.BaseInstallFlow)3