Java 类org.apache.hadoop.hdfs.server.namenode.BlockPlacementPolicyRaid.CachedFullPathNames 实例源码

项目:hadoop-EAR    文件:TestBlockPlacementPolicyRaid.java   
private void verifyCachedFullPathNameResult(
    CachedFullPathNames cachedFullPathNames, FSInodeInfo inode, int cachedReads)
    throws IOException {
  Assert.assertEquals(inode.getFullPathName(),
                      policy.getFullPathName(inode));
  Assert.assertEquals(cachedReads,
      h.events.get(InjectionEvent.BLOCKPLACEMENTPOLICYRAID_CACHED_PATH).intValue());
}
项目:mapreduce-fork    文件:TestBlockPlacementPolicyRaid.java   
/**
 * Test BlockPlacementPolicyRaid.CachedFullPathNames
 * Verify that the results obtained from cache is the same as
 * the results obtained directly
 */
@Test
public void testCachedPathNames() throws IOException {
  setupCluster();
  try {
    String file1 = "/dir/file1";
    String file2 = "/dir/file2";
    DFSTestUtil.createFile(fs, new Path(file1), 3, (short)1, 0L);
    DFSTestUtil.createFile(fs, new Path(file2), 4, (short)1, 0L);
    // test full path cache
    CachedFullPathNames cachedFullPathNames =
        new CachedFullPathNames(namesystem);
    FSInodeInfo inode1 = null;
    FSInodeInfo inode2 = null;
    namesystem.dir.readLock();
    try {
      inode1 = namesystem.dir.rootDir.getNode(file1, true);
      inode2 = namesystem.dir.rootDir.getNode(file2, true);
    } finally {
      namesystem.dir.readUnlock();
    }
    verifyCachedFullPathNameResult(cachedFullPathNames, inode1);
    verifyCachedFullPathNameResult(cachedFullPathNames, inode1);
    verifyCachedFullPathNameResult(cachedFullPathNames, inode2);
    verifyCachedFullPathNameResult(cachedFullPathNames, inode2);
    try {
      Thread.sleep(1200L);
    } catch (InterruptedException e) {
    }
    verifyCachedFullPathNameResult(cachedFullPathNames, inode2);
    verifyCachedFullPathNameResult(cachedFullPathNames, inode1);
  } finally {
    if (cluster != null) {
      cluster.shutdown();
    }
  }
}
项目:mapreduce-fork    文件:TestBlockPlacementPolicyRaid.java   
private void verifyCachedFullPathNameResult(
    CachedFullPathNames cachedFullPathNames, FSInodeInfo inode)
throws IOException {
  String res1 = inode.getFullPathName();
  String res2 = cachedFullPathNames.get(inode);
  LOG.info("Actual path name: " + res1);
  LOG.info("Cached path name: " + res2);
  Assert.assertEquals(cachedFullPathNames.get(inode),
                      inode.getFullPathName());
}
项目:RDFS    文件:TestBlockPlacementPolicyRaid.java   
private void verifyCachedFullPathNameResult(
    CachedFullPathNames cachedFullPathNames, FSInodeInfo inode)
    throws IOException {
  Assert.assertEquals(cachedFullPathNames.get(inode),
                      inode.getFullPathName());
}