Search in sources :

Example 1 with EofException

use of org.mortbay.jetty.EofException in project voldemort by voldemort.

the class HdfsFetcherAdvancedTest method testEofExceptionIntermittentDuringFetch.

/*
     * Tests that HdfsFetcher can correctly fetch a file when there is an
     * IOException, specifically an EofException during the fetch this test case
     * is different from the earlier one since it simulates an excpetion midway
     * a fetch
     */
@Test
public void testEofExceptionIntermittentDuringFetch() throws Exception {
    setUp();
    input = fs.open(source);
    FileSystem spyfs = Mockito.spy(fs);
    FSDataInputStream spyinput = Mockito.spy(input);
    Mockito.doAnswer(Mockito.CALLS_REAL_METHODS).doThrow(new EofException()).when(spyinput).read();
    Mockito.doReturn(spyinput).doReturn(input).when(spyfs).open(source);
    byte[] actualCheckSum = null;
    try {
        actualCheckSum = copyFileWithCheckSumTest(fetcher, spyfs, source, copyLocation, stats, CheckSumType.MD5, buffer);
    } catch (Exception ex) {
        if (isCompressed) {
            // This is expected
            return;
        } else {
            Assert.fail("Unexpected exption thrown : " + ex.getMessage());
        }
    }
    assertEquals(Arrays.equals(actualCheckSum, checksumCalculated), true);
}
Also used : EofException(org.mortbay.jetty.EofException) FileSystem(org.apache.hadoop.fs.FileSystem) FSDataInputStream(org.apache.hadoop.fs.FSDataInputStream) EofException(org.mortbay.jetty.EofException) UnauthorizedStoreException(voldemort.store.readonly.UnauthorizedStoreException) VoldemortException(voldemort.VoldemortException) IOException(java.io.IOException) QuotaExceededException(voldemort.store.quota.QuotaExceededException) Test(org.junit.Test)

Aggregations

IOException (java.io.IOException)1 FSDataInputStream (org.apache.hadoop.fs.FSDataInputStream)1 FileSystem (org.apache.hadoop.fs.FileSystem)1 Test (org.junit.Test)1 EofException (org.mortbay.jetty.EofException)1 VoldemortException (voldemort.VoldemortException)1 QuotaExceededException (voldemort.store.quota.QuotaExceededException)1 UnauthorizedStoreException (voldemort.store.readonly.UnauthorizedStoreException)1