Java Code Examples for org.elasticsearch.ExceptionsHelper#unwrapCorruption()

The following examples show how to use org.elasticsearch.ExceptionsHelper#unwrapCorruption() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RecoverySourceHandler.java    From crate with Apache License 2.0 6 votes vote down vote up
private void handleErrorOnSendFiles(Store store, StoreFileMetaData md, Exception e) throws Exception {
    final IOException corruptIndexException;
    if ((corruptIndexException = ExceptionsHelper.unwrapCorruption(e)) != null) {
        if (store.checkIntegrityNoException(md) == false) { // we are corrupted on the primary -- fail!
            logger.warn("{} Corrupted file detected {} checksum mismatch", shardId, md);
            failEngine(corruptIndexException);
            throw corruptIndexException;
        } else { // corruption has happened on the way to replica
            RemoteTransportException exception = new RemoteTransportException(
                "File corruption occurred on recovery but checksums are ok", null);
            exception.addSuppressed(e);
            logger.warn(() -> new ParameterizedMessage(
                "{} Remote file corruption on node {}, recovering {}. local checksum OK",
                shardId, request.targetNode(), md), corruptIndexException);
            throw exception;
        }
    } else {
        throw e;
    }
}
 
Example 2
Source File: Lucene.java    From Elasticsearch with Apache License 2.0 2 votes vote down vote up
/**
 * Returns <tt>true</tt> iff the given exception or
 * one of it's causes is an instance of {@link CorruptIndexException}, 
 * {@link IndexFormatTooOldException}, or {@link IndexFormatTooNewException} otherwise <tt>false</tt>.
 */
public static boolean isCorruptionException(Throwable t) {
    return ExceptionsHelper.unwrapCorruption(t) != null;
}
 
Example 3
Source File: Lucene.java    From crate with Apache License 2.0 2 votes vote down vote up
/**
 * Returns {@code true} iff the given exception or
 * one of it's causes is an instance of {@link CorruptIndexException},
 * {@link IndexFormatTooOldException}, or {@link IndexFormatTooNewException} otherwise {@code false}.
 */
public static boolean isCorruptionException(Throwable t) {
    return ExceptionsHelper.unwrapCorruption(t) != null;
}