Package org.apache.hadoop.fs

Examples of org.apache.hadoop.fs.FileSystem.open()


    fs.setOwner(file, "root", null);

    setupAuditLogs();

    try {
      userfs.open(file);
      fail("open must not succeed");
    } catch(AccessControlException e) {
      System.out.println("got access denied, as expected.");
    }
    verifyAuditLogs(false);
View Full Code Here


      // write to file
      stm.write(fileData);
      stm.close();
     
      // now test the skip function
      FSDataInputStream instm = fs.open(file1);
      byte[] actual = new byte[fileData.length];
      // read something from the block first, otherwise BlockReaderLocal.skip()
      // will not be invoked
      int nread = instm.read(actual, 0, 3);
      long skipped = 2*size+3;
 
View Full Code Here

        if (raf != null) raf.close();
      }
      cluster = new MiniDFSCluster.Builder(conf).numDataNodes(1).format(false).build();
      cluster.waitActive();
      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 " +
View Full Code Here

      // We should still be able to read the other file.
      // 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();
View Full Code Here

      Path path = new Path(file);
      // create file
      FSDataOutputStream output = fileSys.create(path);
      output.writeBytes("Some test data to write longer than 10 bytes");
      output.close();
      FSDataInputStream input = fileSys.open(path);
      input.seek(10);
      boolean threw = false;
      try {
        input.seek(100);
      } catch (IOException e) {
View Full Code Here

        FileSystem fs = cluster.getFileSystem();
        Path dir = new Path("/wrwelkj");
        assertFalse("File should not exist for test.", fs.exists(dir));

        try {
          FSDataInputStream in = fs.open(dir);
          try {
            in.close();
            fs.close();
          } finally {
            assertTrue("Did not get a FileNotFoundException for non-existing" +
View Full Code Here

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

      checkStatistics(fs, ++readOps, writeOps, largeReadOps);
     
      fs.getFileBlockLocations(status, 0, 0);
      checkStatistics(fs, ++readOps, writeOps, largeReadOps);
     
      FSDataInputStream in = fs.open(file);
      in.close();
      checkStatistics(fs, ++readOps, writeOps, largeReadOps);
     
      fs.setReplication(file, (short)2);
      checkStatistics(fs, readOps, ++writeOps, largeReadOps);
View Full Code Here

      out[0].close();
      for(; i < 200; i++) {out[1].write(i);}
      out[1].close();

      //verify
      FSDataInputStream[] in = {fs.open(p[0]), fs.open(p[1])}
      for(i = 0; i < 100; i++) {assertEquals(i, in[0].read());}
      for(i = 0; i < 200; i++) {assertEquals(i, in[1].read());}
    } finally {
      if (cluster != null) {cluster.shutdown();}
    }
View Full Code Here

      out[0].close();
      for(; i < 200; i++) {out[1].write(i);}
      out[1].close();

      //verify
      FSDataInputStream[] in = {fs.open(p[0]), fs.open(p[1])}
      for(i = 0; i < 100; i++) {assertEquals(i, in[0].read());}
      for(i = 0; i < 200; i++) {assertEquals(i, in[1].read());}
    } finally {
      if (cluster != null) {cluster.shutdown();}
    }
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.