Search in sources :

Example 6 with ErrorMessage

use of org.openkilda.messaging.error.ErrorMessage in project open-kilda by telstra.

the class FlowTopologyTest method deleteUnknownFlowCommandBoltTest.

@Test
public void deleteUnknownFlowCommandBoltTest() throws Exception {
    String flowId = UUID.randomUUID().toString();
    ConsumerRecord<String, String> record;
    deleteFlow(flowId);
    record = nbConsumer.pollMessage();
    assertNotNull(record);
    assertNotNull(record.value());
    ErrorMessage errorMessage = objectMapper.readValue(record.value(), ErrorMessage.class);
    assertNotNull(errorMessage);
    ErrorData errorData = errorMessage.getData();
    assertEquals(ErrorType.NOT_FOUND, errorData.getErrorType());
}
Also used : ErrorMessage(org.openkilda.messaging.error.ErrorMessage) ErrorData(org.openkilda.messaging.error.ErrorData) AbstractStormTest(org.openkilda.wfm.AbstractStormTest) Test(org.junit.Test)

Example 7 with ErrorMessage

use of org.openkilda.messaging.error.ErrorMessage in project open-kilda by telstra.

the class FlowTopologyTest method errorFlowDeleteMessageStatusBoltTopologyEngineBoltTest.

@Test
public void errorFlowDeleteMessageStatusBoltTopologyEngineBoltTest() throws Exception {
    String flowId = UUID.randomUUID().toString();
    ConsumerRecord<String, String> record;
    createFlow(flowId);
    record = cacheConsumer.pollMessage();
    assertNotNull(record);
    assertNotNull(record.value());
    record = nbConsumer.pollMessage();
    assertNotNull(record);
    assertNotNull(record.value());
    deleteFlow(flowId);
    record = cacheConsumer.pollMessage();
    assertNotNull(record);
    InfoMessage message = objectMapper.readValue(record.value(), InfoMessage.class);
    assertNotNull(message);
    ImmutablePair<Flow, Flow> flow = getFlowPayload(message);
    assertNotNull(flow);
    record = nbConsumer.pollMessage();
    assertNotNull(record);
    assertNotNull(record.value());
    statusFlow(flowId);
    record = nbConsumer.pollMessage();
    assertNotNull(record);
    assertNotNull(record.value());
    ErrorMessage errorMessage = objectMapper.readValue(record.value(), ErrorMessage.class);
    assertNotNull(errorMessage);
    ErrorData errorData = errorMessage.getData();
    assertEquals(ErrorType.NOT_FOUND, errorData.getErrorType());
    errorFlowTopologyEngineCommand(flowId, ErrorType.DELETION_FAILURE);
    record = nbConsumer.pollMessage();
    assertNotNull(record);
    assertNotNull(record.value());
    errorMessage = objectMapper.readValue(record.value(), ErrorMessage.class);
    assertNotNull(errorMessage);
    errorData = errorMessage.getData();
    assertEquals(ErrorType.DELETION_FAILURE, errorData.getErrorType());
    statusFlow(flowId);
    record = nbConsumer.pollMessage();
    assertNotNull(record);
    assertNotNull(record.value());
    errorMessage = objectMapper.readValue(record.value(), ErrorMessage.class);
    assertNotNull(errorMessage);
    errorData = errorMessage.getData();
    assertEquals(ErrorType.NOT_FOUND, errorData.getErrorType());
}
Also used : InfoMessage(org.openkilda.messaging.info.InfoMessage) ErrorMessage(org.openkilda.messaging.error.ErrorMessage) ErrorData(org.openkilda.messaging.error.ErrorData) RemoveFlow(org.openkilda.messaging.command.flow.RemoveFlow) Flow(org.openkilda.messaging.model.Flow) InstallOneSwitchFlow(org.openkilda.messaging.command.flow.InstallOneSwitchFlow) AbstractStormTest(org.openkilda.wfm.AbstractStormTest) Test(org.junit.Test)

Example 8 with ErrorMessage

use of org.openkilda.messaging.error.ErrorMessage in project open-kilda by telstra.

