Search in sources :

Example 1 with CommandMessage

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

the class TestUtils method createTopology.

public static Set<CommandMessage> createTopology(final SwitchService switchService, final IslService islService) {
    Set<CommandMessage> commands = new HashSet<>();
    switchService.add(new SwitchInfoData(srcSwitchId, SwitchEventType.ADDED, address, name, "OVS 1"));
    switchService.add(new SwitchInfoData(firstTransitSwitchId, SwitchEventType.ADDED, address, name, "OVS 2"));
    switchService.add(new SwitchInfoData(secondTransitSwitchId, SwitchEventType.ADDED, address, name, "OVS 1"));
    switchService.add(new SwitchInfoData(dstSwitchId, SwitchEventType.ADDED, address, name, "OVS 2"));
    switchService.activate(new SwitchInfoData(srcSwitchId, SwitchEventType.ACTIVATED, address, name, "OVS 1"));
    switchService.activate(new SwitchInfoData(firstTransitSwitchId, SwitchEventType.ACTIVATED, address, name, "OVS 2"));
    switchService.activate(new SwitchInfoData(secondTransitSwitchId, SwitchEventType.ACTIVATED, address, name, "OVS 1"));
    switchService.activate(new SwitchInfoData(dstSwitchId, SwitchEventType.ACTIVATED, address, name, "OVS 2"));
    PathNode srcNode;
    PathNode dstNode;
    List<PathNode> list;
    srcNode = new PathNode(srcSwitchId, 1, 0);
    dstNode = new PathNode(firstTransitSwitchId, 2, 1);
    list = asList(srcNode, dstNode);
    islService.discoverLink(new IslInfoData(10L, list, portSpeed));
    islService.discoverLink(new IslInfoData(10L, Lists.reverse(list), portSpeed));
    srcNode = new PathNode(firstTransitSwitchId, 1, 0);
    dstNode = new PathNode(secondTransitSwitchId, 2, 1);
    list = asList(srcNode, dstNode);
    islService.discoverLink(new IslInfoData(10L, list, portSpeed));
    islService.discoverLink(new IslInfoData(10L, Lists.reverse(list), portSpeed));
    srcNode = new PathNode(secondTransitSwitchId, 1, 0);
    dstNode = new PathNode(dstSwitchId, 2, 1);
    list = asList(srcNode, dstNode);
    islService.discoverLink(new IslInfoData(10L, list, portSpeed));
    islService.discoverLink(new IslInfoData(10L, Lists.reverse(list), portSpeed));
    commands.add(new CommandMessage(new InstallIngressFlow(0L, flowId, COOKIE, srcSwitchId, DIRECT_INCOMING_PORT, DIRECT_OUTGOING_PORT, INPUT_VLAN_ID, TRANSIT_VLAN_ID, OutputVlanType.REPLACE, 10000L, 0L), METER_ID, DEFAULT_CORRELATION_ID, Destination.WFM));
    commands.add(new CommandMessage(new InstallTransitFlow(0L, flowId, COOKIE, firstTransitSwitchId, DIRECT_INCOMING_PORT, DIRECT_OUTGOING_PORT, TRANSIT_VLAN_ID), 0L, DEFAULT_CORRELATION_ID, Destination.WFM));
    commands.add(new CommandMessage(new InstallTransitFlow(0L, flowId, COOKIE, secondTransitSwitchId, DIRECT_INCOMING_PORT, DIRECT_OUTGOING_PORT, TRANSIT_VLAN_ID), 0L, DEFAULT_CORRELATION_ID, Destination.WFM));
    commands.add(new CommandMessage(new InstallEgressFlow(0L, flowId, COOKIE, dstSwitchId, DIRECT_INCOMING_PORT, DIRECT_OUTGOING_PORT, TRANSIT_VLAN_ID, OUTPUT_VLAN_ID, OutputVlanType.REPLACE), 0L, DEFAULT_CORRELATION_ID, Destination.WFM));
    commands.add(new CommandMessage(new InstallIngressFlow(0L, flowId, COOKIE, srcSwitchId, REVERSE_INGOING_PORT, REVERSE_OUTGOING_PORT, OUTPUT_VLAN_ID, TRANSIT_VLAN_ID, OutputVlanType.REPLACE, 10000L, 0L), METER_ID, DEFAULT_CORRELATION_ID, Destination.WFM));
    commands.add(new CommandMessage(new InstallTransitFlow(0L, flowId, COOKIE, srcSwitchId, REVERSE_INGOING_PORT, REVERSE_OUTGOING_PORT, TRANSIT_VLAN_ID), 0L, DEFAULT_CORRELATION_ID, Destination.WFM));
    commands.add(new CommandMessage(new InstallTransitFlow(0L, flowId, COOKIE, srcSwitchId, REVERSE_INGOING_PORT, REVERSE_OUTGOING_PORT, TRANSIT_VLAN_ID), 0L, DEFAULT_CORRELATION_ID, Destination.WFM));
    commands.add(new CommandMessage(new InstallEgressFlow(0L, flowId, COOKIE, srcSwitchId, REVERSE_INGOING_PORT, REVERSE_OUTGOING_PORT, 2, INPUT_VLAN_ID, OutputVlanType.REPLACE), 0L, DEFAULT_CORRELATION_ID, Destination.WFM));
    return commands;
}
Also used : InstallIngressFlow(org.openkilda.messaging.command.flow.InstallIngressFlow) InstallTransitFlow(org.openkilda.messaging.command.flow.InstallTransitFlow) IslInfoData(org.openkilda.messaging.info.event.IslInfoData) SwitchInfoData(org.openkilda.messaging.info.event.SwitchInfoData) PathNode(org.openkilda.messaging.info.event.PathNode) InstallEgressFlow(org.openkilda.messaging.command.flow.InstallEgressFlow) CommandMessage(org.openkilda.messaging.command.CommandMessage) HashSet(java.util.HashSet)

