use of org.openkilda.server42.control.messaging.Control.CommandPacket.Builder in project open-kilda by telstra.
the class GateTest method listIslsTest.
@Test
public void listIslsTest() throws Exception {
Builder commandPacketResponseBuilded = CommandPacketResponse.newBuilder();
String switchId = "00:00:1b:45:18:d6:71:5a";
IslEndpoint port1 = IslEndpoint.newBuilder().setSwitchId(switchId).setPort(1).build();
IslEndpoint port2 = IslEndpoint.newBuilder().setSwitchId(switchId).setPort(2).build();
IslEndpoint port3 = IslEndpoint.newBuilder().setSwitchId(switchId).setPort(3).build();
IslEndpoint port4 = IslEndpoint.newBuilder().setSwitchId(switchId).setPort(4).build();
commandPacketResponseBuilded.addResponse(Any.pack(port1));
commandPacketResponseBuilded.addResponse(Any.pack(port2));
commandPacketResponseBuilded.addResponse(Any.pack(port3));
commandPacketResponseBuilded.addResponse(Any.pack(port4));
CommandPacketResponse commandPacketResponse = commandPacketResponseBuilded.build();
when(zeroMqClient.send(argThat(commandPacket -> commandPacket.getType() == Type.LIST_ISLS))).thenReturn(commandPacketResponse);
gate.listen(ListIslsRequest.builder().switchId(new SwitchId(switchId)).build());
ArgumentCaptor<ListIslsResponse> argument = ArgumentCaptor.forClass(ListIslsResponse.class);
verify(template).send(eq(toStorm), argument.capture());
ListIslsResponse response = argument.getValue();
assertThat(response.getPorts()).contains(port1.getPort(), port2.getPort(), port3.getPort(), port4.getPort());
}
use of org.openkilda.server42.control.messaging.Control.CommandPacket.Builder in project open-kilda by telstra.
the class Gate method listen.
@KafkaHandler
void listen(@Payload AddIsl data) {
Builder builder = CommandPacket.newBuilder();
builder.setType(Type.ADD_ISL);
SwitchId switchId = data.getSwitchId();
String switchIdKey = switchId.toString();
IslEndpoint endpoint = IslEndpoint.newBuilder().setSwitchId(switchIdKey).setPort(data.getPort()).build();
IslRttControl.AddIsl addIsl = IslRttControl.AddIsl.newBuilder().setIsl(endpoint).setSwitchMac(switchId.toMacAddress()).setUdpSrcPort(islRttUdpSrcPortOffset + data.getPort()).setTransitEncapsulationType(IslRttControl.AddIsl.EncapsulationType.VLAN).setTransitTunnelId(switchToVlanMap.get(switchIdKey)).setHashCode(data.hashCode()).build();
builder.addCommand(Any.pack(addIsl));
try {
zeroMqClient.send(builder.build());
} catch (InvalidProtocolBufferException e) {
log.error("Marshalling error on {}", data, e);
}
}
use of org.openkilda.server42.control.messaging.Control.CommandPacket.Builder in project open-kilda by telstra.
the class Gate method listen.
@KafkaHandler
void listen(PushSettings data) {
Builder builder = CommandPacket.newBuilder();
Control.PushSettings pushSettings = Control.PushSettings.newBuilder().setPacketGenerationIntervalInMs(data.getPacketGenerationIntervalInMs()).build();
builder.setType(Type.PUSH_SETTINGS);
builder.addCommand(Any.pack(pushSettings));
CommandPacket packet = builder.build();
try {
zeroMqClient.send(packet);
} catch (InvalidProtocolBufferException e) {
log.error("Marshalling error on {}", data);
}
}
use of org.openkilda.server42.control.messaging.Control.CommandPacket.Builder in project open-kilda by telstra.
the class Gate method listen.
@KafkaHandler
void listen(@Payload ClearIsls data) {
Builder builder = CommandPacket.newBuilder();
builder.setType(Type.CLEAR_ISLS);
IslRttControl.ClearIslsFilter clearIslsFilter = IslRttControl.ClearIslsFilter.newBuilder().setSwitchId(data.getSwitchId().toString()).build();
builder.addCommand(Any.pack(clearIslsFilter));
try {
zeroMqClient.send(builder.build());
} catch (InvalidProtocolBufferException e) {
log.error("Marshalling error on {}", data, e);
}
}
Aggregations