本文整理汇总了Java中org.apache.samza.config.Config.entrySet方法的典型用法代码示例。如果您正苦于以下问题:Java Config.entrySet方法的具体用法?Java Config.entrySet怎么用?Java Config.entrySet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.samza.config.Config
的用法示例。
在下文中一共展示了Config.entrySet方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: convertConfigToCoordinatorMessage
import org.apache.samza.config.Config; //导入方法依赖的package包/类
private void convertConfigToCoordinatorMessage(Config config) {
try {
for (Map.Entry<String, String> configPair : config.entrySet()) {
byte[] keyBytes = null;
byte[] messgeBytes = null;
if (configPair.getKey().startsWith(CHANGELOGPREFIX)) {
String[] changelogInfo = configPair.getKey().split(":");
String changeLogPartition = configPair.getValue();
SetChangelogMapping changelogMapping = new SetChangelogMapping(changelogInfo[1], changelogInfo[2], Integer.parseInt(changeLogPartition));
keyBytes = MAPPER.writeValueAsString(changelogMapping.getKeyArray()).getBytes("UTF-8");
messgeBytes = MAPPER.writeValueAsString(changelogMapping.getMessageMap()).getBytes("UTF-8");
} else {
SetConfig setConfig = new SetConfig("source", configPair.getKey(), configPair.getValue());
keyBytes = MAPPER.writeValueAsString(setConfig.getKeyArray()).getBytes("UTF-8");
messgeBytes = MAPPER.writeValueAsString(setConfig.getMessageMap()).getBytes("UTF-8");
}
// The ssp here is the coordinator ssp (which is always fixed) and not the task ssp.
put(systemStreamPartition, new IncomingMessageEnvelope(systemStreamPartition, "", keyBytes, messgeBytes));
}
setIsAtHead(systemStreamPartition, true);
} catch (Exception e) {
throw new SamzaException(e);
}
}
示例2: setAwsClientConfigs
import org.apache.samza.config.Config; //导入方法依赖的package包/类
private void setAwsClientConfigs(Config config, ClientConfiguration clientConfig) {
for (Entry<String, String> entry : config.entrySet()) {
boolean found = false;
String key = entry.getKey();
String value = entry.getValue();
if (StringUtils.isEmpty(value)) {
continue;
}
for (Method method : ClientConfiguration.class.getMethods()) {
// For each property invoke the corresponding setter, if it exists
if (method.getName().equals("set" + key)) {
found = true;
Class<?> type = method.getParameterTypes()[0];
try {
if (type == long.class) {
method.invoke(clientConfig, Long.valueOf(value));
} else if (type == int.class) {
method.invoke(clientConfig, Integer.valueOf(value));
} else if (type == boolean.class) {
method.invoke(clientConfig, Boolean.valueOf(value));
} else if (type == String.class) {
method.invoke(clientConfig, value);
}
LOG.info("Loaded property " + key + " = " + value);
break;
} catch (Exception e) {
throw new IllegalArgumentException(
String.format("Error trying to set field %s with the value '%s'", key, value), e);
}
}
}
if (!found) {
LOG.warn("Property " + key + " ignored as there is no corresponding set method");
}
}
}
示例3: writeConfig
import org.apache.samza.config.Config; //导入方法依赖的package包/类
/**
* Helper method that sends a series of SetConfig messages to the coordinator
* stream.
*
* @param source
* An identifier to denote which source is sending a message. This
* can be any arbitrary string.
* @param config
* The config object to store in the coordinator stream.
*/
public void writeConfig(String source, Config config) {
log.debug("Writing config: {}", config);
for (Map.Entry<String, String> configPair : config.entrySet()) {
send(new SetConfig(source, configPair.getKey(), configPair.getValue()));
}
systemProducer.flush(source);
}