Example 2 with CommandMessage

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

the class CacheBolt method getNetworkRequest.

private Values getNetworkRequest() {
    Values values = null;
    try {
        CommandMessage command = new CommandMessage(new NetworkCommandData(), System.currentTimeMillis(), Utils.SYSTEM_CORRELATION_ID, Destination.TOPOLOGY_ENGINE);
        values = new Values(Utils.MAPPER.writeValueAsString(command));
    } catch (IOException exception) {
        logger.error("Could not serialize network cache request", exception);
    }
    return values;
}
Also used : Values(org.apache.storm.tuple.Values) IOException(java.io.IOException) NetworkCommandData(org.openkilda.messaging.command.discovery.NetworkCommandData) CommandMessage(org.openkilda.messaging.command.CommandMessage)

Example 3 with CommandMessage

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

the class CacheBolt method emitRerouteCommands.

private void emitRerouteCommands(Set<ImmutablePair<Flow, Flow>> flows, Tuple tuple, String correlationId, FlowOperation operation) {
    for (ImmutablePair<Flow, Flow> flow : flows) {
        try {
            flow.getLeft().setState(FlowState.DOWN);
            flow.getRight().setState(FlowState.DOWN);
            FlowRerouteRequest request = new FlowRerouteRequest(flow.getLeft(), operation);
            Values values = new Values(Utils.MAPPER.writeValueAsString(new CommandMessage(request, System.currentTimeMillis(), correlationId, Destination.WFM)));
            outputCollector.emit(StreamType.WFM_DUMP.toString(), tuple, values);
            logger.debug("Flow {} reroute command message sent with correlationId {}", flow.getLeft().getFlowId(), correlationId);
        } catch (JsonProcessingException exception) {
            logger.error("Could not format flow reroute request by flow={}", flow, exception);
        }
    }
}
Also used : Values(org.apache.storm.tuple.Values) FlowRerouteRequest(org.openkilda.messaging.command.flow.FlowRerouteRequest) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) Flow(org.openkilda.messaging.model.Flow) CommandMessage(org.openkilda.messaging.command.CommandMessage)

Example 4 with CommandMessage

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

