本文整理了Java中org.apache.storm.utils.Utils.readYamlFile()
方法的一些代码示例,展示了Utils.readYamlFile()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Utils.readYamlFile()
方法的具体详情如下:
包路径:org.apache.storm.utils.Utils
类名称: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)
);
}
内容来源于网络,如有侵权,请联系作者删除!