Package org.apache.hadoop.hdfs

Examples of org.apache.hadoop.hdfs.RemoteBlockReader


  /**
   * Verify that if we read an entire block, we send CHECKSUM_OK
   */
  @Test
  public void testBlockVerification() throws Exception {
    RemoteBlockReader reader = (RemoteBlockReader)spy(
        util.getBlockReader(testBlock, 0, FILE_SIZE_K * 1024));
    util.readAndCheckEOS(reader, FILE_SIZE_K * 1024, true);
    verify(reader).sendReadResult(reader.dnSock, Status.CHECKSUM_OK);
    reader.close();
  }
View Full Code Here


  /**
   * Test that if we do an incomplete read, we don't call CHECKSUM_OK
   */
  @Test
  public void testIncompleteRead() throws Exception {
    RemoteBlockReader reader = (RemoteBlockReader)spy(
        util.getBlockReader(testBlock, 0, FILE_SIZE_K * 1024));
    util.readAndCheckEOS(reader, FILE_SIZE_K / 2 * 1024, false);

    // We asked the blockreader for the whole file, and only read
    // half of it, so no CHECKSUM_OK
    verify(reader, never()).sendReadResult(reader.dnSock, Status.CHECKSUM_OK);
    reader.close();
  }
View Full Code Here

   * the whole block or not.
   */
  @Test
  public void testCompletePartialRead() throws Exception {
    // Ask for half the file
    RemoteBlockReader reader = (RemoteBlockReader)spy(
        util.getBlockReader(testBlock, 0, FILE_SIZE_K * 1024 / 2));
    // And read half the file
    util.readAndCheckEOS(reader, FILE_SIZE_K * 1024 / 2, true);
    verify(reader).sendReadResult(reader.dnSock, Status.CHECKSUM_OK);
    reader.close();
  }
View Full Code Here

    int lengths[] = new int[] { 30, 300, 512, 513, 1025 };
    for (int startOffset : startOffsets) {
      for (int length : lengths) {
        DFSClient.LOG.info("Testing startOffset = " + startOffset + " and " +
                           " len=" + length);
        RemoteBlockReader reader = (RemoteBlockReader)spy(
            util.getBlockReader(testBlock, startOffset, length));
        util.readAndCheckEOS(reader, length, true);
        verify(reader).sendReadResult(reader.dnSock, Status.CHECKSUM_OK);
        reader.close();
      }
    }
  }
View Full Code Here

  private class MockGetBlockReader implements Answer<RemoteBlockReader> {
    public RemoteBlockReader reader = null;
    private Socket sock = null;

    public RemoteBlockReader answer(InvocationOnMock invocation) throws Throwable {
      RemoteBlockReader prevReader = reader;
      reader = (RemoteBlockReader) invocation.callRealMethod();
      if (sock == null) {
        sock = reader.dnSock;
      } else if (prevReader != null && prevReader.hasSentStatusCode()) {
        // Can't reuse socket if the previous BlockReader didn't read till EOS.
        assertSame("DFSInputStream should use the same socket",
                   sock, reader.dnSock);
      } return reader;
    }
View Full Code Here

TOP

Related Classes of org.apache.hadoop.hdfs.RemoteBlockReader

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.