Package org.apache.hadoop.fs

Examples of org.apache.hadoop.fs.FSDataOutputStream.sync()


      // create a new file.
      final String f = DIR + "foo";
      final Path fpath = new Path(f);
      FSDataOutputStream out = TestFileCreation.createFile(dfs, fpath, DATANODE_NUM);
      out.write("something".getBytes());
      out.sync();

      // set the soft and hard limit to be 1 second so that the
      // namenode triggers lease recovery
      cluster.setLeasePeriod(leasePeriod, leasePeriod);
      // wait for the lease to expire
View Full Code Here


      System.out.println("Created file simpleFlush.dat");

      // write to file
      int mid = fileSize/2;
      stm.write(fileContents, 0, mid);
      stm.sync();
      System.out.println("Wrote and Flushed first part of file.");

      // write the remainder of the file
      stm.write(fileContents, mid, fileSize - mid);
      System.out.println("Written second part of file");
View Full Code Here

      System.out.println("Wrote and Flushed first part of file.");

      // write the remainder of the file
      stm.write(fileContents, mid, fileSize - mid);
      System.out.println("Written second part of file");
      stm.sync();
      stm.sync();
      System.out.println("Wrote and Flushed second part of file.");

      // verify that full blocks are sane
      checkFile(fs, file1, 1);
View Full Code Here

      // write the remainder of the file
      stm.write(fileContents, mid, fileSize - mid);
      System.out.println("Written second part of file");
      stm.sync();
      stm.sync();
      System.out.println("Wrote and Flushed second part of file.");

      // verify that full blocks are sane
      checkFile(fs, file1, 1);
View Full Code Here

      System.out.println("Created file complexFlush.dat");

      int start = 0;
      for (start = 0; (start + 29) < fileSize; ) {
        stm.write(fileContents, start, 29);
        stm.sync();
        start += 29;
      }
      stm.write(fileContents, start, fileSize-start);

      // verify that full blocks are sane
View Full Code Here

    byte [] bytes = Bytes.toBytes(getName());
    // First verify that using streams all works.
    Path p = new Path(dir, getName() + ".fsdos");
    FSDataOutputStream out = fs.create(p);
    out.write(bytes);
    out.sync();
    FSDataInputStream in = fs.open(p);
    assertTrue(in.available() > 0);
    byte [] buffer = new byte [1024];
    int read = in.read(buffer);
    assertEquals(bytes.length, read);
View Full Code Here

      // write two full blocks.
      int remainingPiece = blockSize/2;
      int blocksMinusPiece = numBlocks * blockSize - remainingPiece;
      writeFile(stm, blocksMinusPiece);
      stm.sync();
      int actualRepl = ((DFSClient.DFSOutputStream)(stm.getWrappedStream())).
                        getNumCurrentReplicas();
      // if we sync on a block boundary, actualRepl will be 0
      assertTrue(file1 + " should be replicated to 1 datanodes, not " + actualRepl,
                 actualRepl == 1);
View Full Code Here

                        getNumCurrentReplicas();
      // if we sync on a block boundary, actualRepl will be 0
      assertTrue(file1 + " should be replicated to 1 datanodes, not " + actualRepl,
                 actualRepl == 1);
      writeFile(stm, remainingPiece);
      stm.sync();

      // rename file wile keeping it open.
      Path fileRenamed = new Path("/filestatusRenamed.dat");
      fs.rename(file1, fileRenamed);
      System.out.println("testFileCreationNamenodeRestart: "
View Full Code Here

      // create a new file.
      final String f = DIR + "foo";
      final Path fpath = new Path(f);
      FSDataOutputStream out = TestFileCreation.createFile(dfs, fpath, DATANODE_NUM);
      out.write("something".getBytes());
      out.sync();
      int actualRepl = ((DFSClient.DFSOutputStream)(out.getWrappedStream())).
                        getNumCurrentReplicas();
      assertTrue(f + " should be replicated to " + DATANODE_NUM + " datanodes.",
                 actualRepl == DATANODE_NUM);
View Full Code Here

      // write two full blocks.
      int remainingPiece = blockSize/2;
      int blocksMinusPiece = numBlocks * blockSize - remainingPiece;
      writeFile(stm, blocksMinusPiece);
      stm.sync();
      int actualRepl = ((DFSClient.DFSOutputStream)(stm.getWrappedStream())).
                        getNumCurrentReplicas();
      // if we sync on a block boundary, actualRepl will be 0
      assertTrue(file1 + " should be replicated to 1 datanodes, not " + actualRepl,
                 actualRepl == 1);
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.