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;
}
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);
}
}
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());
}
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());
}
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;
}
Aggregations