Package org.apache.hadoop.hdfs

Examples of org.apache.hadoop.hdfs.DistributedFileSystem.create()


      runCommand(admin, new String[]{"-clrQuota", childDir0.toString()}, false);
      c = dfs.getContentSummary(childDir0);
      assertEquals(c.getQuota(), -1);
     
      // 10: create a file /test/datafile1
      fout = dfs.create(childFile1, replication);
     
      // 10.s: but writing fileLen bytes should result in an quota exception
      hasException = false;
      try {
        fout.write(new byte[fileLen]);
View Full Code Here


        .numDataNodes(1).build();
    try {
      cluster.waitClusterUp();
      DistributedFileSystem fs = cluster.getFileSystem();
      Path path = new Path("/test");
      FSDataOutputStream out = fs.create(path);
      out.writeBytes("data");
      out.hsync();
     
      List<LocatedBlock> blocks = DFSTestUtil.getAllBlocks(fs.open(path));
      final LocatedBlock block = blocks.get(0);
View Full Code Here

          if (getNumberOfFiles() > rtc.min_file)
            break;
        }
        Path fileName = new Path(outputPath, file_prefix + currentId);
        try {
          out = dfs.create(fileName,
                           FsPermission.getDefault(),
                           false,
                           dfs.getConf().getInt("io.file.buffer.size", 4096),
                           (short)replication,
                           dfs.getDefaultBlockSize(),
View Full Code Here

    // no check, if it's not it throws an exception which is what we want
    DistributedFileSystem dfs =
      (DistributedFileSystem)cluster.getFileSystem();
    // OP_ADD 0, OP_SET_GENSTAMP 10
    Path pathFileCreate = new Path("/file_create");
    FSDataOutputStream s = dfs.create(pathFileCreate);
    // OP_CLOSE 9
    s.close();
    // OP_RENAME 1
    Path pathFileMoved = new Path("/file_moved");
    dfs.rename(pathFileCreate, pathFileMoved);
View Full Code Here

    dfs.delete(pathFileMoved, false);
    // OP_MKDIR 3
    Path pathDirectoryMkdir = new Path("/directory_mkdir");
    dfs.mkdirs(pathDirectoryMkdir);
    // OP_SET_REPLICATION 4
    s = dfs.create(pathFileCreate);
    s.close();
    dfs.setReplication(pathFileCreate, (short)1);
    // OP_SET_PERMISSIONS 7
    Short permission = 0777;
    dfs.setPermission(pathFileCreate, new FsPermission(permission));
View Full Code Here

       * Before this, we have
       * /
       *  /testtwo
       *    /filetwo
       */
      FSDataOutputStream outStream = fs.create(new Path("/testfour/file"));
      assertTrue(outStream != null);
      expectedLastInodeId += 2;
      inodeCount += 2;
      assertEquals(expectedLastInodeId, fsDir.getLastInodeId());
      long expectedFile4InodeId = fsDir.getINode("/testfour/file").getId();
View Full Code Here

  @Test
  public void testAbandon() throws Exception {
    NameNode nn = cluster.getNameNode();
    DistributedFileSystem fs = (DistributedFileSystem) cluster.getFileSystem();
    String fileName = "/testAbandon";
    fs.create(new Path(fileName));
    LocatedBlock lbk = nn.addBlock(fileName, fs.getClient().getClientName());
    INodeFileUnderConstruction cons = (INodeFileUnderConstruction) nn.namesystem.dir
        .getINode(fileName);
    cons.setTargets(null, -1);
    nn.abandonBlock(lbk.getBlock(), fileName, fs.getClient().getClientName());
View Full Code Here

  doAnswer(delayAnswer).when(spyBytesWritten).inc(anyInt());
  metrics.bytesWritten = spyBytesWritten;

  try {
      // create a new file.
      FSDataOutputStream stm = fs.create(p);
      stm.write(1);
      stm.sync();
      stm.write(2);
      stm.close();
View Full Code Here

    cluster.waitActive();
    DistributedFileSystem fs = (DistributedFileSystem) cluster.getFileSystem();
    OutputStream out = null;
    try {
      fs.mkdirs(new Path("/test-target"));
      out = fs.create(new Path("/test-source/foo")); // don't close
      fs.rename(new Path("/test-source/"), new Path("/test-target/"));

      fs.setSafeMode(SafeModeAction.SAFEMODE_ENTER);
      cluster.getNameNode().saveNamespace();
      fs.setSafeMode(SafeModeAction.SAFEMODE_LEAVE);
View Full Code Here

    nFadvise.set(0);
    InjectionHandler.set(new FadviseHandler(advise));
    DistributedFileSystem fs = (DistributedFileSystem) cluster.getFileSystem();
    WriteOptions options = new WriteOptions();
    options.setFadvise(advise);
    FSDataOutputStream out = fs.create(new Path("/test"), null, true, 1024,
        (short) 3, BLOCK_SIZE, 512, null, null, options);
    Random r = new Random();
    byte buffer[] = new byte[BLOCK_SIZE];
    r.nextBytes(buffer);
    out.write(buffer);
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.