Package org.apache.hadoop.fs

Examples of org.apache.hadoop.fs.FSDataInputStream.readFully()


    FSDataOutputStream out;
    int fileSize = (int) fs.listStatus(path)[0].getLen();

    FSDataInputStream in = fs.open(path);
    byte[] corrupted_bytes = new byte[fileSize];
    in.readFully(0, corrupted_bytes, 0, fileSize);
    in.close();

    switch (corruption) {
      case APPEND_GARBAGE:
        fs.delete(path, false);
View Full Code Here


      assertFalse(getClientContext.getDisableLegacyBlockReaderLocal());
    }
   
    FSDataInputStream stm = fs.open(name);
    byte[] actual = new byte[expected.length-readOffset];
    stm.readFully(readOffset, actual);
    checkData(actual, readOffset, expected, "Read 2");
    stm.close();
    // Now read using a different API.
    actual = new byte[expected.length-readOffset];
    stm = fs.open(name);
View Full Code Here

      fs = cluster.getFileSystem();
      fsIn = fs.open(TEST_PATH);
      try {
        byte buf[] = new byte[100];
        fsIn.seek(2000);
        fsIn.readFully(buf, 0, buf.length);
        Assert.fail("shouldn't be able to read from corrupt 0-length " +
            "block file.");
      } catch (IOException e) {
        DFSClient.LOG.error("caught exception ", e);
      }
View Full Code Here

      // This is important because it indicates that we detected that the
      // previous block was corrupt, rather than blaming the problem on
      // communication.
      fsIn = fs.open(TEST_PATH2);
      byte buf[] = new byte[original.length];
      fsIn.readFully(buf, 0, buf.length);
      TestBlockReaderLocal.assertArrayRegionsEqual(original, 0, buf, 0,
          original.length);
      fsIn.close();
      fsIn = null;
    } finally {
View Full Code Here

                                  Path path,
                                  int length) throws IOException {
    FSDataInputStream in = fs.open(path);
    try {
      byte[] buf = new byte[length];
      in.readFully(0, buf);
      return toChar(buf);
    } finally {
      in.close();
    }
  }
View Full Code Here

        byte[] buf = new byte[1024];
        out.write(buf);
        out.close();
       
        FSDataInputStream in = fs.open(path);
        in.readFully(buf);
        in.close();
        fs.close();
      }
    }
    finally {
View Full Code Here

      stats.assertNotDroppedInRange(0, TEST_PATH_LEN);

      // read file
      fis = fs.open(new Path(TEST_PATH));
      byte buf[] = new byte[17];
      fis.readFully(4096, buf, 0, buf.length);

      // we should not have dropped anything because of the small read.
      stats = tracker.getStats(fadvisedFileName);
      stats.assertNotDroppedInRange(0, TEST_PATH_LEN - WRITE_PACKET_SIZE);
    } finally {
View Full Code Here

    if (status != null) {
      int len = Ints.checkedCast(status.getLen());
      byte [] content = new byte[len];
      FSDataInputStream in = fs.open(idPath);
      try {
        in.readFully(content);
      } catch (EOFException eof) {
        LOG.warn("Cluster ID file " + idPath.toString() + " was empty");
      } finally{
        in.close();
      }
View Full Code Here

                                                      FileStatus status) throws IOException {
    int len = Ints.checkedCast(status.getLen());
    byte [] content = new byte[len];
    FSDataInputStream fsDataInputStream = fs.open(status.getPath());
    try {
      fsDataInputStream.readFully(content);
    } finally {
      fsDataInputStream.close();
    }
    HTableDescriptor htd = null;
    try {
View Full Code Here

    byte[] expected = new byte[fileSize];
    Random rand = new Random(seed);
    rand.nextBytes(expected);
    // do a sanity check. Read the file
    byte[] actual = new byte[fileSize];
    stm.readFully(0, actual);
    checkAndEraseData(actual, 0, expected, "Read Sanity Test");
    stm.close();
  }
 
  private void cleanupFile(FileSystem fileSys, Path name) throws IOException {
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.