Search in sources :

Example 16 with ErrorMessage

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

the class SwitchManager method receive.

/**
 * {@inheritDoc}
 */
@Override
public Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx) {
    logger.debug("OF_ERROR: {}", msg);
    // TODO: track xid for flow id
    if (OFType.ERROR.equals(msg.getType())) {
        ErrorMessage error = new ErrorMessage(new ErrorData(ErrorType.INTERNAL_ERROR, ((OFErrorMsg) msg).getErrType().toString(), null), System.currentTimeMillis(), DEFAULT_CORRELATION_ID, Destination.WFM_TRANSACTION);
        // TODO: Most/all commands are flow related, but not all. 'kilda.flow' might
        // not be the best place to send a generic error.
        kafkaProducer.postMessage("kilda.flow", error);
    }
    return Command.CONTINUE;
}
Also used : ErrorMessage(org.openkilda.messaging.error.ErrorMessage) ErrorData(org.openkilda.messaging.error.ErrorData)

Example 17 with ErrorMessage

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

the class ErrorBolt method execute.

/**
 * {@inheritDoc}
 */
@Override
public void execute(Tuple tuple) {
    ComponentType componentId = ComponentType.valueOf(tuple.getSourceComponent());
    StreamType streamId = StreamType.valueOf(tuple.getSourceStreamId());
    ErrorType errorType = (ErrorType) tuple.getValueByField(FlowTopology.ERROR_TYPE_FIELD);
    ErrorMessage error = (ErrorMessage) tuple.getValueByField(AbstractTopology.MESSAGE_FIELD);
    error.setDestination(Destination.NORTHBOUND);
    Values values = new Values(error);
    try {
        logger.debug("Request tuple={}", tuple);
        switch(componentId) {
            case CRUD_BOLT:
            case SPLITTER_BOLT:
                logger.debug("Error message: data={}", error.getData());
                outputCollector.emit(StreamType.RESPONSE.toString(), tuple, values);
                break;
            default:
                logger.debug("Skip message from unknown component: component={}, stream={}, error-type={}", componentId, streamId, errorType);
                break;
        }
    } catch (Exception exception) {
        logger.error("Could not process message: {}", tuple, exception);
    } finally {
        logger.debug("Error message ack: component={}, stream={}, tuple={}, values={}", tuple.getSourceComponent(), tuple.getSourceStreamId(), tuple, values);
        outputCollector.ack(tuple);
    }
}
Also used : StreamType(org.openkilda.wfm.topology.flow.StreamType) ComponentType(org.openkilda.wfm.topology.flow.ComponentType) ErrorType(org.openkilda.messaging.error.ErrorType) Values(org.apache.storm.tuple.Values) ErrorMessage(org.openkilda.messaging.error.ErrorMessage)

Example 18 with ErrorMessage

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

the class FlowTopologyTest method shouldFailOnCreatingConflictingFlow.

@Test
public void shouldFailOnCreatingConflictingFlow() 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 + "_alt");
    record = nbConsumer.pollMessage();
    assertNotNull(record);
    assertNotNull(record.value());
    ErrorMessage errorMessage = objectMapper.readValue(record.value(), ErrorMessage.class);
    assertNotNull(errorMessage);
    ErrorData errorData = errorMessage.getData();
    assertEquals(ErrorType.CREATION_FAILURE, 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 19 with ErrorMessage

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

the class FlowTopologyTest method errorFlowCreateMessageStatusBoltTopologyEngineBoltTest.

@Test
public void errorFlowCreateMessageStatusBoltTopologyEngineBoltTest() 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());
    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.CREATION_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.CREATION_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 : 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) AbstractStormTest(org.openkilda.wfm.AbstractStormTest) Test(org.junit.Test)

Example 20 with ErrorMessage

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

the class FlowTopologyTest method errorFlowTopologyEngineCommand.

private ErrorMessage errorFlowTopologyEngineCommand(final String flowId, final ErrorType type) throws IOException {
    System.out.println("TOPOLOGY: Error flow");
    ErrorData errorData = new ErrorData(type, "Could not operate with flow", flowId);
    ErrorMessage errorMessage = new ErrorMessage(errorData, 0, "error-flow", Destination.WFM);
    // sendTopologyEngineMessage(errorMessage);
    sendMessage(errorMessage, topologyConfig.getKafkaFlowTopic());
    return errorMessage;
}
Also used : ErrorMessage(org.openkilda.messaging.error.ErrorMessage) ErrorData(org.openkilda.messaging.error.ErrorData)

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