Search in sources :

Example 16 with CommandMessage

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

the class FlowTopologyTest method removeFlowTopologyEngineSpeakerBoltTest.

@Test
public void removeFlowTopologyEngineSpeakerBoltTest() throws Exception {
    String flowId = UUID.randomUUID().toString();
    ConsumerRecord<String, String> ofsRecord;
    ConsumerRecord<String, String> record;
    createFlow(flowId);
    record = cacheConsumer.pollMessage();
    assertNotNull(record);
    assertNotNull(record.value());
    record = nbConsumer.pollMessage();
    assertNotNull(record);
    assertNotNull(record.value());
    statusFlow(flowId);
    record = nbConsumer.pollMessage();
    assertNotNull(record);
    assertNotNull(record.value());
    InfoMessage infoMessage = objectMapper.readValue(record.value(), InfoMessage.class);
    assertNotNull(infoMessage);
    FlowStatusResponse infoData = (FlowStatusResponse) infoMessage.getData();
    assertNotNull(infoData);
    FlowIdStatusPayload flowNbPayload = infoData.getPayload();
    assertNotNull(flowNbPayload);
    assertEquals(flowId, flowNbPayload.getId());
    assertEquals(FlowState.ALLOCATED, flowNbPayload.getStatus());
    RemoveFlow data = removeFlowCommand(flowId);
    ofsRecord = ofsConsumer.pollMessage();
    assertNotNull(ofsRecord);
    assertNotNull(ofsRecord.value());
    CommandMessage response = objectMapper.readValue(ofsRecord.value(), CommandMessage.class);
    assertNotNull(response);
    RemoveFlow responseData = (RemoveFlow) response.getData();
    Long transactionId = responseData.getTransactionId();
    responseData.setTransactionId(0L);
    assertEquals(data, responseData);
    responseData.setTransactionId(transactionId);
    statusFlow(flowId);
    record = nbConsumer.pollMessage();
    assertNotNull(record);
    assertNotNull(record.value());
    infoMessage = objectMapper.readValue(record.value(), InfoMessage.class);
    assertNotNull(infoMessage);
    infoData = (FlowStatusResponse) infoMessage.getData();
    assertNotNull(infoData);
    flowNbPayload = infoData.getPayload();
    assertNotNull(flowNbPayload);
    assertEquals(flowId, flowNbPayload.getId());
    assertEquals(FlowState.IN_PROGRESS, flowNbPayload.getStatus());
    response.setDestination(Destination.WFM_TRANSACTION);
    removeRuleCommand(response);
    statusFlow(flowId);
    record = nbConsumer.pollMessage();
    assertNotNull(record);
    assertNotNull(record.value());
    infoMessage = objectMapper.readValue(record.value(), InfoMessage.class);
    assertNotNull(infoMessage);
    infoData = (FlowStatusResponse) infoMessage.getData();
    assertNotNull(infoData);
    flowNbPayload = infoData.getPayload();
    assertNotNull(flowNbPayload);
    assertEquals(flowId, flowNbPayload.getId());
    assertEquals(FlowState.UP, flowNbPayload.getStatus());
}
Also used : FlowStatusResponse(org.openkilda.messaging.info.flow.FlowStatusResponse) RemoveFlow(org.openkilda.messaging.command.flow.RemoveFlow) FlowIdStatusPayload(org.openkilda.messaging.payload.flow.FlowIdStatusPayload) InfoMessage(org.openkilda.messaging.info.InfoMessage) CommandMessage(org.openkilda.messaging.command.CommandMessage) AbstractStormTest(org.openkilda.wfm.AbstractStormTest) Test(org.junit.Test)

Example 17 with CommandMessage

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

the class FlowTopologyTest method deleteFlow.

private Flow deleteFlow(final String flowId) throws IOException {
    System.out.println("NORTHBOUND: Delete flow");
    Flow payload = new Flow();
    payload.setFlowId(flowId);
    FlowDeleteRequest commandData = new FlowDeleteRequest(payload);
    CommandMessage message = new CommandMessage(commandData, 0, "delete-flow", Destination.WFM);
    // sendNorthboundMessage(message);
    // sendTopologyEngineMessage(message);
    sendFlowMessage(message);
    return payload;
}
Also used : FlowDeleteRequest(org.openkilda.messaging.command.flow.FlowDeleteRequest) RemoveFlow(org.openkilda.messaging.command.flow.RemoveFlow) Flow(org.openkilda.messaging.model.Flow) InstallOneSwitchFlow(org.openkilda.messaging.command.flow.InstallOneSwitchFlow) CommandMessage(org.openkilda.messaging.command.CommandMessage)

Example 18 with CommandMessage

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

the class FlowTopologyTest method pathFlow.

private PathInfoData pathFlow(final String flowId) throws IOException {
    System.out.println("NORTHBOUND: Path flow");
    FlowIdStatusPayload payload = new FlowIdStatusPayload(flowId);
    FlowPathRequest commandData = new FlowPathRequest(payload);
    CommandMessage message = new CommandMessage(commandData, 0, "path-flow", Destination.WFM);
    // sendNorthboundMessage(message);
    sendFlowMessage(message);
    return new PathInfoData(0L, Collections.emptyList());
}
Also used : PathInfoData(org.openkilda.messaging.info.event.PathInfoData) FlowIdStatusPayload(org.openkilda.messaging.payload.flow.FlowIdStatusPayload) FlowPathRequest(org.openkilda.messaging.command.flow.FlowPathRequest) CommandMessage(org.openkilda.messaging.command.CommandMessage)

Example 19 with CommandMessage

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

the class FlowTopologyTest method dumpFlows.

private FlowIdStatusPayload dumpFlows(final String flowId) throws IOException {
    System.out.println("NORTHBOUND: Get flows");
    FlowIdStatusPayload payload = new FlowIdStatusPayload(flowId);
    FlowsGetRequest commandData = new FlowsGetRequest(payload);
    CommandMessage message = new CommandMessage(commandData, 0, "get-flows", Destination.WFM);
    // sendNorthboundMessage(message);
    sendFlowMessage(message);
    return payload;
}
Also used : FlowsGetRequest(org.openkilda.messaging.command.flow.FlowsGetRequest) FlowIdStatusPayload(org.openkilda.messaging.payload.flow.FlowIdStatusPayload) CommandMessage(org.openkilda.messaging.command.CommandMessage)

Example 20 with CommandMessage

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

the class RecordHandler method parseRecord.

private void parseRecord(ConsumerRecord<String, String> record) {
    try {
        String value = (String) record.value();
        // TODO: Prior to Message changes, this MAPPER would read Message ..
        // but, changed to BaseMessage and got an error wrt "timestamp" ..
        // so, need to experiment with why CommandMessage can't be read as
        // a BaseMessage
        CommandMessage message = MAPPER.readValue(value, CommandMessage.class);
        doControllerMsg(message);
    } catch (Exception exception) {
        logger.error("error parsing record={}", record.value(), exception);
    }
}
Also used : SwitchOperationException(org.openkilda.floodlight.switchmanager.SwitchOperationException) 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