Exemplo n.º 1
0
    /** Create a file with a length of <code>fileSize</code>. The file is filled with 'a'. */
    private void genFile(Path file, long fileSize) throws IOException {
      long startTime = Time.now();
      FSDataOutputStream out = null;
      try {
        out =
            fc.create(
                file,
                EnumSet.of(CreateFlag.CREATE, CreateFlag.OVERWRITE),
                CreateOpts.createParent(),
                CreateOpts.bufferSize(4096),
                CreateOpts.repFac((short) 3));
        executionTime[CREATE] += (Time.now() - startTime);
        numOfOps[CREATE]++;

        long i = fileSize;
        while (i > 0) {
          long s = Math.min(fileSize, WRITE_CONTENTS.length);
          out.write(WRITE_CONTENTS, 0, (int) s);
          i -= s;
        }

        startTime = Time.now();
        executionTime[WRITE_CLOSE] += (Time.now() - startTime);
        numOfOps[WRITE_CLOSE]++;
      } finally {
        IOUtils.cleanup(LOG, out);
      }
    }
Exemplo n.º 2
0
 public static void createFile(FileContext fc, Path path, int numBlocks, int blockSize)
     throws IOException {
   createFile(fc, path, numBlocks, CreateOpts.blockSize(blockSize), CreateOpts.createParent());
 }
Exemplo n.º 3
0
 public static void createFile(FileContext fc, Path path) throws IOException {
   createFile(fc, path, DEFAULT_NUM_BLOCKS, CreateOpts.createParent());
 }
Exemplo n.º 4
0
 public static void writeFile(FileContext fc, Path path, byte b[]) throws IOException {
   FSDataOutputStream out =
       fc.create(path, EnumSet.of(CreateFlag.CREATE), CreateOpts.createParent());
   out.write(b);
   out.close();
 }