Search in sources :

Example 1 with RecoverFilesRecoveryException

use of org.elasticsearch.indices.recovery.RecoverFilesRecoveryException in project elasticsearch by elastic.

the class ExceptionSerializationTests method testRecoverFilesRecoveryException.

public void testRecoverFilesRecoveryException() throws IOException {
    ShardId id = new ShardId("foo", "_na_", 1);
    ByteSizeValue bytes = new ByteSizeValue(randomIntBetween(0, 10000));
    RecoverFilesRecoveryException ex = serialize(new RecoverFilesRecoveryException(id, 10, bytes, null));
    assertEquals(ex.getShardId(), id);
    assertEquals(ex.numberOfFiles(), 10);
    assertEquals(ex.totalFilesSize(), bytes);
    assertEquals(ex.getMessage(), "Failed to transfer [10] files with total size of [" + bytes + "]");
    assertNull(ex.getCause());
    ex = serialize(new RecoverFilesRecoveryException(null, 10, bytes, new NullPointerException()));
    assertNull(ex.getShardId());
    assertEquals(ex.numberOfFiles(), 10);
    assertEquals(ex.totalFilesSize(), bytes);
    assertEquals(ex.getMessage(), "Failed to transfer [10] files with total size of [" + bytes + "]");
    assertTrue(ex.getCause() instanceof NullPointerException);
}
Also used : ShardId(org.elasticsearch.index.shard.ShardId) RecoverFilesRecoveryException(org.elasticsearch.indices.recovery.RecoverFilesRecoveryException) ByteSizeValue(org.elasticsearch.common.unit.ByteSizeValue)

Aggregations

ByteSizeValue (org.elasticsearch.common.unit.ByteSizeValue)1 ShardId (org.elasticsearch.index.shard.ShardId)1 RecoverFilesRecoveryException (org.elasticsearch.indices.recovery.RecoverFilesRecoveryException)1