Search in sources :

Example 1 with IndexFailureImpl

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);
    }
}
Also used : IndexFailureImpl(org.graylog2.indexer.IndexFailureImpl) ResultMessage(org.graylog2.indexer.results.ResultMessage) Message(org.graylog2.plugin.Message) IndexFailure(org.graylog2.indexer.IndexFailure) BulkItemResponse(org.elasticsearch.action.bulk.BulkItemResponse) LinkedList(java.util.LinkedList) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap) IndexSet(org.graylog2.indexer.IndexSet)

Aggregations

ImmutableMap (com.google.common.collect.ImmutableMap)1 LinkedList (java.util.LinkedList)1 Map (java.util.Map)1 BulkItemResponse (org.elasticsearch.action.bulk.BulkItemResponse)1 IndexFailure (org.graylog2.indexer.IndexFailure)1 IndexFailureImpl (org.graylog2.indexer.IndexFailureImpl)1 IndexSet (org.graylog2.indexer.IndexSet)1 ResultMessage (org.graylog2.indexer.results.ResultMessage)1 Message (org.graylog2.plugin.Message)1