azkaban.utils.Props.getFlattened()方法的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(4.6k)|赞(0)|评价(0)|浏览(125)

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

Props.getFlattened介绍

[英]Returns a map of all the flattened properties, the item in the returned map is sorted alphabetically by the key value.
[中]返回所有展开属性的映射,返回的映射中的项按键值的字母顺序排序。

代码示例

代码示例来源:origin: azkaban/azkaban

/**
 * prints the current Job props to the Job log.
 */
protected void logJobProperties() {
 if (this.jobProps != null &&
   this.jobProps.getBoolean(JOB_DUMP_PROPERTIES_IN_LOG, false)) {
  try {
   final Map<String, String> flattenedProps = this.jobProps.getFlattened();
   this.info("******   Job properties   ******");
   this.info(String.format("- Note : value is masked if property name ends with '%s'.",
     SENSITIVE_JOB_PROP_NAME_SUFFIX));
   for (final Map.Entry<String, String> entry : flattenedProps.entrySet()) {
    final String key = entry.getKey();
    final String value = key.endsWith(SENSITIVE_JOB_PROP_NAME_SUFFIX) ?
      SENSITIVE_JOB_PROP_VALUE_PLACEHOLDER :
      entry.getValue();
    this.info(String.format("%s=%s", key, value));
   }
   this.info("****** End Job properties  ******");
  } catch (final Exception ex) {
   this.log.error("failed to log job properties ", ex);
  }
 }
}

代码示例来源:origin: azkaban/azkaban

/**
 * Helper method to recursively find the node to override props.
 *
 * @param nodeBean the node bean
 * @param pathList the path list
 * @param idx the idx
 * @param prop the props to override
 * @return the boolean
 */
private static boolean overridePropsInNodeBean(final NodeBean nodeBean, final String[] pathList,
  final int idx, final Props prop) {
 if (idx < pathList.length && nodeBean.getName().equals(pathList[idx])) {
  if (idx == pathList.length - 1) {
   if (prop.containsKey(Constants.NODE_TYPE)) {
    nodeBean.setType(prop.get(Constants.NODE_TYPE));
   }
   final Map<String, String> config = prop.getFlattened();
   config.remove(Constants.NODE_TYPE);
   nodeBean.setConfig(config);
   return true;
  }
  for (final NodeBean bean : nodeBean.getNodes()) {
   if (overridePropsInNodeBean(bean, pathList, idx + 1, prop)) {
    return true;
   }
  }
 }
 return false;
}

代码示例来源:origin: azkaban/azkaban

Assert.assertTrue(grandParentProps.getFlattened().isEmpty());
Map<String, String> set = grandParentProps.getFlattened();
Assert.assertEquals(2, set.size());
Assert.assertEquals("value1", set.get("test1"));
parentProps.put("test3", "value3");
parentProps.put("test4", "value4");
set = parentProps.getFlattened();
Assert.assertEquals(4, set.size());
Assert.assertEquals("value3", set.get("test3"));
props.put("test5", "value5");
props.put("test1", "value1.1");
set = props.getFlattened();
Assert.assertEquals(5, set.size());
Assert.assertEquals("value5", set.get("test5"));
props2.put("0", "0");
props2.put("1", "1");
set = props2.getFlattened();
int index = 0;
for (final Map.Entry<String, String> item : set.entrySet()) {

代码示例来源:origin: com.linkedin.azkaban/azkaban-common

/**
 * prints the current Job props to the Job log.
 */
protected void logJobProperties() {
 if (this.jobProps != null &&
   this.jobProps.getBoolean(JOB_DUMP_PROPERTIES_IN_LOG, false)) {
  try {
   final Map<String, String> flattenedProps = this.jobProps.getFlattened();
   this.info("******   Job properties   ******");
   this.info(String.format("- Note : value is masked if property name ends with '%s'.",
     SENSITIVE_JOB_PROP_NAME_SUFFIX));
   for (final Map.Entry<String, String> entry : flattenedProps.entrySet()) {
    final String key = entry.getKey();
    final String value = key.endsWith(SENSITIVE_JOB_PROP_NAME_SUFFIX) ?
      SENSITIVE_JOB_PROP_VALUE_PLACEHOLDER :
      entry.getValue();
    this.info(String.format("%s=%s", key, value));
   }
   this.info("****** End Job properties  ******");
  } catch (final Exception ex) {
   this.log.error("failed to log job properties ", ex);
  }
 }
}

代码示例来源:origin: com.linkedin.azkaban/azkaban-common

/**
 * Helper method to recursively find the node to override props.
 *
 * @param nodeBean the node bean
 * @param pathList the path list
 * @param idx the idx
 * @param prop the props to override
 * @return the boolean
 */
private static boolean overridePropsInNodeBean(final NodeBean nodeBean, final String[] pathList,
  final int idx, final Props prop) {
 if (idx < pathList.length && nodeBean.getName().equals(pathList[idx])) {
  if (idx == pathList.length - 1) {
   if (prop.containsKey(Constants.NODE_TYPE)) {
    nodeBean.setType(prop.get(Constants.NODE_TYPE));
   }
   final Map<String, String> config = prop.getFlattened();
   config.remove(Constants.NODE_TYPE);
   nodeBean.setConfig(config);
   return true;
  }
  for (final NodeBean bean : nodeBean.getNodes()) {
   if (overridePropsInNodeBean(bean, pathList, idx + 1, prop)) {
    return true;
   }
  }
 }
 return false;
}

相关文章