本文整理了Java中azkaban.utils.Props
类的一些代码示例,展示了Props
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Props
类的具体详情如下:
包路径:azkaban.utils.Props
类名称:Props
[英]Hashmap implementation of a hierarchical properties with helpful converter functions and Exception throwing. This class is not threadsafe.
[中]Hashmap实现了一个分层属性,带有有用的转换函数和异常抛出。这个类不是线程安全的。
代码示例来源:origin: azkaban/azkaban
private static Props getMySQLProps(final String sqlScriptsDir) {
final Props props = new Props();
props.put("database.type", "mysql");
props.put("mysql.port", "3306");
props.put("mysql.host", "localhost");
props.put("mysql.database", "azkabanunittest");
props.put("mysql.user", "root");
props.put("database.sql.scripts.dir", sqlScriptsDir);
props.put("mysql.password", "");
props.put("mysql.numconnections", 10);
return props;
}
代码示例来源:origin: azkaban/azkaban
private static void updateDerivedConfigs(final Props azkabanSettings) {
final boolean isSslEnabled = azkabanSettings.getBoolean("jetty.use.ssl", true);
final int port = isSslEnabled
? azkabanSettings.getInt("jetty.ssl.port", DEFAULT_SSL_PORT_NUMBER)
: azkabanSettings.getInt("jetty.port", DEFAULT_PORT_NUMBER);
// setting stats configuration for connectors
final String hostname = azkabanSettings.getString("jetty.hostname", "localhost");
azkabanSettings.put("server.hostname", hostname);
azkabanSettings.put("server.port", port);
azkabanSettings.put("server.useSSL", String.valueOf(isSslEnabled));
}
代码示例来源: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
/**
* 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
/**
* Returns a list of strings with the sep as the separator of the value. If the value is null,
* it'll return the defaultValue.
*/
public List<String> getStringList(final String key, final List<String> defaultValue,
final String sep) {
if (containsKey(key)) {
return getStringList(key, sep);
} else {
return defaultValue;
}
}
代码示例来源:origin: azkaban/azkaban
public AbstractMailer(final Props props, final EmailMessageCreator messageCreator) {
this.azkabanName = props.getString("azkaban.name", "azkaban");
this.messageCreator = messageCreator;
final long maxAttachmentSizeInMB =
props.getInt("mail.max.attachment.size.mb", 100);
this.attachmentMazSizeInByte = maxAttachmentSizeInMB * MB_IN_BYTES;
}
代码示例来源:origin: azkaban/azkaban
final String jobType = jobProps.getString("type");
if (jobType == null || jobType.length() == 0) {
for (final String k : pluginJobProps.getKeySet()) {
if (!jobProps.containsKey(k)) {
jobProps.put(k, pluginJobProps.get(k));
pluginLoadProps = new Props();
代码示例来源:origin: azkaban/azkaban
@Test
public void testUploadOrUpdateProjectProperty() throws Exception {
final Props props = new Props();
props.setSource("source1");
props.put("key1", "value1");
props.put("key2", "value2");
createThreeProjects();
final Project project = this.loader.fetchProjectByName("mytestProject");
this.loader.uploadProjectProperty(project, props);
final Props sameProps = this.loader.fetchProjectProperty(project, props.getSource());
Assert.assertEquals(sameProps.get("key1"), "value1");
Assert.assertEquals(sameProps.get("key2"), "value2");
props.put("key2", "value9");
this.loader.updateProjectProperty(project, props);
final Props sameProps2 = this.loader.fetchProjectProperty(project, props.getSource());
Assert.assertEquals(sameProps2.get("key2"), "value9");
}
代码示例来源:origin: azkaban/azkaban
public static Props resolveProps(final Props props) {
if (props == null) {
return null;
}
final Props resolvedProps = new Props();
final LinkedHashSet<String> visitedVariables = new LinkedHashSet<>();
for (final String key : props.getKeySet()) {
String value = props.get(key);
if (value == null) {
logger.warn("Null value in props for key '" + key + "'. Replacing with empty string.");
value = "";
}
visitedVariables.add(key);
final String replacedValue =
resolveVariableReplacement(value, props, visitedVariables);
visitedVariables.clear();
resolvedProps.put(key, replacedValue);
}
for (final String key : resolvedProps.getKeySet()) {
final String value = resolvedProps.get(key);
final String expressedValue = resolveVariableExpression(value);
resolvedProps.put(key, expressedValue);
}
return resolvedProps;
}
代码示例来源:origin: azkaban/azkaban
final String relative = getRelativeFilePath(base, file.getPath());
try {
parent = new Props(parent, file);
parent.setSource(relative);
this.nodeMap.remove(jobName);
} else {
final Props prop = new Props(parent, file);
final String relative = getRelativeFilePath(base, file.getPath());
prop.setSource(relative);
final String type = prop.getString("type", null);
if (type == null) {
this.errors.add("Job doesn't have type set '" + jobName + "'.");
node.setPropsSource(parent.getSource());
if (prop.getBoolean(CommonJobProperties.ROOT_NODE, false)) {
this.rootNodes.add(jobName);
代码示例来源:origin: azkaban/azkaban
jobProp = new Props();
ret.put("jobType", jobProp.get("type"));
overrideProp = new Props(jobProp);
for (final String ps : jobProp.getKeySet()) {
generalParams.put(ps, jobProp.getString(ps));
for (final String ops : overrideProp.getKeySet()) {
overrideParams.put(ops, overrideProp.getString(ops));
代码示例来源: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"));
}
代码示例来源: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
/**
* 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
private SslSocketConnector getSslSocketConnector(final int sslPortNumber) {
final SslSocketConnector secureConnector = new SslSocketConnector();
secureConnector.setPort(sslPortNumber);
secureConnector.setKeystore(this.props.getString("jetty.keystore"));
secureConnector.setPassword(this.props.getString("jetty.password"));
secureConnector.setKeyPassword(this.props.getString("jetty.keypassword"));
secureConnector.setTruststore(this.props.getString("jetty.truststore"));
secureConnector.setTrustPassword(this.props.getString("jetty.trustpassword"));
secureConnector.setHeaderBufferSize(MAX_HEADER_BUFFER_SIZE);
// set up vulnerable cipher suites to exclude
final List<String> cipherSuitesToExclude = this.props
.getStringList("jetty.excludeCipherSuites");
logger.info("Excluded Cipher Suites: " + String.valueOf(cipherSuitesToExclude));
if (cipherSuitesToExclude != null && !cipherSuitesToExclude.isEmpty()) {
secureConnector.setExcludeCipherSuites(cipherSuitesToExclude.toArray(new String[0]));
}
return secureConnector;
}
}
代码示例来源: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
@Test
public void testCreateDirectoryFlowLoader() {
final FlowLoaderFactory loaderFactory = new FlowLoaderFactory(new Props(null));
final File projectDir = ExecutionsTestUtil.getFlowDir(FLOW_10_TEST_DIRECTORY);
final FlowLoader loader = loaderFactory.createFlowLoader(projectDir);
assertThat(loader instanceof DirectoryFlowLoader).isTrue();
}
代码示例来源:origin: azkaban/azkaban
@Inject
public EmailMessageCreator(final Props props) {
this.mailHost = props.getString("mail.host", "localhost");
this.mailPort = props.getInt("mail.port", DEFAULT_SMTP_PORT);
this.mailUser = props.getString("mail.user", "");
this.mailPassword = props.getString("mail.password", "");
this.mailSender = props.getString("mail.sender", "");
this.tls = props.getString("mail.tls", "false");
this.usesAuth = props.getBoolean("mail.useAuth", true);
}
代码示例来源:origin: azkaban/azkaban
static String getURLForTopic(final String topic, final Props azkProps) {
return azkProps.getString(
Constants.ConfigurationKeys.AZKABAN_SERVER_EXTERNAL_TOPIC_URL.replace("${topic}", topic),
"");
}
代码示例来源:origin: azkaban/azkaban
/**
* Returns a java.util.Properties file populated with both current and parent properties.
*/
public Properties toAllProperties() {
Properties allProp = new Properties();
// import local properties
allProp.putAll(toProperties());
// import parent properties
if(_parent != null)
allProp.putAll(_parent.toProperties());
return allProp;
}
内容来源于网络,如有侵权,请联系作者删除!