热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

org.apache.hadoop.fs.FileSystem.delete()方法的使用及代码示例

本文整理了Java中org.apache.hadoop.fs.FileSystem.delete()方法的一些代码示例,展示了FileSystem.delete()的具体用法。这些代码示例主要来源于G

本文整理了Java中org.apache.hadoop.fs.FileSystem.delete()方法的一些代码示例,展示了FileSystem.delete()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。FileSystem.delete()方法的具体详情如下:
包路径:org.apache.hadoop.fs.FileSystem
类名称:FileSystem
方法名:delete

FileSystem.delete介绍

[英]Delete a file/directory.
[中]删除文件/目录。

代码示例

代码示例来源:origin: voldemort/voldemort

public static void deletePathIfExists(JobConf conf, String stepOutputPath) throws IOException {
Path path = new Path(stepOutputPath);
FileSystem fs = path.getFileSystem(conf);
if(fs.exists(path)) {
fs.delete(path, true);
}
}

代码示例来源:origin: h2oai/h2o-2

@Override public Object call() throws Exception {
FileSystem fs = FileSystem.get(_iceRoot.toUri(), CONF);
fs.delete(_iceRoot, true);
return null;
}
}, false, 0);

代码示例来源:origin: apache/incubator-druid

public static String runTask(String[] args) throws Exception
{
String workingPath = args[0];
log.info("Deleting indexing hadoop working path [%s].", workingPath);
Path p = new Path(workingPath);
FileSystem fs = p.getFileSystem(new Configuration());
fs.delete(p, true);
return null;
}
}

代码示例来源:origin: prestodb/presto

private void cleanupFile(Path file)
{
try {
fileSystem.delete(file, false);
if (fileSystem.exists(file)) {
throw new IOException("Delete failed");
}
}
catch (IOException e) {
log.warn(e, "Failed to delete temporary file: " + file);
}
}

代码示例来源:origin: apache/flink

@Override
public void run() {
LOG.info("Cancelling deployment from Deployment Failure Hook");
failSessionDuringDeployment(yarnClient, yarnApplication);
LOG.info("Deleting files in {}.", yarnFilesDir);
try {
FileSystem fs = FileSystem.get(yarnConfiguration);
if (!fs.delete(yarnFilesDir, true)) {
throw new IOException("Deleting files in " + yarnFilesDir + " was unsuccessful");
}
fs.close();
} catch (IOException e) {
LOG.error("Failed to delete Flink Jar and configuration files in HDFS", e);
}
}
}

代码示例来源:origin: apache/hbase

@After
public void cleanUp() throws IOException {
// delete and recreate the test directory, ensuring a clean test dir between tests
Path testDir = UTIL.getDataTestDir();
FileSystem fs = UTIL.getTestFileSystem();
fs.delete(testDir, true);
if (!fs.mkdirs(testDir)) throw new IOException("Failed mkdir " + testDir);
}

代码示例来源:origin: apache/kylin

@Override
public void deleteSlice(String workingDir, String sliceFileName) throws IOException {
Path path = new Path(workingDir, sliceFileName);
logger.trace("delete slice at {}", path);
if (fileSystem.exists(path)) {
fileSystem.delete(path, false);
}
}

代码示例来源:origin: h2oai/h2o-2

@Override public Object call() throws Exception {
Path p = new Path(_iceRoot, getIceName(v));
FileSystem fs = FileSystem.get(p.toUri(), CONF);
fs.delete(p, true);
return null;
}
}, false, 0);

代码示例来源:origin: apache/hive

private void moveUpFiles(Path specPath, Configuration hconf, Logger log)
throws IOException, HiveException {
FileSystem fs = specPath.getFileSystem(hconf);
if (fs.exists(specPath)) {
FileStatus[] taskOutputDirs = fs.listStatus(specPath);
if (taskOutputDirs != null) {
for (FileStatus dir : taskOutputDirs) {
Utilities.renameOrMoveFiles(fs, dir.getPath(), specPath);
fs.delete(dir.getPath(), true);
}
}
}
}

