本文整理了Java中org.apache.metron.common.utils.KafkaUtils.normalizeProtocol()
方法的一些代码示例,展示了KafkaUtils.normalizeProtocol()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。KafkaUtils.normalizeProtocol()
方法的具体详情如下:
包路径:org.apache.metron.common.utils.KafkaUtils
类名称:KafkaUtils
方法名:normalizeProtocol
暂无
代码示例来源:origin: apache/metron
public Map<String, Object> normalizeProtocol(Map<String, Object> configs) {
if(configs.containsKey(SECURITY_PROTOCOL)) {
String protocol = normalizeProtocol((String)configs.get(SECURITY_PROTOCOL));
configs.put(SECURITY_PROTOCOL, protocol);
}
return configs;
}
代码示例来源:origin: apache/metron
public Map<String, Object> createProducerConfigs() {
Map<String, Object> producerConfig = new HashMap<>();
producerConfig.put("bootstrap.servers", brokerUrl);
producerConfig.put("key.serializer", keySerializer);
producerConfig.put("value.serializer", valueSerializer);
producerConfig.put("request.required.acks", requiredAcks);
producerConfig.put(ProducerConfig.BATCH_SIZE_CONFIG, DEFAULT_BATCH_SIZE);
producerConfig.putAll(producerConfigs == null?new HashMap<>():producerConfigs);
producerConfig = KafkaUtils.INSTANCE.normalizeProtocol(producerConfig);
return producerConfig;
}
代码示例来源:origin: apache/metron
@Bean
public Map<String, Object> producerProperties() {
Map<String, Object> producerConfig = new HashMap<>();
producerConfig.put("bootstrap.servers", environment.getProperty(MetronRestConstants.KAFKA_BROKER_URL_SPRING_PROPERTY));
producerConfig.put("key.serializer", "org.apache.kafka.common.serialization.StringSerializer");
producerConfig.put("value.serializer", "org.apache.kafka.common.serialization.StringSerializer");
producerConfig.put("request.required.acks", 1);
if (environment.getProperty(MetronRestConstants.KERBEROS_ENABLED_SPRING_PROPERTY, Boolean.class, false)) {
producerConfig.put("security.protocol", KafkaUtils.INSTANCE.normalizeProtocol(environment.getProperty(MetronRestConstants.KAFKA_SECURITY_PROTOCOL_SPRING_PROPERTY)));
}
return producerConfig;
}
代码示例来源:origin: apache/metron
/**
* Create properties that will be used by {@link org.apache.metron.rest.config.KafkaConfig#createConsumerFactory()}
*
* @return Configurations used by {@link org.apache.metron.rest.config.KafkaConfig#createConsumerFactory()}.
*/
@Bean
public Map<String, Object> consumerProperties() {
final Map<String, Object> props = new HashMap<>();
props.put("bootstrap.servers", environment.getProperty(MetronRestConstants.KAFKA_BROKER_URL_SPRING_PROPERTY));
props.put("group.id", "metron-rest");
props.put("enable.auto.commit", "false");
props.put("auto.commit.interval.ms", "1000");
props.put("session.timeout.ms", "30000");
props.put("key.deserializer", "org.apache.kafka.common.serialization.StringDeserializer");
props.put("value.deserializer", "org.apache.kafka.common.serialization.StringDeserializer");
if (environment.getProperty(MetronRestConstants.KERBEROS_ENABLED_SPRING_PROPERTY, Boolean.class, false)) {
props.put("security.protocol", KafkaUtils.INSTANCE.normalizeProtocol(environment.getProperty(MetronRestConstants.KAFKA_SECURITY_PROTOCOL_SPRING_PROPERTY)));
}
return props;
}
代码示例来源:origin: apache/metron
protected String[] getParserStartCommand(String names) {
List<String> command = new ArrayList<>();
command.add( environment.getProperty(MetronRestConstants.PARSER_SCRIPT_PATH_SPRING_PROPERTY));
// sensor type
command.add( "-s");
command.add( names);
// zookeeper
command.add( "-z");
command.add( environment.getProperty(MetronRestConstants.ZK_URL_SPRING_PROPERTY));
// kafka broker
command.add( "-k");
command.add( environment.getProperty(MetronRestConstants.KAFKA_BROKER_URL_SPRING_PROPERTY));
// kafka security protocol
command.add( "-ksp");
command.add(KafkaUtils.INSTANCE.normalizeProtocol(environment.getProperty(MetronRestConstants.KAFKA_SECURITY_PROTOCOL_SPRING_PROPERTY)));
// extra topology options
boolean kerberosEnabled = environment.getProperty(MetronRestConstants.KERBEROS_ENABLED_SPRING_PROPERTY, Boolean.class, false);
boolean topologyOptionsDefined = StringUtils.isNotBlank(environment.getProperty(MetronRestConstants.PARSER_TOPOLOGY_OPTIONS_SPRING_PROPERTY));
if (kerberosEnabled && topologyOptionsDefined) {
command.add("-e");
command.add(environment.getProperty(MetronRestConstants.PARSER_TOPOLOGY_OPTIONS_SPRING_PROPERTY));
}
return command.toArray(new String[0]);
}
代码示例来源:origin: apache/metron
);
if(securityProtocol.isPresent()) {
kafkaSpoutConfigOptions.putIfAbsent("security.protocol", KafkaUtils.INSTANCE.normalizeProtocol(securityProtocol.get()));
代码示例来源:origin: apache/metron
/**
* Create an object with the specified properties and exposing the specified fields.
* @param kafkaProps The special kafka properties
* @param subscription The subscription to the kafka topic(s)
* @param zkQuorum The zookeeper quorum. We will use this to pull the brokers from this.
* @param fieldsConfiguration The fields to expose in the storm tuple emitted.
*/
public SimpleStormKafkaBuilder( Map<String, Object> kafkaProps
, Subscription subscription
, String zkQuorum
, List<String> fieldsConfiguration
)
{
super( getBootstrapServers(zkQuorum, kafkaProps)
, createDeserializer(Optional.ofNullable((String)kafkaProps.get(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG)), DEFAULT_DESERIALIZER)
, createDeserializer(Optional.ofNullable((String)kafkaProps.get(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG)), DEFAULT_DESERIALIZER)
, subscription
);
kafkaProps = KafkaUtils.INSTANCE.normalizeProtocol(kafkaProps);
setProp(kafkaProps);
setRecordTranslator(new SpoutRecordTranslator<>(FieldsConfiguration.toList(fieldsConfiguration)));
}
内容来源于网络,如有侵权,请联系作者删除!