use of org.apache.metron.common.error.MetronError in project metron by apache.
the class BulkWriterComponentTest method writeShouldProperlyHandleWriterErrors.
@Test
public void writeShouldProperlyHandleWriterErrors() throws Exception {
Throwable e = new Exception("test exception");
MetronError error = new MetronError().withSensorType(sensorType).withErrorType(Constants.ErrorType.INDEXING_ERROR).withThrowable(e).withRawMessages(Arrays.asList(message1, message2));
BulkWriterResponse response = new BulkWriterResponse();
response.addAllErrors(e, tupleList);
when(bulkMessageWriter.write(sensorType, configurations, Arrays.asList(tuple1, tuple2), Arrays.asList(message1, message2))).thenReturn(response);
BulkWriterComponent<JSONObject> bulkWriterComponent = new BulkWriterComponent<>(collector);
bulkWriterComponent.write(sensorType, tuple1, message1, bulkMessageWriter, configurations, messageGetStrategy);
bulkWriterComponent.write(sensorType, tuple2, message2, bulkMessageWriter, configurations, messageGetStrategy);
verifyStatic(times(1));
ErrorUtils.handleError(collector, error);
}
use of org.apache.metron.common.error.MetronError in project metron by apache.
the class ParserBolt method handleError.
protected void handleError(byte[] originalMessage, Tuple tuple, Throwable ex, OutputCollector collector) {
MetronError error = new MetronError().withErrorType(Constants.ErrorType.PARSER_ERROR).withThrowable(ex).withSensorType(getSensorType()).addRawMessage(originalMessage);
ErrorUtils.handleError(collector, error);
collector.ack(tuple);
}
Aggregations