代码示例来源:origin: apache/incubator-gobblin

@Test
public void testFromInstrumentedScheme() throws Exception {
File tmpDir = Files.createTempDir();
tmpDir.deleteOnExit();
FileSystem fs = FileSystem.get(new URI(InstrumentedLocalFileSystem.SCHEME + ":///"), new Configuration());
Assert.assertTrue(fs instanceof InstrumentedLocalFileSystem);
Assert.assertTrue(DecoratorUtils.resolveUnderlyingObject(fs) instanceof LocalFileSystem);
Assert.assertEquals(fs.getFileStatus(new Path("/tmp")).getPath(), new Path("instrumented-file:///tmp"));
Assert.assertEquals(fs.getUri().getScheme(), "instrumented-file");
Path basePath = new Path(tmpDir.getAbsolutePath());
Assert.assertTrue(fs.exists(basePath));
Path file = new Path(basePath, "file");
Assert.assertFalse(fs.exists(file));
fs.create(new Path(basePath, "file"));
Assert.assertTrue(fs.exists(file));
Assert.assertEquals(fs.getFileStatus(file).getLen(), 0);
Assert.assertEquals(fs.listStatus(basePath).length, 1);
fs.delete(file, false);
Assert.assertFalse(fs.exists(file));
}

代码示例来源:origin: apache/hive

public PerformTestRCFileAndSeqFile(boolean local, String file)
throws IOException {
if (local) {
fs = FileSystem.getLocal(conf);
} else {
fs = FileSystem.get(conf);
}
conf.setInt(RCFile.Writer.COLUMNS_BUFFER_SIZE_CONF_STR, 1 * 1024 * 1024);
if (file == null) {
Path dir = new Path(System.getProperty("test.tmp.dir", ".") + "/mapred");
testRCFile = new Path(dir, "test_rcfile");
testSeqFile = new Path(dir, "test_seqfile");
} else {
testRCFile = new Path(file + "-rcfile");
testSeqFile = new Path(file + "-seqfile");
}
fs.delete(testRCFile, true);
fs.delete(testSeqFile, true);
System.out.println("RCFile:" + testRCFile.toString());
System.out.println("SequenceFile:" + testSeqFile.toString());
}

代码示例来源:origin: apache/hive

private void corruptDataFile(final String file, final Configuration conf, final int addRemoveBytes)
throws Exception {
Path bPath = new Path(file);
Path cPath = new Path(bPath.getParent(), bPath.getName() + ".corrupt");
FileSystem fs = bPath.getFileSystem(conf);
FileStatus fileStatus = fs.getFileStatus(bPath);
int len = addRemoveBytes == Integer.MIN_VALUE ? 0 : (int) fileStatus.getLen() + addRemoveBytes;
byte[] buffer = new byte[len];
FSDataInputStream fdis = fs.open(bPath);
fdis.readFully(0, buffer, 0, (int) Math.min(fileStatus.getLen(), buffer.length));
fdis.close();
FSDataOutputStream fdos = fs.create(cPath, true);
fdos.write(buffer, 0, buffer.length);
fdos.close();
fs.delete(bPath, false);
fs.rename(cPath, bPath);
}

代码示例来源:origin: alibaba/mdrill

