Search in sources :

Example 1 with ClearIsls

use of org.openkilda.server42.control.messaging.islrtt.ClearIsls in project open-kilda by telstra.

the class GateTest method testClearIsls.

@Test
public void testClearIsls() throws Exception {
    ClearIsls clearIsls = ClearIsls.builder().switchId(new SwitchId("00:00:1b:45:18:d6:71:5a")).build();
    gate.listen(clearIsls);
    CommandPacket commandPacket = getCommandPacket();
    assertThat(commandPacket.getType()).isEqualTo(Type.CLEAR_ISLS);
    assertThat(commandPacket.getCommandList()).hasSize(1);
    Any command = commandPacket.getCommand(0);
    assertThat(command.is(IslRttControl.ClearIslsFilter.class)).isTrue();
    IslRttControl.ClearIslsFilter unpack = command.unpack(IslRttControl.ClearIslsFilter.class);
    String switchId = clearIsls.getSwitchId().toString();
    assertThat(unpack.getSwitchId()).isEqualTo(switchId);
}
Also used : ClearIsls(org.openkilda.server42.control.messaging.islrtt.ClearIsls) SwitchId(org.openkilda.model.SwitchId) IslRttControl(org.openkilda.server42.control.messaging.islrtt.IslRttControl) CommandPacket(org.openkilda.server42.control.messaging.Control.CommandPacket) Any(com.google.protobuf.Any) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 2 with ClearIsls

use of org.openkilda.server42.control.messaging.islrtt.ClearIsls in project open-kilda by telstra.

the class StubApplicationTests method clearIsls.

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

Example 3 with ClearIsls

use of org.openkilda.server42.control.messaging.islrtt.ClearIsls 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);
    }
}
Also used : Builder(org.openkilda.server42.control.messaging.Control.CommandPacket.Builder) InvalidProtocolBufferException(com.google.protobuf.InvalidProtocolBufferException) IslRttControl(org.openkilda.server42.control.messaging.islrtt.IslRttControl) KafkaHandler(org.springframework.kafka.annotation.KafkaHandler)

Example 4 with ClearIsls

use of org.openkilda.server42.control.messaging.islrtt.ClearIsls in project open-kilda by telstra.

the class IslHandler method processDeactivateIslMonitoringOnSwitch.

/**
 * Deactivate monitoring for ISLs on provided switch.
 *
 * @param switchId specify the ISL endpoint.
 */
public void processDeactivateIslMonitoringOnSwitch(SwitchId switchId) {
    ClearIsls clearIsls = ClearIsls.builder().headers(buildHeader()).switchId(switchId).build();
    emit(STREAM_CONTROL_COMMANDS_ID, getCurrentTuple(), new Values(switchId.toString(), clearIsls));
}
Also used : ClearIsls(org.openkilda.server42.control.messaging.islrtt.ClearIsls) Values(org.apache.storm.tuple.Values)

Aggregations

ClearIsls (org.openkilda.server42.control.messaging.islrtt.ClearIsls)2 IslRttControl (org.openkilda.server42.control.messaging.islrtt.IslRttControl)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 ListIslsPayload (org.openkilda.server42.control.stormstub.api.ListIslsPayload)1 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)1 KafkaHandler (org.springframework.kafka.annotation.KafkaHandler)1 MvcResult (org.springframework.test.web.servlet.MvcResult)1