Search in sources :

Example 1 with ClearFlows

use of org.openkilda.server42.control.messaging.flowrtt.ClearFlows in project open-kilda by telstra.

the class Gate method listen.

@KafkaHandler
void listen(ClearFlows data, @Header(KafkaHeaders.RECEIVED_MESSAGE_KEY) String switchIdKey) {
    Builder builder = CommandPacket.newBuilder();
    builder.setType(Type.CLEAR_FLOWS);
    SwitchId switchId = new SwitchId(switchIdKey);
    FlowRttControl.ClearFlowsFilter clearFlowsFilter = FlowRttControl.ClearFlowsFilter.newBuilder().setDstMac(switchId.toMacAddress()).build();
    builder.addCommand(Any.pack(clearFlowsFilter));
    try {
        zeroMqClient.send(builder.build());
    } catch (InvalidProtocolBufferException e) {
        log.error("Marshalling error on {}", data);
    }
}
Also used : Builder(org.openkilda.server42.control.messaging.Control.CommandPacket.Builder) InvalidProtocolBufferException(com.google.protobuf.InvalidProtocolBufferException) SwitchId(org.openkilda.model.SwitchId) FlowRttControl(org.openkilda.server42.control.messaging.flowrtt.FlowRttControl) KafkaHandler(org.springframework.kafka.annotation.KafkaHandler)

Example 2 with ClearFlows

use of org.openkilda.server42.control.messaging.flowrtt.ClearFlows in project open-kilda by telstra.

the class StubApplicationTests method clearFlows.

@BeforeEach
public void clearFlows() throws Exception {
    mockMvc.perform(delete("/kafka/flow/").param("switchId", switchId)).andExpect(status().isOk());
    MvcResult result = mockMvc.perform(get("/kafka/flow/").param("switchId", switchId)).andReturn();
    ListFlowsPayload emptyPayload = new ListFlowsPayload();
    mockMvc.perform(asyncDispatch(result)).andExpect(status().isOk()).andExpect(content().json(objectWriter.writeValueAsString(emptyPayload)));
}
Also used : ListFlowsPayload(org.openkilda.server42.control.stormstub.api.ListFlowsPayload) MvcResult(org.springframework.test.web.servlet.MvcResult) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 3 with ClearFlows

use of org.openkilda.server42.control.messaging.flowrtt.ClearFlows in project open-kilda by telstra.

the class FlowHandler method notifyDeactivateFlowMonitoring.

private void notifyDeactivateFlowMonitoring(SwitchId switchId) {
    ClearFlows clearFlows = ClearFlows.builder().headers(buildHeader()).build();
    emit(STREAM_CONTROL_COMMANDS_ID, getCurrentTuple(), new Values(switchId.toString(), clearFlows));
}
Also used : ClearFlows(org.openkilda.server42.control.messaging.flowrtt.ClearFlows) Values(org.apache.storm.tuple.Values)

Example 4 with ClearFlows

use of org.openkilda.server42.control.messaging.flowrtt.ClearFlows in project open-kilda by telstra.

the class GateTest method clearFlowsTest.

@Test
public void clearFlowsTest() throws Exception {
    Headers headers = Headers.builder().correlationId("some-correlation-id").build();
    ClearFlows clearFlows = ClearFlows.builder().headers(headers).build();
    String dpId = "00:00:1b:45:18:d6:71:5a";
    gate.listen(clearFlows, dpId);
    CommandPacket commandPacket = getCommandPacket();
    assertThat(commandPacket.getType()).isEqualTo(Type.CLEAR_FLOWS);
    assertThat(commandPacket.getCommandList()).hasSize(1);
    Any command = commandPacket.getCommand(0);
    assertThat(command.is(FlowRttControl.ClearFlowsFilter.class)).isTrue();
    FlowRttControl.ClearFlowsFilter unpack = command.unpack(FlowRttControl.ClearFlowsFilter.class);
    String dstMac = "1b:45:18:d6:71:5a";
    assertThat(unpack.getDstMac()).isEqualTo(dstMac);
}
Also used : Headers(org.openkilda.server42.control.messaging.flowrtt.Headers) ClearFlows(org.openkilda.server42.control.messaging.flowrtt.ClearFlows) FlowRttControl(org.openkilda.server42.control.messaging.flowrtt.FlowRttControl) CommandPacket(org.openkilda.server42.control.messaging.Control.CommandPacket) Any(com.google.protobuf.Any) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

ClearFlows (org.openkilda.server42.control.messaging.flowrtt.ClearFlows)2 FlowRttControl (org.openkilda.server42.control.messaging.flowrtt.FlowRttControl)2 Any (com.google.protobuf.Any)1 InvalidProtocolBufferException (com.google.protobuf.InvalidProtocolBufferException)1 Values (org.apache.storm.tuple.Values)1 Test (org.junit.Test)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1 SwitchId (org.openkilda.model.SwitchId)1 CommandPacket (org.openkilda.server42.control.messaging.Control.CommandPacket)1 Builder (org.openkilda.server42.control.messaging.Control.CommandPacket.Builder)1 Headers (org.openkilda.server42.control.messaging.flowrtt.Headers)1 ListFlowsPayload (org.openkilda.server42.control.stormstub.api.ListFlowsPayload)1 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)1 KafkaHandler (org.springframework.kafka.annotation.KafkaHandler)1 MvcResult (org.springframework.test.web.servlet.MvcResult)1