public static void truncate(FileSystem lfs,Path target) throws IOException
{
LOG.info("truncate "+target.toString());
if (lfs.exists(target)) {
lfs.delete(target, true);
}
lfs.mkdirs(target.getParent());
}
public static String readVertify(FileSystem fs, Path file) throws IOException {

代码示例来源:origin: apache/storm

@Test
public void testDoubleCreateSemantics() throws Exception {
//1 create an already existing open file w/o override flag
Path file1 = new Path(dir.toString() + Path.SEPARATOR_CHAR + "file1");
try (FSDataOutputStream os1 = fs.create(file1, false)) {
fs.create(file1, false); // should fail
fail("Create did not throw an exception");
} catch (RemoteException e) {
Assert.assertEquals(AlreadyBeingCreatedException.class, e.unwrapRemoteException().getClass());
}
//2 close file and retry creation
try {
fs.create(file1, false); // should still fail
fail("Create did not throw an exception");
} catch (FileAlreadyExistsException e) {
// expecting this exception
}
//3 delete file and retry creation
fs.delete(file1, false);
try (FSDataOutputStream os2 = fs.create(file1, false)) {
Assert.assertNotNull(os2);
}
}

代码示例来源:origin: apache/hbase

private String setRootDirAndCleanIt(final HBaseTestingUtility htu, final String subdir)
throws IOException {
Path testdir = htu.getDataTestDir(subdir);
FileSystem fs = FileSystem.get(htu.getConfiguration());
if (fs.exists(testdir)) assertTrue(fs.delete(testdir, true));
FSUtils.setRootDir(htu.getConfiguration(), testdir);
return FSUtils.getRootDir(htu.getConfiguration()).toString();
}

代码示例来源:origin: apache/incubator-druid

@Override
public void killAll() throws IOException
{
log.info("Deleting all segment files from hdfs dir [%s].", storageDirectory.toUri().toString());
final FileSystem fs = storageDirectory.getFileSystem(config);
fs.delete(storageDirectory, true);
}

代码示例来源:origin: prestodb/presto

private void deleteSchemaFile(String type, Path metadataDirectory)
{
try {
if (!metadataFileSystem.delete(new Path(metadataDirectory, PRESTO_SCHEMA_FILE_NAME), false)) {
throw new PrestoException(HIVE_METASTORE_ERROR, "Could not delete " + type + " schema");
}
}
catch (IOException e) {
throw new PrestoException(HIVE_METASTORE_ERROR, "Could not delete " + type + " schema", e);
}
}

代码示例来源:origin: apache/kylin

public static void deletePath(Configuration conf, Path path) throws IOException {
FileSystem fs = FileSystem.get(path.toUri(), conf);
if (fs.exists(path)) {
fs.delete(path, true);
}
}

代码示例来源:origin: apache/storm

private static void createSeqFile(FileSystem fs, Path file, int rowCount) throws IOException {
Configuration cOnf= new Configuration();
try {
if (fs.exists(file)) {
fs.delete(file, false);
}
SequenceFile.Writer w = SequenceFile.createWriter(fs, conf, file, IntWritable.class, Text.class);
for (int i = 0; i w.append(new IntWritable(i), new Text("line " + i));
}
w.close();
System.out.println("done");
} catch (IOException e) {
e.printStackTrace();
}
}

代码示例来源:origin: Alluxio/alluxio

/**
* Creates the HDFS filesystem to store output files.
*
* @param conf Hadoop configuration
*/
private void createHdfsFilesystem(Configuration conf) throws Exception {
// Inits HDFS file system object
mFileSystem = FileSystem.get(URI.create(conf.get("fs.defaultFS")), conf);
mOutputFilePath = new Path("./MapReduceOutputFile");
if (mFileSystem.exists(mOutputFilePath)) {
mFileSystem.delete(mOutputFilePath, true);
}
}

推荐阅读
  • 本文整理了Java中org.apache.hadoop.hive.ql.plan.ExprNodeColumnDesc.getTypeInfo()方法的一些代码示例,展 ... [详细]
  • Java太阳系小游戏分析和源码详解
    本文介绍了一个基于Java的太阳系小游戏的分析和源码详解。通过对面向对象的知识的学习和实践,作者实现了太阳系各行星绕太阳转的效果。文章详细介绍了游戏的设计思路和源码结构,包括工具类、常量、图片加载、面板等。通过这个小游戏的制作,读者可以巩固和应用所学的知识,如类的继承、方法的重载与重写、多态和封装等。 ... [详细]
  • Iamtryingtomakeaclassthatwillreadatextfileofnamesintoanarray,thenreturnthatarra ... [详细]
  • 向QTextEdit拖放文件的方法及实现步骤
    本文介绍了在使用QTextEdit时如何实现拖放文件的功能,包括相关的方法和实现步骤。通过重写dragEnterEvent和dropEvent函数,并结合QMimeData和QUrl等类,可以轻松实现向QTextEdit拖放文件的功能。详细的代码实现和说明可以参考本文提供的示例代码。 ... [详细]
  • Spring特性实现接口多类的动态调用详解
    本文详细介绍了如何使用Spring特性实现接口多类的动态调用。通过对Spring IoC容器的基础类BeanFactory和ApplicationContext的介绍,以及getBeansOfType方法的应用,解决了在实际工作中遇到的接口及多个实现类的问题。同时,文章还提到了SPI使用的不便之处,并介绍了借助ApplicationContext实现需求的方法。阅读本文,你将了解到Spring特性的实现原理和实际应用方式。 ... [详细]
  • 本文讨论了一个关于cuowu类的问题,作者在使用cuowu类时遇到了错误提示和使用AdjustmentListener的问题。文章提供了16个解决方案,并给出了两个可能导致错误的原因。 ... [详细]
  • 自动轮播,反转播放的ViewPagerAdapter的使用方法和效果展示
    本文介绍了如何使用自动轮播、反转播放的ViewPagerAdapter,并展示了其效果。该ViewPagerAdapter支持无限循环、触摸暂停、切换缩放等功能。同时提供了使用GIF.gif的示例和github地址。通过LoopFragmentPagerAdapter类的getActualCount、getActualItem和getActualPagerTitle方法可以实现自定义的循环效果和标题展示。 ... [详细]
  • 本文介绍了安全性要求高的真正密码随机数生成器的概念和原理。首先解释了统计学意义上的伪随机数和真随机数的区别,以及伪随机数在密码学安全中的应用。然后讨论了真随机数的定义和产生方法,并指出了实际情况下真随机数的不可预测性和复杂性。最后介绍了随机数生成器的概念和方法。 ... [详细]
  • 本文介绍了关于Java异常的八大常见问题,包括异常管理的最佳做法、在try块中定义的变量不能用于catch或finally的原因以及为什么Double.parseDouble(null)和Integer.parseInt(null)会抛出不同的异常。同时指出这些问题是由于不同的开发人员开发所导致的,不值得过多思考。 ... [详细]
  • 本文介绍了闭包的定义和运转机制,重点解释了闭包如何能够接触外部函数的作用域中的变量。通过词法作用域的查找规则,闭包可以访问外部函数的作用域。同时还提到了闭包的作用和影响。 ... [详细]
  • Java容器中的compareto方法排序原理解析
    本文从源码解析Java容器中的compareto方法的排序原理,讲解了在使用数组存储数据时的限制以及存储效率的问题。同时提到了Redis的五大数据结构和list、set等知识点,回忆了作者大学时代的Java学习经历。文章以作者做的思维导图作为目录,展示了整个讲解过程。 ... [详细]
  • 原文地址:https:www.cnblogs.combaoyipSpringBoot_YML.html1.在springboot中,有两种配置文件,一种 ... [详细]
  • http:my.oschina.netleejun2005blog136820刚看到群里又有同学在说HTTP协议下的Get请求参数长度是有大小限制的,最大不能超过XX ... [详细]
  • JavaScript和HTML之间的交互是经由过程事宜完成的。事宜:文档或浏览器窗口中发作的一些特定的交互霎时。能够运用侦听器(或处置惩罚递次来预订事宜),以便事宜发作时实行相应的 ... [详细]
  • 基于移动平台的会展导游系统APP设计与实现的技术介绍与需求分析
    本文介绍了基于移动平台的会展导游系统APP的设计与实现过程。首先,对会展经济和移动互联网的概念进行了简要介绍,并阐述了将会展引入移动互联网的意义。接着,对基础技术进行了介绍,包括百度云开发环境、安卓系统和近场通讯技术。然后,进行了用户需求分析和系统需求分析,并提出了系统界面运行流畅和第三方授权等需求。最后,对系统的概要设计进行了详细阐述,包括系统前端设计和交互与原型设计。本文对基于移动平台的会展导游系统APP的设计与实现提供了技术支持和需求分析。 ... [详细]
author-avatar
mobiledu2502920327
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有