the class FlowTopologyTest method createAlreadyExistsFlowCommandBoltTest.

@Test
public void createAlreadyExistsFlowCommandBoltTest() throws Exception {
    String flowId = UUID.randomUUID().toString();
    ConsumerRecord<String, String> record;
    createFlow(flowId);
    record = cacheConsumer.pollMessage();
    assertNotNull(record);
    assertNotNull(record.value());
    record = nbConsumer.pollMessage();
    assertNotNull(record);
    assertNotNull(record.value());
    createFlow(flowId);
    record = nbConsumer.pollMessage();
    assertNotNull(record);
    assertNotNull(record.value());
    ErrorMessage errorMessage = objectMapper.readValue(record.value(), ErrorMessage.class);
    assertNotNull(errorMessage);
    ErrorData errorData = errorMessage.getData();
    assertEquals(ErrorType.ALREADY_EXISTS, errorData.getErrorType());
}
Also used : ErrorMessage(org.openkilda.messaging.error.ErrorMessage) ErrorData(org.openkilda.messaging.error.ErrorData) AbstractStormTest(org.openkilda.wfm.AbstractStormTest) Test(org.junit.Test)

Example 9 with ErrorMessage

use of org.openkilda.messaging.error.ErrorMessage in project open-kilda by telstra.

the class FlowTopologyTest method errorFlowUpdateMessageStatusBoltTopologyEngineBoltTest.

@Test
public void errorFlowUpdateMessageStatusBoltTopologyEngineBoltTest() throws Exception {
    String flowId = UUID.randomUUID().toString();
    ConsumerRecord<String, String> record;
    createFlow(flowId);
    record = cacheConsumer.pollMessage();
    assertNotNull(record);
    assertNotNull(record.value());
    record = nbConsumer.pollMessage();
    assertNotNull(record);
    assertNotNull(record.value());
    updateFlow(flowId);
    record = cacheConsumer.pollMessage();
    assertNotNull(record);
    InfoMessage message = objectMapper.readValue(record.value(), InfoMessage.class);
    assertNotNull(message);
    ImmutablePair<Flow, Flow> flow = getFlowPayload(message);
    assertNotNull(flow);
    record = nbConsumer.pollMessage();
    assertNotNull(record);
    assertNotNull(record.value());
    statusFlow(flowId);
    record = nbConsumer.pollMessage();
    assertNotNull(record);
    assertNotNull(record.value());
    InfoMessage infoMessageUp = objectMapper.readValue(record.value(), InfoMessage.class);
    assertNotNull(infoMessageUp);
    FlowStatusResponse infoDataUp = (FlowStatusResponse) infoMessageUp.getData();
    assertNotNull(infoDataUp);
    FlowIdStatusPayload flowNbPayloadUp = infoDataUp.getPayload();
    assertNotNull(flowNbPayloadUp);
    assertEquals(flowId, flowNbPayloadUp.getId());
    assertEquals(FlowState.ALLOCATED, flowNbPayloadUp.getStatus());
    errorFlowTopologyEngineCommand(flowId, ErrorType.UPDATE_FAILURE);
    record = nbConsumer.pollMessage();
    assertNotNull(record);
    assertNotNull(record.value());
    ErrorMessage errorMessage = objectMapper.readValue(record.value(), ErrorMessage.class);
    assertNotNull(errorMessage);
    ErrorData errorData = errorMessage.getData();
    assertEquals(ErrorType.UPDATE_FAILURE, errorData.getErrorType());
    statusFlow(flowId);
    record = nbConsumer.pollMessage();
    assertNotNull(record);
    assertNotNull(record.value());
    InfoMessage infoMessage = objectMapper.readValue(record.value(), InfoMessage.class);
    assertNotNull(infoMessage);
    FlowStatusResponse response = (FlowStatusResponse) infoMessage.getData();
    assertNotNull(response);
    FlowIdStatusPayload flowNbPayload = response.getPayload();
    assertNotNull(flowNbPayload);
    assertEquals(flowId, flowNbPayload.getId());
    assertEquals(FlowState.DOWN, flowNbPayload.getStatus());
}
Also used : FlowStatusResponse(org.openkilda.messaging.info.flow.FlowStatusResponse) FlowIdStatusPayload(org.openkilda.messaging.payload.flow.FlowIdStatusPayload) InfoMessage(org.openkilda.messaging.info.InfoMessage) ErrorMessage(org.openkilda.messaging.error.ErrorMessage) ErrorData(org.openkilda.messaging.error.ErrorData) RemoveFlow(org.openkilda.messaging.command.flow.RemoveFlow) Flow(org.openkilda.messaging.model.Flow) InstallOneSwitchFlow(org.openkilda.messaging.command.flow.InstallOneSwitchFlow) AbstractStormTest(org.openkilda.wfm.AbstractStormTest) Test(org.junit.Test)

Example 10 with ErrorMessage

use of org.openkilda.messaging.error.ErrorMessage in project open-kilda by telstra.

the class RecordHandler method doControllerMsg.

protected void doControllerMsg(CommandMessage message) {
    // Define the destination topic where the reply will be sent to.
    final String replyToTopic;
    if (message instanceof CommandWithReplyToMessage) {
        replyToTopic = ((CommandWithReplyToMessage) message).getReplyTo();
    } else {
        replyToTopic = OUTPUT_FLOW_TOPIC;
    }
    final Destination replyDestination = getDestinationForTopic(replyToTopic);
    try {
        CommandData data = message.getData();
        handleCommand(message, data, replyToTopic, replyDestination);
    } catch (FlowCommandException e) {
        ErrorMessage error = new ErrorMessage(e.makeErrorResponse(), System.currentTimeMillis(), message.getCorrelationId(), replyDestination);
        context.getKafkaProducer().postMessage(replyToTopic, error);
    } catch (Exception e) {
        logger.error("Unhandled exception: {}", e);
    }
}
Also used : Destination(org.openkilda.messaging.Destination) CommandWithReplyToMessage(org.openkilda.messaging.command.CommandWithReplyToMessage) DiscoverIslCommandData(org.openkilda.messaging.command.discovery.DiscoverIslCommandData) CommandData(org.openkilda.messaging.command.CommandData) DiscoverPathCommandData(org.openkilda.messaging.command.discovery.DiscoverPathCommandData) NetworkCommandData(org.openkilda.messaging.command.discovery.NetworkCommandData) ErrorMessage(org.openkilda.messaging.error.ErrorMessage) SwitchOperationException(org.openkilda.floodlight.switchmanager.SwitchOperationException)

Aggregations

ErrorMessage (org.openkilda.messaging.error.ErrorMessage)23 ErrorData (org.openkilda.messaging.error.ErrorData)18 Test (org.junit.Test)11 InfoMessage (org.openkilda.messaging.info.InfoMessage)10 AbstractStormTest (org.openkilda.wfm.AbstractStormTest)10 Values (org.apache.storm.tuple.Values)4 Message (org.openkilda.messaging.Message)4 CommandMessage (org.openkilda.messaging.command.CommandMessage)4 RemoveFlow (org.openkilda.messaging.command.flow.RemoveFlow)4 IOException (java.io.IOException)3 SwitchOperationException (org.openkilda.floodlight.switchmanager.SwitchOperationException)3 CommandData (org.openkilda.messaging.command.CommandData)3 ISwitchManager (org.openkilda.floodlight.switchmanager.ISwitchManager)2 BaseInstallFlow (org.openkilda.messaging.command.flow.BaseInstallFlow)2 InstallOneSwitchFlow (org.openkilda.messaging.command.flow.InstallOneSwitchFlow)2 MessageException (org.openkilda.messaging.error.MessageException)2 InfoData (org.openkilda.messaging.info.InfoData)2 FlowStatusResponse (org.openkilda.messaging.info.flow.FlowStatusResponse)2 SwitchRulesResponse (org.openkilda.messaging.info.switches.SwitchRulesResponse)2 Flow (org.openkilda.messaging.model.Flow)2