本文整理了Java中azkaban.utils.Props.get()
方法的一些代码示例,展示了Props.get()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Props.get()
方法的具体详情如下:
包路径:azkaban.utils.Props
类名称:Props
方法名:get
[英]Return value if available in current Props otherwise return from parent
[中]返回值(如果在当前道具中可用),否则从父道具返回
代码示例来源:origin: azkaban/azkaban
/**
* @param azkProps Azkaban Properties
*/
public GangliaMetricEmitter(final Props azkProps) {
this.gmetricPath = azkProps.get(GANGLIA_METRIC_REPORTER_PATH);
}
代码示例来源:origin: azkaban/azkaban
@Inject
public AzkabanCommonModuleConfig(final Props props) {
this.props = props;
this.storageImplementation = props.getString(AZKABAN_STORAGE_TYPE, this.storageImplementation);
this.localStorageBaseDirPath = props
.getString(AZKABAN_STORAGE_LOCAL_BASEDIR, this.localStorageBaseDirPath);
this.hdfsRootUri = props.get(AZKABAN_STORAGE_HDFS_ROOT_URI) != null ? props
.getUri(AZKABAN_STORAGE_HDFS_ROOT_URI) : null;
}
代码示例来源:origin: azkaban/azkaban
/**
* Logs the property in the given logger
*/
public void logProperties(final Logger logger, final String comment) {
logger.info(comment);
for (final String key : getKeySet()) {
logger.info(" key=" + key + " value=" + get(key));
}
}
代码示例来源:origin: azkaban/azkaban
/**
* Return value if available in current Props otherwise return from parent
*/
public String get(final Object key) {
if (this._current.containsKey(key)) {
return this._current.get(key);
} else if (this._parent != null) {
return this._parent.get(key);
} else {
return null;
}
}
代码示例来源:origin: azkaban/azkaban
/**
* Put all properties in the props into the current props. Will handle null p.
*/
public void putAll(final Props p) {
if (p == null) {
return;
}
for (final String key : p.getKeySet()) {
this.put(key, p.get(key));
}
}
代码示例来源:origin: azkaban/azkaban
/**
* Returns a java.util.Properties file populated with the current Properties in here.
* Note: if you want to import parent properties (e.g., database credentials), please use
* toAllProperties
*/
public Properties toProperties() {
final Properties p = new Properties();
for (final String key : this._current.keySet()) {
p.setProperty(key, get(key));
}
return p;
}
代码示例来源:origin: azkaban/azkaban
public static Map<String, String> toStringMap(final Props props, final boolean localOnly) {
final HashMap<String, String> map = new HashMap<>();
final Set<String> keyset = localOnly ? props.localKeySet() : props.getKeySet();
for (final String key : keyset) {
final String value = props.get(key);
map.put(key, value);
}
return map;
}
代码示例来源:origin: azkaban/azkaban
/**
* Store only those properties defined at this local level
*
* @param out The output stream to write to
* @throws IOException If the file can't be found or there is an io error
*/
public void storeLocal(final OutputStream out) throws IOException {
final Properties p = new Properties();
for (final String key : this._current.keySet()) {
p.setProperty(key, get(key));
}
p.store(out, null);
}
代码示例来源:origin: azkaban/azkaban
/**
* Returns the double representation of the value. If the value is null, then the default value is
* returned. If the value isn't a double, then a parse exception will be thrown.
*/
public double getDouble(final String name, final double defaultValue) {
if (containsKey(name)) {
return Double.parseDouble(get(name).trim());
} else {
return defaultValue;
}
}
代码示例来源:origin: azkaban/azkaban
/**
* Gets the string from the Props. If it doesn't exist, it will return the defaultValue
*/
public String getString(final String key, final String defaultValue) {
if (containsKey(key)) {
return get(key);
} else {
return defaultValue;
}
}
代码示例来源:origin: azkaban/azkaban
/**
* Returns true if the value equals "true". If the value is null, then the default value is
* returned.
*/
public boolean getBoolean(final String key, final boolean defaultValue) {
if (containsKey(key)) {
return "true".equalsIgnoreCase(get(key).trim());
} else {
return defaultValue;
}
}
代码示例来源:origin: azkaban/azkaban
/**
* Returns the long representation of the value. If the value is null, then the default value is
* returned. If the value isn't a long, then a parse exception will be thrown.
*/
public long getLong(final String name, final long defaultValue) {
if (containsKey(name)) {
return Long.parseLong(get(name));
} else {
return defaultValue;
}
}
代码示例来源:origin: azkaban/azkaban
/**
* Returns the int representation of the value. If the value is null, then the default value is
* returned. If the value isn't a int, then a parse exception will be thrown.
*/
public int getInt(final String name, final int defaultValue) {
if (containsKey(name)) {
return Integer.parseInt(get(name).trim());
} else {
return defaultValue;
}
}
代码示例来源:origin: azkaban/azkaban
public Class<?> getClass(final String key, final boolean initialize, final ClassLoader cl) {
try {
if (containsKey(key)) {
return Class.forName(get(key), initialize, cl);
} else {
throw new UndefinedPropertyException("Missing required property '"
+ key + "'");
}
} catch (final ClassNotFoundException e) {
throw new IllegalArgumentException(e);
}
}
代码示例来源:origin: azkaban/azkaban
/**
* Returns true if the value equals "true". If the value is null, then an
* UndefinedPropertyException is thrown.
*/
public boolean getBoolean(final String key) {
if (containsKey(key)) {
return "true".equalsIgnoreCase(get(key));
} else {
throw new UndefinedPropertyException("Missing required property '" + key
+ "'");
}
}
代码示例来源:origin: azkaban/azkaban
/**
* Puts only the local props from p into the current properties
*/
public void putLocal(final Props p) {
for (final String key : p.localKeySet()) {
this.put(key, p.get(key));
}
}
代码示例来源:origin: azkaban/azkaban
/**
* Gets the string from the Props. If it doesn't exist, throw and UndefinedPropertiesException
*/
public String getString(final String key) {
if (containsKey(key)) {
return get(key);
} else {
throw new UndefinedPropertyException("Missing required property '" + key
+ "'");
}
}
代码示例来源:origin: azkaban/azkaban
@Test
public void testGetFlowProps() {
final Props flowProps = FlowLoaderUtils.getPropsFromYamlFile(BASIC_FLOW_NAME,
ExecutionsTestUtil.getFlowFile(BASIC_FLOW_YML_TEST_DIR, BASIC_FLOW_YML_FILE));
assertThat(flowProps.size()).isEqualTo(2);
assertThat(flowProps.get(Constants.NODE_TYPE)).isEqualTo(Constants.FLOW_NODE_TYPE);
assertThat(flowProps.get(FLOW_CONFIG_KEY)).isEqualTo(FLOW_CONFIG_VALUE);
}
代码示例来源:origin: azkaban/azkaban
@Test
public void testGetJobPropsFromBasicFlow() {
final Props jobProps = FlowLoaderUtils
.getPropsFromYamlFile(BASIC_FLOW_NAME + Constants.PATH_DELIMITER + SHELL_ECHO,
ExecutionsTestUtil.getFlowFile(BASIC_FLOW_YML_TEST_DIR, BASIC_FLOW_YML_FILE));
assertThat(jobProps.size()).isEqualTo(2);
assertThat(jobProps.get(Constants.NODE_TYPE)).isEqualTo(TYPE_COMMAND);
assertThat(jobProps.get(TYPE_COMMAND)).isEqualTo(ECHO_COMMAND);
}
代码示例来源:origin: azkaban/azkaban
@Test
public void testInvalidSyntax() throws Exception {
final Props propsGrandParent = new Props();
final Props propsParent = new Props(propsGrandParent);
final Props props = new Props(propsParent);
propsParent.put("my", "name");
props.put("res1", "$(my)");
final Props resolved = PropsUtils.resolveProps(props);
Assert.assertEquals("$(my)", resolved.get("res1"));
}
内容来源于网络,如有侵权,请联系作者删除!