|
|
|
@ -1,5 +1,5 @@
|
|
|
|
|
/*
|
|
|
|
|
* Copyright 2012-2019 the original author or authors.
|
|
|
|
|
* Copyright 2012-2020 the original author or authors.
|
|
|
|
|
*
|
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
@ -91,6 +91,8 @@ public class KafkaProperties {
|
|
|
|
|
|
|
|
|
|
private final Template template = new Template();
|
|
|
|
|
|
|
|
|
|
private final Security security = new Security();
|
|
|
|
|
|
|
|
|
|
public List<String> getBootstrapServers() {
|
|
|
|
|
return this.bootstrapServers;
|
|
|
|
|
}
|
|
|
|
@ -143,6 +145,10 @@ public class KafkaProperties {
|
|
|
|
|
return this.template;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Security getSecurity() {
|
|
|
|
|
return this.security;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private Map<String, Object> buildCommonProperties() {
|
|
|
|
|
Map<String, Object> properties = new HashMap<>();
|
|
|
|
|
if (this.bootstrapServers != null) {
|
|
|
|
@ -152,6 +158,7 @@ public class KafkaProperties {
|
|
|
|
|
properties.put(CommonClientConfigs.CLIENT_ID_CONFIG, this.clientId);
|
|
|
|
|
}
|
|
|
|
|
properties.putAll(this.ssl.buildProperties());
|
|
|
|
|
properties.putAll(this.security.buildProperties());
|
|
|
|
|
if (!CollectionUtils.isEmpty(this.properties)) {
|
|
|
|
|
properties.putAll(this.properties);
|
|
|
|
|
}
|
|
|
|
@ -217,6 +224,8 @@ public class KafkaProperties {
|
|
|
|
|
|
|
|
|
|
private final Ssl ssl = new Ssl();
|
|
|
|
|
|
|
|
|
|
private final Security security = new Security();
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Frequency with which the consumer offsets are auto-committed to Kafka if
|
|
|
|
|
* 'enable.auto.commit' is set to true.
|
|
|
|
@ -297,6 +306,10 @@ public class KafkaProperties {
|
|
|
|
|
return this.ssl;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Security getSecurity() {
|
|
|
|
|
return this.security;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Duration getAutoCommitInterval() {
|
|
|
|
|
return this.autoCommitInterval;
|
|
|
|
|
}
|
|
|
|
@ -426,7 +439,7 @@ public class KafkaProperties {
|
|
|
|
|
map.from(this::getKeyDeserializer).to(properties.in(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG));
|
|
|
|
|
map.from(this::getValueDeserializer).to(properties.in(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG));
|
|
|
|
|
map.from(this::getMaxPollRecords).to(properties.in(ConsumerConfig.MAX_POLL_RECORDS_CONFIG));
|
|
|
|
|
return properties.with(this.ssl, this.properties);
|
|
|
|
|
return properties.with(this.ssl, this.security, this.properties);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
@ -435,6 +448,8 @@ public class KafkaProperties {
|
|
|
|
|
|
|
|
|
|
private final Ssl ssl = new Ssl();
|
|
|
|
|
|
|
|
|
|
private final Security security = new Security();
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Number of acknowledgments the producer requires the leader to have received
|
|
|
|
|
* before considering a request complete.
|
|
|
|
@ -498,6 +513,10 @@ public class KafkaProperties {
|
|
|
|
|
return this.ssl;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Security getSecurity() {
|
|
|
|
|
return this.security;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String getAcks() {
|
|
|
|
|
return this.acks;
|
|
|
|
|
}
|
|
|
|
@ -595,7 +614,7 @@ public class KafkaProperties {
|
|
|
|
|
map.from(this::getKeySerializer).to(properties.in(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG));
|
|
|
|
|
map.from(this::getRetries).to(properties.in(ProducerConfig.RETRIES_CONFIG));
|
|
|
|
|
map.from(this::getValueSerializer).to(properties.in(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG));
|
|
|
|
|
return properties.with(this.ssl, this.properties);
|
|
|
|
|
return properties.with(this.ssl, this.security, this.properties);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
@ -604,6 +623,8 @@ public class KafkaProperties {
|
|
|
|
|
|
|
|
|
|
private final Ssl ssl = new Ssl();
|
|
|
|
|
|
|
|
|
|
private final Security security = new Security();
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* ID to pass to the server when making requests. Used for server-side logging.
|
|
|
|
|
*/
|
|
|
|
@ -623,6 +644,10 @@ public class KafkaProperties {
|
|
|
|
|
return this.ssl;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Security getSecurity() {
|
|
|
|
|
return this.security;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String getClientId() {
|
|
|
|
|
return this.clientId;
|
|
|
|
|
}
|
|
|
|
@ -647,7 +672,7 @@ public class KafkaProperties {
|
|
|
|
|
Properties properties = new Properties();
|
|
|
|
|
PropertyMapper map = PropertyMapper.get().alwaysApplyingWhenNonNull();
|
|
|
|
|
map.from(this::getClientId).to(properties.in(ProducerConfig.CLIENT_ID_CONFIG));
|
|
|
|
|
return properties.with(this.ssl, this.properties);
|
|
|
|
|
return properties.with(this.ssl, this.security, this.properties);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
@ -659,6 +684,8 @@ public class KafkaProperties {
|
|
|
|
|
|
|
|
|
|
private final Ssl ssl = new Ssl();
|
|
|
|
|
|
|
|
|
|
private final Security security = new Security();
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Kafka streams application.id property; default spring.application.name.
|
|
|
|
|
*/
|
|
|
|
@ -705,6 +732,10 @@ public class KafkaProperties {
|
|
|
|
|
return this.ssl;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Security getSecurity() {
|
|
|
|
|
return this.security;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String getApplicationId() {
|
|
|
|
|
return this.applicationId;
|
|
|
|
|
}
|
|
|
|
@ -775,7 +806,7 @@ public class KafkaProperties {
|
|
|
|
|
map.from(this::getClientId).to(properties.in(CommonClientConfigs.CLIENT_ID_CONFIG));
|
|
|
|
|
map.from(this::getReplicationFactor).to(properties.in("replication.factor"));
|
|
|
|
|
map.from(this::getStateDir).to(properties.in("state.dir"));
|
|
|
|
|
return properties.with(this.ssl, this.properties);
|
|
|
|
|
return properties.with(this.ssl, this.security, this.properties);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
@ -1167,6 +1198,30 @@ public class KafkaProperties {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static class Security {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Security protocol used to communicate with brokers.
|
|
|
|
|
*/
|
|
|
|
|
private String protocol;
|
|
|
|
|
|
|
|
|
|
public String getProtocol() {
|
|
|
|
|
return this.protocol;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setProtocol(String protocol) {
|
|
|
|
|
this.protocol = protocol;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Map<String, Object> buildProperties() {
|
|
|
|
|
Properties properties = new Properties();
|
|
|
|
|
PropertyMapper map = PropertyMapper.get().alwaysApplyingWhenNonNull();
|
|
|
|
|
map.from(this::getProtocol).to(properties.in(CommonClientConfigs.SECURITY_PROTOCOL_CONFIG));
|
|
|
|
|
return properties;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@SuppressWarnings("serial")
|
|
|
|
|
private static class Properties extends HashMap<String, Object> {
|
|
|
|
|
|
|
|
|
@ -1174,8 +1229,9 @@ public class KafkaProperties {
|
|
|
|
|
return (value) -> put(key, value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Properties with(Ssl ssl, Map<String, String> properties) {
|
|
|
|
|
Properties with(Ssl ssl, Security security, Map<String, String> properties) {
|
|
|
|
|
putAll(ssl.buildProperties());
|
|
|
|
|
putAll(security.buildProperties());
|
|
|
|
|
putAll(properties);
|
|
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|