Package org.apache.hadoop.hdfs

Examples of org.apache.hadoop.hdfs.DFSClient.open()


    {
      final int b = bufferSize.getValue(conf);
      final DFSClient dfsclient = new DFSClient(nnRpcAddr, conf);
      HdfsDataInputStream in = null;
      try {
        in = new HdfsDataInputStream(dfsclient.open(fullpath, b, true));
        in.seek(offset.getValue());
      } catch(IOException ioe) {
        IOUtils.cleanup(LOG, in);
        IOUtils.cleanup(LOG, dfsclient);
        throw ioe;
View Full Code Here


    {
      final int b = bufferSize.getValue(conf);
      final DFSClient dfsclient = newDfsClient(nnId, conf);
      HdfsDataInputStream in = null;
      try {
        in = new HdfsDataInputStream(dfsclient.open(fullpath, b, true));
        in.seek(offset.getValue());
      } catch(IOException ioe) {
        IOUtils.cleanup(LOG, in);
        IOUtils.cleanup(LOG, dfsclient);
        throw ioe;
View Full Code Here

      }
    } catch (InterruptedException e) {
      response.sendError(400, e.getMessage());
      return;
    }
    in = dfs.open(filename);
    long contentLength = in.getFileLength();
    if (pos != null) {
      contentLength -= pos;
      in.seek(pos);
    }
View Full Code Here

    // Current system has foo deleted and bar with length 2
    // test snapshot has foo with length 1 and bar with length 1

    // Checking current file system
    assertTrue(!dfs.exists(foo));
    DFSInputStream in = client.open("/bar");
    assertTrue(in.getFileLength() == 2);
    assertTrue(in.read() == 1);
    assertTrue(in.read() == 2);
    assertTrue(in.read() == -1); //eof
View Full Code Here

               path);

      // Pessimistically update last block length from DataNode.
      // File could have been renamed, and a new file created in its place.
      try {
        DFSInputStream stm = client.open(path);
        DFSLocatedBlocks locBlks = stm.fetchLocatedBlocks();

        if (locBlks.locatedBlockCount() >= blks.length) {
          if (blks[index] != null && locBlks.get(index) != null) {
            if (blks[index].getBlockId() == locBlks.get(index).getBlock().getBlockId()) {
View Full Code Here

    LocatedBlocks[] blocksArr = ssProtocol.getLocatedBlocks("test", "/bar/foo");
    assertTrue(blocksArr.length == 1); // 1 file

    DFSClient client = new DFSClient(conf);
    DFSInputStream stm = client.open("/bar/foo");
    LocatedBlocks locBlks = blocksArr[0];
    DFSLocatedBlocks dfsLocBlks = stm.fetchLocatedBlocks();
    stm.close();

    assertTrue(locBlks.locatedBlockCount() == 1); // one byte so must be one block
View Full Code Here

    assertTrue(locBlks.getFileLength() == 1);

    blocksArr = ssProtocol.getLocatedBlocks("test", "/bar/woot");
    assertTrue(blocksArr.length == 1); // 1 file

    stm = client.open("/bar/woot");
    locBlks = blocksArr[0];
    dfsLocBlks = stm.fetchLocatedBlocks();
    stm.close();

    assertTrue(locBlks.locatedBlockCount() == 1); // one byte so must be one block
View Full Code Here

      }
    } catch (InterruptedException e) {
      response.sendError(400, e.getMessage());
      return;
    }
    in = dfs.open(filename);
    long contentLength = in.getFileLength();
    if (pos != null) {
      contentLength -= pos;
      in.seek(pos);
    }
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.