org.apache.storm.utils.Utils.forceDelete()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(3.6k)|赞(0)|评价(0)|浏览(136)

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

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.");
    }
  }
}

相关文章

Utils类方法