the class CacheBolt method emitRestoreCommands.

private void emitRestoreCommands(Set<ImmutablePair<Flow, Flow>> flows, Tuple tuple) {
    if (flows != null) {
        ResourceCache resourceCache = new ResourceCache();
        for (ImmutablePair<Flow, Flow> flow : flows) {
            resourceCache.allocateFlow(flow);
        }
        for (ImmutablePair<Flow, Flow> flow : flows) {
            try {
                FlowRestoreRequest request = new FlowRestoreRequest(flowCache.buildFlow(flow.getLeft(), new ImmutablePair<>(null, null), resourceCache));
                resourceCache.deallocateFlow(flow);
                Values values = new Values(Utils.MAPPER.writeValueAsString(new CommandMessage(request, System.currentTimeMillis(), UUID.randomUUID().toString(), Destination.WFM)));
                outputCollector.emit(StreamType.WFM_DUMP.toString(), tuple, values);
                logger.info("Flow {} restore command message sent", flow.getLeft().getFlowId());
            } catch (JsonProcessingException exception) {
                logger.error("Could not format flow restore request by flow={}", flow, exception);
            }
        }
    }
}
Also used : ImmutablePair(org.openkilda.messaging.model.ImmutablePair) Values(org.apache.storm.tuple.Values) FlowRestoreRequest(org.openkilda.messaging.command.flow.FlowRestoreRequest) ResourceCache(org.openkilda.pce.cache.ResourceCache) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) Flow(org.openkilda.messaging.model.Flow) CommandMessage(org.openkilda.messaging.command.CommandMessage)

Example 5 with CommandMessage

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

the class OFELinkBolt method sendNetworkRequest.

/**
 * Send network dump request to FL
 */
private void sendNetworkRequest(Tuple tuple) {
    try {
        logger.debug("Send network dump request");
        CommandMessage command = new CommandMessage(new NetworkCommandData(), System.currentTimeMillis(), Utils.SYSTEM_CORRELATION_ID, Destination.CONTROLLER);
        String json = Utils.MAPPER.writeValueAsString(command);
        collector.emit(islDiscoveryTopic, tuple, new Values(PAYLOAD, json));
    } catch (JsonProcessingException exception) {
        logger.error("Could not serialize network cache request", exception);
    }
}
Also used : Values(org.apache.storm.tuple.Values) NetworkCommandData(org.openkilda.messaging.command.discovery.NetworkCommandData) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) CommandMessage(org.openkilda.messaging.command.CommandMessage)

Aggregations

CommandMessage (org.openkilda.messaging.command.CommandMessage)70 Message (org.openkilda.messaging.Message)36 InfoMessage (org.openkilda.messaging.info.InfoMessage)32 Test (org.junit.Test)19 ErrorMessage (org.openkilda.messaging.error.ErrorMessage)18 Values (org.apache.storm.tuple.Values)11 FlowIdStatusPayload (org.openkilda.messaging.payload.flow.FlowIdStatusPayload)11 RemoveFlow (org.openkilda.messaging.command.flow.RemoveFlow)8 Flow (org.openkilda.messaging.model.Flow)8 IOException (java.io.IOException)7 CommandData (org.openkilda.messaging.command.CommandData)7 AbstractStormTest (org.openkilda.wfm.AbstractStormTest)7 HashSet (java.util.HashSet)6 SwitchInfoData (org.openkilda.messaging.info.event.SwitchInfoData)6 CommandWithReplyToMessage (org.openkilda.messaging.command.CommandWithReplyToMessage)5 NetworkCommandData (org.openkilda.messaging.command.discovery.NetworkCommandData)5 InstallOneSwitchFlow (org.openkilda.messaging.command.flow.InstallOneSwitchFlow)5 FlowDeleteRequest (org.openkilda.messaging.command.flow.FlowDeleteRequest)4 FlowPathRequest (org.openkilda.messaging.command.flow.FlowPathRequest)4 FlowRerouteRequest (org.openkilda.messaging.command.flow.FlowRerouteRequest)4