Package org.apache.hadoop.fs

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


          LOG.info("The lock file length has changed.");
          return false;
        }
        byte[] buf = new byte[_lockKey.length];
        FSDataInputStream inputStream = _fileSystem.open(lockPath);
        inputStream.readFully(buf);
        inputStream.close();
        if (Arrays.equals(_lockKey, buf)) {
          return true;
        }
        LOG.info("The lock information has been changed.");
View Full Code Here


        if (len != _lockKey.length) {
          return false;
        }
        byte[] buf = new byte[_lockKey.length];
        FSDataInputStream inputStream = _fileSystem.open(lockPath);
        inputStream.readFully(buf);
        inputStream.close();
        if (Arrays.equals(_lockKey, buf)) {
          return true;
        }
        return false;
View Full Code Here

    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:
        out = fs.append(path);
View Full Code Here

  private byte[] readFile(Path inputPath, long len) throws Exception {
    FSDataInputStream fsIn = fs.open(inputPath);
    // state data will not be that "long"
    byte[] data = new byte[(int)len];
    fsIn.readFully(data);
    fsIn.close();
    return data;
  }

  /*
 
View Full Code Here

    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

      final FSDataInputStream in = fs.open(p);
      in.seek(offset);
     
      //read all remaining data
      in.readFully(buf);
      in.close();
 
      for (int i = 0; i < buf.length; i++) {
        assertEquals("Position " + i + ", offset=" + offset + ", length=" + len,
            mydata[i + offset], buf[i]);
View Full Code Here

      final int offset = two_third;
      final int len = mydata.length - offset;
      final byte[] buf = new byte[len];

      final FSDataInputStream in = fs.open(p);
      in.readFully(offset, buf);
      in.close();
 
      for (int i = 0; i < buf.length; i++) {
        assertEquals("Position " + i + ", offset=" + offset + ", length=" + len,
            mydata[i + offset], buf[i]);
View Full Code Here

    final FSDataInputStream in = fs.open(p, 64 << 10);
    in.seek(offset);
    for(; remaining > 0; ) {
      t.tick(checked, "offset=%d, remaining=%d", offset, remaining);
      final int n = (int)Math.min(remaining, buf.length);
      in.readFully(buf, 0, n);
      checkData(offset, remaining, n, buf, expected);

      offset += n;
      remaining -= n;
      checked += n;
View Full Code Here

        offset, remaining);
    final FSDataInputStream in = fs.open(p, 64 << 10);
    for(; remaining > 0; ) {
      t.tick(checked, "offset=%d, remaining=%d", offset, remaining);
      final int n = (int)Math.min(remaining, buf.length);
      in.readFully(offset, buf, 0, n);
      checkData(offset, remaining, n, buf, expected);

      offset += n;
      remaining -= n;
      checked += n;
View Full Code Here

               dfs.getFileStatus(filepath).getLen() == size);

    // verify that there is enough data to read.
    System.out.println("File size is good. Now validating sizes from datanodes...");
    FSDataInputStream stmin = dfs.open(filepath);
    stmin.readFully(0, actual, 0, size);
    stmin.close();
  }

  /**
   * This test makes the client does not renew its lease and also
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.