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;
}
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;
}
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);
}
}
}
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);
}
}
}
}
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);
}
}
Aggregations