本文整理了Java中org.apache.storm.utils.Utils.forceDelete()
方法的一些代码示例,展示了Utils.forceDelete()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Utils.forceDelete()
方法的具体详情如下:
包路径:org.apache.storm.utils.Utils
类名称:Utils
方法名:forceDelete
[英]Deletes a file or directory and its contents if it exists. Does not complain if the input is null or does not exist.
[中]删除文件或目录及其内容(如果存在)。如果输入为空或不存在,则不会抱怨。
代码示例来源:origin: apache/storm
/**
* Delete the topo dir if it contains zero port dirs.
*/
@VisibleForTesting
void cleanupEmptyTopoDirectory(File dir) throws IOException {
File topoDir = dir.getParentFile();
if (topoDir.listFiles().length == 0) {
Utils.forceDelete(topoDir.getCanonicalPath());
}
}
代码示例来源:origin: apache/storm
@VisibleForTesting
public void forceDeleteTopoDistDir(String topoId) throws IOException {
Utils.forceDelete(ServerConfigUtils.masterStormDistRoot(conf, topoId));
}
代码示例来源:origin: apache/storm
public static void main(String[] args) throws Exception {
SysOutOverSLF4J.sendSystemOutAndErrToSLF4J();
Map<String, Object> conf = ConfigUtils.readStormConfig();
Object port = conf.get(Config.STORM_ZOOKEEPER_PORT);
String localPath = (String) conf.get(DaemonConfig.DEV_ZOOKEEPER_PATH);
Utils.forceDelete(localPath);
Zookeeper.mkInprocessZookeeper(localPath, ObjectReader.getInt(port));
}
}
代码示例来源:origin: apache/storm
Utils.forceDelete(path);
cleanupEmptyTopoDirectory(dir);
numFilesCleaned++;
代码示例来源:origin: apache/storm
@Override
public void deleteIfExists(File path, String user, String logPrefix) throws IOException {
String absolutePath = path.getAbsolutePath();
if (Utils.checkFileExists(absolutePath)) {
LOG.info("Deleting path (runAsUser) {}", absolutePath);
if (user == null) {
user = Files.getOwner(path.toPath()).getName();
}
List<String> commands = new ArrayList<>();
commands.add("rmr");
commands.add(absolutePath);
ClientSupervisorUtils.processLauncherAndWait(_conf, user, commands, null, logPrefix);
if (Utils.checkFileExists(absolutePath)) {
// It's possible that permissions were not set properly on the directory, and
// the user who is *supposed* to own the dir does not. In this case, try the
// delete as the supervisor user.
Utils.forceDelete(absolutePath);
if (Utils.checkFileExists(absolutePath)) {
throw new RuntimeException(path + " was not deleted.");
}
}
}
}
代码示例来源:origin: apache/storm
/**
* Clean up test environment.
*/
@After
public void tearDown() {
if (StringUtils.isNotEmpty(topoPath)) {
try {
Utils.forceDelete(topoPath);
} catch (IOException e) {
// ignore...
}
}
}
代码示例来源:origin: apache/storm
Utils.forceDelete(file.getPath());
LOG.info("Delete file: {}, size: {}, lastModified: {}", canonicalPath, fileSize, lastModified);
toDeleteSize -= fileSize;
代码示例来源:origin: apache/storm
final Response returnedFilterTopoId = handler.listLogFiles("user", null, "topoB", null, origin);
Utils.forceDelete(rootPath);
代码示例来源:origin: apache/storm
forceDeleteArgs.add(path);
return null;
}).when(mockUtils).forceDelete(anyString());
代码示例来源:origin: org.apache.storm/storm-core
@Override
public void deleteIfExists(File path, String user, String logPrefix) throws IOException {
String absolutePath = path.getAbsolutePath();
LOG.info("Deleting path {}", absolutePath);
if (user == null) {
user = Files.getOwner(path.toPath()).getName();
}
List<String> commands = new ArrayList<>();
commands.add("rmr");
commands.add(absolutePath);
SupervisorUtils.processLauncherAndWait(_conf, user, commands, null, logPrefix);
if (Utils.checkFileExists(absolutePath)) {
// It's possible that permissions were not set properly on the directory, and
// the user who is *supposed* to own the dir does not. In this case, try the
// delete as the supervisor user.
Utils.forceDelete(absolutePath);
if (Utils.checkFileExists(absolutePath)) {
throw new RuntimeException(path + " was not deleted.");
}
}
}
内容来源于网络,如有侵权,请联系作者删除!