当前位置: 首页>>代码示例>>Java>>正文


Java MRAsyncDiskService.moveAndDeleteAbsolutePath方法代码示例

本文整理汇总了Java中org.apache.hadoop.mapreduce.util.MRAsyncDiskService.moveAndDeleteAbsolutePath方法的典型用法代码示例。如果您正苦于以下问题:Java MRAsyncDiskService.moveAndDeleteAbsolutePath方法的具体用法?Java MRAsyncDiskService.moveAndDeleteAbsolutePath怎么用?Java MRAsyncDiskService.moveAndDeleteAbsolutePath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.hadoop.mapreduce.util.MRAsyncDiskService的用法示例。


在下文中一共展示了MRAsyncDiskService.moveAndDeleteAbsolutePath方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: deleteLocalPath

import org.apache.hadoop.mapreduce.util.MRAsyncDiskService; //导入方法依赖的package包/类
/**
 * Delete a local path with asyncDiskService if available,
 * or otherwise synchronously with local file system.
 */
private static void deleteLocalPath(MRAsyncDiskService asyncDiskService,
    LocalFileSystem fs, Path path) throws IOException {
  boolean deleted = false;
  if (asyncDiskService != null) {
    // Try to delete using asyncDiskService
    String localPathToDelete = 
      path.toUri().getPath();
    deleted = asyncDiskService.moveAndDeleteAbsolutePath(localPathToDelete);
    if (!deleted) {
      LOG.warn("Cannot find DistributedCache path " + localPathToDelete
          + " on any of the asyncDiskService volumes!");
    }
  }
  if (!deleted) {
    // If no asyncDiskService, we will delete the files synchronously
    fs.delete(path, true);
  }
  LOG.info("Deleted path " + path);
}
 
开发者ID:rekhajoshm,项目名称:mapreduce-fork,代码行数:24,代码来源:TrackerDistributedCacheManager.java

示例2: testMRAsyncDiskService

import org.apache.hadoop.mapreduce.util.MRAsyncDiskService; //导入方法依赖的package包/类
/**
 * This test creates some directories and then removes them through 
 * MRAsyncDiskService. 
 */
@Test
public void testMRAsyncDiskService() throws Throwable {

  FileSystem localFileSystem = FileSystem.getLocal(new Configuration());
  String[] vols = new String[]{TEST_ROOT_DIR + "/0",
      TEST_ROOT_DIR + "/1"};
  MRAsyncDiskService service = new MRAsyncDiskService(
      localFileSystem, vols);
  
  String a = "a";
  String b = "b";
  String c = "b/c";
  String d = "d";
  
  File fa = new File(vols[0], a);
  File fb = new File(vols[1], b);
  File fc = new File(vols[1], c);
  File fd = new File(vols[1], d);
  
  // Create the directories
  fa.mkdirs();
  fb.mkdirs();
  fc.mkdirs();
  fd.mkdirs();
  
  assertTrue(fa.exists());
  assertTrue(fb.exists());
  assertTrue(fc.exists());
  assertTrue(fd.exists());
  
  // Move and delete them
  service.moveAndDeleteRelativePath(vols[0], a);
  assertFalse(fa.exists());
  service.moveAndDeleteRelativePath(vols[1], b);
  assertFalse(fb.exists());
  assertFalse(fc.exists());
  
  assertFalse(service.moveAndDeleteRelativePath(vols[1], "not_exists"));
  
  // asyncDiskService is NOT able to delete files outside all volumes.
  IOException ee = null;
  try {
    service.moveAndDeleteAbsolutePath(TEST_ROOT_DIR + "/2");
  } catch (IOException e) {
    ee = e;
  }
  assertNotNull("asyncDiskService should not be able to delete files "
      + "outside all volumes", ee);
  // asyncDiskService is able to automatically find the file in one
  // of the volumes.
  assertTrue(service.moveAndDeleteAbsolutePath(vols[1] + Path.SEPARATOR_CHAR + d));
  
  // Make sure everything is cleaned up
  makeSureCleanedUp(vols, service);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:60,代码来源:TestMRAsyncDiskService.java


注:本文中的org.apache.hadoop.mapreduce.util.MRAsyncDiskService.moveAndDeleteAbsolutePath方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。