Code example for Random

Methods: nextLong

0
  } 
 
  /** create a file with a length of <code>fileLen</code> */ 
  private void createFile(String fileName, long fileLen, short replicas) throws IOException {
    Path filePath = new Path(fileName);
    DFSTestUtil.createFile(fs, filePath, fileLen, replicas, rand.nextLong());
  } 
      
 
  public void testFilesInGetListingOps() throws Exception { 
    createFile("/tmp1/t1", 3200, (short)3); 
    createFile("/tmp1/t2", 3200, (short)3); 
    createFile("/tmp2/t1", 3200, (short)3); 
    createFile("/tmp2/t2", 3200, (short)3); 
    cluster.getNameNode().getListing("/tmp1", HdfsFileStatus.EMPTY_NAME) ;
    assertEquals(2,nnMetrics.numFilesInGetListingOps.getCurrentIntervalValue());
    cluster.getNameNode().getListing("/tmp2", HdfsFileStatus.EMPTY_NAME) ;
    assertEquals(4,nnMetrics.numFilesInGetListingOps.getCurrentIntervalValue());
    // test non-existent path 
    cluster.getNameNode().getListing("/tmp", HdfsFileStatus.EMPTY_NAME) ;