• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Trash类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.hadoop.fs.Trash的典型用法代码示例。如果您正苦于以下问题:Java Trash类的具体用法?Java Trash怎么用?Java Trash使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Trash类属于org.apache.hadoop.fs包,在下文中一共展示了Trash类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: moveToTrash

import org.apache.hadoop.fs.Trash; //导入依赖的package包/类
private boolean moveToTrash(PathData item) throws IOException {
  boolean success = false;
  if (!skipTrash) {
    try {
      success = Trash.moveToAppropriateTrash(item.fs, item.path, getConf());
    } catch(FileNotFoundException fnfe) {
      throw fnfe;
    } catch (IOException ioe) {
      String msg = ioe.getMessage();
      if (ioe.getCause() != null) {
        msg += ": " + ioe.getCause().getMessage();
      }
      throw new IOException(msg + ". Consider using -skipTrash option", ioe);
    }
  }
  return success;
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:18,代码来源:Delete.java


示例2: startTrashEmptier

import org.apache.hadoop.fs.Trash; //导入依赖的package包/类
private void startTrashEmptier(final Configuration conf) throws IOException {
  long trashInterval =
      conf.getLong(FS_TRASH_INTERVAL_KEY, FS_TRASH_INTERVAL_DEFAULT);
  if (trashInterval == 0) {
    return;
  } else if (trashInterval < 0) {
    throw new IOException("Cannot start trash emptier with negative interval."
        + " Set " + FS_TRASH_INTERVAL_KEY + " to a positive value.");
  }
  
  // This may be called from the transitionToActive code path, in which
  // case the current user is the administrator, not the NN. The trash
  // emptier needs to run as the NN. See HDFS-3972.
  FileSystem fs = SecurityUtil.doAsLoginUser(
      new PrivilegedExceptionAction<FileSystem>() {
        @Override
        public FileSystem run() throws IOException {
          return FileSystem.get(conf);
        }
      });
  this.emptier = new Thread(new Trash(fs, conf).getEmptier(), "Trash Emptier");
  this.emptier.setDaemon(true);
  this.emptier.start();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:25,代码来源:NameNode.java


示例3: moveToTrash

import org.apache.hadoop.fs.Trash; //导入依赖的package包/类
private boolean moveToTrash(PathData item) throws IOException {
   boolean success = false;
   if (!skipTrash) {
     try {
       success = Trash.moveToAppropriateTrash(item.fs, item.path, getConf());
     } catch(FileNotFoundException fnfe) {
       throw fnfe;
     } catch (IOException ioe) {
       String msg = ioe.getMessage();
       if (ioe.getCause() != null) {
         msg += ": " + ioe.getCause().getMessage();
}
       throw new IOException(msg + ". Consider using -skipTrash option", ioe);
     }
   }
   return success;
 }
 
开发者ID:naver,项目名称:hadoop,代码行数:18,代码来源:Delete.java


示例4: deleteDirectory

import org.apache.hadoop.fs.Trash; //导入依赖的package包/类
/**
 * Delete the specified directory, using the trash as available.
 *
 * @param conf configuration object
 * @param path path to delete
 *
 * @throws IOException if there's an error deleting the directory.
 */
public static void deleteDirectory(Configuration conf, Path path) throws IOException {

  Trash trash = new Trash(path.getFileSystem(conf), conf);
  try {
    if (!trash.isEnabled()) {
      LOG.debug("Trash is not enabled for " + path + " so deleting instead");
      FileSystem fs = path.getFileSystem(conf);
      fs.delete(path, true);
    } else {
      boolean removed = trash.moveToTrash(path);
      if (removed) {
        LOG.debug("Moved to trash: " + path);
      } else {
        LOG.error("Item already in trash: " + path);
      }
    }
  } catch (FileNotFoundException e) {
    LOG.debug("Attempting to delete non-existent directory " + path);
    return;
  }
}
 
开发者ID:airbnb,项目名称:reair,代码行数:30,代码来源:FsUtils.java


示例5: trashNonDefaultFS

import org.apache.hadoop.fs.Trash; //导入依赖的package包/类
public static void trashNonDefaultFS(Configuration conf) throws IOException {
  conf.set("fs.trash.interval", "10"); // 10 minute
  // attempt non-default FileSystem trash
  {
    final FileSystem lfs = FileSystem.getLocal(conf);
    Path p = TEST_DIR;
    Path f = new Path(p, "foo/bar");
    if (lfs.exists(p)) {
      lfs.delete(p, true);
    }
    try {
      f = writeFile(lfs, f);

      FileSystem.closeAll();
      FileSystem localFs = FileSystem.get(URI.create("file:///"), conf);
      Trash lTrash = new Trash(localFs, conf);
      lTrash.moveToTrash(f.getParent());
      checkTrash(localFs, lTrash.getCurrentTrashDir(), f);
    } finally {
      if (lfs.exists(p)) {
        lfs.delete(p, true);
      }
    }
  }
}
 
开发者ID:rhli,项目名称:hadoop-EAR,代码行数:26,代码来源:TestTrash.java


示例6: startTrashEmptier

import org.apache.hadoop.fs.Trash; //导入依赖的package包/类
private void startTrashEmptier(final Configuration conf) throws IOException {
  long trashInterval =
      conf.getLong(FS_TRASH_INTERVAL_KEY, FS_TRASH_INTERVAL_DEFAULT);
  if (trashInterval == 0) {
    return;
  } else if (trashInterval < 0) {
    throw new IOException(
        "Cannot start tresh emptier with negative interval." + " Set " +
            FS_TRASH_INTERVAL_KEY + " to a positive value.");
  }

  // This may be called from the transitionToActive code path, in which
  // case the current user is the administrator, not the NN. The trash
  // emptier needs to run as the NN. See HDFS-3972.
  FileSystem fs =
      SecurityUtil.doAsLoginUser(new PrivilegedExceptionAction<FileSystem>() {
            @Override
            public FileSystem run() throws IOException {
              return FileSystem.get(conf);
            }
          });
  this.emptier =
      new Thread(new Trash(fs, conf).getEmptier(), "Trash Emptier");
  this.emptier.setDaemon(true);
  this.emptier.start();
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:27,代码来源:NameNode.java


示例7: testMoveToTrash

import org.apache.hadoop.fs.Trash; //导入依赖的package包/类
@Test
public void testMoveToTrash() throws IOException {
  Path hadoopUtilsTestDir = new Path(Files.createTempDir().getAbsolutePath(), "HadoopUtilsTestDir");
  Configuration conf = new Configuration();
  // Set the time to keep it in trash to 10 minutes.
  // 0 means object will be deleted instantly.
  conf.set("fs.trash.interval", "10");
  FileSystem fs = FileSystem.getLocal(conf);
  Trash trash = new Trash(fs, conf);
  TrashPolicy trashPolicy = TrashPolicy.getInstance(conf, fs, fs.getHomeDirectory());
  Path trashPath = trashPolicy.getCurrentTrashDir();

  fs.mkdirs(hadoopUtilsTestDir);
  Assert.assertTrue(fs.exists(hadoopUtilsTestDir));
  trash.moveToTrash(hadoopUtilsTestDir.getParent());
  Assert.assertFalse(fs.exists(hadoopUtilsTestDir));
  Assert.assertTrue(fs.exists(trashPath));
}
 
开发者ID:apache,项目名称:incubator-gobblin,代码行数:19,代码来源:HadoopUtilsTest.java


示例8: processArguments

import org.apache.hadoop.fs.Trash; //导入依赖的package包/类
@Override
protected void processArguments(LinkedList<PathData> args)
throws IOException {
  Trash trash = new Trash(getConf());
  trash.expunge();
  trash.checkpoint();    
}
 
开发者ID:naver,项目名称:hadoop,代码行数:8,代码来源:Delete.java


示例9: moveToTrash

import org.apache.hadoop.fs.Trash; //导入依赖的package包/类
public static void moveToTrash(Configuration conf, Path path) throws IOException {
  Trash t = new Trash(conf);
  boolean isMoved = t.moveToTrash(path);
  t.expunge();
  if (!isMoved) {
    logger.error("Trash is not enabled or file is already in the trash.");
  }
}
 
开发者ID:XiaoMi,项目名称:linden,代码行数:9,代码来源:ShardWriter.java


示例10: testPluggableTrash

import org.apache.hadoop.fs.Trash; //导入依赖的package包/类
@Test
public void testPluggableTrash() throws IOException {
  Configuration conf = new Configuration();

  // Test plugged TrashPolicy
  conf.setClass("fs.trash.classname", TestTrashPolicy.class, TrashPolicy.class);
  Trash trash = new Trash(conf);
  assertTrue(trash.getTrashPolicy().getClass().equals(TestTrashPolicy.class));
}
 
开发者ID:rhli,项目名称:hadoop-EAR,代码行数:10,代码来源:TestTrash.java


示例11: startTrashEmptier

import org.apache.hadoop.fs.Trash; //导入依赖的package包/类
private void startTrashEmptier(Configuration conf) throws IOException {
  if (conf.getInt("fs.trash.interval", 0) == 0) {
    return;
  }
  FileSystem fs = NameNode.getTrashFileSystem(conf);
  this.trash = new Trash(fs, conf);
  this.emptier = new Thread(trash.getEmptier(), "Trash Emptier");
  this.emptier.setDaemon(true);
  this.emptier.start();
}
 
开发者ID:rhli,项目名称:hadoop-EAR,代码行数:11,代码来源:NameNode.java


示例12: moveToTrash

import org.apache.hadoop.fs.Trash; //导入依赖的package包/类
private boolean moveToTrash(PathData item) throws IOException {
  boolean success = false;
  if (!skipTrash) {
    try {
      success = Trash.moveToAppropriateTrash(item.fs, item.path, getConf());
    } catch(FileNotFoundException fnfe) {
      throw fnfe;
    } catch (IOException ioe) {
        throw new IOException(ioe.getMessage() + ". Consider using -skipTrash option", ioe);
    }
  }
  return success;
}
 
开发者ID:ict-carch,项目名称:hadoop-plus,代码行数:14,代码来源:Delete.java


示例13: trash

import org.apache.hadoop.fs.Trash; //导入依赖的package包/类
public boolean trash(final Path path)
{
    return run(new Retryable<Boolean>()
    {
        @Override
        public Boolean call()
                throws Exception
        {
            return Trash.moveToAppropriateTrash(fs, path, conf);
        }
    });
}
 
开发者ID:civitaspo,项目名称:embulk-output-hdfs,代码行数:13,代码来源:HdfsClient.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Token类代码示例发布时间:2022-05-21
下一篇:
Java ExistsResponse类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap