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

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

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

Utils.readYamlFile介绍

暂无

代码示例

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

/**
   * Load the configs associated with the configKey from the targetFilePath.
   * @param configKey The key from which we want to get the scheduler config.
   * @return The scheduler configuration if exists; null otherwise.
   */
  @Override
  public Map<String, Object> load(String configKey) {
    if (targetFilePath != null) {
      try {
        Map<String, Object> raw = (Map<String, Object>) Utils.readYamlFile(targetFilePath);
        if (raw != null) {
          return (Map<String, Object>) raw.get(configKey);
        }
      } catch (Exception e) {
        LOG.error("Failed to load from file {}", targetFilePath);
      }
    }
    return null;
  }
}

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

/**
 * Return topology owner from worker meta file.
 *
 * @param metaFile metadata file
 */
public String getTopologyOwnerFromMetadataFile(String metaFile) {
  Map<String, Object> map = (Map<String, Object>) Utils.readYamlFile(metaFile);
  return ObjectReader.getString(map.get(TOPOLOGY_SUBMITTER_USER), null);
}

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

/**
 * Return worker id from worker meta file.
 *
 * @param metaFile metadata file
 */
public String getWorkerIdFromMetadataFile(String metaFile) {
  Map<String, Object> map = (Map<String, Object>) Utils.readYamlFile(metaFile);
  return ObjectReader.getString(map == null ? null : map.get("worker-id"), null);
}

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

private Map<String, Object> loadFromFile(File file) {
  Map<String, Object> ret = null;
  try {
    ret = (Map<String, Object>) Utils.readYamlFile(file.getCanonicalPath());
  } catch (IOException e) {
    LOG.error("Filed to load from file. Exception: {}", e.getMessage());
  }
  if (ret != null) {
    try {
      LOG.debug("returning a new map from file {}", file.getCanonicalPath());
    } catch (java.io.IOException e) {
      LOG.debug("Could not get PATH from file object in debug print. Ignoring");
    }
    return ret;
  }
  return null;
}

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

/**
 * Get the whitelist of users and groups for given file.
 *
 * @param fileName file name to get the whitelist
 */
public LogUserGroupWhitelist getLogUserGroupWhitelist(String fileName) {
  File wlFile = ServerConfigUtils.getLogMetaDataFile(fileName);
  Map<String, Object> map = (Map<String, Object>) Utils.readYamlFile(wlFile.getAbsolutePath());
  if (map == null) {
    return null;
  }
  List<String> logsUsers = ObjectReader.getStrings(map.get(DaemonConfig.LOGS_USERS));
  List<String> logsGroups = ObjectReader.getStrings(map.get(DaemonConfig.LOGS_GROUPS));
  return new LogUserGroupWhitelist(
      logsUsers.isEmpty() ? new HashSet<>() : new HashSet<>(logsUsers),
      logsGroups.isEmpty() ? new HashSet<>() : new HashSet<>(logsGroups)
  );
}

相关文章

Utils类方法