use of org.graylog2.indexer.IndexFailureImpl in project graylog2-server by Graylog2.
the class Messages method propagateFailure.
private void propagateFailure(BulkItemResponse[] items, List<Map.Entry<IndexSet, Message>> messageList, String errorMessage) {
final List<IndexFailure> indexFailures = new LinkedList<>();
for (BulkItemResponse item : items) {
if (item.isFailed()) {
LOG.trace("Failed to index message: {}", item.getFailureMessage());
// Write failure to index_failures.
final BulkItemResponse.Failure f = item.getFailure();
final Map.Entry<IndexSet, Message> messageEntry = messageList.get(item.getItemId());
final Map<String, Object> doc = ImmutableMap.<String, Object>builder().put("letter_id", item.getId()).put("index", f.getIndex()).put("type", f.getType()).put("message", f.getMessage()).put("timestamp", messageEntry.getValue().getTimestamp()).build();
indexFailures.add(new IndexFailureImpl(doc));
}
}
LOG.error("Failed to index [{}] messages. Please check the index error log in your web interface for the reason. Error: {}", indexFailures.size(), errorMessage);
try {
// TODO: Magic number
indexFailureQueue.offer(indexFailures, 25, TimeUnit.MILLISECONDS);
} catch (InterruptedException e) {
LOG.warn("Couldn't save index failures.", e);
}
}
Aggregations