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

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

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

Utils.checkFileExists介绍

暂无

代码示例

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

public static boolean enabled() {
  return Utils.checkFileExists(CGROUP_STATUS_FILE);
}

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

protected void forceDeleteImpl(String path) throws IOException {
  LOG.debug("Deleting path {}", path);
  if (checkFileExists(path)) {
    try {
      FileUtils.forceDelete(new File(path));
    } catch (FileNotFoundException ignored) {
    }
  }
}

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

public static void rmrAsUser(Map<String, Object> conf, String id, String path) throws IOException {
  String user = ServerUtils.getFileOwner(path);
  String logPreFix = "rmr " + id;
  List<String> commands = new ArrayList<>();
  commands.add("rmr");
  commands.add(path);
  ClientSupervisorUtils.processLauncherAndWait(conf, user, commands, null, logPreFix);
  if (Utils.checkFileExists(path)) {
    throw new RuntimeException(path + " was not deleted.");
  }
}

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

static boolean doRequiredTopoFilesExist(Map<String, Object> conf, String stormId) throws IOException {
  String stormroot = ConfigUtils.supervisorStormDistRoot(conf, stormId);
  String stormjarpath = ConfigUtils.supervisorStormJarPath(stormroot);
  String stormcodepath = ConfigUtils.supervisorStormCodePath(stormroot);
  String stormconfpath = ConfigUtils.supervisorStormConfPath(stormroot);
  if (!Utils.checkFileExists(stormroot)) {
    return false;
  }
  if (!Utils.checkFileExists(stormcodepath)) {
    return false;
  }
  if (!Utils.checkFileExists(stormconfpath)) {
    return false;
  }
  if (ConfigUtils.isLocalMode(conf) || Utils.checkFileExists(stormjarpath)) {
    return true;
  }
  return false;
}

代码示例来源: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

@Override
protected boolean runProfilingCommand(List<String> command, Map<String, String> env, String logPrefix, File targetDir) throws
  IOException, InterruptedException {
  String user = this.getWorkerUser();
  String td = targetDir.getAbsolutePath();
  LOG.info("Running as user: {} command: {}", user, command);
  String containerFile = ServerUtils.containerFilePath(td);
  if (Utils.checkFileExists(containerFile)) {
    SupervisorUtils.rmrAsUser(_conf, containerFile, containerFile);
  }
  String scriptFile = ServerUtils.scriptFilePath(td);
  if (Utils.checkFileExists(scriptFile)) {
    SupervisorUtils.rmrAsUser(_conf, scriptFile, scriptFile);
  }
  String script = ServerUtils.writeScript(td, command, env);
  List<String> args = Arrays.asList("profiler", td, script);
  int ret = ClientSupervisorUtils.processLauncherAndWait(_conf, user, args, env, logPrefix);
  return ret == 0;
}

代码示例来源:origin: org.apache.storm/storm-core

public static boolean checkFileExists(String dir, String file) {
  return checkFileExists(dir + FILE_PATH_SEPARATOR + file);
}

代码示例来源:origin: org.apache.storm/storm-core

protected void forceDeleteImpl(String path) throws IOException {
  LOG.debug("Deleting path {}", path);
  if (checkFileExists(path)) {
    try {
      FileUtils.forceDelete(new File(path));
    } catch (FileNotFoundException ignored) {}
  }
}

代码示例来源:origin: org.apache.storm/storm-core

public static void rmrAsUser(Map<String, Object> conf, String id, String path) throws IOException {
  String user = Utils.getFileOwner(path);
  String logPreFix = "rmr " + id;
  List<String> commands = new ArrayList<>();
  commands.add("rmr");
  commands.add(path);
  SupervisorUtils.processLauncherAndWait(conf, user, commands, null, logPreFix);
  if (Utils.checkFileExists(path)) {
    throw new RuntimeException(path + " was not deleted.");
  }
}

代码示例来源:origin: org.apache.storm/storm-core

static boolean doRequiredTopoFilesExist(Map<String, Object> conf, String stormId) throws IOException {
  String stormroot = ConfigUtils.supervisorStormDistRoot(conf, stormId);
  String stormjarpath = ConfigUtils.supervisorStormJarPath(stormroot);
  String stormcodepath = ConfigUtils.supervisorStormCodePath(stormroot);
  String stormconfpath = ConfigUtils.supervisorStormConfPath(stormroot);
  if (!Utils.checkFileExists(stormroot))
    return false;
  if (!Utils.checkFileExists(stormcodepath))
    return false;
  if (!Utils.checkFileExists(stormconfpath))
    return false;
  if (ConfigUtils.isLocalMode(conf) || Utils.checkFileExists(stormjarpath))
    return true;
  return false;
}

代码示例来源: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.");
    }
  }
}

代码示例来源:origin: org.apache.storm/storm-core

@Override
protected boolean runProfilingCommand(List<String> command, Map<String, String> env, String logPrefix, File targetDir) throws IOException, InterruptedException {
  String user = this.getWorkerUser();
  String td = targetDir.getAbsolutePath();
  LOG.info("Running as user: {} command: {}", user, command);
  String containerFile = Utils.containerFilePath(td);
  if (Utils.checkFileExists(containerFile)) {
    SupervisorUtils.rmrAsUser(_conf, containerFile, containerFile);
  }
  String scriptFile = Utils.scriptFilePath(td);
  if (Utils.checkFileExists(scriptFile)) {
    SupervisorUtils.rmrAsUser(_conf, scriptFile, scriptFile);
  }
  String script = Utils.writeScript(td, command, env);
  List<String> args = Arrays.asList("profiler", td, script);
  int ret = SupervisorUtils.processLauncherAndWait(_conf, user, args, env, logPrefix);
  return ret == 0;
}

相关文章

Utils类方法